// N/A #endregion #region Encounter Methods /// <summary> /// Sets up an encounter /// CALLED BY ENEMIES /// </summary> public void StartEncounter(Encounter enc, Enemy.EnemyFaction hitEnemyFaction, Encounter.SpecialEncounters encounterType) { //change music to combat at encounter start SoundManager.PlayMusic(SoundManager.Music.Combat, this.gameObject); if (encounterActive) { MergeEncounters(); } Helper.DebugLogDivider(); //Reset aggression encounterAggressionCurrent = 0f; //Set flagged for being in an encounter encounterActive = true; //Set encounter type currentEncounterType = encounterType; //Update position of the encounter (which will simply be used as this object's location for debug purposes) this.transform.position = enc.transform.position; //Grab enemies within range and add them to the encounter for (int i = 0; i < zoneEnemies.Count; ++i) { //Try to add enemy to encounter if ((enc.transform.position - zoneEnemies[i].transform.position).sqrMagnitude <= Mathf.Pow(enc.Range, 2)) { encounterEnemies.Add(zoneEnemies[i]); zoneEnemies[i].GetComponent <Enemy>().StartEncounter(); } if (encounterEnemies.Count > 6) { Debug.Log("More than 6 enemies in encounter!"); Debug.Break(); throw new UnityException();//Don't allow more than 6 enemies in an encounter... if this line of code triggers then we need to fix something } } // spawn any extra enemies foreach (int key in enc.categoryXEnemies) { SpawnExtraEnemies(key); // spawn any extra enemies } Debug.Log("Starting Encounter... Enemies = " + encounterEnemies.Count + ", now assigning attack targets... @ " + Time.fixedTime); //Now that we have all the encounter enemies setup, we can assign attack targets for (int i = 0; i < encounterEnemies.Count; ++i) { Enemy e = encounterEnemies[i].GetComponent <Enemy>(); //Tell the enemies not to ally the player if they're of an opposing faction if (e.faction == hitEnemyFaction) { e.AlliedWithPlayer = false; //Try to add enemy to grid cell if they're not allied with the player e.MoveTarget = SendNewMoveTarget(e); } else { e.AlliedWithPlayer = true; e.gameObject.GetComponent <Entity>().SpeedModifier *= allySpeedMultiplier;//NOTE: This was changed to use multiplication to test the new speed system @ 11/8 e.AttackTarget = GetNewAttackTarget(e.faction); } } }
/// <summary> /// Converts a special encounter type enum to a wave ID enum /// </summary> /// <param name="encType">Special encounter type</param> /// <returns>Wave ID</returns> public WaveIDs SpecialEncounterTypeToWaveID(Encounter.SpecialEncounters encType) { WaveIDs result = WaveIDs.NONE; switch (encType) { case Encounter.SpecialEncounters.CastleKeepFinalEncounter: result = WaveIDs.KingOfDarkFinalBoss; break; case Encounter.SpecialEncounters.ThroneRoomFinalEncounter: result = WaveIDs.KingOfManFinalBoss; break; default: throw new UnityException("ERROR: Bad encounter type input!"); } return result; }