Ejemplo n.º 1
0
        // Update is called once per frame
        void Update()
        {
            if (removeAfterDelay)
            {
                delayTimer += Time.deltaTime;

                if (delayTimer > DELAY_CONSTANT)
                {
                    handler = new EndGame(this, player);
                    handler.affect();
                    delayTimer       = 0;
                    removeAfterDelay = false;
                }
            }
            //Display health and change texture accordingly
            transform.Find("HealthText").GetComponent <TextMesh>().text = hp.ToString();
            if (hp <= (maxHP) / 4)    //Under 1/4 hp
            {
                GetComponent <Renderer>().material.mainTexture = tree3Texture;
                transform.Find("HealthText").GetComponent <TextMesh>().color = Color.red;
            }
            else if (hp <= (3 * maxHP) / 4)    //Under 3/4 hp
            {
                GetComponent <Renderer>().material.mainTexture = tree2Texture;
                transform.Find("HealthText").GetComponent <TextMesh>().color = Color.yellow;
            }
            else if (hp > (3 * maxHP) / 4)     //Over 3/4 hp
            {
                GetComponent <Renderer>().material.mainTexture = tree1Texture;
                transform.Find("HealthText").GetComponent <TextMesh> ().color = Color.green;
            }
            if (this.player.isActive)
            {
                transform.Find("NameText").GetComponent <TextMesh> ().text = ">>" + this.player.playerName + "<<";
            }
            else         //Enemy name is red
            {
                transform.Find("NameText").GetComponent <TextMesh> ().text = this.player.playerName;
            }
            if (dmgTimer > 0)
            {
                dmgTimer--;
            }
            else
            {
                transform.Find("DamageText").GetComponent <TextMesh>().text = "";
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        // Update is called once per frame
        void Update()
        {
            if(removeAfterDelay){
            delayTimer += Time.deltaTime;

            if(delayTimer > DELAY_CONSTANT){

                handler = new EndGame(this, player);
                handler.affect();
                delayTimer = 0;
                removeAfterDelay = false;
            }
            }
            //Display health and change texture accordingly
            transform.Find("HealthText").GetComponent<TextMesh>().text = hp.ToString();
            if(hp <= (maxHP)/4) { //Under 1/4 hp
            renderer.material.mainTexture = tree3Texture;
            transform.Find("HealthText").GetComponent<TextMesh>().color = Color.red;
            } else if (hp <= (3*maxHP)/4) {//Under 3/4 hp
            renderer.material.mainTexture = tree2Texture;
            transform.Find("HealthText").GetComponent<TextMesh>().color = Color.yellow;
            } else if (hp > (3*maxHP)/4) { //Over 3/4 hp
            renderer.material.mainTexture = tree1Texture;
            transform.Find ("HealthText").GetComponent<TextMesh> ().color = Color.green;
            }
            if (this.player.isActive) {
            transform.Find ("NameText").GetComponent<TextMesh> ().text = ">>"+this.player.playerName+"<<";
            } else { //Enemy name is red
            transform.Find ("NameText").GetComponent<TextMesh> ().text = this.player.playerName;
            }
            if (dmgTimer > 0) {
            dmgTimer--;
            } else {
            transform.Find("DamageText").GetComponent<TextMesh>().text = "";
            }
        }