예제 #1
0
파일: Game.cs 프로젝트: jonthysell/Kolohe
        public bool TryPlayerMove(Direction direction)
        {
            (int dx, int dy) = direction.GetDeltas();
            int targetX = Player.X + dx;
            int targetY = Player.Y + dy;

            if (WorldMap.Contains(targetX, targetY) && Player.CanPlaceOnTile(WorldMap[targetX, targetY]))
            {
                var currentCreature = Creatures[targetX, targetY];
                if (currentCreature is null || currentCreature == Player)
                {
                    // Open position
                    Creatures[Player.X, Player.Y] = null;
                    SetPlayerPosition(targetX, targetY);
                    Tick((GameInput)((int)GameInput.PlayerMoveUp + (int)direction));
                    return(true);
                }
            }

            return(false);
        }