Esempio n. 1
0
 public void SetMode_DestroyFloor()
 {
     BuildModeIsObjects = false;
     buildModeTile      = Tile.TileType.Empty;
 }
Esempio n. 2
0
 public void SetMode_Bulldoze()
 {
     buildModeIsObjects = false;
     buildModeTile      = Tile.TileType.Empty;
 }
Esempio n. 3
0
 public void SetTileAt(Vector2 position, Tile.TileType type)
 {
     WorldData[(int)position.x, (int)position.y].SetType(type);
 }
Esempio n. 4
0
 public void setTileTypeEmpty()
 {
     selectedTileType = Tile.TileType.Empty;
 }
Esempio n. 5
0
 //Function for UI "TILE" button
 public void setTileTypeFloor()
 {
     selectedTileType = Tile.TileType.Floor;
 }
 public static bool IsNotPastHeightLimit(Coordinate c, TileGrid tileGrid, Tile.TileType tileType, int limit)
 {
     return(IsNotPastHeightLimit(c, tileGrid, tileType, null, limit, false));
 }
Esempio n. 7
0
    /// <summary>
    /// Initializes and populates the grid.
    /// </summary>
    void Start()
    {
        // Initial settings
        puzzleFinished = false;
        winMessage.Hide();
        Teleporter.ResetCount();
        pauseMenu.SetActive(false);
        player.GetComponent <Player>().CanMove = true;

        // get level info
        TextAsset levelInfo = Level.LevelInfo;

        string[] txtLines = levelInfo.text.Split('\n');

        // read in level info
        try {
            width  = int.Parse(txtLines[0]);
            height = int.Parse(txtLines[1]);

            // create the puzzle grid and solution grid
            gridTiles     = new Tile[width][];
            solutionTiles = new Tile[width][];
            for (int i = 0; i < width; i += 1)
            {
                gridTiles[i]     = new Tile[height];
                solutionTiles[i] = new Tile[height];
            }

            // create grid game object
            gridObjects = new GameObject();
            gridObjects.transform.parent = gameObject.transform;
            gridObjects.name             = "GridObjects";

            // create grid tiles, set default tile colours
            for (int i = 0; i < width; i += 1)
            {
                for (int j = 0; j < height; j += 1)
                {
                    gridTiles[i][height - 1 - j] = new Tile(ReadTileType(txtLines[j + 2][i]), gridObjects, i, height - 1 - j);
                }
            }

            // place player at start location
            player.transform.parent        = gridObjects.transform;
            playerStartLocation.x          = playerCurrentLocation.x = int.Parse(txtLines[2 + height]);
            playerStartLocation.y          = playerCurrentLocation.y = int.Parse(txtLines[3 + height]);
            player.transform.localPosition = new Vector2((float)playerStartLocation.x, (float)playerStartLocation.y);

            // read in tools
            #region Read in tools and create them
            int toolNum = int.Parse(txtLines[4 + height]);
            int lineNum = 5 + height;

            // create tools
            gridTools = new Dictionary <IntVector.IntVector2, Tool>();
            for (int i = 0; i < toolNum; i += 1)
            {
                char toolType = txtLines[lineNum][0];

                if (toolType == 'c')   // colour picker
                {
                    ColourPicker.Colour  col = ReadColour(txtLines[lineNum][1]);
                    IntVector.IntVector2 loc = new IntVector.IntVector2(int.Parse(txtLines[lineNum + 1]), int.Parse(txtLines[lineNum + 2]));
                    ColourPicker         cp  = new ColourPicker(loc.x, loc.y, col, gridObjects);
                    gridTools.Add(loc, cp);
                    lineNum += 3;
                }
                else if (toolType == 's')       // splash
                {
                    ColourPicker.Colour  col = ReadColour(txtLines[lineNum][1]);
                    IntVector.IntVector2 loc = new IntVector.IntVector2(int.Parse(txtLines[lineNum + 1]), int.Parse(txtLines[lineNum + 2]));
                    Splash s = new Splash(loc.x, loc.y, col, this, gridObjects);
                    gridTools.Add(loc, s);
                    lineNum += 3;
                }
                else if (toolType == 'l')       // line shot
                {
                    ColourPicker.Colour col = ReadColour(txtLines[lineNum][1]);
                    int numDir           = int.Parse(txtLines[lineNum + 1]);
                    List <Direction> dir = new List <Direction>();
                    for (int j = 0; j < numDir; j += 1)
                    {
                        dir.Add(ReadDirection(txtLines[lineNum + 2][j]));
                    }
                    IntVector.IntVector2 loc = new IntVector.IntVector2(int.Parse(txtLines[lineNum + 3]), int.Parse(txtLines[lineNum + 4]));
                    LineShot             l   = new LineShot(loc.x, loc.y, this, col, dir, gridObjects);
                    gridTools.Add(loc, l);
                    lineNum += 5;
                }
                else if (toolType == 'e')
                {
                    IntVector.IntVector2 loc = new IntVector.IntVector2(int.Parse(txtLines[lineNum + 1]), int.Parse(txtLines[lineNum + 2]));
                    Eraser e = new Eraser(loc.x, loc.y, gridObjects);
                    gridTools.Add(loc, e);
                    lineNum += 3;
                }
                else if (toolType == 't')
                {
                    IntVector.IntVector2 loc1 = new IntVector.IntVector2(int.Parse(txtLines[lineNum + 1]), int.Parse(txtLines[lineNum + 2]));
                    IntVector.IntVector2 loc2 = new IntVector.IntVector2(int.Parse(txtLines[lineNum + 3]), int.Parse(txtLines[lineNum + 4]));
                    Teleporter           t1   = new Teleporter(loc1.x, loc1.y, this, gridObjects);
                    Teleporter           t2   = new Teleporter(loc2.x, loc2.y, this, gridObjects, t1);
                    t1.Other = t2;
                    gridTools.Add(loc1, t1);
                    gridTools.Add(loc2, t2);
                    lineNum += 5;
                }
                else if (toolType == 'r')
                {
                    Direction            d   = ReadDirection(txtLines[lineNum][1]);
                    IntVector.IntVector2 loc = new IntVector.IntVector2(int.Parse(txtLines[lineNum + 1]), int.Parse(txtLines[lineNum + 2]));
                    Redirection          r   = new Redirection(loc.x, loc.y, gridObjects, d);
                    gridTools.Add(loc, r);
                    lineNum += 3;
                }
                else
                {
                    throw new System.Exception();
                }
            }
            #endregion

            // create solution grid object and the mini-guide
            #region Read in solution and create overlay
            solutionGrid                  = new GameObject();
            solutionGrid.name             = "Solution";
            solutionGrid.transform.parent = transform;

            // create mini-guide
            GameObject miniGuide = new GameObject();
            miniGuide.name = "Mini-Guide";

            GameObject guideOutline = new GameObject();
            guideOutline.name = "GuideOutline";
            guideOutline.transform.localPosition = new Vector2(0.0f, 0.0f);
            guideOutline.transform.parent        = miniGuide.transform;

            GameObject guideTiles = new GameObject();
            guideTiles.name = "GuideTiles";
            guideTiles.transform.localPosition = new Vector2(0.0f, 0.0f);
            guideTiles.transform.parent        = miniGuide.transform;

            // read in solution
            for (int i = 0; i < width; i += 1)
            {
                for (int j = 0; j < height; j += 1)
                {
                    ColourPicker.Colour col = ReadColour(txtLines[lineNum + j][i]);
                    int x = (i + height - 1 - j) % 2;

                    // overlay
                    solutionTiles[i][height - 1 - j] = new Tile(col, solutionGrid, i, height - 1 - j, gridTiles[i][height - 1 - j].Type);

                    // mini guide
                    Tile.TileType t = gridTiles[i][height - 1 - j].Type;
                    if (t != Tile.TileType.Blank)
                    {
                        if (t == Tile.TileType.Default || t == Tile.TileType.Ice)
                        {
                            ResourceLoader.GetSpriteGameObject("GuideTile", guideTiles, i, height - 1 - j, "Guide", 1, "Sprites/Tiles/Tile-Default-" + x.ToString(), col);
                        }
                        else
                        {
                            ResourceLoader.GetSpriteGameObject("GuideTile", guideTiles, i, height - 1 - j, "Guide", 1, "Sprites/Tiles/Tile-Dark-" + x.ToString(), col);
                        }
                        ResourceLoader.GetSpriteGameObject("GuideOutline", guideOutline, i, height - 1 - j, "Guide", 0, "Sprites/Tiles/Tile-Outline");
                    }
                }
            }

            // set cursor
            cursor = ResourceLoader.GetSpriteGameObject("Cursor", miniGuide, playerCurrentLocation.x, playerCurrentLocation.y, "Guide", 2, "Sprites/Tiles/Cursor");
            solutionGrid.SetActive(false);

            // set position and scale
            miniGuide.transform.position   = new Vector2(transform.position.x + ((float)width) + 1.0f, ((float)height) / 4);
            miniGuide.transform.localScale = new Vector2(0.35f, 0.35f);
            #endregion

            // center the camera on the grid
            float aspectMultiplier = (16.0f / 9.0f) / ((float)Screen.width / Screen.height);
            cam.transform.position = new Vector3(((float)width) * 1.35f / 2.0f, ((float)height - 1) / 2.0f, -10.0f);
            cam.GetComponent <Camera>().orthographicSize = Mathf.Max(5.0f, (((float)width) * 0.5f + 0.5f) * aspectMultiplier, (((float)height) * 0.5f + 0.5f) * aspectMultiplier);

            // count number of correct tiles initially
            CountCorrectTiles();
            defaultCorrectTiles = correctTiles;
        } catch {
            Debug.Log("Invalid level information.");
        }
    }
Esempio n. 8
0
 public void SetTile(int col, int row, Tile.TileType tile)
 {
     map[col, row] = tile;
 }