コード例 #1
0
        public void AddBlockInstance(CardInstance attacker, CardInstance blocker, ref int count)
        {
            BlockInstance b = null;

            b = GetBlockInstanceOfAttacker(attacker);
            if (b == null)
            {
                b          = new BlockInstance();
                b.attacker = attacker;
                blockInstances.Add(attacker, b);
            }

            if (!b.blocker.Contains(blocker))
            {
                b.blocker.Add(blocker);
            }

            count = b.blocker.Count;
        }
コード例 #2
0
        void BattleResolveForPlayers()
        {
            PlayerHolder player = Settings.gameManager.currentPlayer;
            PlayerHolder enemy  = Settings.gameManager.GetEnemyOf(player);

            if (enemy.attackingCards.Count == 0)
            {
                photonView.RPC("RPC_BattleResolveCallback", PhotonTargets.All, enemy.photonId);
                // photonView.RPC("RPC_PlayerEndsPhase", PhotonTargets.All, player.photonId);

                return;
            }

            Dictionary <CardInstance, BlockInstance> blockDict = Settings.gameManager.GetBlockInstances();

            for (int i = 0; i < enemy.attackingCards.Count; i++)
            {
                CardInstance   inst   = enemy.attackingCards[i];
                Card           c      = inst.viz.card;
                CardProperties attack = c.GetProperty(dataHolder.attackElement);
                if (attack == null)
                {
                    Debug.LogError("You are attacking with a card that can't attack");
                    continue;
                }

                int damageValue = attack.intValue;

                BlockInstance bi = GetBlockInstanceOfAttacker(inst, gm.GetBlockInstances());
                if (bi != null)
                {
                    for (int b = 0; b < bi.blocker.Count; b++)
                    {
                        CardProperties def = c.GetProperty(gm.defenceProperty);
                        if (def == null)
                        {
                            Debug.LogWarning("You are trying to block with a card with no defense element!");
                            continue;
                        }

                        damageValue -= def.intValue;

                        if (def.intValue <= damageValue)
                        {
                            bi.blocker[b].CardInstanceToGraveyard();
                        }
                    }
                }

                if (damageValue <= 0)
                {
                    damageValue = 0;
                    PlayerWantsToUseCard(inst.viz.card.instID, enemy.photonId, CardOpertation.cardToGraveyard);
                }

                enemy.DropCard(inst, false);
                player.DoDamage(damageValue);
                photonView.RPC("RPC_SyncPlayerHealth", PhotonTargets.All, player.photonId, player.health);
            }

            photonView.RPC("RPC_BattleResolveCallback", PhotonTargets.All, enemy.photonId);
            //photonView.RPC("RPC_PlayerEndsPhase", PhotonTargets.All, player.photonId);

            return;
        }