Exemplo n.º 1
0
 void Awake()
 {
     if (Animator == null)
     {
         Animator = GetComponent <MotionMachine>();
     }
 }
Exemplo n.º 2
0
            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;
            }
Exemplo n.º 3
0
 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);
             }
         }
     }
 }
Exemplo n.º 4
0
 public override void OnMachineDisable(MotionMachine machine, Motion motion)
 {
     base.OnMachineDisable(machine, motion);
     if (Root != null)
     {
         //Root.StopEffect();
     }
 }
Exemplo n.º 5
0
 public void OnDestroy(MotionMachine machine, MotionCommander commander)
 {
     if (Motions != null)
     {
         Motions.Clear();
     }
     Machine   = null;
     Commander = null;
 }
Exemplo n.º 6
0
 public MotionMachine GetMotionMachine()
 {
     if (Machine == null)
     {
         MotionMachine[] machines = GetComponentsInParent <MotionMachine>();
         if (machines != null && machines.Length > 0)
         {
             Machine = machines[0];
         }
     }
     return(Machine);
 }
Exemplo n.º 7
0
 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);
             }
         }
     }
 }
Exemplo n.º 8
0
 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);
         }
     }
 }
Exemplo n.º 9
0
 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;
         }
     }
 }
Exemplo n.º 10
0
 public virtual void OnMachineDestroy(MotionMachine machine, Motion motion)
 {
 }
Exemplo n.º 11
0
 public virtual void OnMachineDisable(MotionMachine machine, Motion motion)
 {
 }
Exemplo n.º 12
0
 public virtual void OnMachineStart(MotionMachine machine, Motion motion)
 {
 }
Exemplo n.º 13
0
 public virtual void OnMachineAwake(MotionMachine machine, Motion motion)
 {
     Machine = machine; Motion = motion;
 }
Exemplo n.º 14
0
 private void OnEnable()
 {
     Instance = target as MotionMachine;
 }
Exemplo n.º 15
0
 void Awake()
 {
     Machine = GetMotionMachine();
 }