Esempio n. 1
0
        public void TurnInput(PlayerInput input)
        {
            GameManager.GetInstance().didTurnAction();

            if (input == PlayerInput.right)
            {
                action = new PlayerTurnAction(0.2f, -1, GameManager.GetInstance().Camera);
            }
            else if (input == PlayerInput.left)
            {
                action = new PlayerTurnAction(0.2f, 1, GameManager.GetInstance().Camera);
            }
            else if (input == PlayerInput.backward)
            {
                if (!GameManager.GetInstance().Map.checkMovability(pos - dir))
                {
                    action = new PlayerMoveAction(0.2f, pos - dir, GameManager.GetInstance().Camera);
                }
                else
                {
                    action = new PlayerPauseAction(0.4f);
                    GameManager.GetInstance().AddMessage("Ouch!");
                }
                EndTurn();
            }
            else if (input == PlayerInput.forward)
            {
                action = new PlayerMoveAction(0.2f, pos + dir, GameManager.GetInstance().Camera);

                if (!GameManager.GetInstance().Map.checkMovability(pos + dir))
                {
                    action = new PlayerMoveAction(0.2f, pos + dir, GameManager.GetInstance().Camera);
                }
                else
                {
                    Entity toAttack = GameManager.GetInstance().Map.checkEntityHit(pos + dir);
                    if (toAttack as Actor != null)
                    {
                        action = new PlayerMeleeAction(0.10f);
                        MeleeAttack((Actor)toAttack);
                    }
                    else if (toAttack as Door != null)
                    {
                        (toAttack as Door).Toggle(0.16f);
                        action = new PlayerPauseAction(0.2f);
                    }
                    else
                    {
                        action = new PlayerPauseAction(0.4f);
                        GameManager.GetInstance().AddMessage("Ouch!");
                    }
                }
                EndTurn();
            }
        }
Esempio n. 2
0
        public void TurnInput(PlayerInput input)
        {
            ownerMap.Gamestate.didTurnAction();

            if (input == PlayerInput.right)
            {
                action = new PlayerTurnAction(0.2f, -1, camera);
            }
            else if (input == PlayerInput.left)
            {
                action = new PlayerTurnAction(0.2f, 1, camera);
            }
            else if (input == PlayerInput.backward)
            {
                if (!ownerMap.checkMovability(pos - dir))
                {
                    action = new PlayerMoveAction(0.2f, pos - dir, camera);
                }
                else
                {
                    action = new PlayerPauseAction(0.4f);
                    ownerMap.Gamestate.AddMessage("Ouch!");
                }
                EndTurn();
            }
            else if (input == PlayerInput.forward)
            {
                action = new PlayerMoveAction(0.2f, pos + dir, camera);

                if (!ownerMap.checkMovability(pos + dir))
                {
                    action = new PlayerMoveAction(0.2f, pos + dir, camera);
                }
                else
                {
                    Entity toAttack = ownerMap.checkEntityHit(pos + dir);
                    if (toAttack as Actor != null)
                    {
                        action = new PlayerMeleeAction(0.10f);
                        MeleeAttack((Actor)toAttack);
                    }
                    else if (toAttack as Door != null)
                    {
                        (toAttack as Door).Toggle(0.16f);
                        action = new PlayerPauseAction(0.2f);
                    }
                    else
                    {
                        action = new PlayerPauseAction(0.4f);
                        ownerMap.Gamestate.AddMessage("Ouch!");
                    }
                }
                EndTurn();
            }
            else if (input == PlayerInput.button)
            {
                int tileType = ownerMap.GetTileAt(MapPosX, MapPosY);
                Item itemHit = ownerMap.GetItemAt(new Vector2(MapPosX, MapPosY));

                if (tileType == -2)
                {
                    ownerMap.Gamestate.AddMessage("You climb down the ladder");
                    ownerMap.Gamestate.GoDownLevel();
                }
                else if (itemHit != null)
                {
                    string message = "You pick up a ";
                    if (itemHit.Amount > 1) message = "You pick up ";

                    ownerMap.Gamestate.AddMessage(message + itemHit.Name);
                    inventory.Add(itemHit);
                    ownerMap.entities.Remove(itemHit);
                    action = new PlayerPauseAction(0.4f);
                }
                else
                {
                    ownerMap.Gamestate.AddMessage("You see nothing here");
                }

                action = new PlayerPauseAction(0.4f);
                EndTurn();
            }
        }