Exemplo n.º 1
0
        public StateManager(StateSystem statesystem, Combat.Character character, ReadOnlyKeyedCollection <Int32, State> states)
        {
            if (statesystem == null)
            {
                throw new ArgumentNullException("statesystem");
            }
            if (character == null)
            {
                throw new ArgumentNullException("character");
            }
            if (states == null)
            {
                throw new ArgumentNullException("states");
            }

            m_statesystem    = statesystem;
            m_character      = character;
            m_states         = states;
            m_persistencemap = new Dictionary <StateController, Int32>();
            m_foreignmanager = null;
            m_statetime      = 0;

#if DEBUG
            m_stateorder = new CircularBuffer <State>(10);
#else
            m_currentstate  = null;
            m_previousstate = null;
#endif
        }
Exemplo n.º 2
0
        protected StateController(StateSystem statesystem, String label, TextSection textsection)
        {
            if (statesystem == null) throw new ArgumentNullException("statesystem");
            if (label == null) throw new ArgumentNullException("label");
            if (textsection == null) throw new ArgumentNullException("textsection");

            m_statesystem = statesystem;
            m_textsection = textsection;
            m_persistence = textsection.GetAttribute<Int32>("persistent", 1);
            m_ignorehitpause = textsection.GetAttribute<Boolean>("ignorehitpause", false);
            m_triggers = BuildTriggers(textsection);
            m_label = label;
        }
Exemplo n.º 3
0
        public StateManager(StateSystem statesystem, Combat.Character character, ReadOnlyKeyedCollection<Int32, State> states)
        {
            if (statesystem == null) throw new ArgumentNullException("statesystem");
            if (character == null) throw new ArgumentNullException("character");
            if (states == null) throw new ArgumentNullException("states");

            m_statesystem = statesystem;
            m_character = character;
            m_states = states;
            m_persistencemap = new Dictionary<StateController, Int32>();
            m_foreignmanager = null;
            m_statetime = 0;

            #if DEBUG
            m_stateorder = new CircularBuffer<State>(10);
            #else
            m_currentstate = null;
            m_previousstate = null;
            #endif
        }
