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;
                //}
            }
        }
Exemple #2
0
        public void LoadCard(Card c)
        {
            if (c == null)
            {
                return;
            }

            card = c;

            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();
                }
                else if (cp.element is ElementText)
                {
                    p.text.text = cp.stringValue;
                }
                else if (cp.element is ElementImage)
                {
                    p.img.sprite = cp.sprite;
                }
            }
        }
Exemple #3
0
 public void Load(Card c)
 {
     if (c == null)
     {
         return;
     }
     card = c;
     c.cardType.OnSetType(this);
     CloseAll();
     for (int i = 0; i < c.properties.Length; i++)
     {
         CardProperties    cp = c.properties[i];
         CardVizProperties p  = GetProperty(cp.e);
         if (p == null)
         {
             continue;
         }
         if (cp.e is IntElement)
         {
             p.text.text = cp.intValue.ToString();
             p.text.gameObject.SetActive(true);
         }
         else if (cp.e is StringElement)
         {
             p.text.text = cp.stringValue;
             p.text.gameObject.SetActive(true);
         }
         else if (cp.e is ImageElement)
         {
             p.img.sprite = cp.spriteValue;
             p.img.gameObject.SetActive(true);
         }
     }
 }
Exemple #4
0
        public string getName()
        {
            //Extract name
            ElementText    nameElement  = Resources.Load("Data/Elements/Name") as ElementText;
            CardProperties nameProperty = SearchProperty(nameElement);
            string         cardName     = nameProperty.stringValue;

            return(cardName);
        }
Exemple #5
0
        //Function that gets an element property in and returns the property that matches the element.
        //If the element is not matched by the properties, it returns null.
        public CardProperties SearchProperty(Element searchedElement)
        {
            CardProperties matchingProperty = null;

            foreach (CardProperties cp in properties)
            {
                if (cp.element == searchedElement)
                {
                    matchingProperty = cp;
                    return(matchingProperty);
                }
            }
            return(matchingProperty);
        }
Exemple #6
0
        public void LoadCard(Card c)
        {
            if (c == null)
            {
                return;
            }

            card = c;
            //c.cardtype.OnSetType(this);

            for (int i = 0; i < c.properties.Length; i++)
            {
                CardProperties    cp = c.properties[i];
                CardVizProperties p  = GetProperties(cp.element);
                if (p == null)
                {
                    continue;
                }
                if (cp.element is ElementText)
                {
                    p.text.text = cp.stringValue;
                }
                else if (cp.element is ElementImage)
                {
                    p.img.sprite = cp.sprite;
                }
                else if (cp.element is ElementInt)
                {
                    p.text.text = cp.intValue.ToString();
                }
            }

            /*
             * title.text = c.cardName;
             * detail.text = c.cardDetail;
             * if(string.IsNullOrEmpty(c.cardFlavor))
             * {
             *  flavor.gameObject.SetActive(false);
             * }
             * else
             * {
             *  flavor.gameObject.SetActive(true);
             *  flavor.text = c.cardFlavor;
             * }
             *
             * artist.text = c.artist;
             * art.sprite = c.art;
             */
        }
Exemple #7
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);
        }