public void SpawnEnemies(Room spawnRoom, int enemyCount) { EnemyGroup group = new EnemyGroup(); deathCount = 0; if (!spawnRoom.isActive) { spawnRoom.Show(); } for (int i = 0; i < enemyCount; i++) { Vector3 spawnPos = SpawnPosFromRoom(spawnRoom); EnemyCharacter enemy = GameObjectFactory.Instantiate <EnemyCharacter>(enemyPrefab, position: spawnPos); enemy.transform.parent = transform; enemy.Spawn(spawnRoom); enemy.DeathEvent += EnemyDied; enemy.SetRank(Random.Range(1, roundCount + 3)); _enemies.Add(enemy); group.Add(enemy); } }
private void Awake() { Id = TargetId; group = transform.parent.GetComponent <EnemyGroup>(); group.Add(Id, transform.parent.position.XY() + Random.insideUnitCircle.normalized * wanderRadius); GetComponent <HealthComponent>().DeathDelegate += KillEnemy; animator = GetComponent <Animator>(); }
/// <summary> /// Start a fight or switch targets forcibly /// </summary> /// <param name="victim"></param> public void StartFighting(IMobile victim) { var wasFighting = IsFighting(); if (victim == null) { victim = this; } if (victim != GetTarget()) { PrimaryTarget = victim; } if (!EnemyGroup.Any(enemy => enemy.Item1 == PrimaryTarget)) { EnemyGroup.Add(new Tuple <IMobile, int>(PrimaryTarget, 0)); } if (!wasFighting) { Processor.StartSubscriptionLoop("Fighting", () => Round.ExecuteRound(this, victim), 50, false); } }