Esempio n. 1
0
        public TileActionRule GetRulesForAction(TileActionRule.ActionType action)
        {
            if (tileActionRules != null)
                return tileActionRules.GetRulesForAction(action);

            return null;
        }
Esempio n. 2
0
 public void AddActionRule(TileActionRule actionRule)
 {
     List<TileActionRule> r = new List<TileActionRule>();
     if (this.actionRules != null)
         r.AddRange(this.actionRules);
     r.Add(actionRule);
     this.actionRules = r.ToArray();
 }
Esempio n. 3
0
        public TileActionRule GetRulesForAction(TileActionRule.ActionType action)
        {
            if (actionRules != null)
            {
                foreach (TileActionRule t in actionRules)
                    if (t.action == action)
                        return t;
            }

            return null;
        }
Esempio n. 4
0
        private void AddTileUpdateRule(XmlElement tileUpdateRuleXML)
        {
            List<TileDefinition> tileDefinitions = new List<TileDefinition>();

            foreach (string tileTypeId in GetAttributeStringValue(tileUpdateRuleXML, "tileType").Split(','))
                tileDefinitions.Add(TileIdToTileDefinition(tileTypeId));

            foreach (TileDefinition tileDefinition in tileDefinitions)
            {
                //Slow.. i'm parsing all the rules for each tile definition to update..
                switch (tileUpdateRuleXML.Name)
                {
                    case "TileRule":
                        {
                            TileUpdateRules tileUpdateRule = tileDefinition.tileUpdateRules;

                            if (tileUpdateRule == null)
                            {
                                tileUpdateRule = new TileUpdateRules();
                                tileDefinition.tileUpdateRules = tileUpdateRule;
                            }

                            foreach (XmlElement ruleXML in GetChildElements(tileUpdateRuleXML))
                                tileUpdateRule.AddRule(ParseTileRule(ruleXML));
                            break;
                        }

                    case "TileActionRule":
                        {
                            TileActionRules tileActionRules = tileDefinition.tileActionRules;

                            if (tileActionRules == null)
                            {
                                tileActionRules = new TileActionRules();
                                tileDefinition.tileActionRules = tileActionRules;
                            }

                            TileActionRule.ActionType tileActionType = (TileActionRule.ActionType)System.Enum.Parse(typeof(TileActionRule.ActionType),
                                                                            GetAttributeStringValue(tileUpdateRuleXML, "action"),
                                                                            true);

                            TileActionRule tileActionRule = tileActionRules.GetRulesForAction(tileActionType);

                            if (tileActionRule == null)
                            {
                                tileActionRule = new TileActionRule();
                                tileActionRule.action = tileActionType;

                                tileActionRules.AddActionRule(tileActionRule);
                            }

                            foreach (XmlElement ruleXML in GetChildElements(tileUpdateRuleXML))
                                tileActionRule.AddRule(ParseTileRule(ruleXML));
                            break;
                        }

                    default:
                        throw new System.Exception("Unknown type of tile rule: " + tileUpdateRuleXML.Name);
                }
            }
        }
Esempio n. 5
0
        private bool ExecuteTileActions(TilePosition pos, TileActionRule.ActionType actionType)
        {
            TileDefinition tileDefinition = GetTileDefinition(GetTileType(pos));

            if (tileDefinition.tileActionRules != null && tileDefinition.tileActionRules.GetRulesForAction(actionType) != null)
            {
                TileActionRule actionRules = tileDefinition.tileActionRules.GetRulesForAction(actionType);

                ExecuteTileRules(pos, GetTile(pos), actionRules.rules);

                return true;
            }

            return false;
        }
Esempio n. 6
0
		public bool HasTileActions(TilePosition pos, TileActionRule.ActionType actionType)
		{
            TileDefinition tileDefinition = GetTileDefinition(GetTileType(pos));

            return tileDefinition.tileActionRules != null && tileDefinition.tileActionRules.GetRulesForAction(actionType) != null;
		}