public TraderQuestion(Vector2 position, Salesman salesman) : base("Trade caravan", false) { _s = salesman; Position = position; Dimention = new Vector2(325, 110); TextArea ta = new TextArea("A trading caravan has arrived at your fortress. Would you like to trade?", new Vector2(12, 35), new Vector2(300, 0)); _yes = new Button("Yes", new Vector2(10, 100)); _no = new Button("No", new Vector2(170, 100)); AddGuiComponent(_yes); AddGuiComponent(_no); AddGuiComponent(ta); CannotClose = true; }
public TraderMenu(Salesman s, Vector2 position) : base("Trader menu", false) { Position = position; _s = s; Dimention = new Vector2(500, 300); List<TraderItem> traderItems = WorldMap.Instance.GetTraderItems(); int counter = 0; foreach (TraderItem t in traderItems) { Label l = new Label(NameHelper.GetNameOfWorldObject(t.Type) + ": ", new Vector2(5 + (counter % 3) * 175, 45 + (counter / 3) * 50)); NumberChooser nc = new NumberChooser(new Vector2(100 + (counter % 3) * 175, 40 + (counter / 3) * 50), t.Amount, 0); AddGuiComponent(l); AddGuiComponent(nc); counter++; } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); float dt = (float)gameTime.ElapsedGameTime.TotalMilliseconds; double dtd = gameTime.ElapsedGameTime.TotalMilliseconds; _camera.Update((float)gameTime.ElapsedGameTime.TotalMilliseconds); _mouse.EngineUpdate(gameTime); _keyboard.EngineUpdate(gameTime); GuiSystem.Update(dt); if (KeyboardInput.IsKeyClicked(Keys.F1)) _speed = 1; if (KeyboardInput.IsKeyClicked(Keys.F2)) _speed *= 2; if (KeyboardInput.IsKeyClicked(Keys.F3)) _worldMap.AddCreature(new Dwarf(new Vector3(30, 75, _worldMap.GetSurfacePoint()), LivingType.Dwarf)); if (KeyboardInput.IsKeyClicked(Keys.F11)) ColorRules.AmbientLight -= 0.1f; if (KeyboardInput.IsKeyClicked(Keys.F12)) ColorRules.AmbientLight =1; if (KeyboardInput.IsKeyClicked(Keys.F5)) TaskManager.ActivateCombatMode(); if (KeyboardInput.IsKeyClicked(Keys.F6)) TaskManager.ActivatePeaceMode(); if (KeyboardInput.IsKeyClicked(Keys.F7)) WaveManager.StartNextWave(); if (KeyboardInput.IsKeyClicked(Keys.F8)) { Salesman s = new Salesman(new Vector3(1, 1, 5)); WorldMap.Instance.AddCreature(s); } if (KeyboardInput.IsKeyClicked(Keys.F10)) DebugRules.SkipPersonalTasks = !DebugRules.SkipPersonalTasks; if (KeyboardInput.IsKeyClicked(Keys.Pause) || KeyboardInput.IsKeyClicked(Keys.Space)) _pause = !_pause; if (elapsedTime > TimeSpan.FromSeconds(1)) { elapsedTime -= TimeSpan.FromSeconds(1); frameRate = frameCounter; frameCounter = 0; } _cursor.Update(dt); if (_pause == false) { for (int i = 0; i < _speed; i++) { _worldMap.Update(dt, dtd); TaskManager.Update(); SimulationWorld.Instance.Update(dt, dtd); PrioritySystem.Update(dt); TaskRequester.Update(dt); } } this.Window.Title = SimulationWorld.Instance.Year.ToString(); // TODO: Add your update logic here base.Update(gameTime); }