添加 CombatNodeComponent 及相关类
- CombatNodeComponent:节点组件,负责提取并开始关卡 - CombatScheduler:关卡调度器,负责关卡的生命周期调度 - MapEntity:地图实体,提供地图相关的数据 - Spawner:出生点,负责标记地图上的敌人出生点坐标 - House:基地,负责标记地图上的敌人目标点坐标
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GeometryTD.Definition;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -14,6 +15,8 @@ namespace GeometryTD.Entity.EntityData
|
||||
[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)
|
||||
@@ -22,6 +25,17 @@ namespace GeometryTD.Entity.EntityData
|
||||
_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
|
||||
@@ -47,5 +61,23 @@ namespace GeometryTD.Entity.EntityData
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,41 +13,37 @@ namespace GeometryTD.Entity.EntityData
|
||||
[Serializable]
|
||||
public abstract class EntityDataBase
|
||||
{
|
||||
[SerializeField]
|
||||
private int m_Id = 0;
|
||||
[SerializeField] private int _id = 0;
|
||||
|
||||
[SerializeField]
|
||||
private int m_TypeId = 0;
|
||||
[SerializeField] private int _typeId = 0;
|
||||
|
||||
[SerializeField]
|
||||
private Vector3 m_Position = Vector3.zero;
|
||||
[SerializeField] private Vector3 _position = Vector3.zero;
|
||||
|
||||
[SerializeField]
|
||||
private Quaternion m_Rotation = Quaternion.identity;
|
||||
[SerializeField] private Quaternion _rotation = Quaternion.identity;
|
||||
|
||||
public EntityDataBase(int entityId, int typeId)
|
||||
{
|
||||
m_Id = entityId;
|
||||
m_TypeId = typeId;
|
||||
_id = entityId;
|
||||
_typeId = typeId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 实体编号。
|
||||
/// 生成的实体编号。
|
||||
/// </summary>
|
||||
public int Id => m_Id;
|
||||
public int Id => _id;
|
||||
|
||||
/// <summary>
|
||||
/// 实体类型编号。
|
||||
/// 实体类型编号(外键)。
|
||||
/// </summary>
|
||||
public int TypeId => m_TypeId;
|
||||
public int TypeId => _typeId;
|
||||
|
||||
/// <summary>
|
||||
/// 实体位置。
|
||||
/// </summary>
|
||||
public Vector3 Position
|
||||
{
|
||||
get => m_Position;
|
||||
set => m_Position = value;
|
||||
get => _position;
|
||||
set => _position = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -55,8 +51,8 @@ namespace GeometryTD.Entity.EntityData
|
||||
/// </summary>
|
||||
public Quaternion Rotation
|
||||
{
|
||||
get => m_Rotation;
|
||||
set => m_Rotation = value;
|
||||
get => _rotation;
|
||||
set => _rotation = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GeometryTD.Entity.EntityData
|
||||
{
|
||||
[Serializable]
|
||||
public class MapData : EntityDataBase
|
||||
{
|
||||
[SerializeField] private int _levelId = 0;
|
||||
|
||||
public MapData(int entityId, int levelId, Vector3 position) : this(entityId, 0, levelId, position)
|
||||
{
|
||||
}
|
||||
|
||||
public MapData(int entityId, int typeId, int levelId, Vector3 position) : base(entityId, typeId)
|
||||
{
|
||||
_levelId = levelId;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public int LevelId
|
||||
{
|
||||
get => _levelId;
|
||||
set => _levelId = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2635b0451d8c944ea0a5761ebc53d51
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user