Exemplo n.º 4
0
        TriggerMap BuildTriggers(TextSection textsection)
        {
            if (textsection == null)
            {
                throw new ArgumentNullException("textsection");
            }

            StringComparer sc       = StringComparer.OrdinalIgnoreCase;
            var            triggers = new SortedDictionary <Int32, List <Evaluation.Expression> >();

            var evalsystem = StateSystem.GetSubSystem <Evaluation.EvaluationSystem>();

            foreach (KeyValuePair <String, String> parsedline in textsection.ParsedLines)
            {
                if (String.Compare(parsedline.Key, 0, "trigger", 0, 7, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    continue;
                }

                Int32 triggernumber = 0;
                if (String.Compare(parsedline.Key, 7, "all", 0, 3, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    triggernumber = 0;
                }
                else if (Int32.TryParse(parsedline.Key.Substring(7), out triggernumber) == false)
                {
                    continue;
                }

                Evaluation.Expression trigger = evalsystem.CreateExpression(parsedline.Value);

                if (triggers.ContainsKey(triggernumber) == false)
                {
                    triggers.Add(triggernumber, new List <Evaluation.Expression>());
                }
                triggers[triggernumber].Add(trigger);
            }

            return(new TriggerMap(triggers));
        }
Exemplo n.º 5
0
        protected StateController(StateSystem statesystem, String label, TextSection textsection)
        {
            if (statesystem == null)
            {
                throw new ArgumentNullException("statesystem");
            }
            if (label == null)
            {
                throw new ArgumentNullException("label");
            }
            if (textsection == null)
            {
                throw new ArgumentNullException("textsection");
            }

            m_statesystem    = statesystem;
            m_textsection    = textsection;
            m_persistence    = textsection.GetAttribute <Int32>("persistent", 1);
            m_ignorehitpause = textsection.GetAttribute <Boolean>("ignorehitpause", false);
            m_triggers       = BuildTriggers(textsection);
            m_label          = label;
        }
Exemplo n.º 6
0
        protected StateController(StateSystem statesystem, string label, TextSection textsection)
        {
            if (statesystem == null)
            {
                throw new ArgumentNullException(nameof(statesystem));
            }
            if (label == null)
            {
                throw new ArgumentNullException(nameof(label));
            }
            if (textsection == null)
            {
                throw new ArgumentNullException(nameof(textsection));
            }

            m_statesystem    = statesystem;
            m_textsection    = textsection;
            m_persistence    = textsection.GetAttribute("persistent", 1);
            m_ignorehitpause = textsection.GetAttribute("ignorehitpause", false);
            m_triggers       = BuildTriggers(textsection);
            m_label          = label;
        }
Exemplo n.º 7
0
        public State(StateSystem statesystem, Int32 number, TextSection textsection, List <StateController> controllers)
        {
            if (statesystem == null)
            {
                throw new ArgumentNullException("statesystem");
            }
            if (number < -3)
            {
                throw new ArgumentOutOfRangeException("State number must be greater then or equal to -3");
            }
            if (textsection == null)
            {
                throw new ArgumentNullException("textsection");
            }
            if (controllers == null)
            {
                throw new ArgumentNullException("controllers");
            }

            m_statesystem     = statesystem;
            m_number          = number;
            m_controllers     = new ReadOnlyList <StateController>(controllers);
            m_statetype       = textsection.GetAttribute <StateType>("type", StateType.Standing);
            m_movetype        = textsection.GetAttribute <MoveType>("MoveType", MoveType.Idle);
            m_physics         = textsection.GetAttribute <Physics>("Physics", Physics.None);
            m_animationnumber = textsection.GetAttribute <Evaluation.Expression>("anim", null);
            m_velocity        = textsection.GetAttribute <Evaluation.Expression>("velset", null);
            m_control         = textsection.GetAttribute <Evaluation.Expression>("ctrl", null);
            m_power           = textsection.GetAttribute <Evaluation.Expression>("poweradd", null);
            m_jugglepoints    = textsection.GetAttribute <Evaluation.Expression>("juggle", null);
            m_faceenemy       = textsection.GetAttribute <Evaluation.Expression>("facep2", null);
            m_hitdefpersist   = textsection.GetAttribute <Evaluation.Expression>("hitdefpersist", null);
            m_movehitpersist  = textsection.GetAttribute <Evaluation.Expression>("movehitpersist", null);
            m_hitcountpersist = textsection.GetAttribute <Evaluation.Expression>("hitcountpersist", null);
            m_spritepriority  = textsection.GetAttribute <Evaluation.Expression>("sprpriority", null);
        }
Exemplo n.º 8
0
        public State(StateSystem statesystem, Int32 number, TextSection textsection, List<StateController> controllers)
        {
            if (statesystem == null) throw new ArgumentNullException("statesystem");
            if (number < -3) throw new ArgumentOutOfRangeException("State number must be greater then or equal to -3");
            if (textsection == null) throw new ArgumentNullException("textsection");
            if (controllers == null) throw new ArgumentNullException("controllers");

            m_statesystem = statesystem;
            m_number = number;
            m_controllers = new ReadOnlyList<StateController>(controllers);
            m_statetype = textsection.GetAttribute<StateType>("type", StateType.Standing);
            m_movetype = textsection.GetAttribute<MoveType>("MoveType", MoveType.Idle);
            m_physics = textsection.GetAttribute<Physics>("Physics", Physics.None);
            m_animationnumber = textsection.GetAttribute<Evaluation.Expression>("anim", null);
            m_velocity = textsection.GetAttribute<Evaluation.Expression>("velset", null);
            m_control = textsection.GetAttribute<Evaluation.Expression>("ctrl", null);
            m_power = textsection.GetAttribute<Evaluation.Expression>("poweradd", null);
            m_jugglepoints = textsection.GetAttribute<Evaluation.Expression>("juggle", null);
            m_faceenemy = textsection.GetAttribute<Evaluation.Expression>("facep2", null);
            m_hitdefpersist = textsection.GetAttribute<Evaluation.Expression>("hitdefpersist", null);
            m_movehitpersist = textsection.GetAttribute<Evaluation.Expression>("movehitpersist", null);
            m_hitcountpersist = textsection.GetAttribute<Evaluation.Expression>("hitcountpersist", null);
            m_spritepriority = textsection.GetAttribute<Evaluation.Expression>("sprpriority", null);
        }