Ejemplo n.º 1
0
        // When a collider trigger this point
        private void OnTriggerEnter(Collider collider)
        {
            // If it has a TankCompass script attatched to it we can say is a player
            TankCompass player = collider.GetComponentInParent <TankCompass>();

            if (player != null)
            {
                // Notify the player that he stepped on you by showing his color
                Color playerColor = player.HitCheckpoint(transform);

                // If the player has a color
                if (playerColor != Color.clear)
                {
                    // Start blinking and play a nice sound effect
                    m_StartBlinking   = true;
                    m_FillImage.color = playerColor;
                    m_Audio.Play();
                }
            }
        }
Ejemplo n.º 2
0
        private GameObject m_CanvasGameObject;                  // Used to disable the world space UI during the Starting and Ending phases of each round.

        public void Setup(Transform[] checkpoints)
        {
            // Reset the laps and his value in the UI dial
            m_Laps         = 0;
            m_LapDial.text = string.Empty;

            // Get references to the components.
            m_Movement         = m_Instance.GetComponent <TankMovement>();
            m_Shooting         = m_Instance.GetComponent <TankShooting>();
            m_Compass          = m_Instance.GetComponent <TankCompass>();
            m_TankStatus       = m_Instance.GetComponent <TankStatus>();
            m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas>().gameObject;

            // Set the player numbers to be consistent across the scripts.
            m_Movement.m_PlayerNumber   = m_PlayerNumber;
            m_Shooting.m_PlayerNumber   = m_PlayerNumber;
            m_Compass.m_PlayerNumber    = m_PlayerNumber;
            m_TankStatus.m_PlayerNumber = m_PlayerNumber;

            //Set the player colors for the UI
            m_Compass.m_PlayerColor    = m_PlayerColor;
            m_TankStatus.m_PlayerColor = m_PlayerColor;

            // Create a string using the correct color that says 'PLAYER 1' etc based on the tank's color and the player's number.
            m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>";

            // Get all of the renderers of the tank.
            MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer> ();

            // Go through all the renderers...
            for (int i = 0; i < renderers.Length; i++)
            {
                // ... set their material color to the color specific to this tank.
                renderers[i].material.color = m_PlayerColor;
            }

            //Set all the checkpoints to be reached
            m_Compass.SetCheckpoints(checkpoints);
        }