123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using System;
- using UnityEngine;
- namespace Game
- {
- public class AnimatorCockController : ICockController
- {
- private readonly Animator _animator;
- private const string Status = "status";
- private const int StatusIdle = 1;
- private const int StatusWalk = 2;
- private const int StatusRun = 3;
- private const int StatusIdle2 = 4;
- private const string TriggerAttack = "attack";
- private const string TriggerUnderAttack = "underattack";
- private const string TriggerJumpAttack = "jumpattack";
- private const string TriggerDie = "die";
- private const string TriggerRandom1 = "random1";
- private const string TriggerRandom2 = "random2";
- private const string TriggerRandom3 = "random3";
- private const string TriggerRandom4 = "random4";
- private const string TriggerRandom5 = "random5";
- public AnimatorCockController(Animator animator)
- {
- _animator = animator;
- }
- public Action OnRun { get; set; }
- public Action OnIdle { get; set; }
- public Action OnAttack { get; set; }
- public Action OnJumpAttack { get; set; }
- public void Idle()
- {
- _animator.SetInteger(Status, StatusIdle);
- OnIdle?.Invoke();
- }
- public void Walk()
- {
- throw new System.NotImplementedException();
- }
- public void Run()
- {
- _animator.SetInteger(Status, StatusRun);
- OnRun?.Invoke();
- }
- public void IdleInBattle()
- {
- _animator.SetInteger(Status, StatusIdle2);
- OnIdle?.Invoke();
- }
- public void Attack()
- {
- _animator.ResetTrigger(TriggerAttack);
- _animator.SetTrigger(TriggerAttack);
- OnAttack?.Invoke();
- }
- public void JumpAndAttack()
- {
- _animator.ResetTrigger(TriggerJumpAttack);
- _animator.SetTrigger(TriggerJumpAttack);
- OnJumpAttack?.Invoke();
- }
- public void UnderAttack()
- {
- _animator.ResetTrigger(TriggerUnderAttack);
- _animator.SetTrigger(TriggerUnderAttack);
- }
- public void Die()
- {
- _animator.ResetTrigger(TriggerDie);
- _animator.SetTrigger(TriggerDie);
- }
- public void RandomAttack(int attack)
- {
- switch (attack)
- {
- case 1:
- _animator.ResetTrigger(TriggerRandom1);
- _animator.SetTrigger(TriggerRandom1);
- break;
- case 2:
- _animator.ResetTrigger(TriggerRandom2);
- _animator.SetTrigger(TriggerRandom2);
- break;
- case 3:
- _animator.ResetTrigger(TriggerRandom3);
- _animator.SetTrigger(TriggerRandom3);
- break;
- case 4:
- _animator.ResetTrigger(TriggerRandom4);
- _animator.SetTrigger(TriggerRandom4);
- break;
- case 5:
- _animator.ResetTrigger(TriggerRandom5);
- _animator.SetTrigger(TriggerRandom5);
- break;
- default:
- _animator.ResetTrigger(TriggerJumpAttack);
- _animator.SetTrigger(TriggerJumpAttack);
- break;
- }
- OnJumpAttack?.Invoke();
- }
- public void BeLift()
- {
- }
- }
- }
|