void FixedUpdate() { //Vector2 averagePos = Vector2.Lerp(transform.position, SwarmAI.AveragePosition() + offset, Time.fixedDeltaTime * smooth); Vector2 averagePos = SwarmAI.AveragePosition(); transform.position = new Vector3(averagePos.x, averagePos.y, -10); }
void Update() { AddAreaPoint(); if (Input.GetMouseButtonDown(1)) { isDrawingRegime = !isDrawingRegime; } if (swarmAI.active) { Vector3[] positions = new Vector3[lineRenderer.positionCount]; SwarmAI.SetMainCopterDirectionToArea(_points); } }
public void notifySoldierKilled(int originZone, byte towerSkillerSpawn) { lock (this) { _waveArmyKilled++; if (_waveArmyKilled == _totalArmy) { notifyWaveEnd(); LevelManager.getInstance().waveFinished(); } UIBuilder.INSTANCE.setEnemyArmyText(_totalArmy - _waveArmyKilled); } SwarmAI.getInstance().notifySoldierKill(originZone, towerSkillerSpawn); }
void OnTriggerEnter2D(Collider2D other) { var objectPosX = other.transform.position.x; var objectPosY = other.transform.position.y; switch (other.tag) { case "Fire": Debug.Log($"WARNING fire is detected! Coordinates: {objectPosX}; {objectPosY}"); SwarmAI.SurroundFire((CircleCollider2D)other); break; case "Water": Debug.Log($"Water is detected! Coordinates: {objectPosX}; {objectPosY}"); Vector2 dron2Water = new Vector2(other.transform.position.x - _copter.transform.position.x, other.transform.position.y - _copter.transform.position.y); SwarmAI.AvoidWater(dron2Water); break; } }
public void beginWave(float spawnPace, Dictionary <string, int> waveData) { _spawnPace = spawnPace; _waveArmySize = 0; foreach (int amount in waveData.Values) { _waveArmySize += amount; } _waveArmyKilled = 0; SwarmAI.getInstance().prepareNewWave(); foreach (GameObject spawnController in _spawnZoneControllers.Values) { spawnController.GetComponent <SpawnZoneController> ().setWaveData(_waveArmySize, _spawnPace); spawnController.GetComponent <SpawnZoneController> ().enabled = true; } _totalArmy = _waveArmySize * _spawnZoneControllers.Count; }
public void preComputePaths() { _computedPaths.Clear(); Dictionary <int, SpawnPoint> enemySpawns = SpawnTable.getInstance().getMonsterSpawnPoints(); foreach (int soldierSpawnIndex in enemySpawns.Keys) { SpawnPoint spawnObject = enemySpawns [soldierSpawnIndex]; SpawnPoint target = SpawnTable.getInstance().getTargetSpawns() [0]; float closer = Mathf.Infinity; int index = 0; foreach (int vIndex in target.getBounds().Keys) { float sqrtMag = (target.getBounds() [vIndex] - spawnObject.getAveragePosition()).sqrMagnitude; if (sqrtMag < closer) { closer = sqrtMag; index = vIndex; } } Vector3 finalTarget = Formulas.getPositionInMap(target.getBounds() [index]); Pathfinder pf = new Pathfinder(spawnObject, finalTarget); PathSolution ps = pf.computePaths(); GameObject go = new GameObject("Spawn_Zone_Controller_" + soldierSpawnIndex); go.transform.parent = World.getInstance().getTerrainTransform(); go.transform.position = Formulas.getPositionInMap(spawnObject.getAveragePosition()); // Irrelevant, but still... go.AddComponent <SpawnZoneController> ()._spawnZone = soldierSpawnIndex; _spawnZoneControllers.Add(soldierSpawnIndex, go); _computedPaths.Add(soldierSpawnIndex, ps); } SwarmAI.getInstance().initialize(_computedPaths); }
public void notifyTowerSpawn(byte index) { SwarmAI.getInstance().notifyTowerSpawn(index); }