1
0
Fork 0
Bildschirmflausch-LD41/Assets/Scripts/Entities/Player.cs

42 lines
959 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : Mob {
public Player() : base(null, 100 )
{
2018-04-21 19:50:12 +02:00
}
2018-04-21 20:13:58 +02:00
private void OnCollisionEnter2D(Collision2D collision)
2018-04-21 19:50:12 +02:00
{
Debug.Log("Collision");
if (collision.collider.tag == "wall") {
Kill();
} else if (collision.collider.tag == "enemy")
{
Mob m = collision.collider.GetComponent(typeof(Mob)) as Mob;
if(m != null)
{
InflictDamage(m.GetDamage()); // TODO think about Mob attac mechanic
}
2018-04-21 19:50:12 +02:00
}
}
2018-04-21 20:13:58 +02:00
private void OnTriggerEnter2D(Collider2D other)
2018-04-21 19:50:12 +02:00
{
if (other.tag == "door") {
Debug.Log("Open door");
}
}
public override void Kill()
{
base.Kill();
Destroy(this.gameObject);
2018-04-22 00:22:56 +02:00
GameController.instance.ChangeState(GameController.GameState.ENDED);
2018-04-21 19:50:12 +02:00
}
}