public static void SetEnemy2Random() { if (Enemy2Random == 0) { Enemy2Random = GalagaHelper.RandomNumber(1, 3); } }
public static void SetAttackinMotion() { MainEnemyFormation mainEnemyForm = GameObject.FindGameObjectWithTag("MainFormation").GetComponent <MainEnemyFormation>(); if (mainEnemyForm && GalagaHelper.EnemiesKilled < 41) { int x = GalagaHelper.RandomNumber(0, 7); if (x == 1) { mainEnemyForm.enemy1Picked = true; } else if (x == 2) { mainEnemyForm.enemy2Picked = true; } else if (x == 3) { mainEnemyForm.enemy3Picked = true; } else if (x == 4) { PrintAllGhostObjects(); } else if (x == 5) { mainEnemyForm.enemy1Picked = true; } else { mainEnemyForm.enemy1Picked = true; } //Debug.Log("Ran random attacks: ".Colored(Colors.green) + x.ToString().Bold()); } }
void PickRandomEnemyThreeAttack() { enemy3 = GameObject.FindGameObjectsWithTag("enemy3"); if (enemy3.Length > 0 && GalagaHelper.isPlayerCaptured == false) { Enemy3Controller enemyThree = enemy3[GalagaHelper.RandomNumber(0, enemy3.Length)].GetComponent <Enemy3Controller>(); if (enemyThree) { Debug.Log("Found Enemy Three"); int randomTractorBeam = GalagaHelper.RandomNumber(0, 10); //6 if (randomTractorBeam == 3 && GalagaHelper.isTractorBeamOn == false && GalagaHelper.isPlayerCaptured == false) { enemyThree.isTractorBeamAttack = true; } else { if (!GalagaHelper.isTractorBeamOn) { enemyThree.isAttackPlayer = true; } } enemyThree.isRandomPicked = true; enemy3Picked = false; } } }
void PickRandomEnemyOne() { enemy1 = GameObject.FindGameObjectsWithTag("enemy1"); if (enemy1.Length > 0 && GalagaHelper.isPlayerCaptured == false) { int randScorpion = GalagaHelper.RandomNumber(0, 5); Debug.Log("Enemy1 RandNumber: ".Colored(Colors.red) + randScorpion.ToString().Colored(Colors.red)); Enemy1Controller enemyOne = enemy1[GalagaHelper.RandomNumber(0, enemy1.Length)].GetComponent <Enemy1Controller>(); if (enemyOne) { if (randScorpion == 3 && GalagaHelper.isTractorBeamOn == false) { enemyOne.startScorpionAttack = true; } else { //Debug.Log("Found EnemyOne"); enemyOne.CreatePath(); //enemyOne.isEnemyFiring = true; } enemyOne.isRandomPicked = true; enemy1Picked = false; } } }
void OnTriggerEnter(Collider other) { Debug.Log("Something hit an enemy4".Colored(Colors.navy)); Projectile playerBullet = other.gameObject.GetComponent <Projectile>(); if (playerBullet) { health -= playerBullet.GetDamage(); playerBullet.Hit(); Debug.Log(gameObject.name.Colored(Colors.red).Bold() + " Enemy hit!".Bold().Colored(Colors.red)); // BEE: if formation = 50 points, diving == 100 if (isNotInFormation) { scoreKeeper.Score(100); } else { scoreKeeper.Score(50); } if (health <= 0) { top = base.addShotSounds(explosionTop[GalagaHelper.RandomNumber(0, explosionTop.Length)], Random.Range(0.8f, 1.2f)); bottom = base.addShotSounds(explosionBottom, Random.Range(0.8f, 1.2f)); top.PlayScheduled(0.3); bottom.Play(); //rend.enabled = false; //meshcol.enabled = false; GameObject explosionPrefab = Instantiate(explosion, gameObject.transform.position, gameObject.transform.rotation) as GameObject; Destroy(explosionPrefab, 3.0f); //Debug.Log("Enemy1 killed: " + gameObject.name.Colored(Colors.blue) + " Parent: " + gameObject.transform.parent.parent.name.Colored(Colors.blue) + " Position: " + gameObject.transform.parent.name.Colored(Colors.blue)); this.isEnemyFiring = false; DisableEnemy(); //Invoke("DisableEnemy", spawnDisableTime); GalagaHelper.EnemiesKilled += 1; if (base.isRandomPicked == true) { isRandomPicked = false; main.isEnemy1Done = true; } iTween onTween = gameObject.GetComponent <iTween>(); if (onTween) { if (onTween.isRunning) { Debug.Log("Enemy4 Killed during Itween".Colored(Colors.red).Bold()); GalagaHelper.isScorpionAttackOn = false; //onTween.isRunning = false; //GalagaHelper.EnemiesSpawned += 1; } } //if (startScorpionAttack) //{ // startScorpionAttack = false; //} SimplePool.Despawn(gameObject); } } }
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; } } }
/// <summary> /// Create path based on points around player. /// </summary> public void CreatePath() { isNotInFormation = true; PlayerController player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>(); tweenPath.Clear(); if (player) { _waypoints.Clear(); _waypoints.Add(transform.position); _originalPosition = transform.position; //Debug.Log(_waypoints[0].ToString().Bold()); player.GetCirclePathScorpions(); Vector3[] pathToPlayer = new Vector3[5]; pathToPlayer = player.scorpionCirclePath; // chose random swoops choosePath = GalagaHelper.RandomNumber(0, 2); switch (choosePath) { case 0: Debug.Log("Path: Circle Player then swoop back up.".Colored(Colors.purple)); break; case 1: Debug.Log("Path: Circle Player then re-appear on top.".Colored(Colors.red)); break; default: Debug.Log("Path: other than 0 or 1 picked.".Colored(Colors.purple)); break; } // Path0 = circle then swoop back up // Path1 = circle then reappear on top if (choosePath == 0) { //_waypoints.Add(GameObject.FindGameObjectWithTag("Point2").GetComponent<Transform>().position); //for (int i = 0; i < 8; i++) for (int i = 0; i < 5; i++) { _waypoints.Add(pathToPlayer[i]); } _waypoints.Add(pathToPlayer[0]); //_waypoints.Add(GameObject.FindGameObjectWithTag("Point2").GetComponent<Transform>().position); Vector3[] newVect30 = new Vector3[_waypoints.Count]; for (int i = 0; i < _waypoints.Count; i++) { newVect30[i] = _waypoints[i]; Debug.Log(gameObject.name.ToString().Bold() + " Path Swoop " + i + ": " + newVect30[i].ToString().Bold()); } // _waypoints.Add(_originalPosition); tweenPath.Add("path", newVect30); tweenPath.Add("time", swoopDownSpeed); tweenPath.Add("easetype", "linear"); tweenPath.Add("orienttopath", true); tweenPath.Add("onComplete", "Path1Complete"); tweenPath.Add("onCompleteTarget", gameObject); iTween.MoveFrom(gameObject, tweenPath); audio = base.addShotSounds(swooshSound, 1.0f); audio.Play(); //this.isEnemyFiring = true; } else { this.isEnemyFiring = true; _waypoints.Add(GameObject.FindGameObjectWithTag("Point2").GetComponent <Transform>().position); //for (int i = 0; i < 9; i++) for (int i = 0; i < 5; i++) { _waypoints.Add(pathToPlayer[i]); } //_waypoints.Add(GameObject.FindGameObjectWithTag("Point2").GetComponent<Transform>().position); //Debug.Log("Waypoints Count: " + _waypoints.Count); Vector3[] newVect3 = new Vector3[_waypoints.Count]; //Debug.Log(_waypoints.Count.ToString().Bold().Italics()); for (int i = 0; i < _waypoints.Count; i++) { newVect3[i] = _waypoints[i]; Debug.Log(gameObject.name.ToString().Bold() + " Path reappear on top " + i + ": " + newVect3[i].ToString().Bold()); } tweenPath.Add("path", newVect3); tweenPath.Add("time", swoopDownSpeed); tweenPath.Add("easetype", "linear"); tweenPath.Add("orienttopath", true); tweenPath.Add("onComplete", "CircleComplete"); tweenPath.Add("onCompleteTarget", gameObject); iTween.MoveTo(gameObject, tweenPath); audio = base.addShotSounds(swooshSound, 1.0f); audio.Play(); //this.isEnemyFiring = true; } } }