예제 #1
0
        // TEMP: activated when EndTurnAction is received.
        public void startTurn()
        {
            player1.isActive = true;
            player2.isActive = false;

            //Deal player 1 a card and set as current player
            GameManager.curPlayer = player1;
            player1.startTurn();
        }
예제 #2
0
        //Initialization for a card and sets it's position to (1000, 1000, 1000)
        public void init(BattlePlayer player, int cardID, int diet, int level, int attack, int health, string species_name, string type, string description)
        {
            this.player             = player;
            this.cardID             = cardID;
            this.manaCost           = level;
            this.transform.position = new Vector3(player.DeckPos.x, player.DeckPos.y, player.DeckPos.z);
            canAttackNow            = true;
            velocity         = 0;
            terminalVelocity = 6000;
            distance         = 0;
            delayTimer       = 0;
            name             = species_name;
            this.diet        = getDietType(diet);
            this.dietNum     = diet;
            this.level       = level;
            maxHP            = hp = health;
            naturalDmg       = dmg = attack;
            //this.type = type; //hide temporarily
            //this.description = description; //hide temporarily

            Debug.Log("diet" + diet);
            //0-omnivore, 1-carnivore, 2-herbivore, 3-spell
            Texture2D cardTexture    = (Texture2D)Resources.Load("Images/Battle/cardfront" + (int)this.diet, typeof(Texture2D));
            Texture2D speciesTexture = (Texture2D)Resources.Load("Images/" + this.name, typeof(Texture2D));

            //Changing cardfront texture
            GetComponent <Renderer>().material.mainTexture = cardTexture;
            transform.Find("CardArt").GetComponent <MeshRenderer> ().material.mainTexture = speciesTexture;

            //Changing card text
//		Color gold = new Color (209f, 234f, 50f, 255f);
            transform.Find("NameText").GetComponent <TextMesh> ().text = TextWrap(this.name, 16);
            transform.Find("TypeText").GetComponent <TextMesh> ().text = this.type;
            transform.Find("TypeText").GetComponent <MeshRenderer> ().material.color        = Color.white;
            transform.Find("DescriptionText").GetComponent <TextMesh> ().text               = TextWrap(this.description, 26);
            transform.Find("DescriptionText").GetComponent <MeshRenderer> ().material.color = Color.white;
            transform.Find("LevelText").GetComponent <TextMesh> ().text = "" + this.level;
            transform.Find("LevelText").GetComponent <MeshRenderer> ().material.color = Color.white;
            transform.Find("DoneText").GetComponent <MeshRenderer> ().material.color  = Color.red;
            transform.Find("DamageText").GetComponent <TextMesh> ().text = "";
            transform.Find("DamageText").GetComponent <MeshRenderer> ().material.color = Color.red;

            //Initializes off screen
            transform.position = new Vector3(1000, 1000, 1000);

            //rotate facedown if player 2
            if (!player.player1 && !Constants.SINGLE_PLAYER)
            {
                transform.rotation = new Quaternion(180, 0, 0, 0);
            }
        }
예제 #3
0
        public static void endTurn()
        {
            // If two_player, only switch turns if player1 isActive
            if (!Constants.SINGLE_PLAYER && player1.isActive)
            {
                protocols.sendEndTurn(player1.playerID);
                //Player's endturn refreshes the player's minions so they can attack next turn.
                player1.endTurn();
                // Not sure if this needs to be here
                player2.endTurn();
                player2.isActive = true;
                player2.addMana();
                if (player2.hand.Count != 5)
                {
                    player2.dealDummyCard(1);
                }
            }

            if (Constants.SINGLE_PLAYER)
            {
                //Player's endturn refreshes the player's minions so they can attack next turn.
                player1.endTurn();
                // Not sure if this needs to be here
                player2.endTurn();
                //PLAYER 1'S TURN ENDING
                if (player1.isActive)
                {
                    //the isActive variables switching for next turn
                    player1.isActive = false;
                    player2.isActive = true;

                    //Sets the current player to player 2 and deals a card
                    GameManager.curPlayer = player2;
                    player2.startTurn();


                    //PLAYER 2'S TURN ENDING
                }
                else
                {
                    //Player 1 is active, Player 2 unactive now
                    player1.isActive = true;
                    player2.isActive = false;

                    //Deal player 1 a card and set as current player
                    GameManager.curPlayer = player1;
                    player1.startTurn();
                }
            }            // End if SinglePlayer
        }
