public static void DropCreatureCard(Transform c, Transform p, CardInstance inst) { SetParentForCard(c, p); inst.SetFlatFooted(true); gameManager.currentPlayer.UseResourcesCard(inst.viz.card.cost); gameManager.currentPlayer.DropCard(inst); }
public override void OnStartPhase() { PlayerHolder p = Settings.gameManager.currentPlayer; if (p.attackingCards.Count == 0) { forceExit = true; return; } for (int i = 0; i < p.attackingCards.Count; i++) { CardInstance inst = p.attackingCards[i]; Card c = inst.viz.cards; CardProperties attack = c.GetProperty(attackElement); if (attack == null) { Debug.LogError("This card cannot be attacked!"); continue; } //in Card.cs - line 14 add : //public CardProperties GetProperty(Element e){ // for(int i = 0; i < properties.Length; i++){ // { if(properties[i].element == e){ // return properties[i]; // } return null; //} } }
BlockCardInstance GetBlockInstanceOfAttacker(CardInstance attacker, Dictionary <CardInstance, BlockCardInstance> dict) { BlockCardInstance block = null; dict.TryGetValue(attacker, out block); return(block); }
BlockCardInstance GetBlockInstanceOfAttacker(CardInstance attacker) { BlockCardInstance block = null; blockInstances.TryGetValue(attacker, out block); return(block); }
public bool TypeAllowForAttack(CardInstance inst) { if (canAttack) { return(true); } return(false); }
public bool CanBeBlocked(CardInstance block) { if (viz.card.cardType.canAttack) { Settings.gameManager.AddBlockCardInstance(this, block); return(true); } return(true); }
public void SetCardOnBattleLine(CardInstance inst) { Vector3 pos = inst.viz.gameObject.transform.position; Settings.SetParentForCard(inst.viz.gameObject.transform, cardsBattleLine.value.transform); pos.z = inst.viz.gameObject.transform.position.z; pos.y = inst.viz.gameObject.transform.position.y; inst.viz.gameObject.transform.position = pos; }
public void DropCard(CardInstance inst, bool registerEvent = true) { if (handCards.Contains(inst)) { handCards.Remove(inst); } cardsDown.Add(inst); if (registerEvent) { string e = userName + " used " + inst.viz.card.name + " for " + inst.viz.card.cost + " resources"; Settings.RegisterEvent(e, Color.red); } }
public void AddBlockCardInstance(CardInstance attacker, CardInstance blocker) { BlockCardInstance b = GetBlockInstanceOfAttacker(attacker); if (b == null) { b = new BlockCardInstance(); b.attacker = attacker; blockInstances.Add(attacker, b); } if (!b.blocker.Contains(blocker)) { b.blocker.Add(blocker); } }
void CreateStartingCards() { ResourcesManager rm = Settings.GetResourcesManager(); for (int i = 0; i < currentPlayer.startingCards.Length; zi++) { GameObject go = Instantiate(cardPrefab) as GameObject; CardViz v = go.GetComponent <CardViz>(); v.LoadCard(rm.GetCardInstance(currentPlayer.startingCards[i])); CardInstance inst = go.GetComponent <CardInstance>(); inst.currentLogic = currentPlayer.handLogic; Settings.SetParentForCard(go.transform, currentPlayer.handGrid.value); } }
public void PickNewCardFormDeck(PlayerHolder p) { if (p.allCards.Count == 0) { Debug.Log("Game Over"); return; } string cardID = p.allCards[0]; p.allCards.RemoveAt(0); ResourcesManager rm = Settings.GetResourcesManager(); GameObject go = Instantiate(cardPrefab) as GameObject; CardViz viz = go.GetComponent <CardViz>(); viz.Load(rm.GetCardInstance(cardID)); CardInstance inst = go.GetComponent <CardInstance>(); inst.currentLogic = p.handCardsLogic; inst.owner = p; Settings.SetParentForCard(go.transform, p.currentHolder.handCardsGrid.value); p.handCards.Add(inst); }
public override bool IsCompleted() { PlayerHolder p = Settings.gameManager.currentPlayer; PlayerHolder e = Settings.gameManager.EnemyOfPlayer(p); if (p.attackingCards.Count == 0) { //Debug.Log("No card Attack"); return(true); } Dictionary <CardInstance, BlockCardInstance> dictBlock = Settings.gameManager.GetBlockInstances(); for (int i = 0; i < p.attackingCards.Count; i++) { CardInstance inst = p.attackingCards[i]; Card c = inst.viz.card; CardProperties attack = c.GetProperty(elementAttack); if (attack == null) { //Debug.Log("Cant not attack with card"); continue; } int attackValue = attack.intValue; BlockCardInstance bi = GetBlockInstanceOfAttacker(inst, dictBlock); if (bi != null) { for (int j = 0; j < bi.blocker.Count; j++) { CardProperties def = c.GetProperty(elementDefence); if (def == null) { Debug.Log("Card No defence"); continue; } attackValue -= def.intValue; if (def.intValue <= attackValue) { // Card Die } } } if (attackValue <= 0) { attackValue = 0; inst.CardInstanceToGraveyard(); } p.DropCard(inst, false); p.currentHolder.SetCardOnDown(inst); inst.SetFlatFooted(true); e.DoDame(attack.intValue); } Settings.gameManager.ClearBlockCardInstance(); p.attackingCards.Clear(); return(true); }
public void Set(CardInstance v) { value = v; }
public void SetInstance(CardInstance instance) { this.instance = instance; }
public void SetCardOnDown(CardInstance inst) { Settings.SetParentForCard(inst.viz.gameObject.transform, cardsDownGrid.value.transform); }