Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        tileGrid = new Transform[gridWidth, gridHeight];

        for (int i = 0; i != gridHeight; ++i)
        {
            for (int j = 0; j != gridWidth; ++j)
            {
                var pos = new Vector3(
                    -gridWidth * gridSpacing / 2 + gridSpacing / 2 + j * gridSpacing,
                    -gridWidth * gridSpacing / 2 + gridSpacing / 2 + i * gridSpacing,
                    0
                    );
                var obj = Instantiate(tileObject, pos, Quaternion.identity, transform);
                obj.name       = $"Damage Tile [{i}, {j}]";
                tileGrid[i, j] = obj.transform;
                //checkerboard
                //if ((i % 3) != 0 || (j % 3) != 0) {
                obj.SetActive(false);
                //}

                //size
                obj.transform.localScale = new Vector3(16.0f / ((float)gridWidth), 16.0f / ((float)gridHeight), 1.0f);
            }
        }
    }
Пример #2
0
    void Start()
    {
        if (row1 == null || row2 == null || row3 == null || row4 == null)
        {
            Debug.Log("Row objects are missing!");
            return;
        }
        // create a multi-dimensional array that includes all the tubes' transform informations
        rowTransformArray = new Transform[4, 3]
        {
            { row1.gameObject.transform.GetChild(0), row1.gameObject.transform.GetChild(1), row1.gameObject.transform.GetChild(2) },
            { row2.gameObject.transform.GetChild(0), row2.gameObject.transform.GetChild(1), row2.gameObject.transform.GetChild(2) },
            { row3.gameObject.transform.GetChild(0), row3.gameObject.transform.GetChild(1), row3.gameObject.transform.GetChild(2) },
            { row4.gameObject.transform.GetChild(0), row4.gameObject.transform.GetChild(1), row4.gameObject.transform.GetChild(2) },
        };


        //No need
        // row1TubePositionY  = new Vector3 (0,rowTransformArray[0,0].position.y,0);
        // row2TubePositionY  = new Vector3 (0,rowTransformArray[1,0].position.y,0);
        //row3TubePositionY  = new Vector3 (0,rowTransformArray[2,0].position.y,0);
        // row4TubePositionY  = new Vector3 (0,rowTransformArray[3,0].position.y,0);
        //



        restartLoopingDistance = new Vector3(50, 0, 0);
    }
Пример #3
0
    private void Start()
    {
        cubes = new Transform[sideLength, sideLength];
        float offset = (float)sideLength / 2f - .5f;

        // Instantiate array of cubes
        for (int x = 0; x < sideLength; x++)
        {
            for (int z = 0; z < sideLength; z++)
            {
                Transform cube = Instantiate(cubePrefab);
                cube.transform.parent = transform;
                cube.localPosition    = new Vector3(x - offset, 0, z - offset);
                cube.localScale       = Vector3.one * cubeScale;

                // Make a checkerboard layer change to demo the layer segmentation
                if ((x + z) % 2 == 0)
                {
                    cube.gameObject.layer = 3;
                }

                cubes[x, z] = cube;
            }
        }
    }
Пример #4
0
    public void generateMap()
    {
        clearMap();

        map     = new Transform[map_width, map_height];
        usedMap = new bool[map_width, map_height];
        var container = GameObject.Find("CellContainer");

        //普通MAP初始化
        for (int i = 0; i < map.GetLength(0); i++)
        {
            for (int j = 0; j < map.GetLength(1); j++)
            {
                //初始化MAP,生成CELL
                var cell = Instantiate(cellPrefeb, container.transform);
                cell.GetComponent <Cell>().Initilize();
                cell.transform.localPosition = new Vector3(i * cell_delta + origin.x, 0.1f, j * cell_delta + origin.y);

                cell.GetComponent <Cell>().mapPos = new Vector2(i, j);
                map[i, j] = cell.transform;

                //初始化UsedMap为False
                usedMap[i, j] = false;
            }
        }
    }
Пример #5
0
    public void GenerateMap()
    {
        currentMap = maps[mapIndex];
        tileMap    = new Transform[currentMap.mapSize.x, currentMap.mapSize.y];
        if (currentMap.seed == "")
        {
            currentMap.seed = Ultility.GetRandomString(rnd, 64);
        }

        CoordAllTitles();
        shuffledTitleCoords = new Queue <Coord>(Ultility.ShuffleArray(allTitleCoords.ToArray(), currentMap.seed));

        string holderName = "Generated Map";

        if (transform.FindChild(holderName))
        {
            DestroyImmediate(transform.FindChild(holderName).gameObject);
        }

        Transform mapHolder = new GameObject(holderName).transform;

        mapHolder.parent = transform;

        CreateFloor(mapHolder, new System.Random(currentMap.seed.GetHashCode()));
        CreateObstacles(mapHolder);

        CreateBorder(mapHolder);
    }
Пример #6
0
    //从当前已生成的CELL构建出MAP
    public void ReadMapFromEditor()
    {
        if (map == null)
        {
            map = new Transform[map_width, map_height];
        }
        if (usedMap == null)
        {
            usedMap = new bool[map_width, map_height];
        }
        for (int i = 0; i < usedMap.GetLength(0); i++)
        {
            for (int j = 0; j < usedMap.GetLength(1); j++)
            {
                usedMap[i, j] = false;
            }
        }
        var cells = this.GetComponentsInChildren <Cell>();

        foreach (var cell in cells)
        {
            var mappos = cell.mapPos;
            map[(int)mappos.x, (int)mappos.y] = cell.transform;
        }
    }
Пример #7
0
    // Start is called before the first frame update
    void Start()
    {
        previous_object_transform = new Transform[100, 100];
        //if (go != null)
        //{
        //    for (int x = 0; x < 10; x++)
        //    {
        //        double z_angle = Random.Range(-30, 30);
        //        go.transform.rotation = Quaternion.Euler(0, 0, (float)z_angle);
        //        double x_len = 1 / Mathf.Cos((float)z_angle);
        //        double y_pos = (x_len * Mathf.Sin((float)z_angle)) / 0.2;
        //        go.transform.position = new Vector3(x * 10, (float)y_pos, 0);
        //        go.transform.localScale = new Vector3((float)x_len, 1, 1);
        //        //new Quaternion(0, 0, Random.Range(-1, 1), 1);
        //        Instantiate(go, go.transform);
        //    }



        /*int max = 100;
         *
         * for (int x = 0; x < max; x++)
         * {
         *  for (int z = 0; z < max; z++)
         *  {
         *      go.transform.position = new Vector3(x, Random.Range(-1, 1), z);
         *      go.transform.rotation = new Quaternion(Random.Range(-1, 1), Random.Range(-1, 1), Random.Range(-1, 1), 1);
         *      Instantiate(go, go.transform);
         *  }
         * }*/
        //}
    }
