private void Awake() { Current = this; _networkManager = FindObjectOfType <NetworkManager>(); // LoadedData ideally comes from the loading scene _loadedData = FindObjectOfType <LoadedData>(); // If there is no loaded data, this scene is just // a false start and we will instantly move to // the loading scene (see Start() ) and then reset this // scene with a loaded data. if (_loadedData != null) { TerrainMap = _loadedData.TerrainData; VisionCache = new VisionCache(TerrainMap); PathData = _loadedData.PathFinderData; Factory = new UnitFactory(); Settings = new Settings(); Team blueTeam = GameObject.Find("Team_Blue").GetComponent <Team>(); Team redTeam = GameObject.Find("Team_Red").GetComponent <Team>(); Deck bluePlayerDeck = ConfigReader.ParseDeck( "player-blue", _loadedData.Armory); Deck redPlayerDeck = ConfigReader.ParseDeck( "player-red", _loadedData.Armory); PlayerData bluePlayer = new PlayerData( bluePlayerDeck, blueTeam, (byte)Players.Count); Players.Add(bluePlayer); blueTeam.Players.Add(bluePlayer); PlayerData redPlayer = new PlayerData( redPlayerDeck, redTeam, (byte)Players.Count); Players.Add(redPlayer); redTeam.Players.Add(redPlayer); Teams.Add(blueTeam); Teams.Add(redTeam); LocalPlayer = gameObject.AddComponent <PlayerBehaviour>(); LocalPlayer.Data = redTeam.Players[0]; _unitRegistry = new UnitRegistry(LocalPlayer.Data.Team, Teams); _inputManager = FindObjectOfType <InputManager>(); if (!_inputManager) { _inputManager = gameObject.AddComponent <InputManager>(); } _inputManager.Session = this; _inputManager.LocalPlayer = LocalPlayer.Data; _visibilityManager = FindObjectOfType <VisibilityManager>(); if (!_visibilityManager) { _visibilityManager = gameObject.AddComponent <VisibilityManager>(); } _visibilityManager.UnitRegistry = _visibilityManager.UnitRegistry ?? _unitRegistry; _deploymentMenu.Initialize(_inputManager, LocalPlayer); SpawnPointBehaviour[] spawns = FindObjectsOfType <SpawnPointBehaviour>(); foreach (SpawnPointBehaviour spawn in spawns) { _inputManager.RegisterSpawnPoint(spawn); } } }
private void Awake() { Current = this; _networkManager = FindObjectOfType <NetworkManager>(); // LoadedData ideally comes from the loading scene _loadedData = FindObjectOfType <LoadedData>(); // If there is no loaded data, this scene is just // a false start and we will instantly move to // the loading scene (see Start() ) and then reset this // scene with a loaded data. if (_loadedData != null) { TerrainMap = _loadedData.TerrainData; VisionCache = new VisionCache(TerrainMap); PathData = _loadedData.PathFinderData; Factory = new UnitFactory(); Settings = new Settings(); Team blueTeam = GameObject.Find("Team_Blue").GetComponent <Team>(); Team redTeam = GameObject.Find("Team_Red").GetComponent <Team>(); Deck bluePlayerDeck = GameSession.Singleton.Decks["player-blue"]; Deck redPlayerDeck = GameSession.Singleton.Decks["player-red"]; PlayerData bluePlayer = new PlayerData( bluePlayerDeck, blueTeam, "Reagan", (byte)Players.Count); Players.Add(bluePlayer); blueTeam.Players.Add(bluePlayer); PlayerData redPlayer = new PlayerData( redPlayerDeck, redTeam, "Gorbachev", (byte)Players.Count); Players.Add(redPlayer); redTeam.Players.Add(redPlayer); Teams.Add(blueTeam); Teams.Add(redTeam); LocalPlayer = gameObject.AddComponent <PlayerBehaviour>(); LocalPlayer.Data = redTeam.Players[0]; _unitRegistry = new UnitRegistry(LocalPlayer.Data.Team, Teams); _inputManager.LocalPlayer = LocalPlayer.Data; _visibilityManager = FindObjectOfType <VisibilityManager>(); if (!_visibilityManager) { _visibilityManager = gameObject.AddComponent <VisibilityManager>(); } _visibilityManager.UnitRegistry = _visibilityManager.UnitRegistry ?? _unitRegistry; _deploymentMenu.Initialize(_inputManager, LocalPlayer); SpawnPoints = FindObjectsOfType <SpawnPointBehaviour>(); for (int i = 0; i < SpawnPoints.Length; i++) { SpawnPoints[i].Id = (byte)i; } } }