Example #1
0
    // Use this for initialization
    void Start()
    {
        m_life = m_maxlife;
        m_state=AnimState.Right;
        m_speed = speedIni;

        m_spawn.m_liveEnemy++;
        GameManager.Instance.m_EnemyList.Add (this);

        //create a health bar
        m_bar = (GameObject) Instantiate (healthbar,
                             new Vector3 (this.transform.position.x - 0.5f, this.transform.position.y + 0.6f, 0),
                             Quaternion.identity);
        m_bar.transform.parent = this.transform;
        m_barController = m_bar.transform.FindChild("above").GetComponent<healthBarController> ();
        m_barController.UpdateHealthBar (m_life * 1.0f / m_maxlife);

        yelltimer = yelltime;

        is_dead = false;
    }
Example #2
0
 void skeletRevive()
 {
     //Debug.Log("revive");
     //judge the rotation then set the trigger
     Vector3 vec = m_currentNode.transform.position - this.transform.position;
     float angle = Mathf.Atan2(vec.y,vec.x) * Mathf.Rad2Deg;//vector.right as the direction
     //Debug.Log (angle);
     if (angle >= -180 && angle < -135) {
         anim.SetTrigger("reviveleft");
         m_state=AnimState.Left;
         angle+=180;
     }
     else if (angle >= -135 && angle < -45) {
         anim.SetTrigger("revivefront");
         m_state=AnimState.Down;
         angle+=90;
     }
     else if (angle >= -45 && angle < 45) {
         anim.SetTrigger("reviveright");
         m_state=AnimState.Right;
     }
     else if (angle >= 45 && angle < 135) {
         anim.SetTrigger("reviveback");
         m_state=AnimState.Up;
         angle-=90;
     }else if(angle>=135 && angle<180){
         anim.SetTrigger("reviveleft");
         m_state=AnimState.Left;
         angle-=180;
     }
     transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);//along axis Z rotate angle degree
     //health return to initial status
     m_life = m_maxlife;
     m_speed = speedIni;
     //create a health bar
     m_bar = (GameObject) Instantiate (healthbar,
                                       new Vector3 (this.transform.position.x - 0.5f, this.transform.position.y + 0.6f, 0),
                                       Quaternion.identity);
     m_bar.transform.parent = this.transform;
     m_barController = m_bar.transform.FindChild("above").GetComponent<healthBarController> ();
     m_barController.UpdateHealthBar (m_life * 1.0f / m_maxlife);
 }