Exemplo n.º 1
0
        public static bool LootChest(Lobby lobby, Player player)
        {
            //var types = MazeLogic.CheckLobbyCoordinate(player.UserCoordinate, lobby);
            var events = MazeLogic.EventsOnCell(player.UserCoordinate, lobby);

            if (events.Contains(EventTypeEnum.Chest))
            {
                if (player.Chest == null && player.Health == lobby.Rules.PlayerMaxHealth)
                {
                    player.Chest = MazeLogic.PickChest(player.UserCoordinate, lobby, player);
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Возвращает можно ли идти в направлении
        /// </summary>
        public static List <PlayerAction> TryMove(Lobby lobby, Player player, Direction direction)
        {
            var coord = Extensions.TargetCoordinate(player.Rotate, direction);
            var types = MazeLogic.CheckLobbyCoordinate(player.UserCoordinate - coord, lobby);

            //TODO: debug
            Console.Clear();
            Console.WriteLine(player.UserCoordinate.X + " " + player.UserCoordinate.Y);
            //===========

            if (types.Contains(MazeObjectType.Wall) || types.Contains(MazeObjectType.Space))
            {
                return new List <PlayerAction> {
                           PlayerAction.OnWall
                }
            }
            ;

            player.UserCoordinate -= coord;
            if (player.Chest != null)
            {
                lobby.Chests.Find(e => e.Id == player.Chest.Id).Position = player.UserCoordinate;
            }
            var actions = new List <PlayerAction>();

            if (types.Contains(MazeObjectType.Event))
            {
                var events = MazeLogic.EventsOnCell(player.UserCoordinate, lobby);
                if (events.Contains(EventTypeEnum.Arsenal))
                {
                    player.Bombs = lobby.Rules.PlayerMaxBombs;
                    player.Guns  = lobby.Rules.PlayerMaxGuns;
                    actions.Add(PlayerAction.OnArsenal);
                }

                if (events.Contains(EventTypeEnum.Hospital))
                {
                    player.Health = lobby.Rules.PlayerMaxHealth;
                    actions.Add(PlayerAction.OnHospital);
                }

                if (events.Contains(EventTypeEnum.Chest))
                {
                    if (player.Chest == null && player.Health == lobby.Rules.PlayerMaxHealth)
                    {
                        player.Chest = MazeLogic.PickChest(player.UserCoordinate, lobby, player);
                        actions.Add(PlayerAction.OnChest);
                    }
                }
            }

            if (types.Contains(MazeObjectType.Player))
            {
                actions.Add(PlayerAction.MeetPlayer);
            }


            if (types.Contains(MazeObjectType.Exit) && player.Chest != null)
            {
                if (player.Chest.IsReal == false)
                {
                    var r = lobby.Chests.Find(e =>
                                              Equals(player.UserCoordinate, e.Position));
                    lobby.Chests.Remove(r);
                    player.Chest = null;
                    actions.Add(PlayerAction.FakeChest);
                }
                else
                {
                    actions.Add(PlayerAction.GameEnd);
                }
            }

            return(actions);
        }