Exemplo n.º 1
0
 public void EndHeavySwing()
 {
     weakSpot.SetWeakSpotActive(false);
     isMissileCooldown = false;
     time         = 0;
     currentState = robotAction.idle;
 }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        currentState      = robotAction.idle;
        isFacingLeft      = true;
        isMissileCooldown = false;
        time = 0;

        weakSpot = GetComponentInChildren <WeakSpot>();

        anim = GetComponent <Animator>();
    }
Exemplo n.º 3
0
    //points in direction of the player when idle
    void eyesOnPlayer()
    {
        //face left
        if (player.transform.position.x < this.transform.position.x)
        {
            Vector3 scale = transform.localScale;
            if (scale.x >= 0f)
            {
                scale.x *= -1;
            }
            transform.localScale = scale;
            isFacingLeft         = true;
        }
        //face right
        else
        {
            Vector3 scale = transform.localScale;
            if (scale.x < 0f)
            {
                scale.x *= -1;
            }
            transform.localScale = scale;
            isFacingLeft         = false;
        }

        time += Time.deltaTime;

        //time to do the swinging animation
        if (time >= 8)
        {
            currentState = robotAction.swing;
        }
        //time to fire a missile
        else if (time >= 5 && !isMissileCooldown)
        {
            currentState = robotAction.missile;
        }
    }
Exemplo n.º 4
0
    //preps up missile
    void fireMissile()
    {
        if (!isMissileCooldown)
        {
            Rigidbody2D firedMissile;
            firedMissile = Instantiate(missile, this.transform.position, this.transform.rotation) as Rigidbody2D;

            //if robot is facing the left, barrage left
            if (isFacingLeft)
            {
                firedMissile.velocity = transform.TransformDirection(Vector3.left) * missileSpeed;
            }

            else             //if the robot is facing right, barrage right
            {
                firedMissile.velocity = transform.TransformDirection(Vector3.right) * missileSpeed;
            }

            isMissileCooldown = true;
        }

        //reset back to idle state
        currentState = robotAction.idle;
    }