示例#1
0
    public void DrawWaterFall(int[, ] mapReference, int Sposition)
    {
        float width         = UnityEngine.Random.Range(0, 3);
        int   startPosition = UnityEngine.Random.Range(0, map.GetUpperBound(0));

        for (int x = 0; x <= width; x++)
        {
            for (int y = 0; y <= mapReference.GetUpperBound(1) * 3; y++)
            {
                WaterfallsTileMap.SetTile(new Vector3Int(Sposition + startPosition + x, -y, 0), waterfallTile);
            }
        }
    }
示例#2
0
    private void Awake()
    {
        //Pools Initialization
        piranhaPool = GetComponent <PiranhaPool> ();

        tileMap.ClearAllTiles();
        detailsTileMap.ClearAllTiles();
        WaterfallsTileMap.ClearAllTiles();
        StartMap = new int[15, 4];
        map      = new int[15, 4];
        topMap   = new int[15, 4];

        #region jumpStartMap
        //its suck for now // redo later // maybe an Map editor// or create map from editor;
        StartMap[0, 0]  = 0;
        StartMap[0, 1]  = 1;
        StartMap[0, 2]  = 1;
        StartMap[0, 3]  = 1;
        StartMap[1, 0]  = 0;
        StartMap[1, 1]  = 1;
        StartMap[1, 2]  = 1;
        StartMap[1, 3]  = 1;
        StartMap[2, 0]  = 0;
        StartMap[2, 1]  = 1;
        StartMap[2, 2]  = 1;
        StartMap[2, 3]  = 1;
        StartMap[3, 0]  = 0;
        StartMap[3, 1]  = 1;
        StartMap[3, 2]  = 1;
        StartMap[3, 3]  = 1;
        StartMap[4, 0]  = 1;
        StartMap[4, 1]  = 1;
        StartMap[4, 2]  = 1;
        StartMap[4, 3]  = 1;
        StartMap[5, 0]  = 1;
        StartMap[5, 1]  = 1;
        StartMap[5, 2]  = 1;
        StartMap[5, 3]  = 1;
        StartMap[6, 0]  = 1;
        StartMap[6, 1]  = 1;
        StartMap[6, 2]  = 1;
        StartMap[6, 3]  = 1;
        StartMap[7, 0]  = 1;
        StartMap[7, 1]  = 1;
        StartMap[7, 2]  = 1;
        StartMap[7, 3]  = 1;
        StartMap[8, 0]  = 1;
        StartMap[8, 1]  = 1;
        StartMap[8, 2]  = 1;
        StartMap[8, 3]  = 1;
        StartMap[9, 0]  = 1;
        StartMap[9, 1]  = 1;
        StartMap[9, 2]  = 1;
        StartMap[9, 3]  = 1;
        StartMap[10, 0] = 1;
        StartMap[10, 1] = 1;
        StartMap[10, 2] = 1;
        StartMap[10, 3] = 1;
        StartMap[11, 0] = 1;
        StartMap[11, 1] = 1;
        StartMap[11, 2] = 1;
        StartMap[11, 3] = 1;
        StartMap[12, 0] = 1;
        StartMap[12, 1] = 1;
        StartMap[12, 2] = 1;
        StartMap[12, 3] = 1;
        StartMap[13, 0] = 0;
        StartMap[13, 1] = 0;
        StartMap[13, 2] = 1;
        StartMap[13, 3] = 1;
        StartMap[14, 0] = 0;
        StartMap[14, 1] = 0;
        StartMap[14, 2] = 1;
        StartMap[14, 3] = 1;
        #endregion

        //map = StartMap;
        map    = PerlinNoiseGenerator(bottomMapWidth, bottomMapHeight);
        topMap = PerlinNoiseGenerator(topMapWidth, topMapHeight);

        DrawMap(topMap, toptileMap, tileToDraw, new Vector2Int(0, 0));
        lastTopXposition = topMap.GetUpperBound(0);

        DrawMap(map, tileMap, tileToDraw, new Vector2Int(0, 0));

        DrawWaterFall(map, 0);
        waterFalltime = UnityEngine.Random.Range(waterfallMinTimer, waterfallMaxTimer);
        GenerateDetails(map, new Vector2Int(0, 0));

        int offSetX = UnityEngine.Random.Range(6, 12);
        int offSetY = UnityEngine.Random.Range(-1, 1);

        int[, ] lastMap = new int[map.GetUpperBound(0), map.GetUpperBound(1)];
        lastMap         = map;

        //CompositeCollider2D cc = tileMap.GetComponent<CompositeCollider2D>();

        Vector2 tilesCenter = new Vector2(((float)tileMap.size.x / 2), 0);
        map         = PerlinNoiseGenerator(bottomMapWidth, bottomMapHeight);
        lastCheck.x = DrawIsland(offSetX, offSetY, lastMap, tilesCenter);
        lastCheck.y = 0;
        DrawMap(map, tileMap, tileToDraw, new Vector2Int(Mathf.RoundToInt(tilesCenter.x * 2) +
                                                         offSetX, offSetY));
        GenerateSpikes(map, new Vector2Int(Mathf.RoundToInt(tilesCenter.x * 2) +
                                           offSetX, offSetY), mapType.platform);
        GenerateDetails(map, new Vector2Int(Mathf.RoundToInt(tilesCenter.x * 2) +
                                            offSetX, offSetY));

        //drawTop
    }