예제 #1
0
        private static FlagBase CreateFlagFromXmlNode(XElement node)
        {
            FlagBase newFlag = null;

            switch (node.Name.ToString())
            {
            case GoalFlag.Save_Node_Name:
                newFlag = Factory.CreateGoalFlag(node.Attribute("texture").Value);
                newFlag.CollisionZoneTopOffset = (float)node.Attribute("zone-top");
                break;

            case CheckpointFlag.Save_Node_Name:
                newFlag = Factory.CreateRestartFlag(node.Attribute("texture").Value);
                newFlag.CollisionZoneTopOffset = (float)node.Attribute("zone-top");
                if (node.Attribute("index") != null)
                {
                    ((CheckpointFlag)newFlag).CheckpointIndex = (int)node.Attribute("index");
                }
                break;
            }

            if (newFlag != null)
            {
                newFlag.GroupNodeName = Data_Group_Node_Name;
            }
            return(newFlag);
        }
예제 #2
0
 public static void LoadFlags(XElement FlagDataGroup, Data.RegistrationCallback registerComponent)
 {
     if (FlagDataGroup != null)
     {
         foreach (XElement node in FlagDataGroup.Elements())
         {
             FlagBase toAdd = CreateFlagFromXmlNode(node);
             toAdd.WorldPosition = new Vector2((float)node.Attribute("x"), (float)node.Attribute("y"));
             if (node.Attribute("left-activation") != null)
             {
                 toAdd.ActivatedWhenMovingLeft = (bool)node.Attribute("left-activation");
             }
             registerComponent(toAdd);
         }
     }
 }