private void OnErrorInPath(AiEntity e) { if (e.GetCurrentTile() != null) { e.SetPath(_aiSystem.CalculateRandomPathByTier(e.GetCurrentTile().GetPosition(), e.getEntityInfo().Tier)); return; } e.SetPath(_aiSystem.CalculateRandomPathByTier(new Vector2(1, 1), e.getEntityInfo().Tier)); }
// Update is called once per frame void Update() { if (!hasgonethrough) { hasgonethrough = true; for (int k = 0; k < enemySpawns.Length; k++) { for (int i = 0; i < enemySpawns[k]; i++) { ArrayList spawnableTiles = AiManager.instance._aiSystem.GetTilesByTier(k + 1); int randomTile = Random.Range(0, spawnableTiles.Count); TileObject targetPosition = (TileObject)spawnableTiles[randomTile]; for (int j = 0; j < usedTiles.Count; j++) { if (targetPosition.GetPosition() == (Vector2)usedTiles[j]) { randomTile = Random.Range(0, spawnableTiles.Count); targetPosition = (TileObject)spawnableTiles[randomTile]; j = 0; } } GameObject newEntity = Instantiate(enemyTiers[k], targetPosition.GetPosition(), Quaternion.identity); AiManager.AddAiEntity(newEntity.GetComponent <AiEntity>()); AiEntity ae = newEntity.GetComponent <AiEntity>(); ae.SetCurrentTile(targetPosition); ae.SetPath(AiManager.instance._aiSystem.CalculateRandomPathByTier(targetPosition.GetPosition(), k + 1)); usedTiles.Add(targetPosition.GetPosition()); } } } }
private void OnDoneInspection(AiEntity e) // doctor { e.SetPath(_aiSystem.CalculateRandomPathByTier(e.GetCurrentTile().GetPosition(), e.getEntityInfo().Tier)); if (e.getEntityInfo().IsDoctor) { e.OnAtTile -= instance.OnAtTile; } }
private void getPath(AiEntity e) { if (e.GetCurrentTile() == null) { return; } // for normal calulate path to random tile e.SetPath(_aiSystem.CalculateRandomPathByTier(e.GetCurrentTile().GetPosition(), e.getEntityInfo().Tier)); }
public void spawnNewDoctor() { ArrayList spawnableTiles = AiManager.instance._aiSystem.GetTilesByTier(doctor.GetComponent <AiEntity>().getEntityInfo().Tier); int randomTile = Random.Range(0, spawnableTiles.Count); TileObject targetPosition = (TileObject)spawnableTiles[randomTile]; GameObject newEntity = Instantiate(doctor, targetPosition.GetPosition(), Quaternion.identity); AiManager.AddAiEntity(newEntity.GetComponent <AiEntity>()); AiEntity ae = newEntity.GetComponent <AiEntity>(); ae.SetCurrentTile(targetPosition); ae.SetPath(AiManager.instance._aiSystem.CalculateRandomPathByTier(targetPosition.GetPosition(), doctor.GetComponent <AiEntity>().getEntityInfo().Tier)); }
private void OnStartInspection(AiEntity e) { if (e.getEntityInfo().IsDoctor) { if (e.getTarget() == null) { e.setTarget(this.getSickEntityInRange(e)); } else { this.doctorCanInspect(e, e.getTarget()); } e.SetPath(_aiSystem.CalulatePathTo(e.GetCurrentTile().GetPosition(), e.getTarget().GetCurrentTile().GetPosition())); e.OnAtTile += instance.OnAtTile; } }
private void OnAtTile(AiEntity e, TileObject t) { // doctor if (e.getEntityInfo().IsDoctor) { if (e.getTarget() == null) { e.setTarget(this.getSickEntityInRange(e)); } else { this.doctorCanInspect(e, e.getTarget()); } if (e.GetCurrentTile().GetPosition() == e.getTarget().GetCurrentTile().GetPosition()) { return; } e.SetPath(_aiSystem.CalulatePathTo(e.GetCurrentTile().GetPosition(), e.getTarget().GetCurrentTile().GetPosition())); } }
static public void SetNewRandomPath(AiEntity e) { e.SetPath(instance._aiSystem.CalculateRandomPathByTier(e.GetCurrentTile().GetPosition(), e.getEntityInfo().Tier)); }