Exemplo n.º 1
0
 private void AttachEvent()
 {
     this.animator = this.View.Animator as StateMachineAnimator;
     if (animator != null)
     {
         animator.AnimationEnd += Animator_AnimationEnd;
     }
 }
Exemplo n.º 2
0
 private void AddMobAI(StateMachineAnimator ani)
 {
     ani.AnimationEnd += (o, e) =>
     {
         if (e.CurrentState == "regen" && ani.Data.States.Contains("stand"))
         {
             e.NextState = "stand";
         }
     };
 }
Exemplo n.º 3
0
        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)];
                };
            }
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        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