Exemple #1
0
 //method for filling core varables. All ennemies will do this the same way
 public void init()
 {
     rigidbody  = GetComponent <Rigidbody>();
     player     = GameObject.Find("Player");
     invTimer   = 51;
     inState    = inStateType.none;
     state      = stateType.wounder;
     startPos   = transform.position;
     startPos.y = 0;
     finalForce = new Vector3(0, 0, 0);
 }
Exemple #2
0
    //method for checking invisnbility frames
    void invCheck()
    {
        if (state != stateType.stunned && state != stateType.dead)
        {
            sTimer = 0;


            if (invTimer < 30 * Time.deltaTime)
            {
                invTimer += 1 * Time.deltaTime;
                inState   = inStateType.damage;
                GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.8f); // displaying invcibility
                state = stateType.recoil;
            }
            else
            {
                inState = inStateType.none;

                //restart velociy and accl

                if (!behindPlayer) //fill opacity if ennemy is not invicle or behind player
                {
                    GetComponent <SpriteRenderer>().color = new Color(1f, 1f, 1f, 1f);
                }
            }
        }
        else
        {
            sTimer += 1 * Time.deltaTime;
            if (state == stateType.stunned)
            {
                inState = inStateType.none;
                if (sTimer >= sTimeStop * Time.deltaTime)
                {
                    state = stateType.wounder;
                }
            }
            else if (state == stateType.dead)
            {
                inState = inStateType.damage;
                if (sTimer >= 200 * Time.deltaTime)
                {
                    if (this.gameObject.name.Contains("Boss"))
                    {
                        SceneManager.LoadScene("VictoryScreen");
                    }
                    Destroy(gameObject);
                }
            }
        }
    }