예제 #4
0
        public static void endTurn()
        {
            // If two_player, only switch turns if player1 isActive
            if (!Constants.SINGLE_PLAYER && player1.isActive) {
                protocols.sendEndTurn (player1.playerID);
                //Player's endturn refreshes the player's minions so they can attack next turn.
                player1.endTurn ();
                // Not sure if this needs to be here
                player2.endTurn ();
                player2.isActive = true;
                player2.addMana ();
                if (player2.hand.Count != 5) {
                    player2.dealDummyCard (1);
                }

            }

            if (Constants.SINGLE_PLAYER) {
                //Player's endturn refreshes the player's minions so they can attack next turn.
                player1.endTurn ();
                // Not sure if this needs to be here
                player2.endTurn ();
                //PLAYER 1'S TURN ENDING
                if (player1.isActive) {

                    //the isActive variables switching for next turn
                    player1.isActive = false;
                    player2.isActive = true;

                    //Sets the current player to player 2 and deals a card
                    GameManager.curPlayer = player2;
                    player2.startTurn ();

                    //PLAYER 2'S TURN ENDING
                } else {

                    //Player 1 is active, Player 2 unactive now
                    player1.isActive = true;
                    player2.isActive = false;

                    //Deal player 1 a card and set as current player
                    GameManager.curPlayer = player1;
                    player1.startTurn ();

                }
            }// End if SinglePlayer
        }
예제 #5
0
        public void init(BattlePlayer player)
        {
            this.player = player;
            maxHP =hp= 11;

            if (player.player1) { //Your name is pink
            //transform.Find ("NameText").GetComponent<TextMesh> ().text = this.player.playerName;
            transform.Find ("NameText").GetComponent<TextMesh> ().color = Color.magenta;
            } else { //Enemy name is red
            //transform.Find ("NameText").GetComponent<TextMesh> ().text = this.player.playerName;
            transform.Find("NameText").GetComponent<TextMesh>().color = Color.red;
            }
            //Set dmg text
            transform.Find("DamageText").GetComponent<TextMesh>().text = "";
            //Set alpha level for fading
            //transform.Find ("DamageText").GetComponent<TextMesh> ().color.a = 0;
            handler = new LivingTreeClick(this, player);
            transform.position = new Vector3(player.TreePos.x, player.TreePos.y, player.TreePos.z);
        }
예제 #6
0
        void Start()
        {
            // Needed to to fade into scene
            Game.StartEnterTransition();
            showLoading = 300;             //5 seconds
            popup       = GameObject.Find("Loading");
            protocols   = (ProtocolManager)gameObject.AddComponent <ProtocolManager>();
            protocols.init();

            enabled = true;
            player1 = (BattlePlayer)gameObject.AddComponent <BattlePlayer>();
            player1.init(true);
            player1.playerID = GameState.player.GetID();
            Debug.Log("player1 ID : " + player1.playerID);
            player1.playerName = GameState.player.GetName();

            // initialize match here

            if (Constants.SINGLE_PLAYER)
            {
                player2 = (BattlePlayer)gameObject.AddComponent <BattlePlayer>();
                player2.init(false);
                player2.playerName = "Player 2";
            }
            else
            {
                // TODO: Need different logic here to make player 2
                // not have cards dealt face up, etx.
                player2 = (BattlePlayer)gameObject.AddComponent <BattlePlayer>();
                player2.init(false);
                player2.playerName = "Player 2";
            }
            // Send MatchStatus protocol
            initMatch();

            curPlayer           = player1;
            GameManager.manager = this;

            // Poll for turn updates
            //StartCoroutine(PollAction(Constants.UPDATE_RATE));
        }
