Example #1
0
    public void OnClick()
    {
        loader.MapAccess(mapcell);
        if (generator != null)
        {
            generator.Setter(loader, mapcell);
        }

        Setted = true;
        button.SetActive(false);
    }
Example #2
0
    public void StartGeneration(MyVector3 value)
    {
        //Debug.Log("ZXCVBNM<");
        MapRogulikeGenerator MapCell = Instantiate(WorldCellPerhub);

        MapCell.transform.SetParent(gameObject.transform);
        MapCell.transform.position = new Vector3(-(float)StaticData.WorldCellSize / 2, -(float)StaticData.WorldCellSize / 2, 1);// myCanvas.transform.position + new Vector3(DX * StaticData.WorldCellSize, DY * -StaticData.WorldCellSize);
        loader.LoadMap();
        ZeroPosition = new Vector2(value.x, value.y);
        if (StaticData.MapData[(int)value.y][(int)value.x].Accesed)
        {
            //  Debug.Log("Pezda");
            MapCell.Setter(loader, StaticData.MapData[(int)value.y][(int)value.x]);
        }
        AddMapCell(MapCell, new Vector3(0, 0));
    }
Example #3
0
    public void CreateWorldMapCell(Vector2 position)
    {
//        Debug.Log("GeneratingMapCell");
//        Debug.Log(position);
        position += new Vector2(StaticData.WorldCellSize / 2, StaticData.WorldCellSize / 2);
//        Debug.Log(position);
        position /= StaticData.WorldCellSize;
        //      Debug.Log(position);
        position.x = Mathf.FloorToInt(position.x);
        position.y = Mathf.FloorToInt(position.y);
        //    Debug.Log((int)position.x+","+(int)position.y);
        //  Debug.Log((int)-0.1);
        WorldMapCell worldMapCell = StaticData.MapData[(int)position.x + (int)ZeroPosition.x][(int)position.y + (int)ZeroPosition.y];

//        Debug.Log(worldMapCell.PosX+"  "+worldMapCell.PosY);
        for (int i = 0; i < MapCells.Length; i++)
        {
            if (MapCells[i] == null)
            {
                continue;
            }
            if (MapCells[i].ThisCell.PosX == worldMapCell.PosX && MapCells[i].ThisCell.PosY == worldMapCell.PosY)
            {
                return;
            }
        }
        Debug.Log(new Vector3((position.x * StaticData.WorldCellSize) - (float)StaticData.WorldCellSize / 2, (float)(position.y * StaticData.WorldCellSize) - (float)StaticData.WorldCellSize / 2, 1));
        MapRogulikeGenerator MapCell = Instantiate(WorldCellPerhub);

        MapCell.transform.SetParent(gameObject.transform);
        MapCell.transform.position = new Vector3((position.x * StaticData.WorldCellSize) - (float)StaticData.WorldCellSize / 2, (float)(position.y * StaticData.WorldCellSize) - (float)StaticData.WorldCellSize / 2, 1);

        MapCell.Setter(loader, worldMapCell);
        //Debug.Log($"Coordinate:{DY}, DX:{DX}");
        //Debug.Log($"ResultCoordinate:{tmpCell.PosY + DY},:{tmpCell.PosX + DX}");
        //Debug.Log($"MessageThis:{StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX].Message}");
        //Debug.Log($"MessageThis:{StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX].PosY}");
        AddMapCell(MapCell, position);
    }
Example #4
0
    public void CreateWorldMapCell(int DX, int DY, MapRogulikeGenerator myCanvas, Vector3 position)
    {
        //Debug.Log("HOLHELL");

        //if (X < 0 || Y < 0 || X > 100 || Y > 100)
        //{
        //    Debug.Log("ERROR:CreateWorldMapCell Uncorrect (WorldState.css)");
        //    return;
        //}
        WorldMapCell tmpCell    = myCanvas.ThisCell;
        WorldMapCell targetCell = StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX];

        for (int i = 0; i < MapCells.Length; i++)
        {
            if (MapCells[i] == null)
            {
                continue;
            }
            if (MapCells[i].transform.position == myCanvas.transform.position + new Vector3(DX * StaticData.WorldCellSize, DY * -StaticData.WorldCellSize))
            {
                if (!MapCells[i].Setted)
                {
                    return;
                }
                if (!MapCells[i].Setted && targetCell.Accesed)
                {
                    MapCells[i].Setter(loader, targetCell);
                }
                else if (!MapCells[i] && targetCell.Generated && !tmpCell.GetKey(DX, DY).gameObject.active)
                {
                    tmpCell.GetKey(DX, DY).gameObject.SetActive(true);
                    tmpCell.GetKey(DX, DY).Set(MapCells[i], targetCell, loader);
                }
                return;
            }
        }

        //Debug.Log("Creating new cell");
        MapRogulikeGenerator MapCell = Instantiate(WorldCellPerhub);

        MapCell.transform.SetParent(gameObject.transform);
        MapCell.transform.position = myCanvas.transform.position + new Vector3(DX * StaticData.WorldCellSize, DY * -StaticData.WorldCellSize);
        if (StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX].Accesed)
        {
            MapCell.Setter(loader, StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX]);
        }
        else if (StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX].Generated)
        {
            Debug.Log("yy .gg");
            if (tmpCell.GetKey(DX, DY) != null)
            {
                Debug.Log("pesda1 .gg");
                tmpCell.GetKey(DX, DY).gameObject.SetActive(true);
                tmpCell.GetKey(DX, DY).Set(MapCell, StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX], loader);
            }
        }
        else if (!StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX].Generated)
        {
            //Debug.LogWarning("Adding to list " + tmpCell.PosY + DY + "  " + tmpCell.PosX + DX);
            GeneratorQuery.Add(StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX]);
            OnGenerationEnded += (x) =>
            {
                Debug.Log("genered .gg");
                GenerationCallback callback = (GenerationCallback)x;
                if (callback.mapCell == StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX])
                {
                    //MapCell.Setter(loader, StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX]);
                    if (tmpCell.GetKey(DX, DY) != null)
                    {
                        Debug.Log("pesda2 .gg");
                        tmpCell.GetKey(DX, DY).gameObject.SetActive(true);
                        tmpCell.GetKey(DX, DY).Set(MapCell, StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX], loader);
                    }
                }
            };
        }
        //Debug.Log($"Coordinate:{DY}, DX:{DX}");
        //Debug.Log($"ResultCoordinate:{tmpCell.PosY + DY},:{tmpCell.PosX + DX}");
        //Debug.Log($"MessageThis:{StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX].Message}");
        //Debug.Log($"MessageThis:{StaticData.MapData[tmpCell.PosY + DY][tmpCell.PosX + DX].PosY}");
        AddMapCell(MapCell, position);
    }