Пример #8
0
    void Start()
    {
        //Load prefab "Grass" from "Resources/Prefabs/" folder.
        tilePrefab = Resources.Load<Transform>("Prefabs/GrassTile");

        //If we can't find the prefab then log a warning.
        if (!tilePrefab)
            Debug.LogWarning("Unable to find TilePrefab in your Resources folder.");

        //Initialize our 2D Transform array with the width and height
        map = new Transform[mapWidth, mapHeight];

        //Iterate over each future tile positions for x and y
        for (int y = 0; y < mapHeight; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                //Instantiate tile prefab at the desired position as a Transform object
                Transform tile = Instantiate(tilePrefab, new Vector3(x * tileSize, y * tileSize, 0), Quaternion.identity) as Transform;
                //Set the tiles parent to the GameObject this script is attached to
                tile.parent = transform;
                //Set the 2D map array element to the current tile that we just created.
                map[x, y] = tile;
            }
        }

        BoxCollider box = gameObject.AddComponent<BoxCollider>();
        box.size = new Vector3(mapWidth * tileSize, mapHeight * tileSize, 0.5f);
        box.center = transform.localPosition + new Vector3((mapWidth * tileSize) * 0.5f, (mapHeight * tileSize) * 0.5f, 0);
    }
Пример #9
0
 void Start()
 {
     nodeArr  = new Node[lX, lY];
     blockArr = new int[lX, lY];
     itemsArr = new Transform[lX, lY];
     started  = false;
 }
    private IEnumerator CreateAsteroids()
    {
        asteroids   = new Asteroid[gridSize, gridSize];
        deathTimers = new float[gridSize, gridSize];
        transforms  = new Transform[gridSize, gridSize];
        int asteroidsCreated = 0;

        for (int i = 0; i < gridSize; i++)
        {
            for (int j = 0; j < gridSize; j++)
            {
                asteroids[i, j] = Instantiate(asteroidPrefab);
                asteroids[i, j].gameObject.SetActive(false);
                deathTimers[i, j] = float.MinValue;
                transforms[i, j]  = asteroids[i, j].transform;
                asteroidsCreated++;
                if (asteroidsCreated % spawnPerFrame == 0)
                {
                    yield return(null);
                }
            }
        }
        gameManager.StartGame();
        areAllCreated = true;
        RestartAsteroids();
    }
Пример #11
0
 void Update()
 {
     // Choose the next destination point when the agent gets
     // close to the current one.
     cash = Random.Range (-10, 25);
     if (agent.remainingDistance < 0.05f)
     {
         timer--;
         if(timer <= 0)
         {
             GotoNextPoint();
             Money.profit += cash;
             timer = Random.Range (80,180);
         }
     }
     if(Router.onion [ID] == true && !started)
     {
         points = Router.Route;
         for(int i = 0; i < points.GetLength(1); i++)
         {
             Debug.Log(points[ID,i]);
             if(points[ID,i] != null)
             {
                 index++;
             }
             else
             {
                 Debug.Log (index);
             }
         }
         GotoNextPoint();
         started = true;
     }
 }
Пример #12
0
    void Start()
    {
        rigidBody = this.GetComponent<Rigidbody>();
        JetLocations = new Transform[2,2];
        DesiredDist = new float[2,2];
        DesiredDist[0,0] = DesiredDist[0,1] = DesiredDist[1,0] = DesiredDist[1,1] = DefaultDesiredDist;		//[0,0] = front left, [0,1] = front right, [1,0] = back left, [1,1] = back right

        var transforms = this.GetComponentsInChildren<Transform>();

        foreach (var t in transforms){
            switch(t.name){
            case "JetFrontLeft":
                JetLocations[0,0] = t;
                break;
            case "JetFrontRight":
                JetLocations[0,1] = t;
                break;
            case "JetBackLeft":
                JetLocations[1,0] = t;
                break;
            case "JetBackRight":
                JetLocations[1,1] = t;
                break;
            case "Front":
                Front = t;
                break;
            case "Back":
                Back = t;
                break;
            }
        }
    }
Пример #13
0
 private void SetActiveFalse(Transform[,] container)
 {
     foreach (var item in container)
     {
         item.gameObject.SetActive(false);
     }
 }
