Пример #1
0
    public PowerupService()
    {
        instance = this;

        ServiceLocator.Register <IPowerupService>(this);

        ServiceLocator.Request <IShotResultService>().RegisterListener(Clean);

        if (rivalInventory == null)
        {
            rivalInventory = new PowerupInventory(true);
        }
    }
Пример #2
0
    /// <summary>
    /// Inicializa los valores de este control para mostrar un power up
    /// </summary>
    /// <param name="_powerUpDescriptor"></param>
    public void ShowAsPowerUp(PowerUpDescriptor _powerUpDescriptor)
    {
        ObtenerReferencias();

        if (_powerUpDescriptor == null)
        {
            // ocultar este control
            SetVisible(false);

            // mostrar en el boton la textura por defecto
            m_btnCompra.GetComponent <GUITexture>().texture = AvataresManager.instance.m_texturaCompraPowerUp;
            m_btnCompra.m_current = AvataresManager.instance.m_texturaCompraPowerUp;
        }
        else
        {
            // mostrar este control
            SetVisible(true);

            // actualizar la cantidad de items
            if (PowerupService.ownInventory == null)
            {
                m_txtCantidad.text = "0";
            }
            else
            {
                m_txtCantidad.text = PowerupService.ownInventory.GetCantidadPowerUp(_powerUpDescriptor.idWs).ToString();
            }
            m_txtCantidadSombra.text = m_txtCantidad.text;

            //m_icono.texture = AvataresManager.instance.GetTexturaPowerUp((int) PowerupInventory.IdWsToPowerup(_powerUpDescriptor.idWs));
            //m_icono.gameObject.SetActive(true);

            // actualizar el resto de textos
            m_txtPrecio.text       = "¤ " + _powerUpDescriptor.precioSoft.ToString();
            m_txtPrecioSombra.text = m_txtPrecio.text;
            m_txtBoost.gameObject.SetActive(false);

            // boton compra
            Texture textura = AvataresManager.instance.GetTexturaPowerUp((int)PowerupInventory.IdWsToPowerup(_powerUpDescriptor.idWs));
            m_btnCompra.GetComponent <GUITexture>().texture = textura;
            m_btnCompra.m_current = textura;

            m_btnCompra.action = (_name) => {
                Interfaz.ClickFX();
                AccionComprarPowerup(_powerUpDescriptor);
            };
        }
    }