示例#1
0
        public void Update(float passedTime)
        {
            bool isReady = true;

            gameScreen.InfoBox.Update(passedTime);
            gameScreen.ChatBox.Update(passedTime);

            if (watchedCharacters.Count != 0)
            {
                foreach (Character watchedCharacter in watchedCharacters)
                {
                    if (!watchedCharacter.IsIdle() ||
                        watchedCharacter.HealthVariation.IsVisible() ||
                        watchedCharacter.DrawingAffects ||
                        watchedCharacter.Target != null)
                    {
                        isReady = false;
                        break;
                    }
                }

                if (isReady)
                {
                    if (trigger == Trigger.SendConfirmUpdate)
                    {
                        SendConfirmUpdateMessage(ConfirmationType.UpdateMessage);
                        gameScreen.ActualTurn = null;
                    }
                    else if (trigger == Trigger.SendConfirmAffects)
                    {
                        SendConfirmUpdateMessage(ConfirmationType.AffectsMessage);
                    }
                    else if (trigger == Trigger.TriggerActionBox)
                    {
                        FillOptions();
                    }

                    watchedCharacters.Clear();
                    trigger = Trigger.DoNothing;
                }
            }

            if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Space))
            {
                ChatInputHandler chatInputHandler = new ChatInputHandler(gameScreen);
                gameScreen.ChatBox.ChatInputHandler = chatInputHandler;
                gameScreen.Handlers.Push(chatInputHandler);
                gameScreen.ChatBox.Show();
                return;
            }

            if (gameScreen.ActionBox.IsVisible)
            {
                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Escape))
                {
                    gameScreen.ActionBox.ClearOptions();
                    gameScreen.ActionBox.AddOption(GameScreen.ACTIONBOX_CONTINUE);
                    gameScreen.ActionBox.AddOption(GameScreen.ACTIONBOX_EXIT);
                }

                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Down))
                {
                    gameScreen.ActionBox.Selection++;
                }

                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Up))
                {
                    gameScreen.ActionBox.Selection--;
                }

                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Enter))
                {
                    HideSelectedCharacter();
                    selectedOption = gameScreen.ActionBox.SelectedValue;
                    switch (gameScreen.ActionBox.SelectedValue)
                    {
                    case GameScreen.ACTIONBOX_WALK:
                        HandleActionWalk();
                        break;

                    case GameScreen.ACTIONBOX_ATTACK:
                        HandleActionAttack();
                        break;

                    case GameScreen.ACTIONBOX_WAIT:
                        HandleActionNext();
                        break;

                    case GameScreen.ACTIONBOX_FINISH:
                        HandleActionNext();
                        break;

                    case GameScreen.ACTIONBOX_EXIT:
                        HandleActionExit();
                        break;

                    case GameScreen.ACTIONBOX_CONTINUE:
                        HandleActionContinue();
                        break;
                    }
                }
            }
            else
            {
                gameScreen.MapCursor.IsVisible = isReady;

                if (isReady && KeyboardManager.Manager.TypedKeys.Contains(Keys.Escape))
                {
                    if (gameScreen.SelectedCharacter != null)
                    {
                        gameScreen.ClearTileMarks();
                        gameScreen.MapCursor.IsVisible = false;
                        gameScreen.Camera.FocusOn(gameScreen.SelectedCharacter.MapLocation);
                    }
                    else
                    {
                        gameScreen.ActionBox.ClearOptions();
                        gameScreen.ActionBox.AddOption(GameScreen.ACTIONBOX_EXIT);
                        gameScreen.ActionBox.AddOption(GameScreen.ACTIONBOX_CONTINUE);
                    }

                    FillOptions();
                }

                if (isReady && KeyboardManager.Manager.TypedKeys.Contains(Keys.Up))
                {
                    Point location = gameScreen.MapCursor.MapLocation;

                    if (gameScreen.TileMarks[location.X, location.Y] != null)
                    {
                        gameScreen.TileMarks[location.X, location.Y].Selected = false;
                    }

                    location.Y--;
                    gameScreen.MapCursor.MapLocation = location;

                    if (gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y] != null)
                    {
                        gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y].Selected = true;
                    }

                    gameScreen.Camera.FocusOn(gameScreen.MapCursor.MapLocation);
                }

                if (isReady && KeyboardManager.Manager.TypedKeys.Contains(Keys.Down))
                {
                    Point location = gameScreen.MapCursor.MapLocation;

                    if (gameScreen.TileMarks[location.X, location.Y] != null)
                    {
                        gameScreen.TileMarks[location.X, location.Y].Selected = false;
                    }

                    location.Y++;
                    gameScreen.MapCursor.MapLocation = location;

                    if (gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y] != null)
                    {
                        gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y].Selected = true;
                    }

                    gameScreen.Camera.FocusOn(gameScreen.MapCursor.MapLocation);
                }

                if (isReady && KeyboardManager.Manager.TypedKeys.Contains(Keys.Right))
                {
                    Point location = gameScreen.MapCursor.MapLocation;

                    if (gameScreen.TileMarks[location.X, location.Y] != null)
                    {
                        gameScreen.TileMarks[location.X, location.Y].Selected = false;
                    }

                    location.X++;
                    gameScreen.MapCursor.MapLocation = location;

                    if (gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y] != null)
                    {
                        gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y].Selected = true;
                    }

                    gameScreen.Camera.FocusOn(gameScreen.MapCursor.MapLocation);
                }

                if (isReady && KeyboardManager.Manager.TypedKeys.Contains(Keys.Left))
                {
                    Point location = gameScreen.MapCursor.MapLocation;

                    if (gameScreen.TileMarks[location.X, location.Y] != null)
                    {
                        gameScreen.TileMarks[location.X, location.Y].Selected = false;
                    }

                    location.X--;
                    gameScreen.MapCursor.MapLocation = location;

                    if (gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y] != null)
                    {
                        gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y].Selected = true;
                    }

                    gameScreen.Camera.FocusOn(gameScreen.MapCursor.MapLocation);
                }

                if (isReady && KeyboardManager.Manager.TypedKeys.Contains(Keys.Enter))
                {
                    if (gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y] != null)
                    {
                        AbstractMessage message = null;
                        Point           target  = gameScreen.MapCursor.MapLocation;

                        switch (selectedOption)
                        {
                        case GameScreen.ACTIONBOX_ATTACK:
                            message = new ActionMessageAttack();
                            ((ActionMessageAttack)message).TargetPlayer = Controller.GetInstance().GetRemotePlayer().Name;
                            ((ActionMessageAttack)message).Target       =
                                gameScreen.MapEngine.Map.Objects[target.X, target.Y].RootName;
                            break;

                        case GameScreen.ACTIONBOX_WALK:
                            message = new ActionMessageWalk();
                            ((ActionMessageWalk)message).Point = target;
                            break;
                        }

                        gameScreen.ClearTileMarks();

                        Controller.GetInstance().Client.SendData(message);
                    }
                }
            }
        }
