Esempio n. 1
0
        public MapController(Map map, MapView mapView)
        {
            this.map = map;
            this.mapView = mapView;
            this.gm = GameMaster.Inst();

            PromptWindow.Inst().Deactive();
            MarketComponent.Inst().SetIsActive(false);
        }
Esempio n. 2
0
        public void LoadAllThread()
        {
            playerColorTexture = GameResources.Inst().GetHudTexture(HUDTexture.PlayerColor);

            //render to texture
            PresentationParameters pp = ScreenManager.GraphicsDevice.PresentationParameters;
            renderTarget = new RenderTarget2D(ScreenManager.GraphicsDevice, pp.BackBufferWidth, pp.BackBufferHeight, false, SurfaceFormat.Color, pp.DepthStencilFormat);

            GameState.game = ScreenManager.Game;

            map = new Map(ScreenManager.Game);
            gameComponents.Add(map);
            gameComponents.Add(PromptWindow.Inst());
            gameComponents.Add(Message.Inst());

            //gamelogi

            foreach (GameComponent gameComponent in gameComponents)
            {
                gameComponent.Initialize();
                gameComponent.LoadContent();
            }

            gMaster.SetMap(map);
            //gMaster.PrepareCampaignScenario();
            #if GENETIC
            GameMaster.Inst().ResetGenetic();
            #endif
            gMaster.StartGame();

            ButtonComponent changeTurnButton = new ButtonComponent(ScreenManager.Game, (int)(Settings.maximumResolution.X - 167), (int)(Settings.maximumResolution.Y - 161), new Rectangle(Settings.scaleW((int)(Settings.maximumResolution.X - 80)), Settings.scaleH((int)(Settings.maximumResolution.Y - 80)), Settings.scaleW(60), Settings.scaleH(60)), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(147), Settings.scaleH(141), "nextTurn", Settings.colorHovorCorner);
            changeTurnButton.Actions += ChangeTurnButtonAction;
            guiComponents.Add(changeTurnButton);
            ButtonComponent menuHUDButton = new ButtonComponent(ScreenManager.Game, Settings.scaleW(20), Settings.scaleH(20), new Rectangle(Settings.scaleW(10), Settings.scaleH(10), Settings.scaleW(20), Settings.scaleH(20)), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(80), Settings.scaleH(80), "menu_button", Settings.colorHovorCorner);
            menuHUDButton.Actions += MenuButtonAction;
            guiComponents.Add(menuHUDButton);
            MaterialsHUDComponent materialsHUDComp = new MaterialsHUDComponent(ScreenManager.Game, ScreenManager.Game.GraphicsDevice.Viewport.Width / 4, ScreenManager.Game.GraphicsDevice.Viewport.Height - 78, GameResources.Inst().GetFont(EFont.MedievalBig), 757, 148, "suroviny_hud");
            guiComponents.Add(materialsHUDComp);
            TopPlayerScoreComponent topPlayer = new TopPlayerScoreComponent();
            guiComponents.Add(topPlayer);
            MarketComponent marketHud = MarketComponent.Inst();
            marketButton = new ButtonComponent(ScreenManager.Game, Settings.scaleW(30), (int)(Settings.maximumResolution.Y - 176), new Rectangle(Settings.scaleW(30), Settings.scaleH((int)(Settings.maximumResolution.Y - 176)), Settings.scaleW(70), Settings.scaleH(70)), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(151), Settings.scaleH(156), "newmessage", Settings.colorHovorCorner);
            marketButton.Actions += MarketButtonAction;

            guiComponents.Add(marketButton);

            foreach (GuiComponent guiComponent in guiComponents)
            {
                guiComponent.Initialize();
                guiComponent.LoadContent();
            }

            MarketComponent.Inst().Initialize();
            MarketComponent.Inst().LoadContent();
            /*
            if(Settings.tutorial != null)
                Tutorial.Inst().Initialize(Settings.tutorial);
            else
                Tutorial.Inst().TurnOff();
             */

            InputManager im = InputManager.Inst();
            String stateGame = "game";

            if (im.AddState(stateGame))
            {
                GameAction pause = new GameAction("pause", GameAction.ActionKind.OnlyInitialPress);
                GameAction nextTurn = new GameAction("nextturn", GameAction.ActionKind.OnlyInitialPress);
                GameAction market = new GameAction("market", GameAction.ActionKind.OnlyInitialPress);
                GameAction cameraleft = new GameAction("cameraleft", GameAction.ActionKind.Normal);
                GameAction cameraright = new GameAction("cameraright", GameAction.ActionKind.Normal);
                GameAction cameraup = new GameAction("cameraup", GameAction.ActionKind.Normal);
                GameAction cameradown = new GameAction("cameradown", GameAction.ActionKind.Normal);
                GameAction cameratop = new GameAction("cameratop", GameAction.ActionKind.Normal);
                GameAction camerabottom = new GameAction("camerabottom", GameAction.ActionKind.Normal);

                GameAction enablemessages = new GameAction("enablemessages", GameAction.ActionKind.OnlyInitialPress);
                GameAction selectTown = new GameAction("selecttown", GameAction.ActionKind.OnlyInitialPress);
                GameAction selectHexa = new GameAction("selecthexa", GameAction.ActionKind.OnlyInitialPress);
                GameAction activateHexa = new GameAction("activatehexa", GameAction.ActionKind.OnlyInitialPress);
                GameAction resignGame = new GameAction("resigngame", GameAction.ActionKind.OnlyInitialPress);

                GameAction switchWireModel = new GameAction("switchwiremodel", GameAction.ActionKind.OnlyInitialPress);
                GameAction showPickingTexture = new GameAction("showpickingtexture", GameAction.ActionKind.OnlyInitialPress);
                GameAction debugInfo = new GameAction("debuginfo", GameAction.ActionKind.OnlyInitialPress);
                im.MapToKey(stateGame, debugInfo, Keys.A);
                im.MapToKey(stateGame, switchWireModel, Keys.W);
                im.MapToKey(stateGame, showPickingTexture, Keys.Q);

                im.MapToKey(stateGame, enablemessages, Keys.P);
                im.MapToKey(stateGame, selectTown, Keys.T);
                im.MapToKey(stateGame, selectHexa, Keys.H);
                im.MapToKey(stateGame, activateHexa, Keys.Enter);
                im.MapToKey(stateGame, resignGame, Keys.F12);

                im.MapToKey(stateGame, pause, Keys.Escape);
                im.MapToKey(stateGame, nextTurn, Keys.Tab);
                im.MapToKey(stateGame, market, Keys.M);
                im.MapToKey(stateGame, cameraleft, Keys.Left);
                im.MapToKey(stateGame, cameraright, Keys.Right);
                im.MapToKey(stateGame, cameraup, Keys.Up);
                im.MapToKey(stateGame, cameradown, Keys.Down);
                im.MapToKey(stateGame, cameratop, Keys.PageUp);
                im.MapToKey(stateGame, camerabottom, Keys.PageDown);
            }
            im.SetActiveState(stateGame);

            String stateGameWindow = "gamewindow";
            if (im.AddState(stateGameWindow))
            {
                GameAction confirm = new GameAction("confirm", GameAction.ActionKind.OnlyInitialPress);
                GameAction close = new GameAction("close", GameAction.ActionKind.OnlyInitialPress);
                GameAction left = new GameAction("left", GameAction.ActionKind.OnlyInitialPress);
                GameAction right = new GameAction("right", GameAction.ActionKind.OnlyInitialPress);
                GameAction quickChangeSources = new GameAction("changesources", GameAction.ActionKind.OnlyInitialPress);
                GameAction canChangeSources = new GameAction("canchange", GameAction.ActionKind.OnlyInitialPress);

                im.MapToKey(stateGameWindow, confirm, Keys.Enter);
                im.MapToKey(stateGameWindow, close, Keys.Escape);
                im.MapToKey(stateGameWindow, left, Keys.Left);
                im.MapToKey(stateGameWindow, right, Keys.Right);
                im.MapToKey(stateGameWindow, quickChangeSources, Keys.N);
                im.MapToKey(stateGameWindow, canChangeSources, Keys.B);
            }

            String stateMessage = "gamemessage";
            if (im.AddState(stateMessage))
            {
                GameAction close = new GameAction("close", GameAction.ActionKind.OnlyInitialPress);
                GameAction cheatsources = new GameAction("cheatsources", GameAction.ActionKind.OnlyInitialPress);
                GameAction cheatpoints = new GameAction("cheatpoints", GameAction.ActionKind.OnlyInitialPress);
                GameAction disablemessages = new GameAction("disablemessages", GameAction.ActionKind.OnlyInitialPress);
                im.MapToKey(stateMessage, disablemessages, Keys.P);
                im.MapToKey(stateMessage, close, Keys.Escape);
                im.MapToKey(stateMessage, close, Keys.Enter);
                im.MapToKey(stateMessage, cheatsources, Keys.F11);
                im.MapToKey(stateMessage, cheatpoints, Keys.F12);

            #if GENETIC
                GameAction printAllChromozones = new GameAction("printgenetic", GameAction.ActionKind.OnlyInitialPress);
                im.MapToKey(stateMessage, printAllChromozones, Keys.G);
            #endif
            }

            String stateMarket = "gamemarket";
            if (im.AddState(stateMarket))
            {
                GameAction ok = new GameAction("ok", GameAction.ActionKind.OnlyInitialPress);
                GameAction close = new GameAction("close", GameAction.ActionKind.OnlyInitialPress);

                GameAction right = new GameAction("right", GameAction.ActionKind.OnlyInitialPress);
                GameAction left = new GameAction("left", GameAction.ActionKind.OnlyInitialPress);
                im.MapToKey(stateMarket, close, Keys.Escape);
                im.MapToKey(stateMarket, ok, Keys.Enter);
                im.MapToKey(stateMarket, close, Keys.M);

                im.MapToKey(stateMarket, right, Keys.Right);
                im.MapToKey(stateMarket, left, Keys.Left);
            }

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();

            isGameLoaded = true;
        }
Esempio n. 3
0
 internal void SetMap(Map map)
 {
     this.map = map;
 }
Esempio n. 4
0
 public MapView(Map map)
 {
     this.map = map;
     viewQueue = new ViewQueue(this);
 }