blob: e98528854180e27f082b01f3ecba593fc3d519ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
using Sonigon;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class CardBar : MonoBehaviour
{
[Header("Sounds")]
public SoundEvent soundCardPick;
[Header("Settings")]
public GameObject pointer;
[Header("Settings")]
public GameObject cardPos;
private GameObject source;
private CardInfo ci;
private GameObject currentCard;
private void Start()
{
source = base.transform.GetChild(0).gameObject;
}
public void ClearBar()
{
if ((bool)currentCard)
{
Object.Destroy(currentCard);
}
for (int num = base.transform.childCount - 1; num >= 0; num--)
{
if (base.transform.GetChild(num).gameObject.activeSelf)
{
Object.Destroy(base.transform.GetChild(num).gameObject);
}
}
}
public void AddCard(CardInfo card)
{
SoundManager.Instance.Play(soundCardPick, base.transform);
ci = card;
GameObject obj = Object.Instantiate(source, source.transform.position, source.transform.rotation, source.transform.parent);
obj.transform.localScale = Vector3.one;
string cardName = card.cardName;
cardName = cardName.Substring(0, 2);
string text = cardName[0].ToString().ToUpper();
if (cardName.Length > 1)
{
string text2 = cardName[1].ToString().ToLower();
cardName = text + text2;
}
else
{
cardName = text;
}
obj.GetComponentInChildren<TextMeshProUGUI>().text = cardName;
obj.GetComponent<CardBarButton>().card = card;
obj.gameObject.SetActive(value: true);
}
public void OnHover(CardInfo card, Vector3 hoverPos)
{
if ((bool)currentCard)
{
Object.Destroy(currentCard);
}
currentCard = CardChoice.instance.AddCardVisual(card, cardPos.transform.position);
Collider2D[] componentsInChildren = currentCard.transform.root.GetComponentsInChildren<Collider2D>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].enabled = false;
}
currentCard.GetComponentInChildren<Canvas>().sortingLayerName = "MostFront";
currentCard.GetComponentInChildren<GraphicRaycaster>().enabled = false;
currentCard.GetComponentInChildren<SetScaleToZero>().enabled = false;
currentCard.GetComponentInChildren<SetScaleToZero>().transform.localScale = Vector3.one * 1.15f;
}
public void StopHover()
{
if ((bool)currentCard)
{
Object.Destroy(currentCard);
}
}
private void Update()
{
}
}
|