problème : le fait que les méthodes update/start/destroy etc des ILevelObject soit abstraites était restreignant (obligation de override) solution : j'ai rendu les méthodes virtuelles à la place de abstraites.
86 lines
1.9 KiB
C#
86 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using static Extensions;
|
|
|
|
public class Entity : LevelObject
|
|
{
|
|
//Attribut
|
|
[SerializeField, LevelSerialize]
|
|
private int _hp;
|
|
[SerializeField, LevelSerialize]
|
|
private float _speed;
|
|
[SerializeField, LevelSerialize]
|
|
private int _attack_damage;
|
|
[SerializeField, LevelSerialize]
|
|
private float _attack_speed;
|
|
private float _attack_speed_wait = 0f;
|
|
|
|
//Enemy Spotted
|
|
private bool _isEnemyDetected = false;
|
|
private Entity _enemy;
|
|
|
|
//GETTERS AND SETTERS
|
|
|
|
public int Hp
|
|
{
|
|
get { return _hp; }
|
|
set { _hp = value; }
|
|
}
|
|
|
|
public float Speed
|
|
{
|
|
get { return _speed; }
|
|
set { _speed = value; }
|
|
}
|
|
|
|
public int AttackDamage
|
|
{
|
|
get { return _attack_damage; }
|
|
set { _attack_damage = value; }
|
|
}
|
|
|
|
public float AttackSpeed
|
|
{
|
|
get { return _attack_speed; }
|
|
set { _attack_speed = value; }
|
|
}
|
|
|
|
public float AttackSpeedWait
|
|
{
|
|
get { return _attack_speed_wait; }
|
|
set { _attack_speed_wait = value; }
|
|
}
|
|
|
|
public bool IsEnemyDetected
|
|
{
|
|
get { return _isEnemyDetected; }
|
|
set { _isEnemyDetected = value; }
|
|
}
|
|
|
|
public Entity Enemy
|
|
{
|
|
get { return _enemy; }
|
|
set { _enemy = value; }
|
|
}
|
|
|
|
#region [LevelManager code]
|
|
public override bool Equals(ILevelObject other)
|
|
{
|
|
if (!(other is Entity)) return false;
|
|
var otherEntity = other as Entity;
|
|
return otherEntity._hp == _hp
|
|
&& otherEntity.Position == Position
|
|
&& otherEntity.Name == Name
|
|
&& otherEntity._speed == _speed
|
|
&& otherEntity._attack_speed == _attack_speed
|
|
&& otherEntity._attack_damage == _attack_damage;
|
|
}
|
|
|
|
public override Dictionary<string, object> ToDictionary()
|
|
{
|
|
return Extensions.ToDictionary(this);
|
|
}
|
|
#endregion
|
|
}
|