public void ReplaceCardInHand(AdventureAsset oldCard, AdventureAsset newCard) { AdventureCardManager acm = FindCardInHand(oldCard); if (acm != null) { acm.adventureAsset = newCard; acm.ReadCardFromAsset(); if (!isAI) { acm.GetComponent <HoverPreview>().ThisPreviewEnabled = true; acm.GetComponent <BetterCardRotation>().CardBack.gameObject.SetActive(false); } } }
GameObject CreateACardAtPositionX(AdventureAsset c, Vector3 position, Vector3 eulerAngles) { // Instantiate a card depending on its type GameObject NewCard; Vector3 temp; NewCard = GameObject.Instantiate(allyCardPrefab, position, Quaternion.Euler(eulerAngles)) as GameObject; temp = new Vector3(newDeck.transform.position.x + 0.5f, newDeck.transform.position.y, newDeck.transform.position.z); NewCard.transform.position = temp; AdventureCardManager manager = NewCard.GetComponent <AdventureCardManager>(); manager.adventureAsset = c; manager.ReadCardFromAsset(); return(NewCard); }
public void ReadCardFromAsset() { CardDescriptionText.text = adventureAsset.Description; CardNameText.text = adventureAsset.characterName; CardPower.text = adventureAsset.CharacterPower; CardAdditionalPower.text = adventureAsset.AdditionalPower; CardFaceImage.sprite = adventureAsset.CardImage; if (PreviewManager != null) { // this is a card and not a preview // Preview GameObject will have OneCardManager as well, but PreviewManager should be null there PreviewManager.adventureAsset = adventureAsset; PreviewManager.ReadCardFromAsset(); } }
//VISUAL AdventureCardManager CreateACardAtPosition(AdventureAsset newAdventureCard, CardLogic newLogic, Vector3 eulerAngles = default(Vector3), Vector3 position = default(Vector3)) { // Instantiate a card depending on its type GameObject NewCard; Vector3 temp; if (newAdventureCard.Description.ToString().Equals("ALLY")) { NewCard = GameObject.Instantiate(allyCardPrefab, position, Quaternion.Euler(eulerAngles)) as GameObject; } else if (newAdventureCard.Description.ToString().Equals("WEAPON")) { NewCard = GameObject.Instantiate(weaponCardPrefab, position, Quaternion.Euler(eulerAngles)) as GameObject; } else if (newAdventureCard.Description.ToString().Equals("AMOUR")) { NewCard = GameObject.Instantiate(amourCardPrefab, position, Quaternion.Euler(eulerAngles)) as GameObject; } else if (newAdventureCard.Description.ToString().Equals("TEST")) { NewCard = GameObject.Instantiate(testCardPrefab, position, Quaternion.Euler(eulerAngles)) as GameObject; } else { NewCard = GameObject.Instantiate(foeCardPrefab, position, Quaternion.Euler(eulerAngles)) as GameObject; } EventTrigger trigger = NewCard.gameObject.GetComponent <EventTrigger> (); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerClick; entry.callback.AddListener((evenData) => { UseCard(NewCard.GetComponent <AdventureCardManager>()); }); trigger.triggers.Add(entry); temp = new Vector3(hand.transform.position.x + cardIndex, hand.transform.position.y, hand.transform.position.z); NewCard.transform.position = temp; NewCard.transform.SetParent(hand.transform, true); cardIndex++; AdventureCardManager manager = NewCard.GetComponent <AdventureCardManager>(); manager.adventureAsset = newAdventureCard; manager.ReadCardFromAsset(); IDHolder id = NewCard.AddComponent <IDHolder>(); id.UniqueID = newLogic.UniqueCardID; //add to cards dealt hand.cardsDealt.Add(NewCard); //hide enemy card from player if (isAI) { NewCard.GetComponent <HoverPreview> ().ThisPreviewEnabled = false; } return(manager); }