Пример #14
0
    // Creates the grid by instantiating provided cell prefabs.
    void CreateGrid()
    {
        Grid = new Transform[(int)Size.x,(int)Size.z];
        MiniMap = new Transform[(int)Size.x,(int)Size.z];

        // Places the cells and names them according to their coordinates in the grid.
        for (int x = 0; x < Size.x; x++) {
            for (int z = 0; z < Size.z; z++) {
                Transform newCell;
                newCell = (Transform)Instantiate(CellPrefab, new Vector3(((float)x)*scaling, 0, ((float)z)*scaling), Quaternion.identity);
                newCell.localScale = new Vector3(scaling, newCell.localScale.y, scaling);
                newCell.name = string.Format("({0},0,{1})", x, z);
                newCell.parent = transform;
                newCell.GetComponent<CellScript>().Position = new Vector3(((float)x)*scaling, 0, ((float)z)*scaling);
                newCell.GetComponentInChildren<TextMesh>().renderer.enabled = false;
                Grid[x,z] = newCell;

                //Create physical minimap
                Transform MMCell;
                MMCell = (Transform)Instantiate(CellPrefab, new Vector3(((float)x)*scaling, -40, ((float)z)*scaling), Quaternion.identity);
                MMCell.localScale = new Vector3(scaling, MMCell.localScale.y, scaling);
                MMCell.name = string.Format("mm({0},0,{1})", x, z);
                MMCell.parent = MMContainer.transform;
                //MMCell.GetComponent<CellScript>().Position = new Vector3(x, -40, z);
                MMCell.GetComponentInChildren<TextMesh>().renderer.enabled = false;
                MiniMap[x,z] = MMCell;
            }
        }
        // Centers the camera on the maze.
        // Feel free to adjust this as needed.
        Camera.main.transform.position = Grid[(int)(Size.x / 2f),(int)(Size.z / 2f)].position - Vector3.up * 20f;
        Camera.main.orthographicSize = Mathf.Max(Size.x * scaling * 0.6f, Size.z * scaling * 0.4f);

        //adds borders around the Grid
        Transform border1, border2, border3, border4;
        border1 = (Transform)Instantiate (CellPrefab, new Vector3 (((Size.x / 2) * scaling) - 1.5f, 0, -1 * (scaling / 2) - 0.5f), Quaternion.identity); //Vector3 is position
        border1.localScale = new Vector3 (scaling * Size.x, 5, 1);
        border1.GetComponentInChildren<TextMesh>().renderer.enabled = false;
        border1.renderer.material = WallMat;
        border1.transform.tag = "Wall";
        border1.parent = transform;
        border2 = (Transform)Instantiate (CellPrefab, new Vector3(Size.x * scaling - 1f, 0, ((Size.z / 2) * scaling) - 1.5f), Quaternion.identity);
        border2.localScale = new Vector3 (1, 5, scaling * Size.z + 2f);
        border2.GetComponentInChildren<TextMesh>().renderer.enabled = false;
        border2.renderer.material = WallMat;
        border2.transform.tag = "Wall";
        border2.parent = transform;
        border3 = (Transform)Instantiate (CellPrefab, new Vector3(((Size.x / 2) * scaling) - 1.5f, 0, Size.z * scaling - 1f), Quaternion.identity);
        border3.localScale = new Vector3 (scaling * Size.x, 5, 1);
        border3.GetComponentInChildren<TextMesh>().renderer.enabled = false;
        border3.renderer.material = WallMat;
        border3.transform.tag = "Wall";
        border3.parent = transform;
        border4 = (Transform)Instantiate(CellPrefab, new Vector3(-2, 0, ((Size.z / 2) * scaling) - 1.5f), Quaternion.identity);
        border4.localScale = new Vector3 (1, 5, scaling * Size.z + 2f);
        border4.GetComponentInChildren<TextMesh>().renderer.enabled = false;
        border4.renderer.material = WallMat;
        border4.transform.tag = "Wall";
        border4.parent = transform;
    }
Пример #15
0
    // Use this for initialization
    void Start()
    {
        _color    = new Color[64];    //zet lengte array
        _material = new Material[64]; // zet lengte array
        for (int i = 0; i < 64; i++)
        {
            _color[i]    = _gradient.Evaluate(i * (1f / 64)); //handige manier om van een gradient veel kleuren te maken
            _material[i] = new Material(_baseMaterial);       //maak 64 materials aan voor iedere kleur of audioband
            _material[i].EnableKeyword("_EMISSION");          //zet emission optie aan in de standard surface shader
        }

        _prefabTransform = new Transform[_gridSize.x, _gridSize.y]; //zet lengte array
        for (int x = 0; x < _gridSize.x; x++)
        {
            for (int z = 0; z < _gridSize.y; z++)
            {
                GameObject prefabInstance = (GameObject)Instantiate(_prefab);                                                 //instantiate game object
                prefabInstance.transform.parent        = this.transform;                                                      // maak het nieuwe object een child van het object waar dit script op zit
                prefabInstance.transform.localPosition = new Vector3(x * _spaceInBetween, 0, z * _spaceInBetween);            //zet positie in de grid
                prefabInstance.transform.GetChild(0).GetComponent <MeshRenderer>().material = _material[Random.Range(0, 64)]; //verdeel een random kleur
                //gebruik onderstaande regel om rijen van dezelfde kleur/band te maken
                //probeer zelf om een interessante verdeling van kleuren te maken
                //prefabInstance.transform.GetChild(0).GetComponent<MeshRenderer>().material = _material[x];
                _prefabTransform[x, z] = prefabInstance.transform;
            }
        }
    }
Пример #16
0
 // Start is called before the first frame update
 void Start()
 {
     map = new Transform[Width, Height];
     map = Generator.Instance.GenerateMap(map);
     while (isStart)
     {
         if (!isMoving)
         {
             Match();
         }
         bool firstTime = true;
         for (int i = 0; i < map.GetLength(0); i++)
         {
             for (int j = 0; j < map.GetLength(1); j++)
             {
                 if (Move(map[i, j], i, j, 10000000000f))
                 {
                     if (firstTime)
                     {
                         isMoving  = false;
                         firstTime = false;
                     }
                 }
                 else
                 {
                     isMoving = true;
                 }
             }
         }
     }
 }
Пример #17
0
    // Use this for initialization
    void Start()
    {
        // Placeholder map

        int xSize     = 100;
        int ySize     = 100;
        int roomCount = 100;
        int maxSize   = 20;

        Transform[,] emptyMap = MakeEmptyMap(xSize, ySize);
        MapData mapData = RoomListGenerator(xSize, ySize, maxSize, roomCount, emptyMap);

        map = mapGenerator(mapData.roomList, mapData.map);
        Instantiate(floor, new Vector3(0, 0, 0), Quaternion.identity);

        for (int i = 0; i < xSize; i++)
        {
            for (int j = 0; j < ySize; j++)
            {
                if (map[i, j] == wall)
                {
                    Instantiate(wall, new Vector3(i, 1, j), Quaternion.identity);
                }
            }
        }

        Instantiate(player, new Vector3(mapData.roomList[0].center.x, 1, mapData.roomList[0].center.y), Quaternion.identity);
        for (int i = 1; i < mapData.roomList.Count - 1; i++)
        {
            Instantiate(monsterGeneric, new Vector3(mapData.roomList[i].center.x, 1, mapData.roomList[i].center.y), Quaternion.identity);
        }
    }
Пример #18
0
    public void Restart()
    {
        GameContext.GameOver = false;
        view.HideGameOverUI();

        Transform[,] modelMap = model.map;
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 18; j++)
            {
                Transform shape = modelMap[i, j];
                if (shape)
                {
                    Destroy(shape.gameObject);
                    modelMap[i, j] = null;
                }
            }
        }

        if (gameManager.currentShape)
        {
            Destroy(gameManager.currentShape.gameObject);
            gameManager.currentShape = null;
        }


        fsm.PerformTransition(Transition.StartButtonClicked);
    }
Пример #19
0
 public void Restart()
 {
     NowScore = 0;
     LoadData();
     Ctrl.Instance.MainGameManager.CleanChild();
     map = new Transform[max_Columns, max_Rows];
 }
Пример #20
0
    void Start()
    {
        grid = new Transform[mapWidth, mapHeight];

        BuildGrid();
        SetNeighbors();
    }
