2018-04-21 18:45:26 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class Player : Mob {
|
|
|
|
|
|
2018-04-22 15:59:14 +02:00
|
|
|
|
public Player() : base(100) { }
|
2018-04-21 18:45:26 +02:00
|
|
|
|
|
2018-04-22 15:59:14 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Collision checking. Player is going to die on any collision with a wall.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="collision"></param>
|
|
|
|
|
private void OnCollisionEnter2D(Collision2D collision) {
|
2018-04-21 19:50:12 +02:00
|
|
|
|
Debug.Log("Collision");
|
2018-04-22 15:59:14 +02:00
|
|
|
|
if ( collision.collider.tag == "wall" ) {
|
|
|
|
|
Death();
|
|
|
|
|
} else if ( collision.collider.tag == "enemy" ) {
|
2018-04-22 05:57:26 +02:00
|
|
|
|
Mob m = collision.collider.GetComponent(typeof(Mob)) as Mob;
|
2018-04-22 15:59:14 +02:00
|
|
|
|
if ( m != null ) {
|
2018-04-22 05:57:26 +02:00
|
|
|
|
InflictDamage(m.GetDamage()); // TODO think about Mob attac mechanic
|
|
|
|
|
}
|
2018-04-21 19:50:12 +02:00
|
|
|
|
|
|
|
|
|
}
|
2018-04-22 15:59:14 +02:00
|
|
|
|
}
|
2018-04-21 19:50:12 +02:00
|
|
|
|
|
2018-04-22 15:59:14 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// This is called when a Player died.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected override void Death() {
|
2018-04-22 19:43:29 +02:00
|
|
|
|
Debug.Log("Player died...");
|
2018-04-21 19:50:12 +02:00
|
|
|
|
Destroy(this.gameObject);
|
2018-04-22 00:22:56 +02:00
|
|
|
|
GameController.instance.ChangeState(GameController.GameState.ENDED);
|
2018-04-22 15:59:14 +02:00
|
|
|
|
}
|
2018-04-21 18:45:26 +02:00
|
|
|
|
}
|