LoadTriggerEffect() публичный статический Метод

public static LoadTriggerEffect ( EffectInfo info ) : Effect
info EffectInfo
Результат Effect
Пример #1
0
        private Trigger ParseTrigger(XElement triggerNode)
        {
            try
            {
                string conditionString;
                if (triggerNode.Attribute("condition") != null)
                {
                    conditionString = triggerNode.RequireAttribute("condition").Value;
                }
                else
                {
                    conditionString = triggerNode.Element("Condition").Value;
                }

                Condition condition = EffectParser.ParseCondition(conditionString);

                Effect effect = EffectParser.LoadTriggerEffect(triggerNode.Element("Effect"));

                return(new Trigger {
                    Condition = condition, Effect = effect
                });
            }
            catch (Exception e)
            {
                throw new GameXmlException(triggerNode, "There was an error parsing a trigger. There may be a syntax error in your condition expression.\n\nThe error message was:\n\n\t" + e.Message);
            }
        }
Пример #2
0
 private Trigger ParseTrigger(TriggerInfo info)
 {
     try
     {
         var condition  = EffectParser.ParseCondition(info.Condition);
         var effect     = EffectParser.LoadTriggerEffect(info.Effect);
         var elseEffect = (info.Else != null) ? EffectParser.LoadTriggerEffect(info.Else) : null;
         return(new Trigger {
             Condition = condition, Effect = effect, Else = elseEffect, ConditionString = info.Condition, Priority = info.Priority ?? 0
         });
     }
     catch (Exception e)
     {
         throw new GameRunException("There was an error parsing a trigger. There may be a syntax error in your condition expression.\n\nThe error message was:\n\n\t" + e.Message);
     }
 }
Пример #3
0
        internal void LoadInfo(StateComponentInfo componentInfo)
        {
            foreach (var stateInfo in componentInfo.States)
            {
                var state = new State()
                {
                    Name = stateInfo.Name
                };
                foreach (var trigger in stateInfo.Triggers)
                {
                    state.AddTrigger(ParseTrigger(trigger));
                }

                state.SetInitial(EffectParser.LoadTriggerEffect(stateInfo.Initializer));
                state.SetLogic(EffectParser.LoadTriggerEffect(stateInfo.Logic));

                states[state.Name] = state;
            }

            foreach (var triggerInfo in componentInfo.Triggers)
            {
                var trigger = ParseTrigger(triggerInfo.Trigger);

                if (triggerInfo.States != null)
                {
                    foreach (var stateName in triggerInfo.States)
                    {
                        if (!states.ContainsKey(stateName))
                        {
                            State state = new State {
                                Name = stateName
                            };
                            states.Add(stateName, state);
                        }
                        states[stateName].AddTrigger(trigger);
                    }
                }
                else
                {
                    foreach (var state in states.Values)
                    {
                        state.AddTrigger(trigger);
                    }
                }
            }
        }