From 22891bf59032ba88262824255a706d652031384b Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 10 Mar 2022 14:07:40 +0800 Subject: * move folder --- Assets/Scripts/Unit/Controller/UnitController.cs | 269 ----------------------- 1 file changed, 269 deletions(-) delete mode 100644 Assets/Scripts/Unit/Controller/UnitController.cs (limited to 'Assets/Scripts/Unit/Controller/UnitController.cs') diff --git a/Assets/Scripts/Unit/Controller/UnitController.cs b/Assets/Scripts/Unit/Controller/UnitController.cs deleted file mode 100644 index 06d5a840..00000000 --- a/Assets/Scripts/Unit/Controller/UnitController.cs +++ /dev/null @@ -1,269 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -//public interface Interactable -//{ -// void OnHit(); -// void OnHurt(); -// void OnGrab(); -//} - -public class UnitController : MonoBehaviour/*, Interactable*/ -{ - public enum UnitType - { - PC, - Monster, - Prop, - } - - public virtual UnitType type { get; } - - // 角色共有的组件 - - public UnitRender unitRender; - - public UnitState unitState; - public PCState pcState { get { return unitState as PCState; } } - public MonsterState monsterState { get { return unitState as MonsterState; } } - - public UnitAnimation unitAnimation; - public PCAnimation pcAnimation { get { return unitAnimation as PCAnimation; } } - public MonsterAnimation monsterAnimation { get { return unitAnimation as MonsterAnimation; } } - - public UnitSkill unitSkill; - - public UnitRootMotion unitRootMotion; - - public UnitCollider unitCollider; - - public UnitDetail unitDetail; - - public UnitBody unitBody; - - public UnitLensEffect unitLensEffect; - - public UnitPreprocessing unitPreprocessing; - - public GameObject unitObj; // 角色模型 - - protected List unitComponents; - - #region 事件监听 - public delegate void OnTimelineEventHandle(AnimationEventBase animEvent); - public OnTimelineEventHandle onTimelineEvent { get; set; } - #endregion - - public bool isTowardRight - { - get - { - return transform.rotation.eulerAngles.y == 0; - } - } - - public virtual bool isOnGround - { - get - { - return transform.position.y <= 0f; - } - } - - public bool isInAir - { - get - { - return !isOnGround; - } - } - - private string m_Folder; - public string folder - { - get - { - return m_Folder; - } - } - - private bool m_Visible; - public bool visible - { - get - { - return m_Visible; - } - } - - public TRS trs - { - get - { - TRS trs = new TRS(); - trs.position = position; - trs.rotation = rotation; - trs.scale = lossyScale; - return trs; - } - } - - public virtual Vector3 center - { - get - { - return GetComponentInChildren().bounds.center; - } - set - { - Vector3 offset = new Vector3(0, -GetComponentInChildren().bounds.size.y / 2f, 0); - transform.position = value + offset; - } - } - - public virtual Vector3 position - { - get - { - return transform.position; - } - set - { - transform.position = value; - } - } - - public virtual Quaternion rotation - { - get - { - return transform.rotation; - } - set - { - transform.rotation = value; - } - } - - public virtual Vector3 lossyScale - { - get - { - return transform.lossyScale; - } - } - - public virtual void Initialize( GameObject obj , string folder) - { - unitObj = obj; - m_Folder = folder; - unitComponents = new List(); - - Initialize(); - - OnPostInitailize(); - } - - protected virtual void Initialize() - { - unitSkill = GetOrAddUnitComponent(); - unitSkill.Initialize(); - - unitRootMotion = GetOrAddUnitComponent(); - unitRootMotion.Initialize(); - - unitCollider = GetOrAddUnitComponent(); - unitCollider.Initialize(); - - unitBody = GetOrAddUnitComponent(); - unitBody.Initialize(); - - unitRender = GetOrAddUnitComponent(); - unitRender.Initialize(); - - unitLensEffect = GetOrAddUnitComponent(); - unitLensEffect.Initialize(); - - unitDetail = gameObject.GetComponentInChildren(); - - unitPreprocessing = GetOrAddUnitComponent(); - unitPreprocessing.Initialize(); - } - - private void OnPostInitailize() - { - if (unitComponents == null) - return; - for(int i = 0; i < unitComponents.Count; ++i) - { - unitComponents[i].OnPostInitialize(); - } - } - - protected T GetOrAddUnitComponent() where T : UnitComponent - { - T comp = gameObject.GetOrAddComponent(); - Debug.Assert(unitComponents != null); - unitComponents.Add(comp); - return comp; - } - - public virtual void Update() - { - unitRender.OnUpdate(); - unitState.OnUpdate(); - unitAnimation.OnUpdate(); - unitSkill.OnUpdate(); - unitRootMotion.OnUpdate(); - unitLensEffect.OnUpdate(); - } - - public virtual void OnDestroy() - { - } - - public virtual void OnHit(CollisionInfo info) - { - } - - public virtual void OnGetHit(CollisionInfo info) - { - } - - public virtual void OnGetShot(CollisionInfo info) - { - } - - - public virtual void OnGrab() - { - } - - public virtual void OnPull() - { - } - - public void SetYPosition(float y) - { - Vector3 pos = transform.position; - pos.y = y; - transform.position = pos; - } - - public UnitSnapshotInfo TakeSnapshot() - { - UnitSnapshotInfo snapshot = new UnitSnapshotInfo(); - snapshot.trs = new TRS(unitObj.transform.position, unitObj.transform.rotation, unitObj.transform.lossyScale); - snapshot.unit = this; - snapshot.animStateHash = unitAnimation.baseLayer.stateHash; - snapshot.normalizedTime = unitAnimation.baseLayer.playbackNormalizedTime; - return snapshot; - } - - public UnitSnapshotInfo TakeSnapshotClosestDashPose(bool forward = true) - { - UnitSnapshotInfo snapshot = new UnitSnapshotInfo(); - return snapshot; - } -} \ No newline at end of file -- cgit v1.1-26-g67d0