116 lines
1.9 KiB
C#
116 lines
1.9 KiB
C#
using System;
|
||
using DragonLi.Core;
|
||
using DragonLi.Frame;
|
||
using Mirror;
|
||
using UnityEngine;
|
||
|
||
// DragonLiAgent
|
||
public class XAgent : Agent
|
||
{
|
||
public Transform HeadPoint;
|
||
public Transform chestPoint;
|
||
|
||
public bool isNavigationInArea = false;
|
||
public int Id;
|
||
public int type;
|
||
[NonSerialized]
|
||
public int LockPlayer = 0;
|
||
|
||
/// <summary>
|
||
/// 索引
|
||
/// </summary>
|
||
public int index;
|
||
|
||
[ServerCallback]
|
||
private void OnTriggerStay(Collider other)
|
||
{
|
||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǵ<EFBFBD><C7B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
if (other.CompareTag("NoWalk"))
|
||
{
|
||
isNavigationInArea = true;
|
||
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||
}
|
||
}
|
||
|
||
[ServerCallback]
|
||
private void OnTriggerExit(Collider other)
|
||
{
|
||
if (other.CompareTag("NoWalk"))
|
||
{
|
||
isNavigationInArea = false;
|
||
}
|
||
}
|
||
|
||
|
||
public override void Die(object info, Transform _sender)
|
||
{
|
||
NavAgent.enabled = false;
|
||
base.Die(info, _sender);
|
||
}
|
||
|
||
public override void OnSpawn()
|
||
{
|
||
base.OnSpawn();
|
||
}
|
||
|
||
public override void InitData()
|
||
{
|
||
Data.Add("atk", new DataRow(SupportDataType.Float)
|
||
{
|
||
Name = "atk",
|
||
FloatValue = 10f
|
||
});
|
||
if (NavAgent.isActiveAndEnabled)
|
||
{
|
||
NavAgent.speed = Data["speed"].FloatValue;
|
||
NavAgent.acceleration = Data["acc"].FloatValue;
|
||
}
|
||
base.InitData();
|
||
}
|
||
|
||
public override void Awake()
|
||
{
|
||
base.Awake();
|
||
}
|
||
|
||
public enum BodyPoint
|
||
{
|
||
Head,
|
||
LeftHand,
|
||
RightHand,
|
||
Leftleg,
|
||
Rightleg,
|
||
chest
|
||
}
|
||
|
||
public Transform FindBody(BodyPoint point)
|
||
{
|
||
switch (point)
|
||
{
|
||
case BodyPoint.Head:
|
||
return HeadPoint;
|
||
case BodyPoint.chest:
|
||
return chestPoint;
|
||
}
|
||
|
||
return chestPoint;
|
||
}
|
||
|
||
internal override void Update()
|
||
{
|
||
if (isServer && gameObject.activeSelf && (base.IsAlive || updateSelf) && DragonLiEntity.ShouldUpdate)
|
||
{
|
||
if (NavAgent != null & NavAgent.enabled)
|
||
{
|
||
UpdateAniamtorValues(NavAgent.velocity);
|
||
}
|
||
else if (base.RigidbodyComponent)
|
||
{
|
||
UpdateAniamtorValues(base.RigidbodyComponent.velocity);
|
||
}
|
||
OnUpdate();
|
||
}
|
||
}
|
||
}
|
||
|