Пример #21
0
    private void Awake()
    {
        graph      = new Transform[mapSize, mapSize];
        cellNumber = new int[mapSize, mapSize];
        for (int i = 0; i < mapSize; i++)
        {
            for (int j = 0; j < mapSize; j++)
            {
                GameObject instance = Instantiate(quad);
                instance.transform.position = new Vector2(j, i);
                GameObject groundInst = Instantiate(ground);
                groundInst.transform.position = new Vector2(j, i);
                graph[i, j] = instance.transform;
                graph[i, j].gameObject.SetActive(false);
                cellNumber[i, j] = cell++;
            }
        }
        for (int i = 0; i < randomNumSize; i++)
        {
            randomNum1 = Random.Range(0, mapSize);
            randomNum2 = Random.Range(0, mapSize);
            while (randomNum1 == tempNum1)
            {
                randomNum1 = Random.Range(0, mapSize);
            }
            while (randomNum2 == tempNum2)
            {
                randomNum2 = Random.Range(0, mapSize);
            }
            tempNum1 = randomNum1;
            tempNum2 = randomNum2;

            graph[randomNum1, randomNum2].gameObject.SetActive(true);
        }
    }
Пример #22
0
    void fillStrategies()
    {
        foreach (IGunStrategy strat in GetComponentsInChildren <IGunStrategy>())
        {
            strategies.Add(strat);
            strat.getGameObject().SetActive(false);
        }

        Helper.FindComponentsInChildrenWithTag <Transform>(gameObject, "barrelEnd");
        List <Transform> transf = new List <Transform>();

        //There we go: Add every component from generic static method into a list of transforms. This List contains the barrelEnds with which we wanna shoot.
        foreach (Component c in Helper.masterList)
        {
            if (c.GetType() == typeof(Transform))
            {
                transf.Add(c.transform);
            }
        }

        guns = new Transform[strategies.Count, 2];
        int count = 0;

        for (int i = 0; i < strategies.Count; i++)
        {
            for (int j = 0; j < AMOUNT_OF_GUNS; j++)
            {
                guns[i, j] = Helper.masterList[count].transform;
                count++;
            }
        }
        strategies[0].getGameObject().SetActive(true);
    }
Пример #23
0
    void Start()
    {
        //Load prefab "Grass" from "Resources/Prefabs/" folder.
        tilePrefab = Resources.Load <Transform>("Prefabs/GrassTile");

        //If we can't find the prefab then log a warning.
        if (!tilePrefab)
        {
            Debug.LogWarning("Unable to find TilePrefab in your Resources folder.");
        }

        //Initialize our 2D Transform array with the width and height
        map = new Transform[mapWidth, mapHeight];

        //Iterate over each future tile positions for x and y
        for (int y = 0; y < mapHeight; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                //Instantiate tile prefab at the desired position as a Transform object
                Transform tile = Instantiate(tilePrefab, new Vector3(x * tileSize, y * tileSize, 0), Quaternion.identity) as Transform;
                //Set the tiles parent to the GameObject this script is attached to
                tile.parent = transform;
                //Set the 2D map array element to the current tile that we just created.
                map[x, y] = tile;
            }
        }

        BoxCollider box = gameObject.AddComponent <BoxCollider>();

        box.size   = new Vector3(mapWidth * tileSize, mapHeight * tileSize, 0.5f);
        box.center = transform.localPosition + new Vector3((mapWidth * tileSize) * 0.5f, (mapHeight * tileSize) * 0.5f, 0);
    }
Пример #24
0
 void Awake()
 {
     digits        = new bool[11][];
     digits[0]     = new bool[] { true, true, true, false, true, true, true };
     digits[1]     = new bool[] { false, false, true, false, false, false, true };
     digits[2]     = new bool[] { false, true, true, true, true, true, false };
     digits[3]     = new bool[] { false, true, true, true, false, true, true };
     digits[4]     = new bool[] { true, false, true, true, false, false, true };
     digits[5]     = new bool[] { true, true, false, true, false, true, true };
     digits[6]     = new bool[] { true, true, false, true, true, true, true };
     digits[7]     = new bool[] { false, true, true, false, false, false, true };
     digits[8]     = new bool[] { true, true, true, true, true, true, true };
     digits[9]     = new bool[] { true, true, true, true, false, true, true };
     digits[10]    = new bool[] { false, false, false, true, false, false, false };
     digits_Lights = new Transform[digitsNumber, 7];
     Transform[] all_transforms = GetComponentsInChildren <Transform>();
     foreach (Transform current in all_transforms)
     {
         if (current.name == "Panel")
         {
             panel = current;
         }
         else
         {
             string[] current_tab = current.name.Split("_".ToCharArray(), 2);
             if (current_tab.Length == 2)
             {
                 digits_Lights[int.Parse(current_tab[0]) - 1, int.Parse(current_tab[1]) - 1] = current;
             }
         }
     }
 }
Пример #25
0
    //This generates our initial map for us and starts placing the terrain based on the tileset.
    //It also sets up our Pathfinding map "nodeMap".
    void LayoutMap()
    {
        boardHolder = new GameObject("Board").transform;
        nodeMap     = new Transform[mapsizeX, mapsizeY];

        for (int x = -1; x < mapsizeX + 1; x++)
        {
            for (int y = -1; y < mapsizeY + 1; y++)
            {
                GameObject toInstantiate = floorTiles[Random.Range(0, floorTiles.Length)];

                if (x == -1 || x == mapsizeX || y == -1 || y == mapsizeY)
                {
                    toInstantiate = boundaryTiles [Random.Range(0, boundaryTiles.Length)];
                    GameObject instance = Instantiate(toInstantiate, new Vector3(x, y, 1f), Quaternion.identity) as GameObject;
                    instance.transform.SetParent(boardHolder);
                }
                else
                {
                    GameObject instance = Instantiate(toInstantiate, new Vector3(x, y, 1f), Quaternion.identity) as GameObject;

                    nodeMap [x, y] = instance.transform;
                    instance.transform.SetParent(boardHolder);
                    instance.transform.position = new Vector2(x, y);
                }
            }
        }
    }
