예제 #1
0
        public void Update(TojamGame game, GameTime gameTime)
        {
            chatLog.Update(game, gameTime);
            textBox.Update(game, gameTime);

            if (game.gameInstance.GameStarted())
            {
                if (game.gameInstance.GetMyPlayer().carLocation != Player.CarLocation.NotInCar)
                {
                    carPicture.SetMidground(CarPicture.Midground.Car);
                }
                else
                {
                    carPicture.SetMidground(CarPicture.Midground.None);
                }

                Location currentLocation = game.gameInstance.world.GetLocation(game.gameInstance.GetMyPlayer().worldLocation);
                carPicture.SetBackground(currentLocation.Background);
            }

            // TODO process messages from the server

            // broadcast ready messages to the server
            if (Keyboard.GetState().IsKeyDown(Keys.Enter))
            {
                String textString = textBox.GetAndClear();
                if (textString != "")
                {
                    game.gameInstance.SendPlayerCommand(textString);
                }
            }

            carPicture.Update(game, gameTime);
            playerStatusIndicator.UpdateToPlayer(game, game.gameInstance.GetMyPlayer());
        }
예제 #2
0
        public void Initialize(TojamGame game)
        {
            // get dimensions to size thingsa round
            renderTarget = new RenderTarget2D(game.GraphicsDevice, chatSceneDimensions.Width, chatSceneDimensions.Height);
            Rectangle screenBounds       = chatSceneDimensions;
            int       messageBufferWidth = 200;

            // build chatlog
            ChatLogStyle style = new ChatLogStyle();

            style.font            = game.GameFont;
            style.linePadding     = 1;
            style.messagePadding  = 5;
            style.externalPadding = 10;
            style.internalBounds  = new Rectangle(
                screenBounds.Width - messageBufferWidth + style.externalPadding,
                style.externalPadding,
                messageBufferWidth - style.externalPadding * 2,
                screenBounds.Height - style.externalPadding
                );
            style.backgroundColor = Color.Black;

            chatLog = new ChatLog(style);
            chatLog.Initialize(game);
            chatLog.AppendMessage("Welcome to Algonquin Park Roadtrip Simulator 2018!", Color.White);
            chatLog.AppendMessage("Your goal is to reach Algonquin Park and have happy camping trip", Color.Gray);
            chatLog.AppendMessage("Type `help` to see commands", Color.Gray);
//			chatLog.AppendMessage("Type 'join <ip>' to join a game, or 'host' to start a new one", Color.Gray);
            chatLog.AppendMessage("Type 'setname <name>' set your name before starting a game", Color.Gray);

            // build textbox
            textBox = new TextBox(
                game.GameFont,
                new Rectangle(
                    0,
                    screenBounds.Height - game.GameFont.LineSpacing,
                    screenBounds.Width - messageBufferWidth,
                    game.GameFont.LineSpacing
                    ));

            // initialize displayable scene
            carPicture = new CarPicture(new Rectangle(0, 0, screenBounds.Width - messageBufferWidth, screenBounds.Height - game.GameFont.LineSpacing * 2 - 5));
            carPicture.Initialize(game);
            carPicture.SetSky(CarPicture.Sky.Day);
            carPicture.SetBackground(CarPicture.Background.Title);
            //carPicture.TriggerEvent("town", new Dictionary<String, Object> { { "townName", "Algonquin" } });

            playerStatusIndicator = new PlayerStatusIndicator(game.GameFont, new Vector2(0, screenBounds.Height - game.GameFont.LineSpacing * 2));
        }