public void Active(MotionMachine machine, MotionCommander commander, Command lastCommand)
            {
                //Debug.LogError(Machine.Character.name+" --active "+ Type.ToString());
                if (machine == null || commander == null)
                {
                    return;
                }
                if (Motions == null || Motions.Count == 0)
                {
                    return;
                }
                Motion motion = Motions[0];

                if (motion == null)
                {
                    return;
                }
                ActiveStatus = true;
                //motion.OnPreEndDelegate -= OnLastMotionEnd;
                motion.OnPreEndDelegate += OnLastMotionEnd;
                if (OnActiveDelegate != null)
                {
                    OnActiveDelegate(this, lastCommand);
                }
                machine.ExecuteMotion(motion.Type);
                return;
            }
 public void OnAwake(MotionMachine machine, MotionCommander commander)
 {
     Machine   = machine;
     Commander = commander;
     if (machine != null)
     {
         if (machine.Motions != null && machine.Motions.Count > 0 && SequentialMotions != null && SequentialMotions.Count > 0)
         {
             for (int i = 0; i < SequentialMotions.Count; i++)
             {
                 RoleMotionType motionType = SequentialMotions[i];
                 Motion         motion     = machine.GetMotion(motionType);
                 if (motion == null)
                 {
                     continue;
                 }
                 if (Motions == null)
                 {
                     Motions = new List <Motion>();
                 }
                 Motions.Add(motion);
             }
         }
     }
 }
 public void OnDestroy(MotionMachine machine, MotionCommander commander)
 {
     if (Motions != null)
     {
         Motions.Clear();
     }
     Machine   = null;
     Commander = null;
 }
Example #4
0
 public MotionCommander GetMotionCommander()
 {
     if (MotionCommander == null)
     {
         MotionCommander[] commanders = GetComponentsInChildren <MotionCommander>(true);
         if (commanders != null && commanders.Length > 0)
         {
             MotionCommander = commanders[0];
         }
     }
     return(MotionCommander);
 }
 public void InActive(MotionMachine machine, MotionCommander commander, Command nextCommand)
 {
     ActiveStatus = false;
     if (OnInActiveDelegate != null)
     {
         OnInActiveDelegate(this, nextCommand);
     }
     if (Motions != null && Motions.Count > 0)
     {
         for (int i = 0; i < Motions.Count; i++)
         {
             Motion tempMotion = Motions[i];
             if (tempMotion == null)
             {
                 continue;
             }
             tempMotion.OnPreEndDelegate -= OnLastMotionEnd;
         }
     }
 }
 void OnEnable()
 {
     Instance = target as MotionCommander;
 }