Пример #26
0
	public void CreateGrid()
	{
		int x = (int)GridSize.x;
		int y = (int)GridSize.y;
		int maxXZ = Mathf.Max(x, y);
		Camera.main.transform.position = new Vector3(maxXZ / 2f, maxXZ * Buffer, maxXZ / 8f);
		GridArray = new Transform[x, y];
		Transform newHex;
		
		for (int i = 0; i < x; i++)
		{
			for (int j = 0; j < y; j++)
			{
				if (j % 2 == 0)
					newHex = (Transform)Network.Instantiate(Tile, new Vector3(i + Offset, 0, j) * Buffer, Quaternion.Euler(90, 90, 180), 0);
				else
					newHex = (Transform)Network.Instantiate(Tile, new Vector3(i, 0, j) * Buffer, Quaternion.Euler(90, 90, 180), 0);
				
				newHex.name = string.Format("({0},{1})", i, j);
				newHex.parent = transform;
				newHex.GetComponent<Tile>().Position = new Vector2(i, j);
				GridArray[i, j] = newHex;
				//nView.RPC("addList",RPCMode.AllBuffered, new object[] {nView.viewID, newHex.GetComponent<NetworkView>().viewID, i, j});
			}
		}
		
	}
Пример #27
0
    MapData RoomListGenerator(int xSize, int ySize, int maxSize, int roomCount, Transform[,] emptyMap)
    {
        List <Room> roomList = new List <Room>();

        for (int i = 0; i < roomCount; i++)
        {
            Room room = new Room();

            room.xSize   = (int)Mathf.Floor(Random.Range(2, maxSize));
            room.ySize   = (int)Mathf.Floor(Random.Range(2, maxSize));
            room.xCorner = (int)Mathf.Floor(Random.Range(2, xSize - maxSize));
            room.yCorner = (int)Mathf.Floor(Random.Range(2, ySize - maxSize));

            Transform[,] emptyMapCopy = new Transform[emptyMap.GetLength(0), emptyMap.GetLength(1)];
            System.Array.Copy(emptyMap, emptyMapCopy, emptyMap.Length);
            emptyMap = room.MakeRoom(emptyMap);

            if (CompareMaps(emptyMap, emptyMapCopy))
            {
                roomList.Add(room);
            }
        }

        MapData mapData = new MapData();

        mapData.roomList = roomList;
        mapData.map      = emptyMap;

        return(mapData);
    }
Пример #28
0
 public void Initialize(Transform[,] _grid)
 {
     grid         = _grid;
     width        = grid.GetLength(0);
     height       = grid.GetLength(1);
     fullRowCount = 0;
 }
Пример #29
0
    // Use this for initialization
    void Start()
    {
        Grid = new Transform[width, width];
        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < width; y++)
            {
                Transform item = Instantiate(bricks);

                SpriteRenderer sprite      = item.GetComponent <SpriteRenderer>();
                float          sizeX       = sprite.bounds.size.x;
                float          xCoordinate = bricks.localPosition.x + (sizeX * (x));

                float size = sprite.bounds.size.y;
                sprite.sprite = colors[Random.Range(0, colors.Length)];

                item.localPosition = new Vector3(xCoordinate, -(bricks.localPosition.y + (size * (y))), 1);
                moving movingClass = item.GetComponent <moving>();
                movingClass.type = sprite.sprite.name;
                movingClass.x    = x;
                movingClass.y    = y;
                item.name        = sprite.sprite.name + "-" + x + "-" + y;
                Grid [x, y]      = item;
            }
        }
        gridmanager.setGrid(Grid);
    }
Пример #30
0
 public void SpawnNextTetromino() // спавнит фигуры
 {
     if (!gameStarted)            // если игра только началась, создает фигуру для управления и показывает следующую фигуру
     {
         grid             = new Transform[gridWidth, gridHeight];
         currentScore     = 0;
         numLineCleared   = 0;
         gameStarted      = true;
         previewTetromino = Instantiate(GetRandomTetromino(), previewPoint, Quaternion.identity, locationspawn);
         nextTetromino    = Instantiate(GetRandomTetromino(), spawnPoint, Quaternion.identity, locationspawn);
         previewTetromino.GetComponent <Tetromino>().enabled      = false;
         previewTetromino.GetComponent <GhostTetromino>().enabled = false;
         nextTetromino.GetComponent <GhostTetromino>().enabled    = false;
         GlobalScore.Instance.Global(this, nextTetromino);
         nextTetromino.Initialize(this);
         SpawnGhostTetromino();
     }
     else//если игра уже идет, следующую фигуру перемещает под управление игрока и показывает следующую фигуру
     {
         previewTetromino.transform.position = spawnPoint;
         nextTetromino = previewTetromino;
         nextTetromino.GetComponent <Tetromino>().enabled = true;
         previewTetromino = Instantiate(GetRandomTetromino(), previewPoint, Quaternion.identity, locationspawn);
         previewTetromino.GetComponent <Tetromino>().enabled      = false;
         previewTetromino.GetComponent <GhostTetromino>().enabled = false;
         nextTetromino.GetComponent <GhostTetromino>().enabled    = false;
         GlobalScore.Instance.Global(this, nextTetromino);
         nextTetromino.Initialize(this);
         SpawnGhostTetromino();
     }
 }
Пример #31
0
    public void Setup(GridArray <TileArrayObject> grid)
    {
        this.grid       = grid;
        visualNodeList  = new List <Transform>();
        visualNodeArray = new Transform[grid.GetHeight(), grid.GetWidth()];

        // Initialize
        for (int row = 0; row < grid.GetHeight(); row++)
        {
            for (int col = 0; col < grid.GetWidth(); col++)
            {
                Vector3 gridPosition = grid.GetWorldPosition(row, col) +
                                       0.5f * new Vector3(grid.GetCellSize(), grid.GetCellSize());
                Transform visualNode = CreateVisualNode(gridPosition);
                visualNodeArray[row, col] = visualNode;
                visualNodeList.Add(visualNode);
            }
        }

        UpdateVisual(grid);

        grid.OnGridObjectChanged += (object sender, GridArray <TileArrayObject> .OnGridObjectChangedEventArgs eventArgs) => {
            updateVisual = true;
        };
    }
