// Use this for initialization void Start() { agent = GetComponent <NavMeshAgent>(); animator = GetComponentInChildren <Animator>(); enemy = GetComponentInParent <Enemy2Controller>(); enemy.OnAttack += OnAttack; enemy.OnDragonAttack += OnDragonAttack; enemy.OnDragonHeal += OnDragonHeal; enemy.OnMultiAttack += OnMultiAttack; }
// Use this for initialization void Start() { rigidbody = GetComponent <Rigidbody>(); transform = GetComponent <Transform>(); audio = GetComponent <AudioSource>(); shippos = GameObject.Find("shippos"); dir = shippos.transform.position - this.transform.position; e2c = this; }
void PickRandomEnemyTwo() { enemy2 = GameObject.FindGameObjectsWithTag("enemy2"); if (enemy2.Length > 0 && GalagaHelper.isPlayerCaptured == false) { //Debug.Log(enemy2[pickedAtRandom].transform.parent.name.Bold() + " Num: " + pickedAtRandom); Enemy2Controller enemyTwo = enemy2[GalagaHelper.RandomNumber(0, enemy2.Length)].GetComponent <Enemy2Controller>(); if (enemyTwo) { Debug.Log("Found EnemyTwo"); //enemy1[pickedAtRandom] enemyTwo.AttackPlayer = true; enemyTwo.isRandomPicked = true; enemy2Picked = false; } } }
void SpawnEnemy(Transform spawn, Transform freePos) { GameObject defaultEnemyPrefab = new GameObject(); if (GalagaHelper.RoundNumber == 1) { switch (GalagaHelper.CurrentRoundPhase) { case GalagaHelper.Formations.Round1Phase1: if (GalagaHelper.JustSpawned < 4) { defaultEnemyPrefab = enemy1Prefab; //Debug.Log("enemy1 spawned".Colored(Colors.yellow)); } else if (GalagaHelper.JustSpawned > 3 && GalagaHelper.JustSpawned < 9) { defaultEnemyPrefab = enemy2Prefab; //Debug.Log("enemy2 spawned".Colored(Colors.red)); } break; case GalagaHelper.Formations.Round1Phase2: //Debug.Log("Free pos == " + freePos.gameObject.name); if (freePos.gameObject.name.Equals("Position") || freePos.gameObject.name.Equals("Position (1)") || freePos.gameObject.name.Equals("Position (6)") || freePos.gameObject.name.Equals("Position (7)")) { defaultEnemyPrefab = enemy3Prefab; } else { defaultEnemyPrefab = enemy2Prefab; } //if (spawnEntranceRight) //{ // defaultEnemyPrefab = enemy2Prefab; //} //else //{ // defaultEnemyPrefab = enemy3Prefab; //} break; case GalagaHelper.Formations.Round1Phase3: Debug.Log("Free pos == " + freePos.gameObject.name); defaultEnemyPrefab = enemy2Prefab; break; case GalagaHelper.Formations.Round1Phase4: Debug.Log("Free pos == " + freePos.gameObject.name); defaultEnemyPrefab = enemy1Prefab; break; case GalagaHelper.Formations.Round1Phase5: defaultEnemyPrefab = enemy1Prefab; break; default: defaultEnemyPrefab = enemy1Prefab; break; } } else if (GalagaHelper.RoundNumber == 2) { switch (GalagaHelper.CurrentRoundPhase) { case GalagaHelper.Formations.Round1Phase1: if (GalagaHelper.JustSpawned < 4) { defaultEnemyPrefab = enemy1Prefab; //Debug.Log("enemy1 spawned".Colored(Colors.yellow)); } else if (GalagaHelper.JustSpawned > 3 && GalagaHelper.JustSpawned < 9) { defaultEnemyPrefab = enemy2Prefab; //Debug.Log("enemy2 spawned".Colored(Colors.red)); } break; case GalagaHelper.Formations.Round1Phase2: //Debug.Log("Free pos == " + freePos.gameObject.name); if (freePos.gameObject.name.Equals("Position") || freePos.gameObject.name.Equals("Position (1)") || freePos.gameObject.name.Equals("Position (6)") || freePos.gameObject.name.Equals("Position (7)")) { defaultEnemyPrefab = enemy3Prefab; } else { defaultEnemyPrefab = enemy2Prefab; } //if (spawnEntranceRight) //{ // defaultEnemyPrefab = enemy2Prefab; //} //else //{ // defaultEnemyPrefab = enemy3Prefab; //} break; case GalagaHelper.Formations.Round1Phase3: defaultEnemyPrefab = enemy2Prefab; break; case GalagaHelper.Formations.Round1Phase4: defaultEnemyPrefab = enemy1Prefab; break; case GalagaHelper.Formations.Round1Phase5: defaultEnemyPrefab = enemy1Prefab; break; default: defaultEnemyPrefab = enemy1Prefab; break; } } GameObject enemy = SimplePool.Spawn(defaultEnemyPrefab, spawn.position, defaultEnemyPrefab.transform.rotation, true) as GameObject; enemy.GetComponent <MeshCollider>().enabled = true; enemy.GetComponent <Renderer>().enabled = true; enemy.transform.position = spawn.position; enemy.transform.parent = freePos; if (GalagaHelper.RoundNumber > 1) { Enemy1Controller EC1 = enemy.GetComponent <Enemy1Controller>(); if (EC1) { EC1.ResetVars(); EC1.isEnemyFiring = false; EC1.Start(); } Enemy2Controller ec2 = enemy.GetComponent <Enemy2Controller>(); if (ec2) { ec2.ResetVars(); ec2.isEnemyFiring = false; ec2.AttackPlayer = false; ec2.Start(); } Enemy3Controller ec3 = enemy.GetComponent <Enemy3Controller>(); if (ec3) { ec3.ResetVars(); ec3.isEnemyFiring = false; ec3.Start(); } } Debug.Log("Enemy Name: " + enemy.name + " Parent: " + enemy.transform.parent.parent.name.Colored(Colors.blue) + " Position: " + enemy.transform.parent.name.Colored(Colors.blue)); //GalagaHelper.EnemiesSpawned += 1; GalagaHelper.JustSpawned += 1; }