/// <summary> /// The constructor is private: loading screens should /// be activated via the static Load method instead. /// </summary> private VictoryScreen(ScreenManager screenManager, GameScreen[] screensToLoad) { this.userCancelled = false; firstTimeHandleInput = true; this.screensToLoad = screensToLoad; this.screenManager = screenManager; toGraphButton = new ButtonComponent(screenManager.Game, (int)(Settings.maximumResolution.X - 150), (int)(Settings.maximumResolution.Y - 200), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(79), Settings.scaleH(66), "HUD/menu_next"); toGraphButton.Actions += ToGraph; toMenuButton = new ButtonComponent(screenManager.Game, 60, (int)(Settings.maximumResolution.Y - 200), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(79), Settings.scaleH(66), "HUD/hotseat_back"); toMenuButton.Actions += ToMenu; toGraphButton.LoadContent(); toMenuButton.LoadContent(); }
public PlayerSettingRowComponent(Game game, int x, int y, SpriteFont font, int width, int height, Color c,String name, int changeState) : base(game,x,y,font,width,height,null) { playerColorTexture = game.Content.Load<Texture2D>("pcolor"); playerColor = c; this.name = name; playerState = new ButtonComponent(game, x + 500, y - 6, font, Settings.scaleW(200), Settings.scaleH(45), null, Settings.PlayerState); playerState.Actions += PlayerStateButtonAction; for(int loop1 = 0; loop1 < changeState; loop1++) playerState.nextText(); playerState.Initialize(); playerState.LoadContent(); addButton = new ButtonComponent(game, x, y, new Rectangle(), font, 34, 32, "HUD/hotseat_plus"); addButton.Actions += AddButtonAction; addButton.Initialize(); addButton.LoadContent(); remButton = new ButtonComponent(game, x, y, new Rectangle(), font, 34, 32, "HUD/hotseat_minus"); remButton.Actions += RemButtonAction; remButton.Initialize(); remButton.LoadContent(); }
/// <summary> /// The constructor is private: loading screens should /// be activated via the static Load method instead. /// </summary> private GraphScreen(ScreenManager screenManager, GameScreen[] screensToLoad) { graphKind = 0; this.userCancelled = false; this.screensToLoad = screensToLoad; this.screenManager = screenManager; this.primitiveBatch = new PrimitiveBatch(screenManager.GraphicsDevice); windowWidth = screenManager.GraphicsDevice.Viewport.Width; windowHeight = screenManager.GraphicsDevice.Viewport.Height; columnNumber = GameMaster.Inst().GetTurnNumber(); if (SetRowNumber()) ToNextGraph(); toMenuButton = new ButtonComponent(screenManager.Game, 60, (int)(Settings.maximumResolution.Y - 200), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(79), Settings.scaleH(66), "HUD/hotseat_back"); toMenuButton.Actions += ToMenu; toMenuButton.LoadContent(); nextGraphButton = new ButtonComponent(screenManager.Game, (int)(Settings.maximumResolution.X - 150), (int)(Settings.maximumResolution.Y - 200), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(79), Settings.scaleH(66), "HUD/menu_next"); nextGraphButton.Actions += NextGraph; nextGraphButton.LoadContent(); }
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; }
/// <summary> /// Load graphics content for the game. /// </summary> public override void LoadContent() { if (content == null) { content = new ContentManager(ScreenManager.Game.Services, "Content"); } else { GameMaster.Inst().DeleteAllPlayers(); return; } startGameButton = new ButtonComponent(ScreenManager.Game, (int)(Settings.maximumResolution.X - 150), (int)(Settings.maximumResolution.Y - 200), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(79), Settings.scaleH(66), "HUD/hotseat_hra_button"); startGameButton.Actions += StartGameSelected; //guiComponents.Add(changeTurnButton); ButtonComponent backButton = new ButtonComponent(ScreenManager.Game, 60, (int)(Settings.maximumResolution.Y - 200), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(79), Settings.scaleH(66), "HUD/hotseat_back"); backButton.Actions += BackSelected; guiComponents.Add(backButton); int counter = 0; /* * Loading AI */ List<String> AIname = new List<String>(); AIname.Add(Strings.MENU_HOT_SEAT_NO_AI); foreach (IComponentAI AI in CoreProviderAI.AI) { AIname.Add(AI.GetAIName()); } Settings.PlayerState = AIname; /* * */ foreach (Color c in Settings.playerColors) { int playerNameID = GetRandomPlayerID(); PlayerSettingRowComponent pSwitch = new PlayerSettingRowComponent(ScreenManager.Game, (int)colorPosition.X, (int)colorPosition.Y, GameResources.Inst().GetFont(EFont.PlayerNameFont), 200, 200, c, Strings.MENU_HOT_SEAT_NAMES[playerNameID], (counter == 0 || counter ==2) ? 1 : 0); playersSettings.Add(pSwitch); colorPosition.Y += playerSpace; if (counter <= 2) { // first two users are active pSwitch.setActive(true); } counter++; } //margin betweent sections colorPosition.Y += 80; points = new MapSettingRowComponent(ScreenManager.Game, (int)colorPosition.X, (int)colorPosition.Y, GameResources.Inst().GetFont(EFont.MedievalBig), 400, 200, Strings.MENU_HOT_SEAT_POINTS, new List<String>() { Settings.winPoints[0].ToString(), Settings.winPoints[1].ToString(), Settings.winPoints[2].ToString() }); mapType = new MapSettingRowComponent(ScreenManager.Game, (int)colorPosition.X, (int)colorPosition.Y + 50, GameResources.Inst().GetFont(EFont.MedievalBig), 400, 200, Strings.MENU_HOT_SEAT_MAP_TYPE, new List<String>() { Strings.GAME_SETTINGS_MAP_TYPE_LOWLAND, Strings.GAME_SETTINGS_MAP_TYPE_NORMAL, Strings.GAME_SETTINGS_MAP_TYPE_WASTELAND }); mapSize = new MapSettingRowComponent(ScreenManager.Game, (int)colorPosition.X, (int)colorPosition.Y + 100, GameResources.Inst().GetFont(EFont.MedievalBig), 400, 200, Strings.MENU_HOT_SEAT_MAP_SIZE, new List<String>() { Strings.GAME_SETTINGS_MAP_SIZE_SMALL, Strings.GAME_SETTINGS_MAP_SIZE_MEDIUM, Strings.GAME_SETTINGS_MAP_SIZE_BIG }); wealth = new MapSettingRowComponent(ScreenManager.Game, (int)colorPosition.X, (int)colorPosition.Y + 150, GameResources.Inst().GetFont(EFont.MedievalBig), 400, 200, Strings.MENU_HOT_SEAT_MAP_WEALTH, new List<String>() { Strings.GAME_SETTINGS_MAP_WEALTH_LOW, Strings.GAME_SETTINGS_MAP_WEALTH_MEDIUM, Strings.GAME_SETTINGS_MAP_WEALTH_HIGH }); guiComponents.Add(points); guiComponents.Add(mapType); guiComponents.Add(mapSize); guiComponents.Add(wealth); foreach (GuiComponent guiComponent in guiComponents) { guiComponent.Initialize(); guiComponent.LoadContent(); } foreach( PlayerSettingRowComponent p in playersSettings ) { p.Initialize(); p.LoadContent(); } foreach (ButtonComponent p in addButtons) { p.Initialize(); p.LoadContent(); } foreach (ButtonComponent p in remButtons) { p.Initialize(); p.LoadContent(); } playerColorTexture = ScreenManager.Game.Content.Load<Texture2D>("pcolor"); startGameButton.Initialize(); startGameButton.LoadContent(); ScreenManager.Game.ResetElapsedTime(); }
/// <summary> /// Method is responsible for disapproving changing same material for same material - like corn for corn /// </summary> /// <returns>true if we should disallow clicking</returns> bool disallowChangingSameTypes(ButtonComponent btn) { if (fromButtons.Contains(btn)) { foreach (ButtonComponent b in toButtons) { //trying to find selected button if (b.getPicked()) { if (b.getType() == btn.getType()) { // first row has bigger priority b.setPicked(false); toSelectKind = SourceKind.Null; marketSlider.setToType(SourceKind.Null); return false; } //we can break because only one button can be selected break; } } } else { foreach (ButtonComponent b in fromButtons) { //trying to find selected button if (b.getPicked()) { if (b.getType() == btn.getType()) { return true; } //we can break because only one button can be selected break; } } } return false; }
/// <summary> /// Creates second row of buttons - what material are we offering to trade /// </summary> protected void createSecondRow() { //bottom row ButtonComponent corn_button = new ButtonComponent(Settings.Game, leftMargin + range.Left + 3*w_space, (int)(range.Top + buttonSize.Y + 2 * space + topMargin), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(buttonSize.X), Settings.scaleH(buttonSize.Y), "corn_market", SourceKind.Corn); corn_button.Actions += MaterialButtonAction; this.content.Add(corn_button); ButtonComponent brick_button = new ButtonComponent(Settings.Game, leftMargin + (int)(range.Left + buttonSize.X + 4 * w_space), (int)(range.Top + buttonSize.Y + 2 * space + topMargin), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(buttonSize.X), Settings.scaleH(buttonSize.Y), "meat_market", SourceKind.Meat); brick_button.Actions += MaterialButtonAction; this.content.Add(brick_button); ButtonComponent wood_button = new ButtonComponent(Settings.Game, leftMargin + (int)(range.Left + 2 * buttonSize.X + 5 * w_space), (int)(range.Top + buttonSize.Y + 2 * space + topMargin), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(buttonSize.X), Settings.scaleH(buttonSize.Y), "stone_market", SourceKind.Stone); wood_button.Actions += MaterialButtonAction; this.content.Add(wood_button); ButtonComponent stone_button = new ButtonComponent(Settings.Game, leftMargin + (int)(range.Left + 3 * buttonSize.X + 6 * w_space), (int)(range.Top + buttonSize.Y + 2 * space + topMargin), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(buttonSize.X), Settings.scaleH(buttonSize.Y), "wood_market", SourceKind.Wood); stone_button.Actions += MaterialButtonAction; this.content.Add(stone_button); ButtonComponent sheep_button = new ButtonComponent(Settings.Game, leftMargin + (int)(range.Left + 4 * buttonSize.X + 7 * w_space), (int)(range.Top + buttonSize.Y + 2 * space + topMargin), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(buttonSize.X), Settings.scaleH(buttonSize.Y), "ore_market", SourceKind.Ore); sheep_button.Actions += MaterialButtonAction; this.content.Add(sheep_button); toButtons.Add(corn_button); toButtons.Add(brick_button); toButtons.Add(wood_button); toButtons.Add(stone_button); toButtons.Add(sheep_button); }
public override void Initialize() { base.Initialize(); this.createFirstRow(); this.createSecondRow(); fillMarketKindTextures(); change_button = new ButtonComponent(Settings.Game, range.Left + 180, (int)(range.Bottom-80), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(104), Settings.scaleH(45), "HUD/OKPromt"); change_button.Actions += ChangeButtonAction; this.content.Add(change_button); ButtonComponent exit_button = new ButtonComponent(Settings.Game, range.Left + 400, (int)(range.Bottom - 80), new Rectangle(), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(104), Settings.scaleH(46), "HUD/NOPromt"); exit_button.Actions += CloseButtonAction; this.content.Add(exit_button); GuiComponent title = new GuiComponent(Settings.Game, range.Left + 240, (int)(range.Top + 20), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(217), Settings.scaleH(43), "trziste_nadpis"); this.content.Add(title); GuiComponent firstRow = new GuiComponent(Settings.Game, range.Left + 3*w_space, (int)(range.Top + topMargin + space + 10), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(154), Settings.scaleH(22), "co_vymenit"); this.content.Add(firstRow); GuiComponent secondRow = new GuiComponent(Settings.Game, range.Left + 3 * w_space, (int)(range.Top + topMargin + buttonSize.Y + 2 * space + 10), GameResources.Inst().GetFont(EFont.MedievalBig), Settings.scaleW(77), Settings.scaleH(14), "za_co_vymenit"); this.content.Add(secondRow); marketSlider = new MarketSliderComponent(Settings.Game, range.Left + 130, (int)(range.Top + topMargin + buttonSize.Y + 4 * space + 10), GameResources.Inst().GetFont(EFont.MedievalBig),372,16,"slider_market"); //this.content.Add(marketSlider); foreach (GuiComponent g in content) { g.Initialize(); g.LoadContent(); } marketSlider.Initialize(); marketSlider.LoadContent(); }