Esempio n. 1
0
        public void generatePuzzle()
        {
            generatetime += Time.deltaTime;
            if (generatetime > timePerGenerate)
            {
                generatetime = 0;

                puzzlecount++;
                System.Random rnd = new System.Random();
                //int puzzleindex = rnd.Next(1, numberOfPuzzle + 1);
                int        puzzleindex = puzzlecount % numberOfPuzzle + 1;
                int        x           = rnd.Next(0, groundsize);
                int        z           = rnd.Next(0, groundsize - 3);
                GameObject newpuzzle   = (GameObject)GameObject.Instantiate(Resources.Load("prefabs/puzzle" + puzzleindex.ToString()));
                newpuzzle.transform.position = new Vector3(x, groundsize - 2, z);
                puzzle newp = new puzzle(newpuzzle, puzzlecount);
                newp.type = puzzleindex;
                for (int i = 0; i < newpuzzle.transform.childCount; i++)
                {
                    GameObject cube = newpuzzle.transform.GetChild(i).gameObject;
                    if (getGrid(cube.transform.position) != 0)
                    {
                        gameover();
                    }
                    Cube newcub = new Cube(cube, puzzlecount);
                    newp.addCube(newcub);
                }
                puzzles.Add(newp);
                curr           = newp;
                newpuzzle.name = puzzlecount.ToString();
            }
        }
Esempio n. 2
0
 public bool addCube(Vector3 coord)
 {
     coord = WorldToCube(coord);
     if (valid(coord) && getGrid(coord) == 0 && money >= 20)
     {
         GameObject cub = (GameObject)GameObject.Instantiate(Resources.Load("prefabs/Cubeadd"));
         cub.transform.position = coord;
         puzzlecount++;
         GameObject puzobj = new GameObject(puzzlecount.ToString());
         cub.transform.parent = puzobj.transform;
         puzzle newp = new puzzle(puzobj, puzzlecount);
         newp.type = 6;
         Cube c = new Cube(cub, puzzlecount);
         newp.addCube(c);
         puzzles.Add(newp);
         money -= 20;
         return(true);
     }
     return(false);
 }