コード例 #1
0
 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);
 }
コード例 #2
0
        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;
                //}
            }
        }
コード例 #3
0
ファイル: BattleResolve.cs プロジェクト: quanghoi2/Cards
        BlockCardInstance GetBlockInstanceOfAttacker(CardInstance attacker, Dictionary <CardInstance, BlockCardInstance> dict)
        {
            BlockCardInstance block = null;

            dict.TryGetValue(attacker, out block);

            return(block);
        }
コード例 #4
0
ファイル: GameManager.cs プロジェクト: quanghoi2/Cards
        BlockCardInstance GetBlockInstanceOfAttacker(CardInstance attacker)
        {
            BlockCardInstance block = null;

            blockInstances.TryGetValue(attacker, out block);

            return(block);
        }
コード例 #5
0
 public bool TypeAllowForAttack(CardInstance inst)
 {
     if (canAttack)
     {
         return(true);
     }
     return(false);
 }
コード例 #6
0
 public bool CanBeBlocked(CardInstance block)
 {
     if (viz.card.cardType.canAttack)
     {
         Settings.gameManager.AddBlockCardInstance(this, block);
         return(true);
     }
     return(true);
 }
コード例 #7
0
ファイル: CardHolder.cs プロジェクト: quanghoi2/Cards
        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;
        }
コード例 #8
0
 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);
     }
 }
コード例 #9
0
ファイル: GameManager.cs プロジェクト: quanghoi2/Cards
        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);
            }
        }
コード例 #10
0
        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);
            }
        }
コード例 #11
0
ファイル: GameManager.cs プロジェクト: quanghoi2/Cards
        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);
        }
コード例 #12
0
ファイル: BattleResolve.cs プロジェクト: quanghoi2/Cards
        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);
        }
コード例 #13
0
 public void Set(CardInstance v)
 {
     value = v;
 }
コード例 #14
0
 public void SetInstance(CardInstance instance)
 {
     this.instance = instance;
 }
コード例 #15
0
ファイル: CardHolder.cs プロジェクト: quanghoi2/Cards
 public void SetCardOnDown(CardInstance inst)
 {
     Settings.SetParentForCard(inst.viz.gameObject.transform, cardsDownGrid.value.transform);
 }