예제 #1
0
    private void Judge()
    {
        switch (map.GetTileType(playerPos, dir))
        {
        case MapBuilder.TileType.Null:
            map.SetTileType(playerPos, dir, MapBuilder.TileType.Player);
            if (map.GetTileType(playerPos, Direction.Null) == MapBuilder.TileType.Player)
            {
                map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.Null);
            }
            else
            {
                map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.TargetPoint);
            }
            canMovePlayer = true;
            break;

        case MapBuilder.TileType.TargetPoint:
            map.SetTileType(playerPos, dir, MapBuilder.TileType.TargetWidthPlayer);
            if (map.GetTileType(playerPos, Direction.Null) == MapBuilder.TileType.Player)
            {
                map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.Null);
            }
            else
            {
                map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.TargetPoint);
            }
            canMovePlayer = true;
            break;

        case MapBuilder.TileType.Box:
            switch (map.GetTileType(playerPos, (Direction)((int)dir * 2)))
            {
            case MapBuilder.TileType.Null:
                map.SetTileType(playerPos, dir, MapBuilder.TileType.Player);
                map.SetTileType(playerPos, (Direction)((int)dir * 2), MapBuilder.TileType.Box);
                if (map.GetTileType(playerPos, Direction.Null) == MapBuilder.TileType.Player)
                {
                    map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.Null);
                }
                else
                {
                    map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.TargetPoint);
                }
                canMovePlayer = true;
                canMoveBox    = true;
                break;

            case MapBuilder.TileType.TargetPoint:
                map.SetTileType(playerPos, dir, MapBuilder.TileType.Player);
                map.SetTileType(playerPos, (Direction)((int)dir * 2), MapBuilder.TileType.targetWidthBox);
                if (map.GetTileType(playerPos, Direction.Null) == MapBuilder.TileType.Player)
                {
                    map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.Null);
                }
                else
                {
                    map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.TargetPoint);
                }
                canMovePlayer = true;
                canMoveBox    = true;
                map.ReduceTagetCount();
                break;
            }
            break;

        case MapBuilder.TileType.targetWidthBox:
            switch (map.GetTileType(playerPos, (Direction)((int)dir * 2)))
            {
            case MapBuilder.TileType.Null:
                map.SetTileType(playerPos, dir, MapBuilder.TileType.TargetWidthPlayer);
                map.SetTileType(playerPos, (Direction)((int)dir * 2), MapBuilder.TileType.Box);
                if (map.GetTileType(playerPos, Direction.Null) == MapBuilder.TileType.Player)
                {
                    map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.Null);
                }
                else
                {
                    map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.TargetPoint);
                }
                canMovePlayer = true;
                canMoveBox    = true;
                map.AddTargetCount();
                break;

            case MapBuilder.TileType.TargetPoint:
                map.SetTileType(playerPos, dir, MapBuilder.TileType.TargetWidthPlayer);
                map.SetTileType(playerPos, (Direction)((int)dir * 2), MapBuilder.TileType.targetWidthBox);
                if (map.GetTileType(playerPos, Direction.Null) == MapBuilder.TileType.Player)
                {
                    map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.Null);
                }
                else
                {
                    map.SetTileType(playerPos, Direction.Null, MapBuilder.TileType.TargetPoint);
                }
                canMovePlayer = true;
                canMoveBox    = true;
                break;
            }
            break;

        default:
            canMovePlayer = false;
            canMoveBox    = false;
            break;
        }
    }