2025-09-28 15:02:57 +08:00
|
|
|
using Data;
|
|
|
|
|
using Managers;
|
2025-08-19 20:22:10 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Entity
|
|
|
|
|
{
|
2025-09-19 08:26:54 +08:00
|
|
|
public class Building : CombatantEntity
|
2025-08-19 20:22:10 +08:00
|
|
|
{
|
2025-09-28 15:02:57 +08:00
|
|
|
private BuildingOutline buildingOutline;
|
|
|
|
|
private BuildingDef buildingDef;
|
|
|
|
|
|
2025-10-03 00:31:34 +08:00
|
|
|
public override void Init(EntityDef entityDefine)
|
2025-09-28 15:02:57 +08:00
|
|
|
{
|
2025-10-03 00:31:34 +08:00
|
|
|
base.Init(entityDefine);
|
|
|
|
|
buildingDef = entityDefine as BuildingDef;
|
2025-09-28 15:02:57 +08:00
|
|
|
buildingOutline = entityPrefab.outline as BuildingOutline;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-19 20:22:10 +08:00
|
|
|
public override void SetTarget(Vector3 pos)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void TryMove()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdatePlayerControls()
|
|
|
|
|
{
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.W))
|
|
|
|
|
{
|
|
|
|
|
transform.position += Vector3.up;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.A))
|
|
|
|
|
{
|
|
|
|
|
transform.position += Vector3.left;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.S))
|
|
|
|
|
{
|
|
|
|
|
transform.position += Vector3.down;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Input.GetKeyDown(KeyCode.D))
|
|
|
|
|
{
|
|
|
|
|
transform.position += Vector3.right;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-09-28 15:02:57 +08:00
|
|
|
|
|
|
|
|
public override void Tick()
|
|
|
|
|
{
|
|
|
|
|
base.Tick();
|
|
|
|
|
if (buildingDef.triggerEvents != null && buildingOutline.PlayerOnGround &&
|
|
|
|
|
Input.GetKeyDown(buildingDef.activateKey))
|
|
|
|
|
{
|
|
|
|
|
foreach (var eventDef in buildingDef.triggerEvents)
|
|
|
|
|
{
|
|
|
|
|
EventManager.Instance.Action(eventDef, this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-08-19 20:22:10 +08:00
|
|
|
}
|
|
|
|
|
}
|