Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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);

                AddGuiComponent(l);
                AddGuiComponent(nc);

                counter++;
            }
        }
Esempio n. 3
0
        /// <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;

            _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.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.Pause))
                _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);
                    TaskManager.Update();
                    SimulationWorld.Instance.Update(16);
                    TaskRequester.Update(16);
                }
            }

            // TODO: Add your update logic here

            base.Update(gameTime);
        }