Пример #32
0
    public void GenerateMap()
    {
        LoadMap();

        //If current map is created, destroy
        string mapHolder = "Generated Map";

        if (transform.FindChild(mapHolder))
        {
            DestroyImmediate(transform.FindChild(mapHolder).gameObject);
        }

        //Generate new map
        Transform newMap = new GameObject(mapHolder).transform;

        newMap.parent = transform;

        m_tileMap = new Transform[m_currentMap.m_mapSize.m_x, m_currentMap.m_mapSize.m_y];
        AssignAllTiles();
        GenerateNavMeshFloor(newMap);
        GenerateNavMeshWalls(newMap);
        GenerateTiles(newMap);
        m_obstacleMap            = new bool[m_currentMap.m_mapSize.m_x, m_currentMap.m_mapSize.m_y];
        m_mapCentre              = new Coord(m_currentMap.m_mapSize.m_x / 2, m_currentMap.m_mapSize.m_y / 2);
        m_allOpenTileCoords      = new List <Coord>(m_allTileCoords);
        m_shuffledObstacleCoords = new Queue <Coord>(Utility.ShuffleArray(m_allTileCoords.ToArray(), m_currentMap.m_seed));
        m_shuffledOpenTileCoords = new Queue <Coord>(Utility.ShuffleArray(m_allOpenTileCoords.ToArray(), m_currentMap.m_seed));
        m_rand = new System.Random(m_currentMap.m_seed);
        GenerateObstacles(newMap);
    }
Пример #33
0
    public FloydWarshall()
    {
        destination = GameObject.FindGameObjectWithTag("Destination").GetComponent <Transform>();
        npc         = GameObject.FindGameObjectsWithTag("NPC");

        foreach (GameObject n in npc)
        {
            nodeList.Add(n.transform);
        }

        node    = nodeList.ToArray();
        minDist = new float[node.Length, npc.Length];
        dest    = new Transform[node.Length, npc.Length];

        for (int k = 0; k < node.Length; k++)
        {
            for (int i = 0; i < npc.Length; i++)
            {
                minDist[i, k] = Vector3.Distance(node[i].position, destination.position);
                float dist1 = minDist[i, k];
                float dist2 = Vector3.Distance(npc[i].transform.position, node[k].position) + Vector3.Distance(node[k].position, destination.position);
                minDist[i, k] = Mathf.Min(dist1, dist2);
                dest[i, k]    = (minDist[i, k] == dist1) ? destination : node[k].transform;
                destination   = dest[i, k];
                destList.Add(dest[i, k]);
                _dest = destList.ToArray();
            }
        }
        dest1 = _dest;
    }
Пример #34
0
    void Start()
    {
        cube_grid_ = new Transform[gridHeight + 2, gridWidth + 2];
        for (int r = 0; r < gridHeight + 2; ++r)
        {
            for (int c = 0; c < gridWidth + 2; ++c)
            {
                cube_grid_[r, c] = transform;
            }
        }

        float center_x = gridWidth * cellWidth / 2.0f;
        float center_y = gridHeight * cellHeight / 2.0f;

        // Setup the cube grid.
        for (int r = 1; r <= gridHeight; ++r)
        {
            for (int c = 1; c <= gridWidth; ++c)
            {
                Vector3 location = new Vector3(c * cellWidth - center_x, 0, r * cellHeight - center_y);
                cube_grid_[r, c] = Instantiate(model, transform.position + location,
                                               transform.rotation * model.transform.rotation) as Transform;
                cube_grid_[r, c].parent = transform;
            }
        }
    }
Пример #35
0
    private void InitGrids()
    {
        // cache dimentions
        this.width = floorCellWidth * cellCols;
        this.depth = floorCellDepth * cellRows;

        // Init cells grid
        gridCells = new Cell[floorCellWidth, floorCellDepth];

        // Init basic grid
        gridBase = new int[width, depth];

        // Biome identities grid
        gridBiomes = new int[width, depth];

        // Massives to be added to the map
        gridMassives = new int[width, depth];
        // Angles for each massive - only the origin is marked; teh value is the angle
        gridAngles = new int[width, depth];

        gridLock = new bool[width, depth];  // locks positions for use  to prevent overlapping of massives -- true = used

        // used for creating borders
        gridBorders = new int[width, depth];

        // Init final grid
        finalGrid = new int[width, depth];

        // Init object grid
        gridElements = new Transform[width, depth];
    }
Пример #36
0
    private int m_score = 0;                // 점수 (라인을 채운 횟수)

    private void Start()
    {
        grid = new Transform[width, height];

        blocks = new Queue <SpriteRenderer>();

        holdPoint.gameObject.SetActive(false);

        foreach (Tetromino tetromino in tetrominos)
        {
            tetromino.spawner = this;
            tetromino.gameObject.SetActive(false);
        }

        // 오브젝트 풀링 생성
        for (int i = 0; i < 200; i++)
        {
            // 블럭 생성
            SpriteRenderer renderer = GameObject.Instantiate(blockOriginal, transform).GetComponent <SpriteRenderer>();

            renderer.gameObject.SetActive(false);

            blocks.Enqueue(renderer);
        }

        SpawnBlock();
    }
Пример #37
0
	// Use this for initialization
	void Start () 
	{
		startingPoint = this.transform.position;
		grid = new Transform[rows,columns];
		size = space.GetComponent<Renderer>().bounds.size;
		makeGrid();
		sendGrid();
	}
Пример #38
0
 // Use this for initialization
 void Start()
 {
     gameBoard	= new CubeSpaceScript[8,8];
     boardPieces = new Transform[8,8];
     player1 = new Player(1);
     player2 = new Player(2);
     board = GameObject.FindGameObjectWithTag ("Board").transform;
     turn = 1;
 }
Пример #39
0
 public void ClearGrid()
 {
     foreach (var i in Grid){
         if (i!=null){
             DestroyImmediate(i.gameObject);
         }
     }
     s_x=s_y=0;
     Grid=new Transform[grid_width,grid_height];
 }
Пример #40
0
    void Start()
    {
        Route = new Transform[1000, 20];
        onion = new bool[1000];
        BusAnimationBoolGetter = GameObject.Find("RotaManager");
        BusButton = GameObject.Find("SetBusButton");
        anim = BusButton.GetComponent <Animator> ();
        //SetTextFinal = false;

        //	Person = GameObject.Find ("Timer").GetComponent<Time> ().person;
    }
Пример #41
0
	// Use this for initialization
	void Awake () {
		instance = this;
		locations = new Transform[rows, cols];
		yackers = new Yacker[rows, cols];
		for(int x = 0; x < rows; x++)
		{
			for(int y = 0; y < cols; y++)
			{
				locations[x,y] = transform.FindChild( x + " - " + y);
			}
		}
	}
Пример #42
0
	// Use this for initialization
	void Awake () {
		instance = this;
		locations = new Transform[rows, cols];
		yackers = new Yacker[rows, cols];
		for(int x = 1; x <= rows; x++)
		{
			for(int y = 1; y <= cols; y++)
			{
				locations[x - 1,y - 1] = transform.FindChild( x + " - " + y);
			}
		}
	}
