void ShowInherit()
        {
            List <string> options = new List <string> {
                " "
            };

            options.AddRange(StateMachineUtility.LayerTypes.ToStringArray());

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Inherits From", GUILayout.Width(100));
            inherit = CustomEditorBase.Popup(inherit, options.ToArray(), GUIContent.none, GUILayout.MinWidth(150));
            inherit = inherit == " " ? "StateLayer" : inherit;

            EditorGUILayout.EndHorizontal();

            if (inherit == "StateLayer")
            {
                lockedStates.Clear();
            }
            else
            {
                lockedStates = StateMachineUtility.LayerStateNameDict[StateMachineUtility.FormatLayer(inherit)];

                for (int i = lockedStates.Count - 1; i >= 0; i--)
                {
                    if (!states.Contains(lockedStates[i]))
                    {
                        AddState(lockedStates[i]);
                    }

                    states.Move(states.IndexOf(lockedStates[i]), 0);
                }
            }
        }
        void GenerateStates()
        {
                        #if !UNITY_WEBPLAYER
            if (string.IsNullOrEmpty(path))
            {
                Logger.LogError("Path can not be empty.");
                return;
            }

            if (string.IsNullOrEmpty(layer))
            {
                Logger.LogError("Layer name can not be empty.");
                return;
            }

            foreach (string state in states)
            {
                string        stateFileName = layer.Capitalized() + state.Capitalized() + ".cs";
                string        stateInherit  = "State";
                List <string> script        = new List <string>();

                if (string.IsNullOrEmpty(state))
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(HelperFunctions.GetAssetPath(stateFileName)))
                {
                    Logger.LogError(string.Format("A script named {0} already exists.", stateFileName));
                    continue;
                }

                string formattedInherit = StateMachineUtility.FormatLayer(inherit);
                if (StateMachineUtility.LayerStateNameDict.ContainsKey(formattedInherit) && StateMachineUtility.LayerStateNameDict[formattedInherit].Contains(state))
                {
                    stateInherit = inherit + state;
                }

                script.Add("using UnityEngine;");
                script.Add("using System.Collections;");
                script.Add("using System.Collections.Generic;");
                script.Add("using Magicolo;");
                script.Add("");
                script.Add("public class " + layer + state + " : " + stateInherit + " {");
                script.Add("	");
                AddLayer(script, layer);
                AddMachine(script);
                AddCallbacks(script, callbackMask);
                script.Add("}");

                File.WriteAllLines(Application.dataPath.Substring(0, Application.dataPath.Length - 6) + path + Path.AltDirectorySeparatorChar + stateFileName, script.ToArray());
            }
                        #endif
        }
Ejemplo n.º 3
0
        void BuildStateDict()
        {
            nameStateDict = new Dictionary <string, IState>();
            states        = GetComponents <State>();

            for (int i = 0; i < states.Length; i++)
            {
                IState state = states[i];
                nameStateDict[state.GetType().Name] = state;
                nameStateDict[StateMachineUtility.FormatState(state.GetType(), state.Layer.GetType())] = state;
            }
        }
Ejemplo n.º 4
0
        void BuildLayerDict()
        {
            nameLayerDict = new Dictionary <string, IStateLayer>();

            foreach (StateLayer layer in layers)
            {
                if (layer != null)
                {
                    nameLayerDict[layer.GetType().Name] = layer;
                    nameLayerDict[StateMachineUtility.FormatLayer(layer.GetType())] = layer;
                }
            }
        }
Ejemplo n.º 5
0
        void BuildStateDict()
        {
            nameStateDict = new Dictionary <string, IState>();

            nameStateDict[EmptyState.Instance.GetType().Name] = EmptyState.Instance;

            foreach (State state in states)
            {
                if (state != null)
                {
                    nameStateDict[state.GetType().Name] = state;
                    nameStateDict[StateMachineUtility.FormatState(state.GetType(), state.layer.GetType())] = state;
                }
            }
        }
Ejemplo n.º 6
0
        void BuildStateDict()
        {
            nameStateDict = new Dictionary <string, IState>();
            states        = new IState[stateReferences.Length];

            nameStateDict[EmptyState.Instance.GetType().Name] = EmptyState.Instance;
            nameStateDict[StateMachineUtility.FormatState(EmptyState.Instance.GetType(), "")] = EmptyState.Instance;

            for (int i = 0; i < stateReferences.Length; i++)
            {
                IState state = (IState)stateReferences[i];

                if (state != null)
                {
                    nameStateDict[state.GetType().Name] = state;
                    nameStateDict[state is StateLayer ? state.GetType().Name : StateMachineUtility.FormatState(state.GetType(), state.Layer.GetType())] = state;
                    states[i] = state;
                }
            }
        }
Ejemplo n.º 7
0
        void BuildLayerDict()
        {
            nameStateDict = new Dictionary <string, IState>();
            nameLayerDict = new Dictionary <string, IStateLayer>();
            layers        = GetComponents <StateLayer>();
            activeLayers  = new IStateLayer[stateReferences.Length];

            for (int i = 0; i < stateReferences.Length; i++)
            {
                IStateLayer layer = (IStateLayer)stateReferences[i];

                if (layer != null)
                {
                    activeLayers[i] = layer;
                }
            }

            for (int i = 0; i < layers.Length; i++)
            {
                IStateLayer layer = layers[i];
                nameStateDict[layer.GetType().Name] = layer;
                nameStateDict[StateMachineUtility.FormatLayer(layer.GetType())] = layer;
            }
        }
Ejemplo n.º 8
0
 protected virtual void Reset()
 {
     StateMachineUtility.CleanUp(null, CachedGameObject);
 }
Ejemplo n.º 9
0
 void Reset()
 {
     StateMachineUtility.CleanUp(null, gameObject);
 }