2024-07-10 19:51:24 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Framework;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
namespace Gameplay.Unit.Data
|
|
|
|
|
|
{
|
|
|
|
|
|
public class UnitViewData
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public GameUnit owner;
|
|
|
|
|
|
|
|
|
|
|
|
public bool isShow;
|
2024-07-11 12:26:25 +08:00
|
|
|
|
|
|
|
|
|
|
private GameObject _activeObj;
|
2024-07-10 19:51:24 +08:00
|
|
|
|
|
|
|
|
|
|
public UnitViewData(GameUnit owner)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.owner = owner;
|
2024-07-11 12:26:25 +08:00
|
|
|
|
_SetActiveObj();
|
2024-09-26 17:57:22 +08:00
|
|
|
|
_SetAnimator();
|
2024-07-10 19:51:24 +08:00
|
|
|
|
isShow = true;
|
|
|
|
|
|
}
|
2024-07-11 12:26:25 +08:00
|
|
|
|
|
2024-09-26 17:57:22 +08:00
|
|
|
|
private void _SetAnimator()
|
|
|
|
|
|
{
|
|
|
|
|
|
var animators = _activeObj.GetComponentsInChildren<Animator>();
|
|
|
|
|
|
for (int i = 0; i < animators.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var animator = animators[i];
|
|
|
|
|
|
animator.cullingMode = AnimatorCullingMode.CullUpdateTransforms;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-11 12:26:25 +08:00
|
|
|
|
private void _SetActiveObj()
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (owner.gameunitType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case EGameUnitType.Character:
|
2024-09-23 16:40:23 +08:00
|
|
|
|
_FindCharacterData();
|
2024-07-11 12:26:25 +08:00
|
|
|
|
break;
|
|
|
|
|
|
case EGameUnitType.Vehicle:
|
|
|
|
|
|
_activeObj = owner.Node.GameObject.transform.GetChild(0).gameObject;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
2024-07-11 15:04:39 +08:00
|
|
|
|
_activeObj = owner.Node.GameObject;
|
2024-07-11 12:26:25 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-23 16:40:23 +08:00
|
|
|
|
|
|
|
|
|
|
private void _FindCharacterData()
|
|
|
|
|
|
{
|
|
|
|
|
|
var parentTrans = owner.Node.GameObject.transform.GetChild(0);
|
|
|
|
|
|
for (int i = 0; i < parentTrans.childCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var child = parentTrans.GetChild(i);
|
|
|
|
|
|
if (child.name.StartsWith("CombineObj_"))
|
|
|
|
|
|
{
|
|
|
|
|
|
_activeObj = child.gameObject;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-07-10 19:51:24 +08:00
|
|
|
|
|
|
|
|
|
|
public void SetShow(bool setShow)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isShow == setShow) return;
|
|
|
|
|
|
isShow = setShow;
|
|
|
|
|
|
EventManager.Instance.Send(EventManager.EventName.INFIGHT_UNIT_VISIBLE_CHANGE, owner);
|
2024-07-11 12:26:25 +08:00
|
|
|
|
_activeObj.SetActive(isShow);
|
2024-07-10 19:51:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|