public void DeselectEquipped(EquippedCardIcon e) { Card c = e.CardObj.GetComponent <Card>(); c.Equipped = false; _equippedCardIcons.Remove(e); Destroy(e.gameObject); }
private void Start() { GameManager.Instance.State = GameState.Customizing; _content = GameObject.FindWithTag("CustomizeScreenContent").transform; _equipped = GameObject.FindWithTag("CustomizeScreenSelected").transform; _cardsOnScreen = new List <Card>(); _equippedCardIcons = new List <EquippedCardIcon>(); if (!File.Exists(Application.persistentDataPath + "/playercollection.save")) { GameManager.Instance.ResetPlayerSave(); } PlayerCollection collection = Utils.Load <PlayerCollection>("playercollection"); //Create cards foreach (string c in collection.Cards) { GameObject go = Instantiate(Utils.LoadCard(c), _content); go.transform.localScale = Vector3.one * 70f; var go_c = go.GetComponent <Card>(); go_c.ShowFullSize = true; _cardsOnScreen.Add(go_c); } //Create equipped list foreach (string e in collection.Equipped) { bool found = false; foreach (Card c in _cardsOnScreen) { if (Utils.CompareCardName(c.CardName, e) && !c.Equipped && !found) { c.Equipped = true; GameObject equipGO = Instantiate(Resources.Load <GameObject>("prefabs/UI/EquippedCardIcon"), _equipped); EquippedCardIcon icon = equipGO.GetComponent <EquippedCardIcon>(); icon.CardName = e; icon.CardObj = c.gameObject; _equippedCardIcons.Add(icon); found = true; } } } }
public void SelectEquippedCard(Card c) { //Handle equipping cards //if list has space, equip, else dont if (_equippedCardIcons.Count >= 9 || c.Equipped) { return; } c.Equipped = true; GameObject equipGO = Instantiate(Resources.Load <GameObject>("prefabs/UI/EquippedCardIcon"), _equipped); EquippedCardIcon icon = equipGO.GetComponent <EquippedCardIcon>(); icon.CardName = c.CardName; icon.CardObj = c.gameObject; _equippedCardIcons.Add(icon); }