Пример #43
0
	void Start()
	{
		int rows = transform.childCount;
		int cols = transform.GetChild (0).childCount;
		RawBoard = new Transform[rows, cols];
		UpdateRawBoardValues ();

		if( TypeOfAnalysisToUse != AnalysisType.HardCodedValues)
			AnalyzeTerrain ();

		PlayerInfluence = new PlayerInfluenceMap(rows, cols, PlayerCenterInfluence, PlayerInfluenceRadius, HighGroundInfluenceBonus, RawBoard);
		players = GetComponent<PlayerManager> ();
	}
Пример #44
0
 void GenerateGrid()
 {
     if (grid != null) {
         for (int j = 0; j < grid.GetLength(0); j++) {
             for (int i = 0; i < grid.GetLength(1); i++) {
                 if (grid[j,i] != null) {
                     Destroy(grid[j,i].gameObject);
                 }
             }
         }
     }
     grid = new Transform[dimZ, dimX];
 }
Пример #45
0
 void Start()
 {
     agent = GetComponent<NavMeshAgent>();
     RouteManager = GameObject.Find ("GameManager");
     // Disabling auto-braking allows for continuous movement
     // between points (ie, the agent doesn't slow down as it
     // approaches a destination point).
     points = new Transform[1000,20];
     Router = RouteManager.GetComponent<RouteManager> ();
     ID = Router.routeID;
     agent.speed = 5;
     money = GameObject.Find ("fad");
     GotoNextPoint();
 }
Пример #46
0
	void Update()
	{
		board = GameObject.Find ("Level").GetComponent<TerrainManager> ().RawBoard;
		players = GameObject.Find ("Players").transform;

		if (HP <= 0)
			Destroy(gameObject);

		if (ShotCooldown > 0)
			ShotCooldown -=Time.deltaTime;

		Fire ();

		UpdatePosition ();
	}
Пример #47
0
 void SetUpBoard()
 {
     board = new Transform[width, length];
     for (int x = 0; x < width; x++) {
         for (int y = 0; y < length; y++) {
             Transform newSquare;
             newSquare = (Transform)Instantiate(squarePrefab, new Vector3 (x + xPos, y + yPos, heightPos), Quaternion.identity);
             newSquare.parent = transform;	//puts grid as parent of gameSquare
             newSquare.name = sayName(newSquare);
             newSquare.GetComponent<TerrainTileScript>().base_energy = 10;
             newSquare.GetComponent<TerrainTileScript>().base_regen_rate = 1;
             board[x, y] = newSquare;		//note that this array is x by z so layout (column, row) instead of (row, column)
         }
     }
 }
Пример #48
0
 void createGrid()
 {
     Grid = new Transform[(int)Size.x,(int)Size.y];
     for(int x = 0; x < Size.x ; x++){
         for(int y = 0; y <Size.y ; y++){
             Transform newCell;
             newCell = (Transform)Instantiate(CellPrefab, new Vector3(x,y,0), Quaternion.identity);
             newCell.name = "{"+x+","+y+"}";
             newCell.parent = transform;
             newCell.GetComponent<cellscript>().position = new Vector3(x,y,0);
             //newCell.GetComponent<cellscript>().ball = ball;
             Grid[x,y] = newCell;
         }
     }
 }
	public PlayerInfluenceMap(int length, int width, float pCenterInfluence, int pInfluenceRadius, float hGroundBonus, Transform[,] brd)
	{
		PlayerCenterInfluence = pCenterInfluence;
		PlayerInfluenceRadius = pInfluenceRadius;

		HighGroundBonus = hGroundBonus;

		board = brd;

		InfluenceMap = new float[length,width];
		rawBoardValues = new float[length, width];

		InitializeRawBoard ();
		ResetPlayerInfluenceMap ();
	}
Пример #50
0
    void Start()
    {
        map = new Transform[mapWidth, mapHeight];

        for (int y = 0; y < mapHeight; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                Transform tile = Instantiate(tilePrefab, new Vector3(x * tileSize, y * tileSize, 0), Quaternion.identity) as Transform;

                tile.parent = transform;

                map[x, y] = tile;
            }
        }
    }
Пример #51
0
    // Creates the grid by instantiating provided cell prefabs.
    void CreateGrid()
    {
        Grid = new Transform[(int)Size.x,(int)Size.z];

        // Places the cells and names them according to their coordinates in the grid.
        for (int x = 0; x < Size.x; x++) {
            for (int z = 0; z < Size.z; z++) {
                Transform newCell;
                newCell = (Transform)Instantiate(CellPrefab, new Vector3(4*x, 0, 4*z), Quaternion.identity);
                newCell.name = string.Format("({0},0,{1})", 4*x, 4*z);
                newCell.parent = transform;
                newCell.GetComponent<CellScript>().Position = new Vector3(4*x, 0, 4*z);
                Grid[x,z] = newCell;
            }
        }
    }
Пример #52
0
	// initialization
	void Start () {
		clickType = TileType.NULL;
		click = false;

		map = new Transform[width, height];

		// create array for tile objects
		for(int i = 0; i < width; ++i)
		{
			for(int j = 0; j < height; ++j)
			{
				// use grass prefab for tile model
				map[i, j] = Instantiate(prefs[3], new Vector3(i, 0, j), Quaternion.identity) as Transform;
				map[i, j].gameObject.AddComponent<Tile>();
				map[i, j].GetComponent<Tile>().Init(this, TileType.grass);
			}
		}
	}
Пример #53
0
	private void AnalyzeTerrain()
	{
		if (TypeOfAnalysisToUse == AnalysisType.Height)
			analyzer = gameObject.AddComponent<HeightAnalyzer>();
		else if (TypeOfAnalysisToUse == AnalysisType.ViewDistance || TypeOfAnalysisToUse == AnalysisType.ShootingDistance)
		{
			analyzer = gameObject.AddComponent<ViewDistanceAnalyzer>();
			if(TypeOfAnalysisToUse == AnalysisType.ViewDistance)
				GetComponent<ViewDistanceAnalyzer>().UnitViewRadius = 99999;
			else // shooting distance
				GetComponent<ViewDistanceAnalyzer>().UnitViewRadius = PlayerInfluenceRadius;
		}

		analyzer.level = RawBoard;
		analyzer.maxTerrainHeat = maxTerrainHeat; // must be > 0
		analyzer.AnalyzeTerrain ();
		RawBoard = analyzer.level;

		DetermineEdges ();
	}
