You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			121 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C#
		
	
			
		
		
	
	
			121 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C#
		
	
| using Entitas;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using Game;
 | |
| 
 | |
| public class AnimationSystem : IExecuteSystem, IInitializeSystem
 | |
| {
 | |
|     private Dictionary<string, int> _paramId;
 | |
|     private IGroup<GameEntity> _entities;
 | |
| 
 | |
|     public void Initialize()
 | |
|     {
 | |
|         _entities = Util.GetGroup(GameMatcher.Animation);
 | |
|         _paramId = new Dictionary<string, int>();
 | |
|         RegisterAnimationParam();
 | |
|     }
 | |
| 
 | |
|     private void RegisterAnimationParam()
 | |
|     {
 | |
|         var aniParams = new List<string>()
 | |
|         {
 | |
|             "isFreeControl",
 | |
|             "isTimelineAnother",
 | |
|             "isGround",
 | |
|             "isWalk",
 | |
|             "isStagger",
 | |
|             "isStun",
 | |
|             "speedX",
 | |
|             "speedY",
 | |
|             "dieTrigger",
 | |
|             "hitTrigger",
 | |
|             "mhitTrigger",
 | |
|             "lhitTrigger",
 | |
|             "airhitTrigger",
 | |
|             "stunhitTrigger",
 | |
|             "reboundTrigger",
 | |
|             "resetTrigger",
 | |
|         };
 | |
|         foreach (var item in aniParams)
 | |
|         {
 | |
|             _paramId[item] = Animator.StringToHash(item);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public void Execute()
 | |
|     {
 | |
|         foreach (var entity in _entities)
 | |
|         {
 | |
|             UpdateMoveAnimationParam(entity);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     private void UpdateMoveAnimationParam(GameEntity entity)
 | |
|     {
 | |
|         var animation = entity.animation;
 | |
|         var move = entity.move;
 | |
|         var velocity = Util.EntityVelocity(entity.ID());
 | |
|         var animator = animation.Animator;
 | |
|         animator.SetBool(Id("isFreeControl"), entity.iD.Data.IsFreeControl);
 | |
|         animator.SetBool(Id("isTimelineAnother"), animation.IsTimelineAnother);
 | |
|         animator.SetBool(Id("isGround"), move.IsGroundLogic);
 | |
|         animator.SetBool(Id("isWalk"), move.IsWalk);
 | |
|         animator.SetBool(Id("isStagger"), Util.EntityIsStagger(entity));
 | |
|         animator.SetBool(Id("isStun"), Util.HasStunBuff(entity.ID()));
 | |
|         animator.SetFloat(Id("speedX"), Mathf.Abs(velocity.x));
 | |
|         animator.SetFloat(Id("speedY"), Mathf.Abs(velocity.y));
 | |
| 
 | |
|         if (animation.ResetMsg)
 | |
|         {
 | |
|             animator.SetTrigger(Id("resetTrigger"));
 | |
|             animation.ResetMsg = false;
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             if (animation.DieMsg)
 | |
|             {
 | |
|                 animator.SetTrigger(Id("dieTrigger"));
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 if (animation.HitMsg)
 | |
|                 {
 | |
|                     animator.SetTrigger(Id("hitTrigger"));
 | |
|                 }
 | |
|                 else if (animation.MHitMsg)
 | |
|                 {
 | |
|                     animator.SetTrigger(Id("mhitTrigger"));
 | |
|                 }
 | |
|                 else if (animation.LHitMsg)
 | |
|                 {
 | |
|                     animator.SetTrigger(Id("lhitTrigger"));
 | |
|                 }
 | |
|                 else if (animation.AirHitMsg)
 | |
|                 {
 | |
|                     animator.SetTrigger(Id("airhitTrigger"));
 | |
|                 }
 | |
|                 else if (animation.StunHitMsg)
 | |
|                 {
 | |
|                     animator.SetTrigger(Id("stunhitTrigger"));
 | |
|                 }
 | |
|                 else if (animation.ReboundMsg)
 | |
|                 {
 | |
|                     animator.SetTrigger(Id("reboundTrigger"));
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         animation.DieMsg = false;
 | |
|         animation.HitMsg = false;
 | |
|         animation.MHitMsg = false;
 | |
|         animation.LHitMsg = false;
 | |
|         animation.AirHitMsg = false;
 | |
|         animation.StunHitMsg = false;
 | |
|         animation.ReboundMsg = false;
 | |
|     }
 | |
| 
 | |
|     private int Id(string paramName)
 | |
|     {
 | |
|         return _paramId[paramName];
 | |
|     }
 | |
| } |