Beispiel #1
0
 public override void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.collider.tag.Equals("RightWall"))
     {
         if (isMovingRight)
         {
             wallCollisionListener(collision.collider.tag);
         }
     }
     else if (collision.collider.tag.Equals("LeftWall"))
     {
         if (isMovingLeft)
         {
             wallCollisionListener(collision.collider.tag);
         }
     }
     if (collision.collider.tag.Equals("Laser"))
     {
         Destroy(collision.collider.gameObject);
         AlienManager.GetInstance().OnAlienDeath();
         animator.SetBool("IsKilled", true);
         // OnDie() is called when the animation is finished playing
     }
     if (collision.collider.tag.Equals("Player"))
     {
         // Debug.Log("Alien collided with Player. Game Over.");
         GameManager.GetInstance().OnGameLost();
     }
 }
Beispiel #2
0
 public override void Start()
 {
     animator = GetComponent <Animator>();
     Alien.wallCollisionListener += OnWallCollision;
     isMovingRight = true;
     isMovingLeft  = false;
     velocity      = alienVelocity;
     AlienManager.GetInstance().AddAlien(this);
 }
Beispiel #3
0
 /**
  * This method is called when the death-animation
  * of an Alien is completed.
  */
 protected override void OnDie()
 {
     AlienManager.GetInstance().RemoveAlien(this);
     base.OnDie(base.points);
     Destroy(this.gameObject);
     if (AlienManager.GetInstance().GetAlienCount() == 0)
     {
         GameManager.GetInstance().OnGameWon();
     }
 }