예제 #7
0
        public void init(BattlePlayer player)
        {
            this.player = player;
            maxHP       = hp = 11;

            if (player.player1)       //Your name is pink
            //transform.Find ("NameText").GetComponent<TextMesh> ().text = this.player.playerName;
            {
                transform.Find("NameText").GetComponent <TextMesh> ().color = Color.magenta;
            }
            else         //Enemy name is red
                         //transform.Find ("NameText").GetComponent<TextMesh> ().text = this.player.playerName;
            {
                transform.Find("NameText").GetComponent <TextMesh>().color = Color.red;
            }
            //Set dmg text
            transform.Find("DamageText").GetComponent <TextMesh>().text = "";
            //Set alpha level for fading
            //transform.Find ("DamageText").GetComponent<TextMesh> ().color.a = 0;
            handler            = new LivingTreeClick(this, player);
            transform.position = new Vector3(player.TreePos.x, player.TreePos.y, player.TreePos.z);
        }
예제 #8
0
        public override void affect()
        {
            BattlePlayer currentPlayer = GameManager.curPlayer;

            if (currentPlayer.clickedCard == null && player.isActive && card.canAttack())
            {
                player.clickedCard = card;
                if (player.player1)
                {
                    Debug.Log("Player 1 is ready to attack");
                }
                else
                {
                    Debug.Log("Player 2 is ready to attack");
                }
            }
            else if (currentPlayer != player && currentPlayer.clickedCard != null && currentPlayer.clickedCard.diet != AbstractCard.DIET.HERBIVORE)
            {
                currentPlayer.targetCard = card;
                bool attackback = false;
                if (currentPlayer.targetCard.diet != AbstractCard.DIET.HERBIVORE)
                {
                    attackback = true;
                }
                currentPlayer.clickedCard.attack(currentPlayer.clickedCard, currentPlayer.targetCard, attackback);

                currentPlayer.getProtocolManager().sendCardAttack(currentPlayer.playerID, currentPlayer.clickedCard.fieldIndex, currentPlayer.targetCard.fieldIndex);

                currentPlayer.clickedCard = null;
                currentPlayer.targetCard  = null;
            }

            if (currentPlayer.clickedCard != null && currentPlayer == player && card != currentPlayer.clickedCard)
            {
                currentPlayer.clickedCard = null;
            }
        }
예제 #9
0
 public InPlay(AbstractCard card, BattlePlayer player) : base(card, player)
 {
 }
예제 #10
0
 public InHand(AbstractCard card, BattlePlayer player)
     : base(card, player)
 {
 }
예제 #11
0
 public EndGame(Trees tree, BattlePlayer player)
     : base(tree, player)
 {
 }
 public AbstractCardHandler(AbstractCard card, BattlePlayer player)
 {
     this.card   = card;
     this.player = player;
 }
예제 #13
0
 public LivingTreeClick(Trees tree, BattlePlayer player)
     : base(tree, player)
 {
 }
예제 #14
0
 public EndGame(Trees tree, BattlePlayer player) : base(tree, player)
 {
 }
예제 #15
0
 public RemoveFromPlay(AbstractCard card, BattlePlayer player)
     : base(card, player)
 {
 }
예제 #16
0
 public TreesHandler(Trees tree, BattlePlayer player)
 {
     this.tree = tree;
     this.player = player;
 }
예제 #17
0
        void Start()
        {
            // Needed to to fade into scene
            Game.StartEnterTransition ();
            showLoading = 300; //5 seconds
            popup = GameObject.Find ("Loading");
            protocols = (ProtocolManager)gameObject.AddComponent ("ProtocolManager");
            protocols.init ();

            enabled = true;
            player1 = (BattlePlayer)gameObject.AddComponent ("BattlePlayer");
            player1.init (true);
            player1.playerID = GameState.player.GetID ();
            Debug.Log ("player1 ID : " + player1.playerID);
            player1.playerName = GameState.player.GetName ();

            // initialize match here

            if (Constants.SINGLE_PLAYER) {
                player2 = (BattlePlayer)gameObject.AddComponent ("BattlePlayer");
                player2.init (false);
                player2.playerName = "Player 2";
            } else {
                // TODO: Need different logic here to make player 2
                // not have cards dealt face up, etx.
                player2 = (BattlePlayer)gameObject.AddComponent ("BattlePlayer");
                player2.init (false);
                player2.playerName = "Player 2";
            }
            // Send MatchStatus protocol
            initMatch ();

            curPlayer = player1;
            GameManager.manager = this;

            // Poll for turn updates
            //StartCoroutine(PollAction(Constants.UPDATE_RATE));
        }
