public void AddSpawnPoint(SpawnPointBehaviour s) { if (!_spawnPointList.Contains(s)) { _spawnPointList.Add(s); } }
private void MaybePurchaseGhostUnits(SpawnPointBehaviour closestSpawn) { if (Input.GetMouseButtonUp(0)) { bool noUIcontrolsInUse = EventSystem.current.currentSelectedGameObject == null; if (!noUIcontrolsInUse) { return; } if (_currentBuyTransaction == null) { return; } closestSpawn.BuyPlatoons(_currentBuyTransaction.GhostPlatoons); if (Input.GetKey(KeyCode.LeftShift)) { // We turned the current ghosts into real units, so: _currentBuyTransaction = _currentBuyTransaction.Clone(); } else { ExitPurchasingMode(); } } }
public static void addSpawnPoint(SpawnPointBehaviour s) { if (!spawnPointList.ContainsKey(s.team)) { spawnPointList.Add(s.team, new List <SpawnPointBehaviour>()); } spawnPointList[s.team].Add(s); }
private void ShowGhostUnitsAndMaybePurchase(RaycastHit terrainHover) { // Show ghost units under mouse: SpawnPointBehaviour closestSpawn = GetClosestSpawn(terrainHover.point); _currentBuyTransaction.PreviewPurchase( terrainHover.point, 2 * terrainHover.point - closestSpawn.transform.position); MaybePurchaseGhostUnits(closestSpawn); }
private SpawnPointBehaviour getClosestSpawn(Vector3 p) { var pointList = spawnPointList[currentTeam]; SpawnPointBehaviour go = pointList[0]; float distance = Single.PositiveInfinity; foreach (var s in pointList) { if (Vector3.Distance(p, s.transform.position) < distance) { distance = Vector3.Distance(p, s.transform.position); go = s; } } return(go); }
private SpawnPointBehaviour GetClosestSpawn(Vector3 p) { var pointList = _spawnPointList.Where( x => x.Team == _localPlayer.Team).ToList(); SpawnPointBehaviour go = pointList.First(); float distance = Single.PositiveInfinity; foreach (var s in pointList) { if (Vector3.Distance(p, s.transform.position) < distance) { distance = Vector3.Distance(p, s.transform.position); go = s; } } return(go); }
// TODO If we can refactor MatchSession to create the spawn points, we will be able to get rid of this: public void AddSpawnPoint(SpawnPointBehaviour spawn) { _inputManager.AddSpawnPoint(spawn); }
// TODO If we can refactor MatchSession to create the spawn points, we will be able to get rid of this: public void RegisterSpawnPoint(SpawnPointBehaviour spawn) { _inputManager.RegisterSpawnPoint(spawn); }
public void CmdEnqueuePlatoonPurchase( byte playerId, byte unitCategoryId, int unitId, int unitCount, byte spawnPointId, Vector3 destinationCenter, float destinationHeading) { Logger.LogNetworking( LogLevel.DEBUG, this, $"Enqueueing platoon purchase at spawn pt = {spawnPointId}."); if (MatchSession.Current.Players.Count > playerId && unitCount >= MIN_PLATOON_SIZE && unitCount <= MAX_PLATOON_SIZE) { if (MatchSession.Current.SpawnPoints.Length > spawnPointId) { PlayerData owner = MatchSession.Current.Players[playerId]; SpawnPointBehaviour spawn = MatchSession.Current.SpawnPoints[spawnPointId]; if (unitCategoryId < owner.Deck.Categories.Length && unitId < GameSession.Singleton.Armory.Categories[unitCategoryId].Count) { Unit unit = GameSession.Singleton.Armory.Categories[unitCategoryId][unitId]; GhostPlatoonBehaviour g = GhostPlatoonBehaviour.CreatePreviewMode(unit, owner, unitCount); g.SetPositionAndOrientation(destinationCenter, destinationHeading); NetworkServer.Spawn(g.gameObject); spawn.BuyPlatoon(g); } else { if (unitCategoryId < GameSession.Singleton.Armory.Categories.Length) { Logger.LogNetworking(LogLevel.ERROR, $"Got bad unit id = {unitId} from " + $"the server. Total units = {GameSession.Singleton.Armory.Categories[unitCategoryId].Count} " + $"(category = {unitCategoryId})."); } else { Logger.LogNetworking(LogLevel.ERROR, $"Got bad category id = {unitCategoryId} from " + $"the server. Total categories = {GameSession.Singleton.Armory.Categories.Length}"); } } } else { Logger.LogNetworking(LogLevel.ERROR, $"Client asked to create a platoon with an invalid spawn id {spawnPointId}."); } } else { // Got an invalid player id, client is trying to crash us? Logger.LogNetworking(LogLevel.ERROR, $"Client asked to create a platoon with an invalid player id {playerId}."); } }