Пример #1
0
    public override void PlaceGround(IBaseBackgroundType groundType, TileConnectionScoreInfo connectionScoreInfo)
    {
        GameObject groundGO = GameObject.Instantiate(OverworldGameplayManager.Instance.GetTileBackgroundPrefab <OverworldTileBaseGround>(), Tile.BackgroundsContainer);
        OverworldTileBaseGround mazeTileBaseGround = groundGO.GetComponent <OverworldTileBaseGround>();

        mazeTileBaseGround.WithType(groundType);
        mazeTileBaseGround.WithConnectionScoreInfo(connectionScoreInfo);
        mazeTileBaseGround.SetTile(Tile);

        Tile.AddBackground(mazeTileBaseGround);
    }
Пример #2
0
    public override void PlaceWater(IBaseBackgroundType waterType, TileConnectionScoreInfo pathConnectionScoreInfo)
    {
        GameObject        waterGO           = GameObject.Instantiate(MazeLevelGameplayManager.Instance.GetTileBackgroundPrefab <MazeTileBaseWater>(), Tile.BackgroundsContainer);
        MazeTileBaseWater mazeTileBaseWater = waterGO.GetComponent <MazeTileBaseWater>();

        mazeTileBaseWater.WithType(waterType);
        mazeTileBaseWater.SetTile(Tile);

        Tile.SetMainMaterial(new WaterMainMaterial());
        Tile.AddBackground(mazeTileBaseWater);
        Tile.TryMakeMarkable(false);

        Tile.SetWalkable(false);
    }
Пример #3
0
    public override void PlaceWater(IBaseBackgroundType waterType, TileConnectionScoreInfo pathConnectionScoreInfo)
    {
        if (Tile.GridLocation.X == 0 && Tile.GridLocation.Y == 0)
        {
            Logger.Warning($"Set water HAMASDKQ");
        }
        GameObject             waterGO = GameObject.Instantiate(OverworldGameplayManager.Instance.GetTileBackgroundPrefab <OverworldTileBaseWater>(), Tile.BackgroundsContainer);
        OverworldTileBaseWater overworldTileBaseWater = waterGO.GetComponent <OverworldTileBaseWater>();

        overworldTileBaseWater.WithType(waterType);
        overworldTileBaseWater.SetTile(Tile);

        Tile.AddBackground(overworldTileBaseWater);
        Tile.SetWalkable(false);
    }
Пример #4
0
 public abstract void PlaceWater(IBaseBackgroundType waterType, TileConnectionScoreInfo pathConnectionScoreInfo);
Пример #5
0
 public abstract void PlaceGround(IBaseBackgroundType groundType, TileConnectionScoreInfo pathConnectionScoreInfo);
Пример #6
0
    public static TileConnectionScoreInfo MapGroundConnectionsWithNeighbours(Tile tile, IBaseBackgroundType groundType)
    {
        Logger.Log($"---------Map neighbours of {tile.GridLocation.X},{tile.GridLocation.Y}--------");
        TileModifierConnectionInfo <TileBaseGround> groundRight = new TileModifierConnectionInfo <TileBaseGround>(Direction.Right);
        TileModifierConnectionInfo <TileBaseGround> groundDown  = new TileModifierConnectionInfo <TileBaseGround>(Direction.Down);
        TileModifierConnectionInfo <TileBaseGround> groundLeft  = new TileModifierConnectionInfo <TileBaseGround>(Direction.Left);
        TileModifierConnectionInfo <TileBaseGround> groundUp    = new TileModifierConnectionInfo <TileBaseGround>(Direction.Up);

        if (!EditorManager.InEditor)
        {
            Logger.Error("MapNeighbourGroundOfTile was not called from the editor");
            return(null);
        }

        foreach (KeyValuePair <ObjectDirection, Tile> neighbour in tile.Neighbours)
        {
            if (!neighbour.Value)
            {
                // if there is no tile as neighbour, it must mean it as the level edge. This counts as a connection.
                // But only if the main tile itself is a land tile
                if (tile.TileMainMaterial.GetType() == typeof(GroundMainMaterial))
                {
                    if (neighbour.Key == ObjectDirection.Right)
                    {
                        groundRight.HasConnection = true;
                    }
                    else if (neighbour.Key == ObjectDirection.Down)
                    {
                        groundDown.HasConnection = true;
                    }
                    else if (neighbour.Key == ObjectDirection.Left)
                    {
                        groundLeft.HasConnection = true;
                    }
                    else if (neighbour.Key == ObjectDirection.Up)
                    {
                        groundUp.HasConnection = true;
                    }
                }
                continue;
            }

            Logger.Warning($"Neighbour at {neighbour.Value.GridLocation.X},{neighbour.Value.GridLocation.Y} is {neighbour.Key} of {tile.GridLocation.X},{tile.GridLocation.Y}. Its main material is {neighbour.Value.TileMainMaterial.GetType()}");

            TileBaseGround tileGround = neighbour.Value.TryGetTileGround();
            //if (tileGround == null || tileGround.TileGroundType.GetType() != groundType.GetType())
            //{
            //    continue;
            //}

            if (neighbour.Value.TileMainMaterial?.GetType() != typeof(GroundMainMaterial))
            {
                continue;
            }

            if (neighbour.Key == ObjectDirection.Right)
            {
                groundRight.HasConnection = true;
                groundRight.TileModifier  = tileGround;
            }
            else if (neighbour.Key == ObjectDirection.Down)
            {
                groundDown.HasConnection = true;
                groundDown.TileModifier  = tileGround;
            }
            else if (neighbour.Key == ObjectDirection.Left)
            {
                groundLeft.HasConnection = true;
                groundLeft.TileModifier  = tileGround;
            }
            else if (neighbour.Key == ObjectDirection.Up)
            {
                groundUp.HasConnection = true;
                groundUp.TileModifier  = tileGround;
            }
        }

        return(TileConnectionRegister.CalculateInversedTileConnectionScore(groundRight, groundDown, groundLeft, groundUp));
    }