public void RegisterUnit(GenericAI unit) { if (units == null) { units = new List <GenericAI>(); } units.Add(unit); }
// Update is called once per frame void FixedUpdate() { timeUntilNewWave--; if (timeUntilNewWave == 0) { wave++; int[] coords = CalculateSpawnSquare(); List <Vector2> spawnLocations = new List <Vector2>(); int enemyCountForThisWave = Mathf.RoundToInt(enemyCountPerWave * (TimeKeeper.Instance.GetTimeDayNormalized() / 2.0f + 0.5f)); if (enemyCountForThisWave > maxEnemyCountPerWave) { enemyCountForThisWave = maxEnemyCountPerWave; } for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { if (Pathing.Instance.GetLocationPathValue(coords[0] * 32 + i, coords[1] * 32 + j) >= 3) { spawnLocations.Add(new Vector2(coords[0] * 32 + i + 0.5f, coords[1] * 32 + j + 0.5f)); } if (spawnLocations.Count >= enemyCountPerWave) { break; } } } GameObject formationObject = Instantiate(aiFormationPrefab, Vector3.zero, Quaternion.identity); AIFormation formation = formationObject.GetComponent <AIFormation>(); float waveSpeed = baseSpeed + (3.0f * (wave / 30.0f)); //maxes out at wave 30 float waveHealth = baseHealth + (400.0f * (wave / 60.0f)); //maxes out at wave 60 if (waveSpeed > maxSpeed) { waveSpeed = maxSpeed; } if (waveHealth > maxHealth) { waveHealth = maxHealth; } for (int i = 0; i < spawnLocations.Count; i++) { GameObject enemy = Instantiate(enemyPrefab, spawnLocations[i], Quaternion.identity); GenericAI enemyAI = enemy.GetComponent <GenericAI>(); enemyAI.SetAlliance(enemyAlliance); enemyAI.SetSpeedAndHealth(waveSpeed, waveHealth); formation.RegisterUnit(enemyAI); } formation.SetGroupTarget(target); enemyCountPerWave++; startingTimeForNewWave = startingTimeForNewWave - 300; if (startingTimeForNewWave < minTimePerWave) { startingTimeForNewWave = minTimePerWave; } timeUntilNewWave = startingTimeForNewWave; } }
void getBehavior() { if (thisBehavior == behaviorCategory.player) { thisAI = AIObject.GetComponent <PlayerAI>(); } else if (thisBehavior == behaviorCategory.random) { thisAI = AIObject.GetComponent <RandomAI>(); } else if (thisBehavior == behaviorCategory.mobileAutoAim) { thisAI = AIObject.GetComponent <MobileAutoAimAI>(); } else { thisAI = AIObject.GetComponent <GenericAI>(); } }
private void lst_Classes_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { int selectedClass = lst_Classes.SelectedIndex; _aiFighter = null; GC.Collect(); switch (selectedClass) { case 0: _aiFighter = new RangerAI(); break; case 1: _aiFighter = new LancerAI(); break; case 2: _aiFighter = new PugilistAI(); break; case 3: _aiFighter = new BasicAI() { IsRanged = true }; break; case 4: _aiFighter = new BasicAI(); break; default: _aiFighter = new ScriptAI(); break; } if (chk_HasCure.IsChecked != null) { _aiFighter.HasCure = (bool)chk_HasCure.IsChecked; } }
public void setBaseComponents() { if (foundAllBaseComponents) { return; } genericAI = GetComponent <GenericEnemy>(); DamageManager = GetComponentInChildren <Damagable>(); if (genericAI != null) { genericAI.controller = this; } if (genericAI != null && DamageManager != null) { this.foundAllBaseComponents = true; this.DamageManager.genericAI = genericAI; } }