public CardDescriptionClass UnlockCard(int cardId) { CardDescriptionClass cardDesc = FindCardDescByID(cardId); if (cardDesc != null) { Debug.Log("card found:" + cardDesc.CardID + " x" + cardDesc.Quantity); if (!cardDesc.CardUnlocked) { cardDesc.NewlyUnlocked = true; cardDesc.CardUnlocked = true; cardDesc.Quantity = 1; } else { cardDesc.Quantity++; if (cardDesc.Quantity > cardDesc.MaxQuantity) { cardDesc.Quantity = cardDesc.MaxQuantity; } else { cardDesc.NewlyUnlocked = true; } } return(cardDesc); } return(null); }
public void CardChecked(string cardName) { CardDescriptionClass cardDesc = FindCardDescByName(cardName); if (cardDesc != null) { cardDesc.NewlyUnlocked = false; } }
public GameObject SpawnCardByName(string name) { CardDescriptionClass cardDesc = FindCardDescByName(name); if (cardDesc != null) { return(SpawnCard(cardDesc, false)); } else { return(null); } }
public GameObject SpawnCardByID(int ID) { CardDescriptionClass cardDesc = FindCardDescByID(ID); if (cardDesc != null) { return(SpawnCard(cardDesc, false)); } else { return(null); } }
public int GetIdByName(string name) { CardDescriptionClass desc = FindCardDescByName(name); if (desc != null) { return(desc.CardID); } else { return(-1); } }
public void LoadUserCard(ItemInstance item) { int id = -1; Int32.TryParse(item.ItemId, out id); CardDescriptionClass cardDesc = FindCardDescByID(id); if (cardDesc != null) { Debug.Log("card found:" + cardDesc.CardID); cardDesc.CardUnlocked = true; cardDesc.Quantity = item.RemainingUses.GetValueOrDefault(1); } DataLoaded = true; }
public List <string> SortCardsList(List <string> ListToSort) { List <string> SortedList = new List <string>(); List <CardDescriptionClass> deckCardsToSort = new List <CardDescriptionClass> (); foreach (string cardName in ListToSort) { CardDescriptionClass desc = FindCardDescByName(cardName); if (desc != null) { deckCardsToSort.Add(desc); } } deckCardsToSort = SortCardsByManaAndName(deckCardsToSort); foreach (CardDescriptionClass CardDescription in deckCardsToSort) { SortedList.Add(CardDescription.Name); } return(SortedList); }
/*void Awake(){ * DontDestroyOnLoad (this); * * if (Instance == null) { * Instance = this; * } else { * DestroyObject(gameObject); * } * }*/ public CardDescriptionClass FindCardDescByID(int ID) { CardDescriptionClass rv = null; foreach (CardDescriptionClass CardDescription in Hero1CardsBase) { if (ID == CardDescription.CardID) { rv = CardDescription; } } if (rv == null) { foreach (CardDescriptionClass CardDescription in Hero2CardsBase) { if (ID == CardDescription.CardID) { rv = CardDescription; } } } if (rv == null) { foreach (CardDescriptionClass CardDescription in UniwersalCardsBase) { if (ID == CardDescription.CardID) { rv = CardDescription; } } } if (rv == null) { Debug.LogWarning("Cannot find card description with ID: " + ID); } return(rv); }
public GameObject SpawnCard(CardDescriptionClass CardDescription, bool build_mode) { GameObject Card; CardInteraction CardInteraction; GameObject Pawn; Pawn PawnComponent; SpriteRenderer cardSpriteRenderer; if (!CardDescription.CardEnabled) { return(null); } Card = (GameObject)Instantiate(CardPrefab, new Vector3(0, 0, 0), Quaternion.identity); Pawn = Card.transform.Find("Pawn").gameObject; Pawn.GetComponent <SpriteRenderer> ().sprite = CardDescription.Background; Pawn.transform.Find("Character").gameObject.GetComponent <SpriteRenderer> ().sprite = CardDescription.Character; cardSpriteRenderer = Card.GetComponent <SpriteRenderer> (); PawnComponent = Pawn.GetComponent <Pawn> (); PawnComponent.CardID = CardDescription.CardID; PawnComponent.Name = CardDescription.Name; PawnComponent.Desc = CardDescription.Description; PawnComponent.CardType = CardDescription.CardMode; PawnComponent.SetAttack(CardDescription.Attack); PawnComponent.SetHealth(CardDescription.Health); PawnComponent.SetConfig(CardDescription.PawnConfig, CardDescription.SpecialMovement); PawnComponent.ApplyConfig(); PawnComponent.ItemApplyConfig = CardDescription.ItemChangePawnConfig; PawnComponent.ItemMergeConfig = CardDescription.ItemMergePawnConfig; if (CardDescription.BulletParticlePrefab != null) { PawnComponent.ShotParticlePrefab = CardDescription.BulletParticlePrefab; } PawnComponent.ShootingMode = CardDescription.ShootingMode; PawnComponent.ShootInterval = CardDescription.ShootInterval; PawnComponent.PawnEffectParameters = CardDescription.EffectParameters; PawnComponent.PawnEffectParticle = CardDescription.EffectParticles; if (CardDescription.DeathSound != null) { PawnComponent.DeathSound = CardDescription.DeathSound; } CardInteraction = Card.GetComponent <CardInteraction> (); CardInteraction.SetName(CardDescription.Name); CardInteraction.SetDescription(CardDescription.Description); CardInteraction.SetCardCost(CardDescription.Cost); CardInteraction.SetCardOrder(1); CardInteraction.CardRole = CardDescription.Role; CardInteraction.CardRarity = CardDescription.Rarity; if (CardDescription.CardMode == CardTypesEnum.Pawn) { CardInteraction.SetTypeDescText("Postać"); } else if (CardDescription.CardMode == CardTypesEnum.Weapon) { CardInteraction.SetTypeDescText("Ekwipunek"); } else if (CardDescription.CardMode == CardTypesEnum.Effect) { CardInteraction.SetTypeDescText("Efekt"); } if (CardDescription.Rarity == CardInteraction.CardRarityEnum.common) { cardSpriteRenderer.sprite = SilverCardSprite; } else if (CardDescription.Rarity == CardInteraction.CardRarityEnum.gold) { cardSpriteRenderer.sprite = GoldCardSprite; } else if (CardDescription.Rarity == CardInteraction.CardRarityEnum.diamond) { cardSpriteRenderer.sprite = DiamondCardSprite; } if (!build_mode) { if (CardDescription.EffectComponent.Length > 0) { Type componentType = Type.GetType(CardDescription.EffectComponent); if (componentType != null) { Pawn.AddComponent(componentType); } else { Debug.LogWarning("You are missing to add component class named: " + CardDescription.EffectComponent); } } } Card.SetActive(true); return(Card); }