84 lines
2.1 KiB
C#
84 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using GeometryTD.Definition;
|
|
using UnityEngine;
|
|
|
|
namespace GeometryTD.Entity.EntityData
|
|
{
|
|
[Serializable]
|
|
public class EnemyData : EntityDataBase
|
|
{
|
|
[SerializeField] private CampType _camp = CampType.Enemy;
|
|
|
|
[SerializeField] private int _maxHealth = 0;
|
|
|
|
[SerializeField] private float _speed = 0;
|
|
|
|
[SerializeField] private Transform _player = null;
|
|
|
|
[SerializeField] private List<Vector3> _pathPoints = new List<Vector3>();
|
|
|
|
public EnemyData(int entityId, int typeId, Transform player, Vector3 pos, int maxHp, float speed) : base(
|
|
entityId, typeId)
|
|
{
|
|
_maxHealth = maxHp;
|
|
_speed = speed;
|
|
Position = pos;
|
|
_player = player;
|
|
_pathPoints.Clear();
|
|
}
|
|
|
|
public EnemyData(int entityId, int typeId, Vector3 pos, int maxHp, float speed,
|
|
IReadOnlyList<Vector3> pathPoints) : base(entityId, typeId)
|
|
{
|
|
_maxHealth = maxHp;
|
|
_speed = speed;
|
|
Position = pos;
|
|
_player = null;
|
|
SetPathPoints(pathPoints);
|
|
}
|
|
|
|
public CampType Camp
|
|
{
|
|
get => _camp;
|
|
set => _camp = value;
|
|
}
|
|
|
|
public int MaxHealth
|
|
{
|
|
get => _maxHealth;
|
|
set => _maxHealth = value;
|
|
}
|
|
|
|
public float Speed
|
|
{
|
|
get => _speed;
|
|
set => _speed = value;
|
|
}
|
|
|
|
public Transform Player
|
|
{
|
|
get => _player;
|
|
set => _player = value;
|
|
}
|
|
|
|
public IReadOnlyList<Vector3> PathPoints => _pathPoints;
|
|
|
|
public bool HasPath => _pathPoints.Count > 0;
|
|
|
|
public void SetPathPoints(IReadOnlyList<Vector3> pathPoints)
|
|
{
|
|
_pathPoints.Clear();
|
|
if (pathPoints == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
for (int i = 0; i < pathPoints.Count; i++)
|
|
{
|
|
_pathPoints.Add(pathPoints[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|