/// <summary> /// Generates a new Level with the current LevelNo in GameManager. /// The Level can be builded by the LevelBuilder. /// </summary> /// <param name="difficulty">the level difficulty</param> /// <returns>The generated level</returns> public Level GenerateNextLevel(int difficulty) { int levelNo = GameManager.GetInstance().LevelNo; GameManager.GetInstance().LevelNo++; levelNo++; /* * // Try to obtain the jungle sections. * List<GameObject> _sectionArray = GetJungleSections(); * if(_sectionArray.Count == 0) * { // No jungle sections present -- simply fetch some random sections * // (two for now). * _sectionArray = GetRandomSections(2); * } */ List <GameObject> sectionArray = GetFixedSections(3); Level newLevel = new Level(difficulty, levelNo); int sectionCount = sectionArray.Count; for (int i = 0; i < sectionCount; i++) { //// int rand = UnityEngine.Random.Range(0, _sectionPrefabs.Count - 1); Section newSection = new Section(sectionArray[i]); newSection.SectionNumber = i + 1; int x = ((levelNo - 1) * sectionCount) + i + 1; List <GameObject> mobs = Datasheet.Mobs(); int monsterCount = (int)(((3 * x) + Math.Sin(1.5 * x) + 7) * Math.Sqrt(GameManager.GetInstance().GetAllTeams()[0].GetHeroTeamMembers().Count)); for (int m = 0; m < monsterCount; m++) { //// TODO: produce inbalance, so that easy mobs are more often, then hard mobs int random = UnityEngine.Random.Range(0, mobs.Count); newSection.AddMob(mobs[random].GetComponent <Mob>()); } List <GameObject> mercenaries = Datasheet.Mercenaries(); for (int m = 0; m < MercenaryCount; m++) { // TODO: produce inbalance, so that easy mercs are more often, then hard mercs int random = UnityEngine.Random.Range(0, mercenaries.Count); newSection.AddMercenary(mercenaries[random].GetComponent <Mercenary>()); } newLevel.AddSection(newSection); } return(newLevel); }
/// <summary> /// spawn all heroes /// </summary> private void SpawnHeroes() { int playerCounter = 1; List <Team> teamList = GameManager.GetInstance().GetAllTeams(); for (int i = 0; i < teamList.Count; i++) { List <Hero> heroList = teamList[i].GetHeroTeamMembers(); for (int j = 0; j < heroList.Count; j++) { Hero h = heroList[j]; h = ((GameObject)Instantiate(h.gameObject)).GetComponent <Hero>(); h.PlayerNo = playerCounter; playerCounter++; h.Type = heroList[j].Type; h.DisplayName = heroList[j].DisplayName; h.name = "Hero" + h.PlayerNo; teamList[i].RemoveMember(heroList[j]); teamList[i].AddMember(h); h.SpecialRespawn(); } } for (int k = 0; k < GameManager.GetInstance().HeroCount; k++) { Debug.Log("[CharacterSelection.cs] Add AI hero"); Hero choosenCharacter = ((GameObject)Instantiate(Datasheet.Heroes()[0])).GetComponent <Hero>(); choosenCharacter.name = "Hero" + playerCounter + "KI"; playerCounter++; choosenCharacter.Type = Hero.Types.AI; Debug.Log("Spawn AI: " + choosenCharacter.name); choosenCharacter.SpecialRespawn(); if (GameManager.GetInstance().TeamCount == 1) { teamList[0].AddMember(choosenCharacter); } } }
/// <summary> /// called once an start /// </summary> public override void Start() { base.Start(); // setting the itemspawner of this hero // TODO: one setting still left... spawn right or left of this hero?? --atm always right GameObject prefab = (GameObject)Resources.Load("SpawnerPrefab"); _itemSpawner = ((GameObject)Instantiate(prefab, transform.position, Quaternion.identity)).GetComponent <Spawner>(); _itemSpawner.Pool = Datasheet.Items(); _itemSpawner.SpawnerType = Spawner.Type.ITEM; _itemSpawner.transform.parent = transform; if (GameManager.GetInstance().GameMode == GameManager.Mode.PLAY) { _itemSpawner.StartSpawnRoutine(UnityEngine.Random.Range(20 + (GameManager.GetInstance().Difficulty * 5), 40 + (GameManager.GetInstance().Difficulty * 5))); } else { // between 30s and 1min _itemSpawner.StartSpawnRoutine(UnityEngine.Random.Range(30, 60)); } }
private void SpawnHeroes(Level level) { int playerCounter = 1; List <Team> teamList = GameManager.GetInstance().GetAllTeams(); int startSection = GameManager.GetInstance().SectionNo - 1; for (int i = 0; i < teamList.Count; i++) { if (teamList[i].TeamNo == 666) { continue; } // Team newTeam = new Team(i+1); List <Hero> heroList = teamList[i].GetHeroTeamMembers(); for (int j = 0; j < heroList.Count; j++) { Hero h = heroList[j]; h = ((GameObject)Instantiate(h.gameObject)).GetComponent <Hero>(); h.PlayerNo = playerCounter; playerCounter++; h.Type = heroList[j].Type; h.DisplayName = heroList[j].DisplayName; h.name = "Hero" + h.PlayerNo; if (level.Sections[startSection] != null) { // spawn on generated level Debug.Log("Spawn: " + h.name); level.Sections[startSection].RespawnCharacter(h); Debug.Log("Hero is spawned in Section " + startSection + 1); } else { // spawn on fix points like on multiplayermaps if (transform.parent.transform.Find("Spawn Player" + (playerCounter - 1)) == null) { Debug.Log("no spawningpoint found for player " + (playerCounter - 1)); } else { h.transform.position = transform.parent.transform.Find("Spawn Player" + ((playerCounter - 1) + (4 * i))).transform.position; } } teamList[i].RemoveMember(heroList[j]); teamList[i].AddMember(h); } } if (level != null) { for (int k = 0; k < GameManager.GetInstance().HeroCount; k++) { Debug.Log("[CharacterSelection.cs] Add AI hero"); Hero choosenCharacter = ((GameObject)Instantiate(Datasheet.Heroes()[Random.Range(0, 2)])).GetComponent <Hero>(); choosenCharacter.name = "Hero" + playerCounter + "KI"; playerCounter++; choosenCharacter.Type = Hero.Types.AI; Debug.Log("Spawn AI: " + choosenCharacter.name); level.Sections[startSection].RespawnCharacter(choosenCharacter); if (GameManager.GetInstance().TeamCount == 1) { teamList[0].AddMember(choosenCharacter); } } } }