Beispiel #1
0
        public void Initialize()
        {
            m_Instance = this;
            m_drawable = new List<IDrawable>();
            m_interactable = new List<IInteractable>();

            // World map
            m_map = new Map();

            // Player on the map
            m_player = new Player(1200, 1200);

            // HUD
            m_HUD = new HUD();

            // World objects from XML
            WorldMapObjectData[] worldMapObjects = WarlockGame.Instance.Content.Load<WorldMapObjectData[]>(@"worldmapobjects");
            List<WorldObjectBase> worldObjects = new List<WorldObjectBase>();

            foreach (WorldMapObjectData objectData in worldMapObjects)
            {
                if (objectData.ObjectType == WorldMapObjectType.City)
                {
                    worldObjects.Add(new City()
                    {
                        AssetName = objectData.WorldMapAssetName,
                        ObjectID = objectData.ObjectID,
                        WorldPosition = new Vector2(objectData.WorldMapXCoord, objectData.WorldMapYCoord),
                    });
                }
                else if (objectData.ObjectType == WorldMapObjectType.Battle)
                {
                    worldObjects.Add(new Battle()
                    {
                        AssetName = objectData.WorldMapAssetName,
                        ObjectID = objectData.ObjectID,
                        WorldPosition = new Vector2(objectData.WorldMapXCoord, objectData.WorldMapYCoord),
                    });
                }
            }

            // these should always be added in opposite order so that objects drawn on top get interaction priority
            m_drawable.Add(m_map);
            foreach (WorldObjectBase worldObjectBase in worldObjects)
                m_drawable.Add(worldObjectBase);
            m_drawable.Add(m_player);
            m_drawable.Add(m_HUD);

            m_interactable.Add(m_HUD);
            m_interactable.Add(m_player);
            foreach (WorldObjectBase worldObjectBase in worldObjects)
                m_interactable.Add(worldObjectBase);
            m_interactable.Add(m_map);

            // Enable only certain gestures
            TouchPanel.EnabledGestures = GestureType.DoubleTap | GestureType.Pinch | GestureType.Tap;
        }
Beispiel #2
0
 public void StartNewGame()
 {
     m_worldGameMode = new WorldGameMode();
     m_worldGameMode.Initialize();
     m_worldGameMode.LoadContent();
     m_worldGameMode.Update();
     m_currentGameMode = m_worldGameMode;
 }