private void AttachEvent() { this.animator = this.View.Animator as StateMachineAnimator; if (animator != null) { animator.AnimationEnd += Animator_AnimationEnd; } }
private void AddMobAI(StateMachineAnimator ani) { ani.AnimationEnd += (o, e) => { if (e.CurrentState == "regen" && ani.Data.States.Contains("stand")) { e.NextState = "stand"; } }; }
private void AddNpcAI(StateMachineAnimator ani) { var actions = new[] { "stand", "say", "mouse", "move", "hand", "laugh", "eye" }; var availActions = ani.Data.States.Where(act => actions.Contains(act)).ToArray(); if (availActions.Length > 0) { ani.AnimationEnd += (o, e) => { e.NextState = availActions[this.random.Next(availActions.Length)]; }; } }
void IUnitAIModel.Register(Unit unit) { StateMachineAnimator = GameObjectPool.Take(StateMachineInfo.Prototype); StateMachineAnimator.transform.SetParent(unit.transform, false); StateMachineAnimator.transform.localPosition = Vector3.zero; behaviours.AddRange(StateMachineAnimator.GetBehaviours <UnitStateMachineBehaviour>()); foreach (IUnitStateMachineBehaviour behaviour in behaviours) { behaviour.Register(this); } Unit = unit; }
public void Start() { //Not set manually? Therefore either in parent or in self. if (ControlledBy == null) { ControlledBy = GetComponentInParent <AActor2D>(); if (ControlledBy == null) { ControlledBy = GetComponent <AActor2D>(); } } ColliderCmp = GetComponentInChildren <Collider2D>(); LadderClimberCmp = GetComponentInParent <LadderClimber>(); DamagableCmp = ControlledBy.DamagableCmp; DamagableCmp.EOnDamageTaken += OnDamageTaken; DamagableCmp.EOnCritHit += OnDamageTaken; StateMachineAnimator.Rebind(); }//Start