Пример #1
0
        BlockCardInstance GetBlockInstanceOfAttacker(CardInstance attacker, Dictionary <CardInstance, BlockCardInstance> dict)
        {
            BlockCardInstance block = null;

            dict.TryGetValue(attacker, out block);

            return(block);
        }
Пример #2
0
        BlockCardInstance GetBlockInstanceOfAttacker(CardInstance attacker)
        {
            BlockCardInstance block = null;

            blockInstances.TryGetValue(attacker, out block);

            return(block);
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        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);
        }