Example #1
0
        private static IGameObject GetGameObjectFromXmlElement(XmlElement element, Dictionary <string, Type> objectMap)
        {
            string objectType = element.GetAttribute("type");
            Tuple <Vector2, Vector2> posAndSize = GetPositionAndSizeFromXmlElement(element);

            IGameObject gameObject = (IGameObject)Activator.CreateInstance(objectMap[objectType]);

            gameObject.SetInitialPosition(posAndSize.Item1);

            if (objectType.Equals("teleporter"))
            {
                DKTeleporter teleporter = (DKTeleporter)gameObject;
                teleporter.Destination = element.GetAttribute("destination");
                gameObject             = teleporter;
            }

            return(gameObject);
        }
 public PlayerTeleportCommand(Player teleportingPlayer, IGameObject gameObject)
 {
     teleporter = (DKTeleporter)gameObject;
     player     = teleportingPlayer;
 }