Пример #54
0
    void CreateGrid()
    {
        Grid = new Transform[(int)Size.x,(int)Size.z];

        for(int x = 0; x < Size.x; x++){
            for(int z = 0; z < Size.z; z++){

                Transform newCell;
                          newCell = (Transform)Instantiate(CellPrefab, new Vector3(x, 0, z), Quaternion.identity);
                          newCell.name = string.Format("({0},0,{1})",x,z);
                          newCell.parent = transform;
                          newCell.GetComponent<CellScript>().Position = new Vector3(x, 0, z);

                Grid[x,z] = newCell;
            }
        }

        Camera.mainCamera.transform.position = Grid[(int)(Size.x/2f),(int)(Size.z/2f)].position + Vector3.up*20f;
        Camera.mainCamera.orthographicSize = Mathf.Max(Size.x, Size.z);
    }
    public static void initGrid(Transform instance, 
	                            float densityOfAtmosphere, 
	                            float heightOfAtomosphere, 
	                            float gravityOfEarth,
	                            float gravityOfSun,
	                            float fixRate,
	                            float squaredAngularVelocity,
	                            int xDivision = 36, int yDivision = 36)
    {
        prefab = instance;
        density = densityOfAtmosphere;
        height = heightOfAtomosphere;
        gridX = xDivision;
        gridY = yDivision;
        gravity = gravityOfEarth;
        sunGravity = gravityOfSun;
        fixForce = fixRate;
        lastUpdate = Time.time;
        squaredOmega = squaredAngularVelocity;

        Transform earth = GameObject.Find ("Earth").transform;

        gridPosition = new Vector3[gridX, gridY];
        gridItem = new Transform[gridX, gridY];
        gridDensity = new Vector3[gridX, gridY];

        for (int x = 0; x < gridX; ++x) {
            for (int y = 1; y < gridY; ++y){
                //if (y == gridY / 2) continue;
                float alpha = 1.0f * x / gridX * Mathf.PI * 2.0f;
                float beta =  1.0f * y / gridY * Mathf.PI;

                gridPosition[x, y] = new Vector3(height * Mathf.Sin(beta) * Mathf.Cos(alpha),
                                                 height * Mathf.Cos(beta),
                                                 height * Mathf.Sin(beta) * Mathf.Sin(alpha));

                gridItem[x, y] = Transform.Instantiate(prefab, gridPosition[x, y] + earth.position, Quaternion.identity) as Transform;

            }
        }
    }
Пример #56
0
    // Creates the grid by instantiating provided cell prefabs.
    void CreateGrid()
    {
        Grid = new Transform[(int)Size.x,(int)Size.z];

        // Places the cells and names them according to their coordinates in the grid.
        for (int x = 0; x < Size.x; x++) {
            for (int z = 0; z < Size.z; z++) {
                Transform newCell;
                newCell = (Transform)Instantiate(CellPrefab, new Vector3(x, 0, z), Quaternion.identity);
                newCell.name = string.Format("({0},0,{1})", x, z);
                newCell.parent = transform;
                newCell.GetComponent<CellScript>().Position = new Vector3(x, 0, z);
                Grid[x,z] = newCell;
            }
        }

        // Centers the camera on the maze.
        // Feel free to adjust this as needed.
        //Camera.main.transform.position = Grid[(int)(Size.x / 2f),(int)(Size.z / 2f)].position + Vector3.up * 20f;
        //Camera.main.orthographicSize = Mathf.Max(Size.x * 0.55f, Size.z * 0.5f);
    }
Пример #57
0
  void Start() {
    cube_grid_ = new Transform[gridHeight + 2, gridWidth + 2];
    for (int r = 0; r < gridHeight + 2; ++r) {
      for (int c = 0; c < gridWidth + 2; ++c) {
        cube_grid_[r, c] = transform;
      }
    }

    float center_x = gridWidth * cellWidth / 2.0f;
    float center_y = gridHeight * cellHeight / 2.0f;

    // Setup the cube grid.
    for (int r = 1; r <= gridHeight; ++r) {
      for (int c = 1; c <= gridWidth; ++c) {
        Vector3 location = new Vector3(c * cellWidth - center_x, 0, r * cellHeight - center_y);
        cube_grid_[r, c] = Instantiate(model, transform.position + location,
                                       transform.rotation * model.transform.rotation) as Transform;
        cube_grid_[r, c].parent = transform;
      }
    }
  }
Пример #58
0
    public void CreateGrid()
    {
        int x = (int)gridSize.x;
        int z = (int)gridSize.y;

        int maxXZ = Mathf.Max(x, z);
        topDown.transform.position = new Vector3 (maxXZ / 2f, maxXZ * buffer, maxXZ / 8f);
        gridArray = new Transform[x, z];
        Transform newCell;
        for (int ix = 0; ix < x; ix++)
        {
            for (int iz = 0; iz < z; iz++)
            {
                newCell = (Transform)Instantiate(cell, new Vector3(ix, 0, iz) * buffer, Quaternion.identity);
                newCell.name = string.Format("({0},{1})", ix, iz);
                newCell.parent = transform;
                newCell.GetComponent<Cell>().Position = new Vector3(ix, iz);
                gridArray[ix, iz] = newCell;
            }
        }
    }
Пример #59
0
	public void GenerateMaze(){
		if (!mazeHolder) {
			mazeHolder = new GameObject ();
			mazeHolder.name = "mazeHolder";
		}
		mazeComplete = false;
		maxStackAmount = 0;
		cellWidth = cellPrefab.transform.lossyScale.x;
		outputStack.Clear ();
		sortingStack.Clear ();
		cellGrid = new Transform[(int)gridSize.x, (int)gridSize.z];

		SetupCells ();

		SetAdjacents ();

		SetDiagonals ();

		ApplyMazeEffect ();	//put c_MazeEffect on normal for default generation

		SetStart ();	//starts the generation process
	}
Пример #60
0
    public void UpdateGrid()
    {
        Grid=new Transform[grid_width,grid_height];
        List<Transform> list = new List<Transform>();

        foreach (Transform t in transform)
        {
            list.Add(t);
        }

        int i=0;
        for (int y=0;y<grid_height;y++){
            for (int x=0;x<grid_width;x++){
                if (i<list.Count){
                    Grid[x,y]=list[i];
                    i++;
                }
                else
                    Grid[x,y]=null;
            }
        }
    }