예제 #18
0
 public LivingTreeClick(Trees tree, BattlePlayer player) : base(tree, player)
 {
 }
예제 #19
0
        // TEMP: activated when EndTurnAction is received.
        public void startTurn()
        {
            player1.isActive = true;
            player2.isActive = false;

            //Deal player 1 a card and set as current player
            GameManager.curPlayer = player1;
            player1.startTurn ();
        }
예제 #20
0
 public TreesHandler(Trees tree, BattlePlayer player)
 {
     this.tree   = tree;
     this.player = player;
 }
예제 #21
0
 public RemoveFromPlay(AbstractCard card, BattlePlayer player) : base(card, player)
 {
 }
예제 #22
0
        //Initialization for a card and sets it's position to (1000, 1000, 1000)
        public void init(BattlePlayer player, int cardID, int diet, int level, int attack, int health, string species_name, string type, string description)
        {
            this.player = player;
            this.cardID = cardID;
            this.manaCost = level;
            this.transform.position = new Vector3 (player.DeckPos.x, player.DeckPos.y, player.DeckPos.z);
            canAttackNow = true;
            velocity = 0;
            terminalVelocity = 6000;
            distance = 0;
            delayTimer = 0;
            name = species_name;
            this.diet = getDietType (diet);
            this.dietNum = diet;
            this.level = level;
            maxHP = hp = health;
            naturalDmg = dmg = attack;
            //this.type = type; //hide temporarily
            //this.description = description; //hide temporarily

            Debug.Log ("diet" + diet);
            //0-omnivore, 1-carnivore, 2-herbivore, 3-spell
            Texture2D cardTexture = (Texture2D)Resources.Load ("Images/Battle/cardfront" + (int)this.diet, typeof(Texture2D));
            Texture2D speciesTexture = (Texture2D)Resources.Load ("Images/" + this.name, typeof(Texture2D));

            //Changing cardfront texture
            renderer.material.mainTexture = cardTexture;
            transform.Find ("CardArt").GetComponent<MeshRenderer> ().material.mainTexture = speciesTexture;

            //Changing card text
            //		Color gold = new Color (209f, 234f, 50f, 255f);
            transform.Find ("NameText").GetComponent<TextMesh> ().text = TextWrap (this.name, 16);
            transform.Find ("TypeText").GetComponent<TextMesh> ().text = this.type;
            transform.Find ("TypeText").GetComponent<MeshRenderer> ().material.color = Color.white;
            transform.Find ("DescriptionText").GetComponent<TextMesh> ().text = TextWrap (this.description, 26);
            transform.Find ("DescriptionText").GetComponent<MeshRenderer> ().material.color = Color.white;
            transform.Find ("LevelText").GetComponent<TextMesh> ().text = "" + this.level;
            transform.Find ("LevelText").GetComponent<MeshRenderer> ().material.color = Color.white;
            transform.Find ("DoneText").GetComponent<MeshRenderer> ().material.color = Color.red;
            transform.Find ("DamageText").GetComponent<TextMesh> ().text = "";
            transform.Find ("DamageText").GetComponent<MeshRenderer> ().material.color = Color.red;

            //Initializes off screen
            transform.position = new Vector3 (1000, 1000, 1000);

            //rotate facedown if player 2
            if (!player.player1 && !Constants.SINGLE_PLAYER) {
                transform.rotation = new Quaternion (180, 0, 0, 0);
            }
        }