Ejemplo n.º 1
0
 // Update is called once per frame
 void Update()
 {
     //Determining walk state
     if (myRigidbody != null)
     {
         if (!myControl.IfStunned() && (myRigidbody.velocity.x != 0) && (myRigidbody.velocity.y == 0))
         {
             PlayWalkSound();
         }
         else
         {
             StopWalkSound();
         }
     }
 }
Ejemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //When hit by enemy projectile
        if (other.tag == "EnemyProjectile")
        {
            if (!myControl.IsDead() && !myControl.IfStunned())
            {
                //Take damage
                int damage = other.GetComponent <Projectile_Behavior> ().GetPower();
                TakeDamage(damage);


                //Stun after taking damage
                //If bullets come from the right, pass in 1, else pass in -1;
                if (other.transform.position.x - transform.position.x >= 0)
                {
                    myControl.Stune(1);
                }
                else
                {
                    myControl.Stune(-1);
                }
            }

            Destroy(other.gameObject);
        }


        //When reach portal
        if (other.tag == "Portal")
        {
            if (CheckWinningCondition())
            {
                myControl.Win();
            }
        }
    }