Esempio n. 1
0
    public void Setup()
    {
        m_Instance.GetComponent <Collider>().enabled = isPlayer;
        // Get references to the components.
        m_movement         = m_Instance.GetComponent <TankMovement>();
        m_shooting         = m_Instance.GetComponent <TankShooting>();
        m_health           = m_Instance.GetComponent <TankHealth>();
        m_propBehavior     = m_Instance.GetComponent <TankPropBehavior>();
        m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas>().gameObject;

        m_movement.m_avatar          = m_avatar;
        m_shooting.m_isPlayer        = isPlayer;
        m_shooting.m_tankmanager     = this;
        m_propBehavior.m_isPlayer    = isPlayer;
        m_propBehavior.m_tankmanager = this;

        m_health.SetIDText(m_avatarName);
        // 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;
        }
    }