/// <summary> /// override method call when the plane is destroyed, if killed by enemy is calling to change the points /// Also calling to the Factory Enemies telling that this plane is destoyed /// </summary> /// <param name="destroyedByPlayer"></param> public override void DestroyPlane(bool destroyedByPlayer = true) { // if the plane was destroyed by the player, increment the level score in the level manager if (destroyedByPlayer) { GameManager.Instance.LevelManager.LevelScore += _points; } // calling the enemy factory about the plane destruction FactoryEnemies.DestroyEnemy(this); }
/// <summary> /// method called when a enemy should be spawn, /// -create the enemy with the enemy factory /// -call the method "CreateEnemyBehaviorFSM" for create the enemy state machine with the spawn info data /// -set the FSM to the enemy /// -add the FSM to the list /// -remove the spawn info from the level spawn info /// </summary> private void processEnemyInfo() { // create the enemy EnemyEntity enemyBeingSpawn = FactoryEnemies.CreateEnemy(_enemiesSpawnInfo[0].EnemyPrefab); // create the FSM for the enemy with the spawn data FSMachine machine = CreateEnemyBehaviorFSM(enemyBeingSpawn, _enemiesSpawnInfo[0]); // set the behavior var for the enemy enemyBeingSpawn.GetComponentInChildren <EnemyBehavior>().Behavior = machine; // adding the enemy to the FSM AddNewEnemyFSM(machine); // remove for the info _enemiesSpawnInfo.RemoveAt(0); }