Example #1
0
        public void LoadCard(Card c)
        {
            if (c == null)
            {
                return;
            }

            c.cardViz = this;

            card = c;

            DisableAll();

            //   c.cardType.OnSetType(this);

            for (int i = 0; i < c.properties.Length; i++)
            {
                CardProperties    cp = c.properties[i];
                CardVizProperties p  = GetProperty(cp.element);

                if (p == null)
                {
                    continue;
                }

                if (cp.element is ElementInt)
                {
                    p.text.text = cp.intValue.ToString();
                    p.text.gameObject.SetActive(true);
                }
                else
                if (cp.element is ElementText)
                {
                    p.text.text = cp.stringValue;
                    p.text.gameObject.SetActive(true);
                }
                else
                if (cp.element is ElementImage)
                {
                    p.img.sprite = cp.sprite;
                    p.img.gameObject.SetActive(true);
                }
            }
        }
Example #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;
        }