public void Init(Vector3 target) { targetPosition = target; activated = true; Vector3 direction = targetPosition - transform.position; direction.Normalize(); directionStep = direction * velocity; SampleTriggered sampleTriggered = GetComponent <SampleTriggered>(); sampleTriggered.activated = false; }
void CreateEnemies(MusicManager musicManager) { for (int a = 0; a < 64; a++) { GameObject enemyInstance = (GameObject)Instantiate(enemyPrefab); //Subscribe the enemy to enemyManager EnemyBehavior enemyBehavior = enemyInstance.GetComponent <EnemyBehavior>(); enemyManager.AddEnemy(enemyBehavior); // Subscribe the enemy to soundManader to animate them SampleTriggered soundTriggeredComponent = enemyInstance.GetComponent <SampleTriggered>(); soundTriggeredComponent.Init(a); musicManager.SubscribeSampleSubscriber(soundTriggeredComponent); enemyInstance.transform.position = this.transform.position; enemyInstance.transform.parent = this.transform; this.transform.eulerAngles = new Vector3(0, -5.625f * a, 0); enemyInstance.transform.position = new Vector3((float)0f, (float)this.transform.position.y, (float)radius); satelites[a] = enemyInstance; } }
public void SubscribeSampleSubscriber(SampleTriggered subscriber) { sampleSubscribers.Add(subscriber); }