public TankEffect m_Effect;                        // Reference to tank's movement script, used to disable and enable control.



    public void Setup(int type)
    {
        // Get references to the components.
        m_Movement = m_Instance.GetComponent<TankMovement>();
        m_Shooting = m_Instance.GetComponent<TankShooting>();
        m_Health = m_Instance.GetComponent<TankHealth>();
        m_Effect = m_Instance.GetComponent<TankEffect>();

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

        m_Movement.m_PlayerType = type;
        m_Shooting.m_PlayerType = type;
        m_Health.m_PlayerType = type;
        m_Effect.m_PlayerType = type;

        if (m_PlayerNumber == 1 || m_PlayerNumber == 2)
        {
            m_Shooting.m_CurrentFireDame = 1;
            m_Shooting.m_CurrentFireSpeed = 25;
            m_Movement.m_Speed = 12;
        }
        else {
            if (m_Movement.m_PlayerType == 0)//normal
            {
                m_Shooting.m_CurrentFireDame = 1;
                m_Shooting.m_CurrentFireSpeed = 25;
                m_Movement.m_Speed = 10;
            }
            else if (m_Movement.m_PlayerType == 1)//fast
            {
                m_Shooting.m_CurrentFireDame = 1;
                m_Shooting.m_CurrentFireSpeed = 30;
                m_Movement.m_Speed = 14;
            }
            else if (m_Movement.m_PlayerType == 2)//power
            {
                m_Shooting.m_CurrentFireDame = 1;
                m_Shooting.m_CurrentFireSpeed = 35;
                m_Movement.m_Speed = 12;
            }
            else if (m_Movement.m_PlayerType == 3)//armo
            {
                m_Shooting.m_CurrentFireDame = 1;
                m_Shooting.m_CurrentFireSpeed = 30;
                m_Movement.m_Speed = 8;
            }

        }

        m_Health.m_CurrentLive = 3;

        // Create a string using the correct color that says 'PLAYER 1' etc based on the tank's color and the player's number.
        if (m_PlayerNumber != 0)
        {
            m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>";
        }
        else
        {
            m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(Color.grey) + ">ENEMY</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.
            if (m_PlayerNumber == 1 || m_PlayerNumber == 2)
                renderers[i].material.color = m_PlayerColor;
            else if (m_Shooting.m_PlayerType != 1)
                renderers[i].material.color = Color.grey;

        }
        m_Effect.initEffect(this);

        if (m_PlayerNumber == 1 || m_PlayerNumber == 2)
        {
            m_Shooting.m_Star = GameObject.Instantiate(GameManager.m_Instancce.m_StarFrefab, m_Health.transform.position, Quaternion.identity) as GameObject;
            m_Shooting.m_Star.transform.position = new Vector3(m_Shooting.m_Star.transform.position.x, 2, m_Shooting.m_Star.transform.position.z);
            m_Shooting.m_Star.transform.parent = m_Health.transform;

            if (m_PlayerNumber == 1)
                m_Shooting.InitNewStar(GameManager.m_TanksStarSave[0]);
            else
                m_Shooting.InitNewStar(GameManager.m_TanksStarSave[1]);
        }

        //if (!SoundEngine.m_isSoundEnable)
       // {
        //    m_Movement.m_MovementAudio.enabled = false;
       // }
       // else
        //    m_Movement.m_MovementAudio.enabled = true;
    }