void Awake() { //Set the reference arrays m_skiers = new SkierController[6] { playerOneSkier, playerTwoSkier, playerThreeSkier, playerFourSkier, null, null }; //Add two nulls at the end so they don't throw errors if functions check those indexes m_skierScoresText = new Text[4] { scoreOne, scoreTwo, scoreThree, scoreFour }; m_roundOverScoresText = new Text[4] { roundOverScoreOne, roundOverScoreTwo, roundOverScoreThree, roundOverScoreFour }; m_prevTopSkier = null; m_planeTextures = new Texture[4] { axlPlaneTexture, carlPlaneTexture, mannyPlaneTexture, hydraPlaneTexture }; m_playerUI = new RectTransform[4] { playerOneUI, playerTwoUI, playerThreeUI, playerFourUI }; m_charImageBW = new Image[4] { axlImageBW, crocImageBW, wolfImageBW, hydImageBW }; m_playerImage = new Image[4] { playerOneImage, playerTwoImage, playerThreeImage, playerFourImage }; m_playerCrown = new Image[4] { playerOneCrown, playerTwoCrown, playerThreeCrown, playerFourCrown }; m_skierLives = new Image[4] { livesOne, livesTwo, livesThree, livesFour }; m_planeImage = new Image[4] { planeOne, planeTwo, planeThree, planeFour }; m_skierMultipliers = new Text[4] { multiplierOne, multiplierTwo, multiplierThree, multiplierFour }; //Make a new array of references to the skiers to sort m_sortedSkiers = new SkierController[m_skiers.Length]; for (int i = 0; i < m_skiers.Length; i++) { m_sortedSkiers[i] = m_skiers[i]; } //Set the spawnpoints in the 2D array m_skierSpawnPos = new Vector3[3, 3] { { m_twoPlayerSkierPos, Vector3.zero, Vector3.zero }, { m_threePlayerSkierPosOne, m_threePlayerSkierPosTwo, Vector3.zero }, { m_fourPlayerSkierPosOne, m_fourPlayerSkierPosTwo, m_fourPlayerSkierPosThree } }; planeHatch.setIsUsingAbility(false); wavePanel.transform.position = canvas.transform.position; SetSkiers(); //Set the skiers to their controllers SetPlane(); //Set which player controls the plane }
//Change which player is playing the particle if needed private void ApplyTopScoreParticle() { if (((int)m_sortedSkiers[0].controller - 1) != (int)m_eCurrentPlaneState) //If the top score player isn't in the plane, { if (m_sortedSkiers[0] != m_prevTopSkier) //If the top player has changed, { m_sortedSkiers[0].SetTopScoreParticle(true); //Start the particle on the new player if (m_prevTopSkier != null) { m_prevTopSkier.SetTopScoreParticle(false); //Stop the particle on the previous player } m_prevTopSkier = m_sortedSkiers[0]; //Update the previous top player } } else //The top score player is in the plane, { if (m_sortedSkiers[1] != m_prevTopSkier) //If the top player has changed, { m_sortedSkiers[1].SetTopScoreParticle(true); //Start the particle on the new player if (m_prevTopSkier != null) { m_prevTopSkier.SetTopScoreParticle(false); //Stop the particle on the previous player } m_prevTopSkier = m_sortedSkiers[1]; //Update the previous top player } } }
void OnTriggerEnter(Collider collider) { if (collider.gameObject.CompareTag("Skier")) //If colliding with a skier, { SkierController skier = collider.gameObject.GetComponent <SkierController>(); if (!skier.IsInvincible()) { gameObject.GetComponent <Renderer>().enabled = false; //Stop rendering the coin AudioManager.Play("CoinCollected"); // plays coin sound effect } } }
void OnTriggerEnter(Collider collision) { if (collision.CompareTag("Skier")) // Will be called if collision with a skier occurs. { Vector3 explosionPos = transform.position; // explosion will occur at the impact site. explosionPos.y = 0; //Make sure that there is no y component Collider[] colliders = Physics.OverlapSphere(explosionPos, radius); // List of colliders within the radius. // animation for the door TetheredMineAnimation.SetBool("IsDoorClosed", true); TetheredMineAnimation.SetBool("IsDoorOpen", false); // Hatch Close Door sound AudioManager.Play("TetherObs&BBHatchDoorClosed"); AudioManager.Play("TetheredMineExplosion"); foreach (Collider hit in colliders) //For all the objects in the radius, { if (hit.CompareTag("Skier")) //If this object is a skier, { SkierController controller = hit.GetComponent <SkierController>(); // Gets all controllers within the radius. if (!controller.IsInvincible()) { controller.HurtSkier(); // Hurts the skier within the radius. } } } ControllerVibrate.VibrateAll(1.0f, 0.5f); //Vibrate all controllers very moderately gameObject.SetActive(false); // Deactivates the mine. m_rb.velocity = Vector3.zero; // Resets velocity. m_rb.angularVelocity = Vector3.zero; // Resets angular velocity. m_rb.transform.rotation = Quaternion.Euler(Vector3.zero); // Resets rotation. m_tmAbility.setIsUsingAbility(false); m_tmAbility.mineAbilityCooldown.SetTimer(); explosionPrefab.transform.position = explosionPos; //Make the explosion happen at the right spot Instantiate(explosionPrefab); //Create the explosion GameFreezer.Freeze(freezeAmount, freezeFrames); //Slow time very briefly for impact } else if (collision.CompareTag("Rock")) //If colliding with an obstacle, { float pushDirection = transform.position.x - collision.transform.position.x; //Calculate if the mine should be pushed left or right if (pushDirection > 0) //If positive, { m_tether.ForceOverTime(new Vector3(m_tmAbility.obstacleForce, 0, 0), m_tmAbility.obstacleForceDuration); //Push right } else //If negative, { m_tether.ForceOverTime(new Vector3(-m_tmAbility.obstacleForce, 0, 0), m_tmAbility.obstacleForceDuration); //Push left } } }