コード例 #1
0
    // Use this for initialization
    void Start()
    {
        GameObject gmControl = GameObject.FindGameObjectWithTag("GameController");

        if (gmControl != null)
        {
            controller             = gmControl.GetComponent <GameController> ();
            controller.player1Name = _p1NameDown;
            controller.player2Name = _p2NameDown;
            controller.pow1        = pow1;
            controller.pow2        = pow2;
            controller.SetName();
            pow1 = controller.pow1;
            pow2 = controller.pow2;
        }

        winnerMenu.SetWinnerMenuAble(false);

        _gestureBang = GestureDetectureBang.GetSharedGestureDetector();

        _gestureBang.AddListener(this);

        ChangeStateTo(GameState.Default);

        ads = new PowliticosADS();
    }
コード例 #2
0
    ///Ação de compra executada pelo botão Comprar
    public IEnumerator buyChar(CharType type)
    {
        if (Application.internetReachability != NetworkReachability.NotReachable)
        {
            Powlitico pow = controller.powliticoForCharType(type);

            try{
                //Tento comprar o personagem
                StoreInventory.BuyItem(pow.storeValues.PRODUCT_ID);
            }catch (Exception e) {
                if (purchase)
                {
                    purchase.CloseWindow();
                }

                Debug.Log("unity/soomla:" + e.Message);
            }
        }
        else
        {
            purchase.CloseWindow();
            LoadAlertConnection();
        }
        yield return(null);
    }
コード例 #3
0
    ///Devolve um Powlitico dado o tipo dele
    public Powlitico powliticoForCharType(CharType type)
    {
        Powlitico powlitico = null;

        foreach (Powlitico pow in powliticos)
        {
            if (type == pow.type)
            {
                powlitico = pow;
                break;
            }
        }

        return(powlitico);
    }
コード例 #4
0
    ///Substitui PowWinner pelo tipo indicado.
    ///OBS: Ao usar essa função você perderá a referência do Powlitico de da sua classe
    /// , favor pegar a referência novamente de powWinner desta classe.
    public void SetPowliticoWinner(CharType type)
    {
        if (powWinner != null)
        {
            //Set o Ganhador dado o tipo dele
            GameObject newPow = Instantiate(powliticoForCharType(type).gameObject, powWinner.gameObject.transform.position, Quaternion.identity) as GameObject;
            newPow.transform.localScale = powWinner.transform.localScale;
            newPow.transform.rotation   = powWinner.transform.rotation;
            newPow.transform.parent     = powWinner.transform.parent;
            Destroy(powWinner.gameObject);
            powWinner = newPow.GetComponent <Powlitico>();

            powWinner.PlaySpeech();
        }
    }
コード例 #5
0
    ///Substitui Pow1 e Pow2 pelos tipos indicados em player1 e player2.
    ///OBS: Ao usar essa função você perderá a referência dos Powliticos de Pow1 e Pow2 da sua classe
    /// , favor pegar a referência novamente de pow1 e pow2 desta classe.
    public void SetPowlitico()
    {
        if ((pow1 != null) && (pow2 != null))
        {
            //Seta Player 1 na tela
            GameObject newPow1 = Instantiate(powliticoForCharType(player1).gameObject, pow1.gameObject.transform.position, Quaternion.identity) as GameObject;
            newPow1.transform.localScale = pow1.transform.localScale;
            newPow1.transform.rotation   = pow1.transform.rotation;
            Destroy(pow1.gameObject);
            pow1 = newPow1.GetComponent <Powlitico>();

            //Seta Player 2 na tela
            GameObject newPow2 = Instantiate(powliticoForCharType(player2).gameObject, pow2.gameObject.transform.position, Quaternion.identity) as GameObject;
            newPow2.transform.localScale = pow2.transform.localScale;
            newPow2.transform.rotation   = pow2.transform.rotation;
            Destroy(pow2.gameObject);
            pow2 = newPow2.GetComponent <Powlitico>();
        }
    }
コード例 #6
0
    ///Seleciono o Char dado o índice dele
    public void SelectChar(int index)
    {
        //Se o indice do botão precionado for diferente de Random então
        if (selectionPanel.buttons [index].buttonType != CharType.RANDOM)
        {
            //Seta o personagem
            controller.powWinner = powlitico;
            controller.SetPowliticoWinner(selectionPanel.buttons[index].buttonType);
            powlitico = controller.powWinner;

            //Seta o Texto referente ao personagem
            nametx.text    = powlitico.info.Nome;
            partido.text   = powlitico.info.Partido;
            twitter.text   = powlitico.info.Twitter;
            descricao.text = powlitico.info.Description;

            //Seleciona o botão
            selectionPanel.UnselectAllButtons();
            selectionPanel.buttons[index].SelectButton();
        }
    }
コード例 #7
0
    ///Ação dos botões de Seleção
    public void BuyChar(int index)
    {
        SetAllButtonsInteractable(false);

        CharType buttonType = selectionPanel.buttons[index].buttonType;

        //Caso Diferente de Random verifico se tenho o Pow
        if (buttonType != CharType.RANDOM)
        {
            //Pego o Pow referente a este indice de botão
            Powlitico powButton = controller.powliticos[index];

            //Verifico se tenho este personagem para compra ou se ele já é desbloqueado
            if (StoreInventory.GetItemBalance(powButton.storeValues.PRODUCT_ID) > 0 || powButton.storeValues.purchaseType == PurchaseType.UNLOCKED)
            {
                //Seleciono este personagem
                SelectButton(index);
            }
            else
            {
                if (powButton.storeValues.purchaseType == PurchaseType.ADS)
                {
                    //Caso seja desbloqueado por ADS
                    LoadADSAlertPurchase(buttonType);
                }
                else
                {
                    //Senão subo alerta de compra
                    LoadAlertPurchase(buttonType);
                }
            }
        }
        else
        {
            SetAllButtonsInteractable(true);
            //SelectButton(index);
        }

        //SelectButton(index);
    }
コード例 #8
0
    private void HandleShowResult(ShowResult result)
    {
        switch (result)
        {
        case ShowResult.Finished:
            Debug.Log("The ad was successfully shown.");
            //
            // YOUR CODE TO REWARD THE GAMER
            // Give coins etc.
            Powlitico pow = controller.powliticoForCharType(charTypeADS);
            StoreInventory.GiveItem(pow.storeValues.PRODUCT_ID, 1);
            purchase.CloseWindow();
            break;

        case ShowResult.Skipped:
            Debug.Log("The ad was skipped before reaching the end.");

            break;

        case ShowResult.Failed:
            Debug.LogError("The ad failed to be shown.");
            break;
        }
    }