Пример #1
0
        //Method Instantiates the cards with AbstractCard scripts from the deckData
        //passed in from server and adds the new card to the deck arraylist
        public void createDeck()
        {
            //For loop for every card in deck passed in from server
            for (int i = 0; i < deckData.getSize(); i++)
            {
                //GameObject instantiated for Card
                GameObject obj = (GameObject)Instantiate(Resources.Load("Prefabs/Battle/Card"));

                //Card back for deck
                //GameObject cardBacks = (GameObject) Instantiate(Resources.Load("Prefabs/Battle/card_old"));

                //Card front for hand
                //obj.AddComponent("AbstractCard");
                AbstractCard script = obj.GetComponent <AbstractCard> ();

                //CardData contains all the variables for an indivdual card
                CardData tempCard = deckData.popCard();
                //public void init(BattlePlayer player, int cardID, int diet, int level, int attack,
                //int health,string species_name, string type, string description
                script.init(this, tempCard.cardID, tempCard.dietType, tempCard.level, tempCard.attack,
                            tempCard.health, tempCard.speciesName, "Large Animal", tempCard.description);

                //Add the card to the deck arraylist
                deck.Add(obj);
            }

            //Makes the deck
            GameObject DeckTop = (GameObject)Instantiate(Resources.Load("Prefabs/Battle/CardBack"));

            DeckTop.transform.position = new Vector3(DeckPos.x, DeckPos.y, DeckPos.z);
        }
        override public void execute()
        {
            Debug.Log("TODO: summonCard() in BattlePlayer, all info:" +
                      cardID + diet + level + attack + health + species_name + type);
            Debug.Log("Executing Summon Card");

            //GameObject instantiated for Card
            GameObject obj = GameManager.player2.instantiateCard();



            //Card back for deck
            //GameObject cardBacks = (GameObject) Instantiate(Resources.Load("Prefabs/Battle/card_old"));

            //Card front for hand
            //obj.AddComponent("AbstractCard");
            AbstractCard script = obj.GetComponent <AbstractCard>();

            script.init(GameManager.player2, cardID, diet, level, attack,
                        health, species_name, "Large Animal", description);

            GameManager.player2.cardsInPlay.Add(obj);
            script.handler = new InPlay(script, GameManager.player2);

            GameObject.Destroy((GameObject)GameManager.player2.hand[0]);
            GameManager.player2.hand.RemoveAt(0);

            GameManager.player2.reposition();

            //script.transform.rotation =  Quaternion.Euler(script.transform.rotation.x, script.transform.rotation.y, 0);
            script.transform.rotation = Quaternion.Euler(script.transform.rotation.x, 180, 0);


            Debug.Log(GameManager.player2.cardsInPlay.Count + " Count");
            Debug.Log(script.name + " " + obj.transform.position);
        }