public void SpawnHero(WaveHero heroDef)
	{
		if (heroDef != null)
		{
			GameObject newHero = entityFactory.GenerateHero(heroDef.heroName);
			newHero.name = newHero.name + num++;
			newHero.transform.position = transform.position;
			
			//Add the hero to the correct party.
			partyManager.AddHeroToParty(heroDef.partyName, newHero.GetComponent<HeroComponent>());
		}		
	}
	/// <summary>
	/// Loads the next hero in the current wave into nextHeroToSpawn.
	/// </summary>
	/// <returns>
	/// True if the next hero is valid, false if the end of the wave was passed.
	/// </returns>
	protected bool LoadNextHero()
	{
		nextHeroToSpawn = waves[currWave].GetNext();
		bool valid = false;
		
		if (nextHeroToSpawn.heroName != String.Empty)
		{
			timeUntilNextSpawn = nextHeroToSpawn.delay;
			
			valid = true;			
		}
		else
			nextHeroToSpawn = null;
		
		return valid;		
	}
	protected void SpawnNewHero(WaveHero nextHeroToSpawn)
	{
		//Locate the correct spawner for the hero.
		HeroSpawner spawner = spawners[nextHeroToSpawn.spawnerName];
		
		//Have the Spawner spawn the hero
		spawner.SpawnHero(nextHeroToSpawn);		
	}
	/// <summary>
	/// Updates the HeroWaveManager and decides if new heroes need to be spawned.
	/// </summary>
	public void Update()
	{	
		//If we're paused then just return and do nothing for now...
		if (Paused)
			return;
		
		//Don't do anything regarding spawning heroes unless we are actually launching a wave!
		if (waveState == WaveState.LaunchingWave)
		{
			timeSinceLastSpawn += Time.deltaTime;
			
			//If we have a hero to spawn and it's time to spawn them then fire the event!
			if (nextHeroToSpawn != null && timeSinceLastSpawn >= timeUntilNextSpawn)
			{
				SpawnNewHero(nextHeroToSpawn);
				nextHeroToSpawn = null;
				timeSinceLastSpawn = 0.0f;
			}
			
			//If we don't have a next hero to spawn then load one
			if (nextHeroToSpawn == null)
			{
				bool valid = LoadNextHero();
				
				//If we didn't get a valid hero back then fire the wave completed spawning event.
				if (!valid)
					OnWaveCompletedSpawning();
			}			
		}
		else if ((waveState == WaveState.WaitingForEndOfWave || waveState == WaveState.Completed) && NumHeroesAlive == 0)
		{
			waveState = WaveState.WaitingToStartWave;
			OnAllWaveEnemiesDefeated(currWave);
			setupNextWave = true;
		}
			
		if (setupNextWave && waveState == WaveState.WaitingToStartWave)
		{
			waveGUIManager.EnableStartWaveButton();	
			OnNextWaveReady(currWave);		
			setupNextWave = false;
		}
	}	
예제 #5
0
	/// <summary>
	/// Adds a hero to the wave following the definition in the provided XmlNode.
	/// </summary>
	/// <param name="node">
	/// The XmlNode containing the definition of the hero to be added to the wave.
	/// </param>
	protected void AddWaveHero(XmlNode node)
	{
		string type = node.Attributes["type"].Value;
		string partyName = node.Attributes["party"].Value;
		string spawnerName = node.Attributes["spawner"].Value;
		float delay = float.Parse(node["delay"].InnerText, NumberStyles.Float, CultureInfo.InvariantCulture);
		
		WaveHero waveHero = new WaveHero(type, partyName, spawnerName, delay);
		waveHero.heroInfo = entityFactory.GetHeroInfo(type);
		
		waveHeroes.Add(waveHero);		
	}
예제 #6
0
	/// <summary>
	/// Gets the next Hero in this Wave to be spawned,
	/// </summary>
	/// <returns>
	/// The name of the Hero and time delay information for the next Hero to be spawned for this Wave.
	/// If the Wave is completed the WaveHero returned contains the empty string.
	/// </returns>
	public WaveHero GetNext()
	{
		WaveHero hero;
		
		if (currHero < NumHeroes)
		{
			hero = waveHeroes[currHero];
			currHero++;			
		}
		else
			hero = new WaveHero(String.Empty, String.Empty, String.Empty, -1.0f);
		
		return hero;		
	}	
	void HandleOnSpawnNewHero(WaveHero hero)
	{
		waveInfoScrollList.RemoveItem(0, true);
	}