/// <summary> /// Set the active harness and formation mode by name /// </summary> /// <param name="aHarnessName">The name of the Harness to switch to</param> /// <param name="aFormationMode">The formation mode to use on the new harness</param> private void SetActiveHarness(string aHarnessName, string aFormationMode = null) { currentHarness = aHarnessName; activeHarness = null; for (int i = 0; i < harnesses.Count; i++) { FormationHarness tHarness = harnesses[i]; if (tHarness == null) continue; if ((activeHarness == null) && (tHarness.name == aHarnessName)) { tHarness.gameObject.SetActive(true); activeHarness = tHarness; } else tHarness.gameObject.SetActive(false); } FormationMode = aFormationMode; }
/// <summary> /// Vacate our current harness, releasing our slot. Attempt to find a new harness from the commander's formation harness /// </summary> /// <param name="ai">The AI executing the action</param> private void SwapHarness(AI ai) { if (_commander == null) { Vacate(ai); _harness = null; return; } FormationHarness tNewHarness = _commander.GetComponentInChildren<FormationHarness>(); if (_harness != tNewHarness) { Vacate(ai); _harness = tNewHarness; } }
/// <summary> /// Vacate our current harness, releasing our slot. Attempt to find a new harness with the name "attack" /// If no harness is found, add a new ScatteredRadiusTarget and use that /// </summary> /// <param name="ai">The AI executing the action</param> private void SwapHarness(AI ai) { Vacate(ai); _harness = null; if (_enemy == null) return; FormationHarness[] tHarnesses = _enemy.GetComponentsInChildren<FormationHarness>(); for (int i = 0; i < tHarnesses.Length; i++) { if (tHarnesses[i].harnessName == "attack") { _harness = tHarnesses[i]; return; } } //If there isn't one already on the enemy, add one ScatteredRadiusFormationHarness tNewHarness = _enemy.AddComponent<ScatteredRadiusFormationHarness>(); tNewHarness.harnessName = "attack"; tNewHarness.maxPositions = 10; tNewHarness.positionDistance = 12f; tNewHarness.scatterWeight = 0.5f; tNewHarness.scatterFrequency = 10f; _harness = tNewHarness; }