示例#2
0
        public void Update(float passedTime)
        {
            gameScreen.InfoBox.Update(passedTime);
            gameScreen.ChatBox.Update(passedTime);

            if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Space))
            {
                ChatInputHandler chatInputHandler = new ChatInputHandler(gameScreen);
                gameScreen.ChatBox.ChatInputHandler = chatInputHandler;
                gameScreen.Handlers.Push(chatInputHandler);
                gameScreen.ChatBox.Show();
                return;
            }

            if (gameScreen.ActionBox.IsVisible)
            {
                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Escape))
                {
                    gameScreen.ActionBox.ClearOptions();
                    gameScreen.ActionBox.AddOption(GameScreen.ACTIONBOX_CONTINUE);
                    gameScreen.ActionBox.AddOption(GameScreen.ACTIONBOX_EXIT);
                }

                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Down))
                {
                    gameScreen.ActionBox.Selection++;
                }

                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Up))
                {
                    gameScreen.ActionBox.Selection--;
                }
                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Enter))
                {
                    switch (gameScreen.ActionBox.SelectedValue)
                    {
                    case GameScreen.ACTIONBOX_SET:
                        HandleActionWalk();
                        break;

                    case GameScreen.ACTIONBOX_NEXT:
                        HandleActionNext();
                        break;

                    case GameScreen.ACTIONBOX_READY:
                        HandleActionFinish();
                        break;

                    case GameScreen.ACTIONBOX_EXIT:
                        HandleActionExit();
                        break;

                    case GameScreen.ACTIONBOX_CONTINUE:
                        HandleActionContinue();
                        break;
                    }
                    gameScreen.ActionBox.Selection = 0;
                }
            }
            else
            {
                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Escape))
                {
                    gameScreen.ClearTileMarks();
                    gameScreen.MapCursor.IsVisible = false;
                    gameScreen.Camera.FocusOn(gameScreen.SelectedCharacter.MapLocation);
                    this.FillOptions();
                }

                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Up))
                {
                    Point location = gameScreen.MapCursor.MapLocation;

                    if (gameScreen.TileMarks[location.X, location.Y] != null)
                    {
                        gameScreen.TileMarks[location.X, location.Y].Selected = false;
                    }

                    location.Y--;
                    gameScreen.MapCursor.MapLocation = location;

                    if (gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y] != null)
                    {
                        gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y].Selected = true;
                    }

                    gameScreen.Camera.FocusOn(gameScreen.MapCursor.MapLocation);
                }

                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Down))
                {
                    Point location = gameScreen.MapCursor.MapLocation;

                    if (gameScreen.TileMarks[location.X, location.Y] != null)
                    {
                        gameScreen.TileMarks[location.X, location.Y].Selected = false;
                    }

                    location.Y++;
                    gameScreen.MapCursor.MapLocation = location;

                    if (gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y] != null)
                    {
                        gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y].Selected = true;
                    }

                    gameScreen.Camera.FocusOn(gameScreen.MapCursor.MapLocation);
                }

                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Right))
                {
                    Point location = gameScreen.MapCursor.MapLocation;

                    if (gameScreen.TileMarks[location.X, location.Y] != null)
                    {
                        gameScreen.TileMarks[location.X, location.Y].Selected = false;
                    }

                    location.X++;
                    if (location.X >= Constants.TACTICS_MODE_WIDTH && Controller.GetInstance().IsServer)
                    {
                        location.X = Constants.TACTICS_MODE_WIDTH - 1;
                    }

                    gameScreen.MapCursor.MapLocation = location;

                    if (gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y] != null)
                    {
                        gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y].Selected = true;
                    }

                    gameScreen.Camera.FocusOn(gameScreen.MapCursor.MapLocation);
                }

                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Left))
                {
                    Point location = gameScreen.MapCursor.MapLocation;

                    if (gameScreen.TileMarks[location.X, location.Y] != null)
                    {
                        gameScreen.TileMarks[location.X, location.Y].Selected = false;
                    }

                    location.X--;
                    if (location.X < gameScreen.MapEngine.Map.MapWidth - Constants.TACTICS_MODE_WIDTH &&
                        !Controller.GetInstance().IsServer)
                    {
                        location.X = gameScreen.MapEngine.Map.MapWidth - Constants.TACTICS_MODE_WIDTH;
                    }

                    gameScreen.MapCursor.MapLocation = location;

                    if (gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y] != null)
                    {
                        gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y].Selected = true;
                    }

                    gameScreen.Camera.FocusOn(gameScreen.MapCursor.MapLocation);
                }

                if (KeyboardManager.Manager.TypedKeys.Contains(Keys.Enter))
                {
                    if (gameScreen.TileMarks[gameScreen.MapCursor.MapLocation.X,
                                             gameScreen.MapCursor.MapLocation.Y] != null)
                    {
                        gameScreen.MapEngine.RealocateObject(gameScreen.SelectedCharacter, gameScreen.MapCursor.MapLocation);
                        gameScreen.Camera.FocusOn(gameScreen.SelectedCharacter.MapLocation);
                        gameScreen.ClearTileMarks();
                        gameScreen.MapCursor.IsVisible = false;
                        FillOptions();
                    }
                }
            }
        }