Beispiel #1
0
        private static void InstantiatePickable(XmlNode objectNode, Dictionary <int, XmlNode> dictProperties, ref List <ICheckpointLoadable> objectsLoadable)
        {
            string xString = objectNode.Attributes["x"].Value;
            float  xPos    = float.Parse(xString, System.Globalization.CultureInfo.InvariantCulture);

            string yString = objectNode.Attributes["y"].Value;
            float  yPos    = float.Parse(yString, System.Globalization.CultureInfo.InvariantCulture);

            Vector2 pos           = new Vector2(xPos + (int.Parse(objectNode.Attributes["width"].Value) / 2), yPos - (int.Parse(objectNode.Attributes["height"].Value) / 2));
            int     globalIdCrate = int.Parse(objectNode.Attributes["gid"].Value) - 1;

            XmlNode properties = dictProperties[globalIdCrate];

            PickableType type = (PickableType)int.Parse(properties.FirstChild.Attributes["value"].Value);
            Pickable     p    = null;

            switch (type)
            {
            case PickableType.Apple:
                p = new Apple(pos);
                break;

            case PickableType.ExtraLife:
                p = new ExtraLife(pos);
                break;

            case PickableType.Crystal:
                p = new CrystalPickable(pos);
                break;
            }

            if (p != null)
            {
                objectsLoadable.Add(p);
            }
        }