Example #1
0
        void Start()
        {
            _gameConfig = new Config();
            loadMap(_gameConfig);

            //Generates a map for the background of the menu
            for (int x = 0; x < _gameConfig.MapWidth; x++)
            {
                for (int y = 0; y < _gameConfig.MapHeight; y++)
                {
                    Tile tile = _map.GetTile(x, y);

                    GameObject tileObject = Instantiate(Resources.Load <GameObject>("Prefabs/Tile"));
                    tileObject.transform.parent     = transform;
                    tileObject.transform.position   = new Vector3(x + 0.5f, y + 0.5f, 3);
                    tileObject.transform.localScale = Vector3.one;

                    TileController controller = tileObject.GetComponent <TileController>();
                    controller.SetTile(tile);
                    controller.SetPosition(x, y);
                    controller.enabled = false;
                }
            }

            _previousSeed = DateTime.UtcNow.ToString();

            //Set the camera
            Camera.main.transform.position = new Vector3(25, 12.5f, -3);
            Camera.main.orthographicSize   = 9;

            _gameConfig.SmoothCount = 1;
            _gameConfig.Seed        = new System.Random(_previousSeed.GetHashCode());
        }
Example #2
0
        public void TileChanged(int positionX, int positionY)
        {
            TileController tile = _children[positionX, positionY].GetComponent <TileController>();

            tile.SetTile(_game.GetViewTile(positionX, positionY));
        }