diff options
author | chai <chaifix@163.com> | 2021-08-04 17:37:56 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-08-04 17:37:56 +0800 |
commit | aafae64318a5a08a68b7033441449c36f0f85a17 (patch) | |
tree | 9908e6fd3b6cd3156e3c105da193950031a21f6e /Assets/Scripts | |
parent | 0081fa2bd7b2bf2c40bbae087a2b5753125de30d (diff) |
*actiontool
Diffstat (limited to 'Assets/Scripts')
-rw-r--r-- | Assets/Scripts/Test 1/TestErika.cs | 2 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Collider/ColliderBox.cs | 7 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitAnimation.cs | 88 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Controller/PCController.cs | 4 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Controller/UnitController.cs | 13 |
5 files changed, 100 insertions, 14 deletions
diff --git a/Assets/Scripts/Test 1/TestErika.cs b/Assets/Scripts/Test 1/TestErika.cs index 96fcec25..528924dc 100644 --- a/Assets/Scripts/Test 1/TestErika.cs +++ b/Assets/Scripts/Test 1/TestErika.cs @@ -35,7 +35,7 @@ public class TestErika : MonoBehaviour private void Init() { UnitController unitCtr = unitController.GetOrAddComponent<UnitController>(); - unitCtr.Initialize(unit); + unitCtr.Initialize(unit, "Assets/Bundle/Unit/PC/Erika/"); UnitRootMotion unitRootMotion = unitCtr.unitRootMotion; diff --git a/Assets/Scripts/Unit/Collider/ColliderBox.cs b/Assets/Scripts/Unit/Collider/ColliderBox.cs index ebcc9a2f..467dff77 100644 --- a/Assets/Scripts/Unit/Collider/ColliderBox.cs +++ b/Assets/Scripts/Unit/Collider/ColliderBox.cs @@ -40,6 +40,13 @@ public class ColliderBox public Vector3 hitBack;
[ColliderType(EColliderType.HitBox), Tooltip("允许多次击中")]
public bool multiHit;
+ [ColliderType(EColliderType.HitBox), Tooltip("击中后的粒子效果")]
+ public string sparkPath;
#endregion
+ #region ThrowBox
+ [ColliderType(EColliderType.ThrowBox), Tooltip("是否允许抓取多个")]
+ public bool multiple;
+ #endregion
+
}
\ No newline at end of file diff --git a/Assets/Scripts/Unit/Component/UnitAnimation.cs b/Assets/Scripts/Unit/Component/UnitAnimation.cs index 5ef7b7a1..18439efb 100644 --- a/Assets/Scripts/Unit/Component/UnitAnimation.cs +++ b/Assets/Scripts/Unit/Component/UnitAnimation.cs @@ -1,6 +1,9 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+#if UNITY_EDITOR
+using UnityEditor;
+#endif
public class AnimatorLayerInfo
{
@@ -8,10 +11,40 @@ public class AnimatorLayerInfo public int layerIndex { get { return (int)layer; } }
+ public string name { get { return m_Animator.GetLayerName(layerIndex); } }
+
private Animator m_Animator;
- public AnimationData animationData;
+ // 当前动作的animation data,如果是blendtree选第一个动作
private AnimationData m_AnimationData;
+ public AnimationData animationData
+ {
+ get
+ {
+ if (clipInfo == null || clipInfo.Length == 0)
+ return null;
+ var clip = clipInfo[0]; //选第一个
+ string folder = m_Owner.folder;
+ string name = clip.clip.name;
+ if (m_AnimationData != null && m_AnimationData.animationName == name)
+ return m_AnimationData;
+ string path = folder + "AnimationData/" + name + ".asset" ;
+#if UNITY_EDITOR
+ m_AnimationData = AssetDatabase.LoadAssetAtPath<AnimationData>(path);
+#endif
+ return m_AnimationData;
+ }
+ }
+
+ // 当前动作所有animation data,包括blendtree使用的所有动画
+ //private List<AnimationData> m_AnimationDatas;
+ //public List<AnimationData> animationDatas
+ //{
+ // get
+ // {
+ // return null;
+ // }
+ //}
// 当前在播放的动作
// 如果处于transition中,动作不变,切换完成后才会到下一个动作
@@ -56,10 +89,39 @@ public class AnimatorLayerInfo }
}
- public int pendingStateHash;
+ public float weight
+ {
+ get
+ {
+ return m_Animator.GetLayerWeight(layerIndex);
+ }
+ }
+
+ public int nextStateHash
+ {
+ get
+ {
+ //if (!isInTransition)
+ // return 0;
+ AnimatorStateInfo nextState = m_Animator.GetNextAnimatorStateInfo(layerIndex);
+ int hash = nextState.shortNameHash; // 如果不在过渡中,hash是0
+ return hash;
+ }
+ }
+
+ public bool isInTransition
+ {
+ get
+ {
+ return m_Animator.IsInTransition(layerIndex);
+ }
+ }
- public AnimatorLayerInfo(Animator animator, UnitAnimation.ELayer layer)
+ UnitController m_Owner;
+
+ public AnimatorLayerInfo(UnitController owner, Animator animator, UnitAnimation.ELayer layer)
{
+ this.m_Owner = owner;
this.m_Animator = animator;
this.layer = layer;
}
@@ -77,7 +139,10 @@ public class UnitAnimation : UnitComponent {
Basic = 0,
Attack,
-
+ SwordAttack,
+ GunAttack,
+ UpperBody,
+ LowerBody,
Count,
}
@@ -112,7 +177,7 @@ public class UnitAnimation : UnitComponent private UnitActionData m_ActionData;
public AnimatorLayerInfo[] layers { get { return m_LayerInfo; } }
- private AnimatorLayerInfo[] m_LayerInfo = new AnimatorLayerInfo[(int)ELayer.Count];
+ private readonly AnimatorLayerInfo[] m_LayerInfo = new AnimatorLayerInfo[(int)ELayer.Count];
public bool isInTransition
{
@@ -121,8 +186,6 @@ public class UnitAnimation : UnitComponent return m_Animator.IsInTransition(0);
}
}
- //public EAnimState curState { get { return m_CurState; } }
- //private EAnimState m_CurState;
public override void Initialize()
{
@@ -133,8 +196,8 @@ public class UnitAnimation : UnitComponent m_Animator.speed = 0;
- m_LayerInfo[0] = new AnimatorLayerInfo(m_Animator, ELayer.Basic);
- m_LayerInfo[1] = new AnimatorLayerInfo(m_Animator, ELayer.Attack);
+ m_LayerInfo[0] = new AnimatorLayerInfo(m_Owner, m_Animator, ELayer.Basic);
+ m_LayerInfo[1] = new AnimatorLayerInfo(m_Owner, m_Animator, ELayer.Attack);
if (m_Animator == null)
{
@@ -174,7 +237,12 @@ public class UnitAnimation : UnitComponent public void AnimAttack()
{
- m_Animator.SetTrigger(ETrigger.ToAttack.ToString());
+ SetTrigger(ETrigger.ToAttack);
+ }
+
+ void SetTrigger(ETrigger trigger)
+ {
+ m_Animator.SetTrigger(trigger.ToString());
}
}
diff --git a/Assets/Scripts/Unit/Controller/PCController.cs b/Assets/Scripts/Unit/Controller/PCController.cs index 4904d60e..5834470a 100644 --- a/Assets/Scripts/Unit/Controller/PCController.cs +++ b/Assets/Scripts/Unit/Controller/PCController.cs @@ -13,9 +13,9 @@ public class PCController : UnitController instance = this;
}
- public override void Initialize(GameObject obj)
+ public override void Initialize(GameObject obj, string folder)
{
- base.Initialize(obj);
+ base.Initialize(obj, folder);
}
diff --git a/Assets/Scripts/Unit/Controller/UnitController.cs b/Assets/Scripts/Unit/Controller/UnitController.cs index 1863ad69..a1eecde6 100644 --- a/Assets/Scripts/Unit/Controller/UnitController.cs +++ b/Assets/Scripts/Unit/Controller/UnitController.cs @@ -42,10 +42,21 @@ public class UnitController : MonoBehaviour }
}
- public virtual void Initialize( GameObject obj )
+ private string m_Folder;
+ public string folder
+ {
+ get
+ {
+ return m_Folder;
+ }
+ }
+
+ public virtual void Initialize( GameObject obj , string folder)
{
unitObj = obj;
+ m_Folder = folder;
+
unitRender = gameObject.GetOrAddComponent<UnitRender>();
unitRender.Initialize();
|