private void RefillHouseHoldSquadMembers() { if (CurrentSquad == null || MaxOccupants <= 0) { return; } if (GameManager.Inst.NPCManager.GetFactionData(CurrentSquad.Faction).CharacterType == CharacterType.Mutant) { int numberToSpawn = MaxOccupants - CurrentSquad.Members.Count; for (int i = 0; i < numberToSpawn; i++) { Vector3 spawnLoc = FindSpawnLocation(); string modelID = GetRandomCharacterModelID(CurrentSquad.Faction); MutantCharacter character = GameManager.Inst.NPCManager.SpawnRandomMutantCharacter(modelID, CurrentSquad, spawnLoc); CurrentSquad.AddMember(character); } } else if (GameManager.Inst.NPCManager.GetFactionData(CurrentSquad.Faction).CharacterType == CharacterType.Animal) { int numberToSpawn = MaxOccupants - CurrentSquad.Members.Count; for (int i = 0; i < numberToSpawn; i++) { Vector3 spawnLoc = FindSpawnLocation(); string modelID = GetRandomCharacterModelID(CurrentSquad.Faction); MutantCharacter character = GameManager.Inst.NPCManager.SpawnRandomAnimalCharacter(modelID, CurrentSquad, spawnLoc); CurrentSquad.AddMember(character); } } else { int currentMembersCount = GetAllMembersCount(); if (currentMembersCount < MaxOccupants) { //first create a commander if there isn't one if (!CurrentSquad.IsThereCommander() && CommanderIdleDest != null) { string modelID = GetRandomCharacterModelID(CurrentSquad.Faction); HumanCharacter commander = GameManager.Inst.NPCManager.SpawnRandomHumanCharacter(modelID, CurrentSquad, CommanderIdleDest.transform.position); commander.IsCommander = true; CurrentSquad.AddMember(commander); CurrentSquad.Commander = commander; } int numberToSpawn = MaxOccupants - currentMembersCount; for (int i = 0; i < numberToSpawn; i++) { Vector3 spawnLoc = FindSpawnLocation(); string modelID = GetRandomCharacterModelID(CurrentSquad.Faction); HumanCharacter character = GameManager.Inst.NPCManager.SpawnRandomHumanCharacter(modelID, CurrentSquad, spawnLoc); CurrentSquad.AddMember(character); } } } }
private void SpawnWave(int waveSize, Faction faction, bool isMultiSpawn) { AISquad enemySquad = new AISquad(); enemySquad.Faction = faction; //select a spawn point GameObject [] spawnPoints = GameObject.FindGameObjectsWithTag("Respawn"); int point = UnityEngine.Random.Range(0, spawnPoints.Length); for (int i = 0; i < waveSize; i++) { if (isMultiSpawn) { point = UnityEngine.Random.Range(0, spawnPoints.Length); } if (faction == Faction.Legionnaires) { enemySquad.AddMember(GameManager.Inst.NPCManager.SpawnRandomHumanCharacter("Bandit", enemySquad, spawnPoints[point].transform.position + new Vector3(UnityEngine.Random.value * 3, 0, UnityEngine.Random.value * 3))); } else if (faction == Faction.Military) { enemySquad.AddMember(GameManager.Inst.NPCManager.SpawnRandomHumanCharacter("Military", enemySquad, spawnPoints[point].transform.position + new Vector3(UnityEngine.Random.value * 3, 0, UnityEngine.Random.value * 3))); } else if (faction == Faction.Mutants) { string mutantName; int goapID; if (this.Stage < 7) { if (UnityEngine.Random.value > 0.6f) { mutantName = "Mutant1"; goapID = 3; } else { mutantName = "Mutant1"; goapID = 3; } } else { if (UnityEngine.Random.value < 0.3f) { mutantName = "Mutant1"; goapID = 3; } else { if (UnityEngine.Random.value > 0.6f) { mutantName = "Mutant4"; goapID = 2; } else { mutantName = "Mutant3"; goapID = 2; } } } MutantCharacter mutant = GameManager.Inst.NPCManager.SpawnRandomMutantCharacter(mutantName, enemySquad, spawnPoints[point].transform.position + new Vector3(UnityEngine.Random.value * 3, 0, UnityEngine.Random.value * 3)); mutant.MyAI.BlackBoard.PatrolLoc = new Vector3(62.7f, 0, -15); mutant.MyAI.BlackBoard.PatrolRange = new Vector3(30, 5, 15); mutant.MyAI.BlackBoard.CombatRange = new Vector3(40, 20, 20); mutant.MyAI.BlackBoard.HasPatrolInfo = true; } } enemySquad.IssueSquadCommand(); }