/// <summary> /// Create path based on wave number. /// </summary> /// <param name="wave"></param> public void CreatePathAndMove(GalagaHelper.Formations form, int RoundNumber) { GalagaHelper.ClearWavePath(); GalagaHelper.GetWavePaths(form, RoundNumber); GalagaHelper.Wave1Delay += 0.06f; if ((int)form == 2 || (int)form == 3) { myTween.Add("path", GalagaHelper.SecondWavePath); if (gameObject.name == "EnemyTwo (16)" || gameObject.name == "EnemyOne (12)") { Debug.Log(GalagaHelper.SecondWavePath[10].ToString().Bold().Colored(Colors.darkblue)); } } else { myTween.Add("path", GalagaHelper.FourthWavePath); if (gameObject.name == "EnemyTwo (16)" || gameObject.name == "EnemyOne (12)") { Debug.Log(GalagaHelper.FourthWavePath[7].ToString().Bold().Colored(Colors.darkblue)); } } myTween.Add("time", movePathTime); myTween.Add("delay", GalagaHelper.Wave1Delay); myTween.Add("easetype", "linear"); myTween.Add("onComplete", "EnemyCompletePath"); myTween.Add("onCompleteTarget", gameObject); iTween.MoveTo(gameObject, myTween); Debug.Log(gameObject.name.Italics().Bold().Colored(Colors.red) + " has added Itween path.".Colored(Colors.red)); }
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()); } }
private void Update() { if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return)) { SceneManager.LoadScene(GalagaHelper.GetScene(Scene.Stage)); } }
void Update() { // Get the number of enemies in place on the current Formation //enemiesInPlace = isEnemyInPlace(); //+ " - enemies in place: " + enemiesInPlace.ToString().Colored(Colors.red if (gameObject.name == "Round1Phase1EnemyFormation") { Debug.Log(gameObject.name.Bold() + " Just Spawned: " + GalagaHelper.JustSpawned + " Enemies Spawned: " + GalagaHelper.EnemiesSpawned + " Enemies Killed: " + GalagaHelper.EnemiesKilled + " Enemies Disabled: " + GalagaHelper.DisabledEnemies + " PlayerLifes: " + GalagaHelper.numOfPlayers); // Check if 8 enemies have spawned then run them GalagaHelper.StartRound1(); if (GalagaHelper.EnemiesKilled >= GalagaHelper.JustSpawned && GalagaHelper.JustSpawned != 0) { Debug.Log("Round2 started".Bold().Sized(11)); // Reset Variables GalagaHelper.ResetFormations(); GalagaHelper.CurrentRoundPhase = GalagaHelper.Formations.Round1Phase1; GalagaHelper.RoundNumber += 1; MainEnemyFormation main = GameObject.FindGameObjectWithTag("MainFormation").GetComponent <MainEnemyFormation>(); main.RestartRound(); GalagaHelper.EnemiesKilled = 0; GalagaHelper.JustSpawned = 0; GalagaHelper.EnemiesSpawned = 0; GalagaHelper.DisabledEnemies = 0; GalagaHelper.isWaveOneStarted = false; SpawnUntilFull(); } } }
/// <summary> /// Spawn every enemy in the formation that you are in and then switch to the next wave. Uses Invoke /// Command to call it self and when full then it sets the currentroundphase to the next wave. /// </summary> public void SpawnUntilFull() { // Get the ntxt Free position that is empty in the formation. Transform freePosition = NextFreePosition(); Transform spawnPoint = GalagaHelper.RespawnPoint(gameObject.name, spawnEntranceRight); if (freePosition) { currentSpawnPos = freePosition; // Alternate between Left and Right entrance. if (spawnEntranceRight) { spawnEntranceRight = false; } else { spawnEntranceRight = true; } // Spawn enemy in enemy1Prefab. SpawnEnemy(spawnPoint, freePosition); } if (NextFreePosition() && this.isFull == false) { Debug.Log(gameObject.name.Bold() + " Free position"); Invoke("SpawnUntilFull", spawnDelay); } else { isFormationUp = true; Debug.Log(gameObject.name + " is formUp"); //GalagaHelper.CurrentRoundPhase += 1; } }
void Start() { // Formations form1 = GameObject.FindGameObjectWithTag("phase1").gameObject; form2 = GameObject.FindGameObjectWithTag("phase2").gameObject; form3 = GameObject.FindGameObjectWithTag("phase31").gameObject; form4 = GameObject.FindGameObjectWithTag("phase41").gameObject; form5 = GameObject.FindGameObjectWithTag("phase51").gameObject; // Movement float distance = transform.position.z - Camera.main.transform.position.z; Vector3 leftMost = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, distance)); Vector3 rightMost = Camera.main.ViewportToWorldPoint(new Vector3(1, 0, distance)); xMin = leftMost.x + padding; xMax = rightMost.x - padding; moveFormation = false; GalagaHelper.RoundNumber = 1; // Starts the Game. Invoke("StartRound", 3.0f); GalagaHelper.SetPlayerIcons(); GalagaHelper.PlacePlayerIcons(); playerText = GameObject.Find("PlayerText"); roundText = GameObject.Find("RoundTitle"); playerTextHigh = GameObject.Find("PlayerTextHigh"); readyText = GameObject.Find("ReadyText"); //playerController = GameObject.FindGameObjectWithTag("CapturedPlayer").GetComponent<PlayerController>(); starfield = GameObject.FindGameObjectWithTag("Starfield").GetComponent <ParticleSystem>(); playerText.SetActive(true); roundText.SetActive(false); playerTextHigh.SetActive(false); readyText.SetActive(false); //roundTextPos = playerText.transform.position; }
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; } } }
public static void SetEnemy2Random() { if (Enemy2Random == 0) { Enemy2Random = GalagaHelper.RandomNumber(1, 3); } }
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); } } }
public override void OnCollision(Collider2D collision) { if (collision.gameObject.tag == GalagaHelper.GetTag(Tag.Player)) { GameManager.Instance.Ship.Lives--; Destroy(gameObject); } }
//private void Move() //{ // transform.position = new Vector2(transform.position.x, transform.position.y - Speed * Time.deltaTime); // Vector3 down = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, Camera.main.nearClipPlane)); // Vector3 up = Camera.main.ViewportToWorldPoint(new Vector3(0, 1, Camera.main.nearClipPlane)); // if (transform.position.y > up.y || transform.position.y < down.y) // { // transform.position = new Vector2(transform.position.x, -transform.position.y); // } //} private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == GalagaHelper.GetTag(Tag.Player)) { GameManager.Instance.Ship.Lives--; Destroy(collision.gameObject); Destroy(gameObject); } }
public override void OnCollision(Collider2D collision) { if (collision.gameObject.tag == GalagaHelper.GetTag(Tag.Enemy)) { var enemy = collision.gameObject.GetComponent <Enemy>(); GameManager.Instance.Score += enemy.Score; Destroy(collision.gameObject); Destroy(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; } } }
public void EnemyBack() { GameObject[] enemyFours = new GameObject[3]; enemyFours = GameObject.FindGameObjectsWithTag("enemy4"); for (int i = 0; i < enemyFours.Length; i++) { enemyFours[i].GetComponent <Transform>().rotation = GalagaHelper.enemyFourOrigRotation; if (i > 0) { SimplePool.Despawn(enemyFours[i]); enemyFours[i].transform.parent = null; } } GalagaHelper.RemoveScorpionPaths(); GameObject.FindGameObjectWithTag("MainFormation").GetComponent <MainEnemyFormation>().isEnemy1Done = true; GalagaHelper.isScorpionAttackOn = false; //Debug.Log("Enemy 4 orig rotation".Colored(Colors.red)); }
private void Update() { base.Update(); if (startScorpionAttack) { GalagaHelper.isScorpionAttackOn = true; form1.GetComponent <EnemySpawner>().CreateEnemy4Trio(this.transform, this.transform.parent.transform); GetComponent <Renderer>().enabled = false; gameObject.transform.parent = null; SimplePool.Despawn(gameObject); GalagaHelper.StartScorpionPaths(); startScorpionAttack = false; } // if enemy has made it to last point then reappear from top // of screen. if (_finishedPath) { //this.isEnemyFiring = false; CreateIncomingPath(); if (_isOnPath) { iTween.PutOnPath(gameObject, _waypoints.ToArray(), _pathPercentage); _pathPercentage += Time.deltaTime * returnPathSpeed / 10; //Debug.Log("path Percent: " + _pathPercentage); if (_pathPercentage > 1) { _isOnPath = false; _finishedPath = false; _pathPercentage = 0; transform.rotation = _originalRotation; main.isEnemy1Done = true; isNotInFormation = false; } } } }
void SendBackToOriginalPos() { if (!isSentBack) { isSentBack = true; iTween.MoveTo(gameObject, _originalPosition, 2.3f); if (playerController.playerCaptured == true) { GalagaHelper.isPlayerCaptured = true; main.isReadyDone = false; GalagaHelper.numOfPlayers += 1; GalagaHelper.PlacePlayerIcons(); player.position = player.position + new Vector3(0, 0, 11.5f); //playerController.enabled = false; CreateNewPlayer(); } sweepTractorBeam = false; // Turn off raycast sweep outOfPlayerRange = false; // this sets the tractor beam in place gotOriginalPosition = false; // first position of enemy3 isTractorBeamAttack = false; // Tractor beam attack setup isNotInFormation = false; // set for getting scorevalues and for ?? GalagaHelper.isTractorBeamOn = false; } }
void Update() { #region SetBeginningText // Set the player text to show like Galaga if (GalagaHelper.RoundNumber == 1) { GalagaHelper.TimeToSpawn = Time.time; GalagaHelper.StartTime = Time.time; } else { GalagaHelper.TimeToSpawn = Time.time - GalagaHelper.StartTime; Debug.Log("Time to Spawn: ".Colored(Colors.red) + GalagaHelper.TimeToSpawn.ToString() + " Time since loaded: ".Colored(Colors.red) + Time.timeSinceLevelLoad); } //Debug.Log(GalagaHelper.TimeToSpawn.ToString().Bold()); if (GalagaHelper.TimeToSpawn > 0f && GalagaHelper.TimeToSpawn < 2.0f) { //Debug.Log("See player text?".Bold()); // show player1 first playerText.SetActive(true); playerTextHigh.SetActive(false); } else if (GalagaHelper.TimeToSpawn > 2.0f && GalagaHelper.TimeToSpawn < 3.5f) { // show round title same place // Debug.Log("See player text?".Bold()); playerText.SetActive(false); roundText.transform.position = playerText.transform.position; roundText.SetActive(true); } else if (GalagaHelper.TimeToSpawn > 3.5f && GalagaHelper.TimeToSpawn < 5.3f) { //Debug.Log("See player text?".Bold()); // Show both playerText.transform.position = playerTextHigh.transform.position; playerText.SetActive(true); roundText.SetActive(true); } else { playerText.SetActive(false); roundText.SetActive(false); isTextDone = true; //Debug.Log("isTextDone eq true"); //timeBetweenSpawn = 0; } #endregion if (GalagaHelper.JustSpawned == 8) { form1.GetComponent <EnemySpawner>().isFull = true; Debug.Log("Form 1 Full".Colored(Colors.green).Bold()); } else if (GalagaHelper.JustSpawned == 16) { form2.GetComponent <EnemySpawner>().isFull = true; this.secondWaveFinished = true; Debug.Log("Form 2 Full".Colored(Colors.green).Bold()); } else if (GalagaHelper.JustSpawned == 24) { form3.GetComponent <EnemySpawner>().isFull = true; this.thirdWaveFinished = true; Debug.Log("Form 3 Full".Colored(Colors.green).Bold()); } else if (GalagaHelper.JustSpawned == 32) { form4.GetComponent <EnemySpawner>().isFull = true; this.fourthWaveFinished = true; Debug.Log("Form 4 Full".Colored(Colors.green).Bold()); } else if (GalagaHelper.JustSpawned == 40) { form5.GetComponent <EnemySpawner>().isFull = true; Debug.Log("Form 5 Full".Colored(Colors.green).Bold()); } //Debug.Log("Time to Spawn: " + GalagaHelper.TimeToSpawn.ToString().Italics()); //Debug.Log(GalagaHelper.CurrentRoundPhase.ToString().Bold()); //Debug.Log("Player lives: ".Bold() + GalagaHelper.numOfPlayers.ToString().Bold()); if (GalagaHelper.CurrentRoundPhase == GalagaHelper.Formations.Round1Phase2 && GalagaHelper.TimeToSpawn > 8.0f) // && GalagaHelper.TimeToSpawn > 11.0f { //GameObject pt2 = GameObject.FindGameObjectWithTag("phase2").gameObject; Debug.Log("Round2 enabled".Colored(Colors.purple)); form2.GetComponent <EnemySpawner>().enabled = true; if (form2.GetComponent <EnemySpawner>().isFormationUp) { Debug.Log("form2 isFormationUp == True; Enemies Just: ".Bold() + GalagaHelper.JustSpawned + " Enemies Spawned: ".Bold() + GalagaHelper.EnemiesSpawned); GalagaHelper.CurrentRoundPhase += 1; if (GalagaHelper.RoundNumber == 2) { form2.GetComponent <EnemySpawner>().SpawnUntilFull(); } } } else if (GalagaHelper.CurrentRoundPhase == GalagaHelper.Formations.Round1Phase3 && secondWaveFinished && GalagaHelper.TimeToSpawn > 15f) //&& GalagaHelper.TimeToSpawn > 15 { //Debug.Log("Round3 enabled".Colored(Colors.purple)); form3.GetComponent <EnemySpawner>().enabled = true; Debug.Log("Round3 enabled. form3 isFormationUp: " + form3.GetComponent <EnemySpawner>().isFormationUp); if (form3.GetComponent <EnemySpawner>().isFormationUp) { GalagaHelper.CurrentRoundPhase += 1; if (GalagaHelper.RoundNumber == 2) { form3.GetComponent <EnemySpawner>().SpawnUntilFull(); } } } else if (GalagaHelper.CurrentRoundPhase == GalagaHelper.Formations.Round1Phase4 && thirdWaveFinished && GalagaHelper.TimeToSpawn > 19f) //&& GalagaHelper.TimeToSpawn > 20 { Debug.Log("Round4 enabled".Colored(Colors.purple)); form4.GetComponent <EnemySpawner>().enabled = true; if (form4.GetComponent <EnemySpawner>().isFormationUp) { GalagaHelper.CurrentRoundPhase += 1; if (GalagaHelper.RoundNumber == 2) { form4.GetComponent <EnemySpawner>().SpawnUntilFull(); } //thirdWaveFinished = false; } } else if (GalagaHelper.CurrentRoundPhase == GalagaHelper.Formations.Round1Phase5 && fourthWaveFinished && GalagaHelper.TimeToSpawn > 24.0f) //&& GalagaHelper.TimeToSpawn > 18 { Debug.Log("Round5 enabled".Colored(Colors.purple)); form5.GetComponent <EnemySpawner>().enabled = true; GalagaHelper.PrintAllGhostObjects(); Debug.Log("Deleting all ghosts.".Colored(Colors.green)); Invoke("StartEnemyAttack", 5.0f); //moveFormation = true; fourthWaveFinished = false; if (GalagaHelper.RoundNumber == 2) { form5.GetComponent <EnemySpawner>().SpawnUntilFull(); } } // Move formation left and right if (moveFormation) { #region MoveCode //if (isMovingRight) //{ // transform.position += Vector3.right * speed * Time.deltaTime; //} //else //{ // transform.position += Vector3.left * speed * Time.deltaTime; //} //float rightEdgeOfFormation = transform.position.x + (0.5f * width); //float leftEdgeOfFormation = transform.position.x - (0.5f * width); //if (leftEdgeOfFormation < xMin) //{ // isMovingRight = true; //} //else if (rightEdgeOfFormation > xMax) //{ // isMovingRight = false; //} #endregion if (!GalagaHelper.isPlayerCaptured) { GalagaHelper.SetAttackinMotion(); } } if (enemyAttacks == 0) { enemyAttacks = 1; isEnemy1Done = true; isEnemy2Done = true; isEnemy3Done = true; } if (enemy1Picked && isEnemy1Done == true) { Debug.Log("Enemy1 called to attack".Bold()); PickRandomEnemyOne(); enemy1Picked = false; isEnemy1Done = false; } if (enemy2Picked && isEnemy2Done == true) { Debug.Log("Enemy2 called to attack".Bold()); PickRandomEnemyTwo(); enemy2Picked = false; isEnemy2Done = false; } if (enemy3Picked && isEnemy3Done == true) { Debug.Log("Enemy3 called to attack".Bold()); PickRandomEnemyThreeAttack(); enemy3Picked = false; isEnemy3Done = false; } //Debug.Log("player captured " + GalagaHelper.isPlayerCaptured + " Starfield paused: " + starfield.isPaused); // If found a player captured then set ready text. if (GalagaHelper.isPlayerCaptured == true) { if (isReadyDone == false) { // turn on Ready text // Pause starfield if (!isPlayerReady) { readyText.SetActive(true); starfield.Pause(); //Debug.Log("Paused starfield"); } else if (isPlayerReady) // player is ready now get rid of readyText { readyText.SetActive(false); //Debug.Log("Starfield Unpaused".Colored(Colors.green)); starfield.Play(); isPlayerReady = false; isReadyDone = true; GalagaHelper.isPlayerCaptured = false; //GameObject player = GameObject.FindGameObjectWithTag("Player").gameObject; //player.GetComponent<Renderer>().enabled = true; //player.GetComponent<MeshCollider>().enabled = true; isEnemy1Done = true; isEnemy2Done = true; isEnemy3Done = true; } } } }
public void LoadGameOverScene() { SceneManager.LoadScene(GalagaHelper.GetScene(Scene.GameOver)); }
void OnTriggerEnter(Collider other) { Projectile enemyProjectile = other.gameObject.GetComponent <Projectile>(); //Enemy1Controller enemy1 = other.gameObject.GetComponent<Enemy1Controller>(); if (other.gameObject.layer == 10 || enemyProjectile) { if (isPlayerLive) { Debug.Log("GameObject " + other.gameObject.name + " hit player."); GameObject explosionPrefab = Instantiate(explosion, gameObject.transform.position, gameObject.transform.rotation) as GameObject; Destroy(explosionPrefab, 3.0f); top = addShotSounds(explosionTop, Random.Range(0.8f, 1.2f)); bottom = addShotSounds(explosionBottom, Random.Range(0.8f, 1.2f)); top.Play(); bottom.Play(); rend.enabled = false; isPlayerLive = false; if (enemyProjectile) { enemyProjectile.Hit(); Debug.Log("Enemy proj hit Player."); } else { SimplePool.Despawn(other.gameObject); Debug.Log("Enemy ran into Player".Colored(Colors.blue)); } //SimplePool.Despawn(this.gameObject); GalagaHelper.numOfPlayers -= 1; GalagaHelper.PlacePlayerIcons(); GalagaHelper.isPlayerCaptured = true; GameObject.FindGameObjectWithTag("MainFormation").GetComponent <MainEnemyFormation>().isReadyDone = false; Destroy(gameObject); if (!CanPlayerStillPlay()) { MainEnemyFormation main = GameObject.FindGameObjectWithTag("MainFormation").GetComponent <MainEnemyFormation>(); main.Invoke("EndGame", 3.0f); } else { CreatePlayer(); } } } //if (enemyProjectile) //{ // if (isPlayerLive) // { // GameObject explosionPrefab = Instantiate(explosion, gameObject.transform.position, gameObject.transform.rotation) as GameObject; // Destroy(explosionPrefab, 3.0f); // Debug.Log("Enemy proj hit Player."); // top = addShotSounds(explosionTop, Random.Range(0.8f, 1.2f)); // bottom = addShotSounds(explosionBottom, Random.Range(0.8f, 1.2f)); // top.Play(); // bottom.Play(); // enemyProjectile.Hit(); // rend.enabled = false; // isPlayerLive = false; // //SimplePool.Despawn(gameObject); // GalagaHelper.numOfPlayers -= 1; // GalagaHelper.PlacePlayerIcons(); // GalagaHelper.isPlayerCaptured = true; // GameObject.FindGameObjectWithTag("MainFormation").GetComponent<MainEnemyFormation>().isReadyDone = false; // Destroy(gameObject); // if (!CanPlayerStillPlay()) // { // MainEnemyFormation main = GameObject.FindGameObjectWithTag("MainFormation").GetComponent<MainEnemyFormation>(); // main.Invoke("EndGame", 3.0f); // //Invoke("EndGame", 3.0f); // } // else // { // CreatePlayer(); // } // } //} Debug.Log("Something hit the player.".Colored(Colors.darkblue)); }
private static void LoadStage() { SceneManager.LoadScene(GalagaHelper.GetScene(Scene.Stage1)); }
public void CreateEnemy4Trio(Transform spawn, Transform freepos) { Hashtable tweenPath = new Hashtable(); Hashtable tweenPath1 = new Hashtable(); Hashtable tweenPath2 = new Hashtable(); GameObject[] scorpionTrio = new GameObject[3]; scorpionTrio[0] = SimplePool.Spawn(enemy4Prefab, spawn.position, enemy4Prefab.transform.rotation, true) as GameObject; scorpionTrio[0].transform.position = spawn.position; scorpionTrio[0].transform.parent = freepos; scorpionTrio[0].GetComponent <MeshCollider>().enabled = true; GalagaHelper.enemyFourOrigRotation = scorpionTrio[0].transform.rotation; scorpionTrio[1] = SimplePool.Spawn(enemy4Prefab, spawn.position, enemy4Prefab.transform.rotation, true) as GameObject; scorpionTrio[1].transform.position = spawn.position; scorpionTrio[1].transform.parent = freepos; scorpionTrio[1].GetComponent <MeshCollider>().enabled = true; scorpionTrio[2] = SimplePool.Spawn(enemy4Prefab, spawn.position, enemy4Prefab.transform.rotation, true) as GameObject; scorpionTrio[2].transform.position = spawn.position; scorpionTrio[2].transform.parent = freepos; scorpionTrio[2].GetComponent <MeshCollider>().enabled = true; PlayerController player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>(); _waypoints = new List <Vector3>(); tweenPath.Clear(); tweenPath1.Clear(); tweenPath2.Clear(); if (player) { for (int i = 0; i < scorpionTrio.Length; i++) { _waypoints.Clear(); _waypoints.Add(scorpionTrio[i].transform.position); _waypoints.Add(GameObject.FindGameObjectWithTag("Point2").GetComponent <Transform>().position); player.GetCirclePathScorpions(); Vector3[] pathToPlayer = new Vector3[5]; pathToPlayer = player.scorpionCirclePath; for (int x = 0; x < 5; x++) { _waypoints.Add(pathToPlayer[x]); } _waypoints.Add(GameObject.FindGameObjectWithTag("Point2").GetComponent <Transform>().position); _waypoints.Add(scorpionTrio[i].transform.position); // Copy Vector3 to a new Vector3 array //Debug.Log("Waypoints Count: " + _waypoints.Count); Vector3[] newVect3 = new Vector3[_waypoints.Count]; //Debug.Log(_waypoints.Count.ToString().Bold().Italics()); for (int y = 0; y < _waypoints.Count; y++) { newVect3[y] = _waypoints[y]; } if (i == 0) { tweenPath.Add("path", newVect3); tweenPath.Add("delay", 0.05f); tweenPath.Add("time", 8.0f); tweenPath.Add("easetype", "linear"); tweenPath.Add("orienttopath", true); GalagaHelper.CollectScorpionPaths(scorpionTrio[i], tweenPath); } else if (i == 1) { tweenPath1.Add("path", newVect3); tweenPath1.Add("delay", 0.6f); tweenPath1.Add("time", 8.0f); tweenPath1.Add("easetype", "linear"); tweenPath1.Add("orienttopath", true); GalagaHelper.CollectScorpionPaths(scorpionTrio[i], tweenPath1); } else if (i == 2) { tweenPath2.Add("path", newVect3); tweenPath2.Add("delay", 1.0f); tweenPath2.Add("time", 8.0f); tweenPath2.Add("easetype", "linear"); tweenPath2.Add("orienttopath", true); tweenPath2.Add("onComplete", "EnemyBack"); tweenPath2.Add("onCompleteTarget", gameObject); GalagaHelper.CollectScorpionPaths(scorpionTrio[i], tweenPath2); } } } }
public void Start() { hero = GameObject.FindGameObjectWithTag("Player"); rend = GetComponent <Renderer>(); meshcol = GetComponent <MeshCollider>(); main = GameObject.FindGameObjectWithTag("MainFormation").GetComponent <MainEnemyFormation>(); spawnDisableTime = 10.0f; // get end direction random GalagaHelper.SetEnemy2Random(); GalagaHelper.Enemy2PathEnd = GalagaHelper.Enemy2PathDirection(); // get Tranform.Lookat() for Enemy2 GalagaHelper.Enemy2LookAt(); //Debug.Log("Enemy2Random: ".Colored(Colors.red) + GalagaHelper.Enemy2Random); round1Phase1spawner = GameObject.Find("Round1Phase1EnemyFormation").GetComponent <EnemySpawner>(); scoreKeeper = GameObject.Find("Score").GetComponent <ScoreKeeper>(); isEnemyFiring = false; //Debug.Log("enemies spawned: " + GalagaHelper.EnemiesSpawned); // Wave 1 path creation. if (GalagaHelper.JustSpawned <= 8) { // Spawn 1 of 5 phases if (round1Phase1spawner.spawnEntranceRight) { myTween.Add("path", GalagaHelper.EntrancePatterns(GalagaHelper.EntranceFlightPatterns.round1_DownRight)); myTween.Add("delay", GalagaHelper.Wave1Delay); GalagaHelper.Wave1Delay += fDelay; //Debug.Log("1 WAVE DELAY; " + GalagaHelper.Wave1Delay); } else { myTween.Add("path", GalagaHelper.EntrancePatterns(GalagaHelper.EntranceFlightPatterns.round1_DownLeft)); myTween.Add("delay", GalagaHelper.Wave1Delay); GalagaHelper.Wave1Delay += fDelay; //Debug.Log("1 WAVE DELAY; " + GalagaHelper.Wave1Delay); } } // Collect all 1st wave enemies and move them all at once with a delay if (GalagaHelper.JustSpawned < 9) { myTween.Add("time", movePathTime); myTween.Add("easetype", "linear"); myTween.Add("onComplete", "EnemyCompletePath"); myTween.Add("onCompleteTarget", gameObject); GalagaHelper.CollectEnemyPaths(gameObject, myTween); //GalagaHelper.CurrentRoundPhase += 1; } if (GalagaHelper.CurrentRoundPhase == GalagaHelper.Formations.Round1Phase2 && GalagaHelper.JustSpawned <= 16) { CreatePathAndMove(GalagaHelper.Formations.Round1Phase2, GalagaHelper.RoundNumber); } else if (GalagaHelper.CurrentRoundPhase == GalagaHelper.Formations.Round1Phase3 && GalagaHelper.JustSpawned <= 24) { CreatePathAndMove(GalagaHelper.Formations.Round1Phase3, GalagaHelper.RoundNumber); } else if (GalagaHelper.CurrentRoundPhase == GalagaHelper.Formations.Round1Phase4 && GalagaHelper.JustSpawned <= 32) { CreatePathAndMove(GalagaHelper.Formations.Round1Phase4, GalagaHelper.RoundNumber); } else if (GalagaHelper.CurrentRoundPhase == GalagaHelper.Formations.Round1Phase5 && GalagaHelper.JustSpawned <= 40) { CreatePathAndMove(GalagaHelper.Formations.Round1Phase5, GalagaHelper.RoundNumber); spawnDisableTime = 2.0f; } }
/// <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; } } }