示例#1
0
文件: Tank.cs 项目: JOCP9733/tank
        /// <summary>
        /// This function gets called by the ogmo level loader
        /// </summary>
        public static void MyCreateEntity(Scene scene, XmlAttributeCollection ogmoParameters)
        {
            //ok ogmo gives us the position in x and y, and the list of decorators in DecoratorList
            int x = ogmoParameters.Int("x", -1);
            int y = ogmoParameters.Int("y", -1);

            //this is how you read a string from ogmo
            string decoList = ogmoParameters.GetNamedItem("DecoratorList").Value;

            //create an instance
            Tank t = new Tank(x, y);

            //try and load an id; if there is none, the id will be -1
            t.NetworkId = ogmoParameters.Int("NetworkId", -1);

            //add to the scene because the decorators need that
            scene.Add(t);

            //split the decorators; they are seperated by a ":" in the DecoratorList string
            string[] decoArray = decoList.Split(':');

            //add each decorator
            foreach (string decoratorName in decoArray)
            {
                //parse the name of the decorator to the decorator-enum, and then add to the tank
                t.AddDecorator((Decorators)Enum.Parse(typeof(Decorators), decoratorName));
            }
        }
示例#2
0
        /// <summary>
        /// This function gets called by the ogmo level loader
        /// </summary>
        public static void MyCreateEntity(Scene scene, XmlAttributeCollection ogmoParameters)
        {
            //ok ogmo gives us the position in x and y, and the list of decorators in DecoratorList
            int x = ogmoParameters.Int("x", -1);
            int y = ogmoParameters.Int("y", -1);

            //this is how you read a string from ogmo
            string   type     = ogmoParameters.GetNamedItem("Type").Value;
            PowerUps typeEnum = Utilities.ParseEnum <PowerUps>(type);

            //create an instance
            PowerUp p = new PowerUp(typeEnum, x, y);

            //add to the scene
            scene.Add(p);
        }