예제 #1
0
파일: Map.cs 프로젝트: chasay2002/UATanks
        private IEnumerator GenerateMap()
        {
            this.TileMap = new Tile[this.MapSize.x, this.MapSize.z];

            var activeTiles = new List <Tile>
            {
                // Spawn first tile
                CreateTile(this.GetRandomPosition())
            };

            while (activeTiles.Count > 0)
            {
                yield return(null);

                SpawnRemainingTiles(activeTiles);
            }

            GameManager.RebuildNavMesh();


            foreach (Tile tile in this.TileMap)
            {
                yield return(null);

                tile.SpawnAgents();
            }

            yield return(null);

            this.SpawnPlayer();

            CustomCamera.CameraSystem.EnableCamera();
            UIMenuNavigator.SwitchToInGameUI();
        }
예제 #2
0
    public void BeginGame()
    {
        // Main camera and UI is turned back on after the map is generated
        CustomCamera.CameraSystem.DisableCamera();
        UIMenuNavigator.DisableAllUI();

        Instance._playerScore = 0;

        if (Instance._mapOfTheDayToggle.isOn)
        {
            Random.InitState(Int32.Parse(
                                 DateTime.Now.Year +
                                 DateTime.Now.Month.ToString() +
                                 DateTime.Now.Day));
        }
        else
        {
            Random.InitState((int)DateTime.Now.Ticks);
        }

        Instance._mapInstance         = new GameObject().AddComponent <Map>();
        Instance._mapInstance.name    = "Map Instance";
        Instance._mapInstance.MapSize = new Map.MapVector2(
            Instance._mapSizeXDropdown.value + 1, Instance._mapSizeYDropdown.value + 1);
    }
예제 #3
0
    private void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this);
        }

        SwitchToMainMenuUI();
    }
예제 #4
0
    public static void EndGame()
    {
        Destroy(Instance._mapInstance.gameObject);

        for (int i = Instance._playerList.Count - 1; i >= 0; i--)
        {
            Destroy(Instance._playerList[i]);
        }

        Instance._playerList.Clear();
        Instance._enemyList.Clear();

        UIMenuNavigator.SwitchToPostGameUI();
        StatsWindow.UpdateStats();
    }