(client) feat:窗口新增独占、占用输入属性,添加部分行为树节点和工作类
This commit is contained in:
12
Client/Assets/Scripts/Entity/BuildingEntity.cs
Normal file
12
Client/Assets/Scripts/Entity/BuildingEntity.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Data;
|
||||
|
||||
namespace Entity
|
||||
{
|
||||
public class BuildingEntity:Entity
|
||||
{
|
||||
void Init(BuildingDef def)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
3
Client/Assets/Scripts/Entity/BuildingEntity.cs.meta
Normal file
3
Client/Assets/Scripts/Entity/BuildingEntity.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 703125e2813a463d9b714841a3f9995f
|
||||
timeCreated: 1753702932
|
@ -9,19 +9,20 @@ using UnityEngine.Serialization;
|
||||
|
||||
namespace Entity
|
||||
{
|
||||
public class Entity:MonoBehaviour,ITick
|
||||
public class Entity : MonoBehaviour, ITick
|
||||
{
|
||||
public SpriteAnimator animatorPrefab;
|
||||
public ImagePrefab imagePrefab;
|
||||
|
||||
|
||||
public AIBase aiTree;
|
||||
public JobBase currentJob;
|
||||
public AttributesDef attributes=new();
|
||||
public AttributesDef attributes = new();
|
||||
public Vector3 direction;
|
||||
public GameObject body;
|
||||
public string affiliation;
|
||||
|
||||
public bool canSelect = true;
|
||||
|
||||
public bool IsChase { set; get; } = true;
|
||||
public bool PlayerControlled
|
||||
{
|
||||
@ -36,15 +37,16 @@ namespace Entity
|
||||
}
|
||||
get => _isPlayerControlled;
|
||||
}
|
||||
public Vector3 Position => transform.position;
|
||||
|
||||
public bool IsDead => attributes.health <= 0;
|
||||
|
||||
private bool _isPlayerControlled = false;
|
||||
private bool _warning = false;
|
||||
|
||||
private Dictionary<Orientation,List<ITick>> bodyAnimationNode=new();
|
||||
public Dictionary<Orientation, List<ITick>> bodyAnimationNode = new();
|
||||
private Dictionary<Orientation, GameObject> bodyNodes = new();
|
||||
|
||||
|
||||
private Orientation currentOrientation = Orientation.Down;
|
||||
|
||||
public virtual void Init(PawnDef pawnDef)
|
||||
@ -70,7 +72,7 @@ namespace Entity
|
||||
if (drawNode == null) continue;
|
||||
var directionRoot = new GameObject(orientation.ToString());
|
||||
directionRoot.transform.SetParent(body.transform, false);
|
||||
InitBodyPart(drawNode, directionRoot,drawingOrder.texturePath);
|
||||
InitBodyPart(drawNode, directionRoot, drawingOrder.texturePath);
|
||||
bodyNodes[orientation] = directionRoot;
|
||||
}
|
||||
currentOrientation = Orientation.Down;
|
||||
@ -83,9 +85,9 @@ namespace Entity
|
||||
}
|
||||
|
||||
// 递归初始化单个绘图节点及其子节点
|
||||
public virtual void InitBodyPart(DrawNodeDef drawNode, GameObject parent,string folderPath)
|
||||
public virtual void InitBodyPart(DrawNodeDef drawNode, GameObject parent, string folderPath)
|
||||
{
|
||||
if(drawNode==null) return;
|
||||
if (drawNode == null) return;
|
||||
|
||||
GameObject nodeObject;
|
||||
if (drawNode.nodeName == "noName")
|
||||
@ -102,8 +104,11 @@ namespace Entity
|
||||
var texture =
|
||||
Managers.PackagesImageManager.Instance.FindBodyTextures(drawNode.packID, folderPath,
|
||||
$"{drawNode.nodeName}_{currentOrientation}");
|
||||
var image = nodeObject.GetComponent<ImagePrefab>();
|
||||
image.SetSprite(texture[0]);
|
||||
if (texture.Length > 0)
|
||||
{
|
||||
var image = nodeObject.GetComponent<ImagePrefab>();
|
||||
image.SetSprite(texture[0]);
|
||||
}
|
||||
break;
|
||||
|
||||
case DrawNodeType.Animation:
|
||||
@ -126,7 +131,7 @@ namespace Entity
|
||||
// 递归初始化子节点
|
||||
foreach (var child in drawNode.children)
|
||||
{
|
||||
InitBodyPart(child, nodeObject,folderPath);
|
||||
InitBodyPart(child, nodeObject, folderPath);
|
||||
}
|
||||
}
|
||||
public void Tick()
|
||||
@ -139,7 +144,6 @@ namespace Entity
|
||||
{
|
||||
AutoBehave();
|
||||
}
|
||||
|
||||
if (bodyAnimationNode.TryGetValue(currentOrientation, out var ticks))
|
||||
{
|
||||
foreach (var tick in ticks)
|
||||
@ -149,9 +153,9 @@ namespace Entity
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void TryAttck()
|
||||
public virtual void TryAttack()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public virtual void SetOrientation(Orientation orientation)
|
||||
@ -174,7 +178,7 @@ namespace Entity
|
||||
if (hit < 0)
|
||||
hit = from.attributes.attack / 100;
|
||||
attributes.health -= hit;
|
||||
|
||||
|
||||
currentJob.StopJob();
|
||||
}
|
||||
|
||||
@ -190,7 +194,7 @@ namespace Entity
|
||||
|
||||
private void AutoBehave()
|
||||
{
|
||||
if(aiTree == null)
|
||||
if (aiTree == null)
|
||||
return;
|
||||
if (currentJob == null || !currentJob.Running)
|
||||
{
|
||||
@ -206,7 +210,7 @@ namespace Entity
|
||||
}
|
||||
currentJob.StartJob(this);
|
||||
}
|
||||
|
||||
|
||||
currentJob.Update();
|
||||
}
|
||||
|
||||
@ -277,7 +281,7 @@ namespace Entity
|
||||
return (AIBase)Activator.CreateInstance(typeof(AIBase));
|
||||
}
|
||||
// 定义可能的命名空间列表
|
||||
var possibleNamespaces = new[] { "AI"};
|
||||
var possibleNamespaces = new[] { "AI" };
|
||||
|
||||
foreach (var ns in possibleNamespaces)
|
||||
{
|
||||
@ -305,4 +309,5 @@ namespace Entity
|
||||
throw new InvalidOperationException($"无法找到类型 {className} 或该类型不是 AIBase 的子类");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -91,7 +91,13 @@ namespace Entity
|
||||
else
|
||||
result.Add(("手动操控",()=>entity.PlayerControlled=true));
|
||||
result.Add(("杀死",()=>entity.Kill()));
|
||||
result.Add(("变成笨蛋",()=>BecomeDefault()));
|
||||
return result;
|
||||
}
|
||||
|
||||
private void BecomeDefault()
|
||||
{
|
||||
entity.Kill();
|
||||
Managers.EntityManage.Instance.GenerateDefaultEntity(entity.Position);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user