Example #1
0
 void Awake()
 {
     if (Animator == null)
     {
         Animator = GetComponent <MotionMachine>();
     }
 }
            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);
             }
         }
     }
 }
Example #4
0
 public override void OnMachineDisable(MotionMachine machine, Motion motion)
 {
     base.OnMachineDisable(machine, motion);
     if (Root != null)
     {
         //Root.StopEffect();
     }
 }
 public void OnDestroy(MotionMachine machine, MotionCommander commander)
 {
     if (Motions != null)
     {
         Motions.Clear();
     }
     Machine   = null;
     Commander = null;
 }
 public MotionMachine GetMotionMachine()
 {
     if (Machine == null)
     {
         MotionMachine[] machines = GetComponentsInParent <MotionMachine>();
         if (machines != null && machines.Length > 0)
         {
             Machine = machines[0];
         }
     }
     return(Machine);
 }
 public override void OnInspectorGUI()
 {
     base.OnInspectorGUI();
     if (Instance == null)
     {
         return;
     }
     if (GUILayout.Button("Auto Generate"))
     {
         MotionMachine machine = Instance.GetMotionMachine();
         if (machine == null || machine.Motions == null || machine.Motions.Count == 0)
         {
             return;
         }
         if (Instance.Commands == null)
         {
             Instance.Commands = new List <MotionCommander.Command>();
         }
         List <Motion> motions = machine.Motions;
         for (int i = 0; i < motions.Count; i++)
         {
             Motion motion = motions[i];
             if (motion == null)
             {
                 continue;
             }
             string[] strArray = motion.Type.ToString().Split(new char[] { '_' });
             if (strArray == null || strArray.Length < 2)
             {
                 continue;
             }
             string tempStr = strArray[1];
             if (tempStr.StartsWith("Pre") || tempStr.EndsWith("End"))
             {
                 continue;
             }
             CharacterCommand        commandType = Utility.RMT_CC(motion.Type);
             MotionCommander.Command command     = Instance.TryGet(commandType);
             if (command == null)
             {
                 command             = new MotionCommander.Command();
                 command.Type        = commandType;
                 command.DisplayName = commandType.ToString();
                 command.SequentialMotions.Add(motion.Type);
                 Instance.Add(command);
             }
         }
     }
 }
 void Awake()
 {
     Machine = GetMotionMachine();
     if (Commands != null && Commands.Count > 0)
     {
         for (int i = 0; i < Commands.Count; i++)
         {
             Command cmd = Commands[i];
             if (cmd == null)
             {
                 continue;
             }
             cmd.OnAwake(Machine, this);
         }
     }
 }
 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;
         }
     }
 }
Example #10
0
 public virtual void OnMachineDestroy(MotionMachine machine, Motion motion)
 {
 }
Example #11
0
 public virtual void OnMachineDisable(MotionMachine machine, Motion motion)
 {
 }
Example #12
0
 public virtual void OnMachineStart(MotionMachine machine, Motion motion)
 {
 }
Example #13
0
 public virtual void OnMachineAwake(MotionMachine machine, Motion motion)
 {
     Machine = machine; Motion = motion;
 }
Example #14
0
 private void OnEnable()
 {
     Instance = target as MotionMachine;
 }
 void Awake()
 {
     Machine = GetMotionMachine();
 }