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 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 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)); }