public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { /*AnimatorClipInfo[] _arrClipInfos = animator.GetCurrentAnimatorClipInfo(layerIndex); AnimatorClipInfo c = _arrClipInfos[0]; slipName = c.clip.name;*/ //Debug.Log("animator.name : " + animator.name + " c.clip.name " + c.clip.name + " stateInfo.length :" + stateInfo.length + " nameHash " + (Animator.StringToHash(c.clip.name) == stateInfo.shortNameHash)); //if (stateInfo.length > 0) //{ /*AnimationClip _clip = new AnimationClip(); AnimationEvent _event = new AnimationEvent(); _event.functionName = "OnClipEvent"; _event.intParameter = 1; _event.time = 0.6f; _clip.AddEvent(_event);*/ /*MyStateMachineBehaviour myState = animator.GetBehaviour<MyStateMachineBehaviour>(); Debug.Log("-----------------------" + myState._name);*/ //} _enity = animator.transform.GetComponentInParent<EnityBind>().Owner; _enityData = _enity.GetProperty("enityData") as EnityData; _enity.SetProperty("onStateEnter",stateInfo); DataEventSource.Instance.DispatcherEvent("onStateEnter", stateInfo); _isEnd = false; _isLock = AnimatorManager.Instance.IsLock(stateInfo.shortNameHash); if (_isLock) { IsLock = _isLock; } GameInput.Log(" state enter >>>>>>>>>>>>>>>>>>>>>>>>> " + AnimatorManager.Instance.HashToString(stateInfo.shortNameHash)); }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { /*AnimatorClipInfo[] _arrClipInfos = animator.GetCurrentAnimatorClipInfo(layerIndex); * AnimatorClipInfo c = _arrClipInfos[0]; * slipName = c.clip.name;*/ //Debug.Log("animator.name : " + animator.name + " c.clip.name " + c.clip.name + " stateInfo.length :" + stateInfo.length + " nameHash " + (Animator.StringToHash(c.clip.name) == stateInfo.shortNameHash)); //if (stateInfo.length > 0) //{ /*AnimationClip _clip = new AnimationClip(); * AnimationEvent _event = new AnimationEvent(); * _event.functionName = "OnClipEvent"; * _event.intParameter = 1; * _event.time = 0.6f; * _clip.AddEvent(_event);*/ /*MyStateMachineBehaviour myState = animator.GetBehaviour<MyStateMachineBehaviour>(); * Debug.Log("-----------------------" + myState._name);*/ //} _enity = animator.transform.GetComponentInParent <EnityBind>().Owner; _enityData = _enity.GetProperty("enityData") as EnityData; _enity.SetProperty("onStateEnter", stateInfo); DataEventSource.Instance.DispatcherEvent("onStateEnter", stateInfo); _isEnd = false; _isLock = AnimatorManager.Instance.IsLock(stateInfo.shortNameHash); if (_isLock) { IsLock = _isLock; } GameInput.Log(" state enter >>>>>>>>>>>>>>>>>>>>>>>>> " + AnimatorManager.Instance.HashToString(stateInfo.shortNameHash)); }
public override void OnStateUpdate(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo, int layerIndex) { foreach (KeyValuePair <string, float> t in _enityData.DictActionTime) { if (stateInfo.normalizedTime > t.Value) { if (_listNode.Contains(t.Key) == false) { _listNode.Add(t.Key); _enity.SetProperty("normalizedTime", t.Key); } } } if (stateInfo.normalizedTime >= 0.95f + transitionTime) { if (!_isEnd) { //GameInput.Log("state to the end " + stateInfo.normalizedTime); _isEnd = true; animator.SetBool("isAttack", false); animator.Play("idle01"); _enity.SetProperty("actinStateEnd", stateInfo); } } /* if (stateInfo.normalizedTime > 0.3f)//播放特效时间节点 * { * if (!_listNode.Contains("effectNode")) * { * _enity.SetProperty("normalizedTime", "effectNode"); * _listNode.Add("effectNode"); * } * } * if (stateInfo.normalizedTime > 0.6f)//播放受击动作时间节点 * { * if (!_listNode.Contains("beAtkNode")) * { * _enity.SetProperty("normalizedTime", "beAtkNode"); * _listNode.Add("beAtkNode"); * } * }*/ }
public override void OnStateUpdate(UnityEngine.Animator animator, UnityEngine.AnimatorStateInfo stateInfo, int layerIndex) { //DataEventSource.Instance.DispatcherEvent("onStateExit", stateInfo); if (stateInfo.normalizedTime >= 0.95f) { if (!_isEnd) { _isEnd = true; _enity.SetProperty("actinStateEnd", stateInfo); animator.Play("idle01"); } } }
private void Init() { _myEnity = new Enity(); _myEnity.SetProperty("name", "enemy"); _myEnity.Go = LoadModel(); _myEnity.AddComponent("display", new DisplayComponent()); _myEnity.AddComponent("actionComponent", new ActionComponent()); _myEnity.AddComponent("transformComponent", new TransformComponent()); _myEnity.AddComponent("lifeBarComponent", new LifeBarComponent()); PatrolComponent patrolComponent = new PatrolComponent(); _myEnity.AddComponent("patrolComponent", patrolComponent); EnityData _enityData = new EnityData(); _myEnity.AddProperty("enityData", _enityData); _myEnity.Transform.gameObject.AddComponent<EnityBind>().Owner = _myEnity; GameInput.Instance.OnUpdate += patrolComponent.Update; }