Esempio n. 1
0
 public override void Start()
 {
     base.Start();
     Analytics.CustomEvent("specialShots");
 }
Esempio n. 2
0
        /// <summary>
        /// Shows the game over dialog.
        /// </summary>
        /// Override this in your own base class if you want to customise the game over window. Be sure to call this base instance when done.
        public virtual void Show(bool isWon)
        {
            Assert.IsTrue(LevelManager.IsActive, "Ensure that you have a LevelManager component attached to your scene.");

            var currentLevel = GameManager.Instance.Levels.Selected;

            // update the player score if necessary
            if ((UpdatePlayerScore == CopyType.Always) || (UpdatePlayerScore == CopyType.OnWin && isWon))
            {
                GameManager.Instance.Player.AddPoints(currentLevel.Score);
            }

            // update the player coins if necessary
            if ((UpdatePlayerCoins == CopyType.Always) || (UpdatePlayerCoins == CopyType.OnWin && isWon))
            {
                GameManager.Instance.Player.AddCoins(currentLevel.Coins);
            }

            // show won / lost game objects as appropriate
            GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Lost", true), !isWon);

            // see if the world or game is won and also if we should unlock the next world / level
            GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "GameWon", true), false);
            GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "WorldWon", true), false);
            GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "LevelWon", true), false);
            GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Won", true), false);
            if (isWon)
            {
                //TODO: if coins unlock mode then need to check all levels are done before saying world complete - same for game...
                //TODO: perhaps in future we might want to distinguish between the first and subsequent times a user completes something?
                //// is the game won
                //if (GameHelper.IsCurrentLevelLastInGame()) {
                //    GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "GameWon", true), true);
                //}

                //// is a world won
                //else if (GameHelper.IsCurrentLevelLastInGame())
                //{
                //    GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "WorldWon", true), true);
                //}

                //// level won
                //else if (GameManager.Instance.Levels.GetNextItem() != null)
                //{
                //    GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "LevelWon", true), true);
                //}

                //// else won with some other condition
                //else
                //{
                GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Won", true), true);
                //}

                // process and update game state - do this last so we can check some bits above.
                GameHelper.ProcessCurrentLevelComplete();
            }

            // set some text based upon the result
            UIHelper.SetTextOnChildGameObject(DialogInstance.gameObject, "AchievementText", GlobalLocalisation.FormatText(LocalisationBase + ".Achievement", currentLevel.Score, currentLevel.Name) ?? LocalisationBase + ".Achievement");

            // setup stars
            var starsGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Stars", true);

            GameObjectHelper.SafeSetActive(starsGameObject, ShowStars);
            if (ShowStars)
            {
                Assert.IsNotNull(starsGameObject, "GameOver->ShowStars is enabled, but could not find a 'Stars' gameobject. Disable the option or fix the structure.");
                starsGameObject.SetActive(ShowStars);
                var newStarsWon = GetNewStarsWon();
                currentLevel.StarsWon |= newStarsWon;
                var star1WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star1", true);
                var star2WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star2", true);
                var star3WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star3", true);
                StarWon(currentLevel.StarsWon, newStarsWon, star1WonGameObject, 1);
                StarWon(currentLevel.StarsWon, newStarsWon, star2WonGameObject, 2);
                StarWon(currentLevel.StarsWon, newStarsWon, star3WonGameObject, 4);
                GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(starsGameObject, "StarWon", true), newStarsWon != 0);
            }

            // set time
            var difference     = DateTime.Now - LevelManager.Instance.StartTime;
            var timeGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Time", true);

            GameObjectHelper.SafeSetActive(timeGameObject, ShowTime);
            if (ShowTime)
            {
                Assert.IsNotNull(timeGameObject, "GameOver->ShowTime is enabled, but could not find a 'Time' gameobject. Disable the option or fix the structure.");

                UIHelper.SetTextOnChildGameObject(timeGameObject, "TimeResult", difference.Minutes.ToString("D2") + "." + difference.Seconds.ToString("D2"), true);
            }

            // set coins
            var coinsGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Coins", true);

            GameObjectHelper.SafeSetActive(coinsGameObject, ShowCoins);
            if (ShowCoins)
            {
                Assert.IsNotNull(coinsGameObject, "GameOver->ShowCoins is enabled, but could not find a 'Coins' gameobject. Disable the option or fix the structure.");
                UIHelper.SetTextOnChildGameObject(coinsGameObject, "CoinsResult", currentLevel.Coins.ToString(), true);
            }

            // set score
            var scoreGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Score", true);

            GameObjectHelper.SafeSetActive(scoreGameObject, ShowScore);
            if (ShowScore)
            {
                Assert.IsNotNull(scoreGameObject, "GameOver->ShowScore is enabled, but could not find a 'Score' gameobject. Disable the option or fix the structure.");
                var distanceText = GlobalLocalisation.FormatText(LocalisationBase + ".ScoreResult", currentLevel.Score.ToString()) ?? LocalisationBase + ".ScoreResult";
                if (currentLevel.HighScore > currentLevel.OldHighScore)
                {
                    distanceText += "\n" + GlobalLocalisation.GetText(LocalisationBase + ".NewHighScore", missingReturnsKey: true);
                }
                UIHelper.SetTextOnChildGameObject(scoreGameObject, "ScoreResult", distanceText, true);
            }

            UpdateNeededCoins();

            // save game state.
            GameManager.Instance.Player.UpdatePlayerPrefs();
            currentLevel.UpdatePlayerPrefs();
            PreferencesFactory.Save();

            // pause
            if (PauseWhenShown)
            {
                _oldTimeScale  = Time.timeScale;
                Time.timeScale = TimeScale;
            }

            //show dialog
            DialogInstance.Show();

            //TODO bug - as we increase TimesPlayedForRatingPrompt on both game start (GameManager) and level finish we can miss this comparison.
            if (GameManager.Instance.TimesPlayedForRatingPrompt == TimesPlayedBeforeRatingPrompt)
            {
                var gameFeedback = new GameFeedback();
                gameFeedback.GameFeedbackAssumeTheyLikeOptional();
            }

#if UNITY_ANALYTICS
            // record some analytics on the level played
            var values = new Dictionary <string, object>
            {
                { "score", currentLevel.Score },
                { "Coins", currentLevel.Coins },
                { "time", difference },
                { "level", currentLevel.Number }
            };
            Analytics.CustomEvent("GameOver", values);
#endif
        }
    public void TrocaDialogo(bool escolha)
    {
        switch (dialogManager.Fase)
        {
        case 1:
        {
            switch (dialogManager.arqDialogo.name)
            {
            case "dialogo_1a":                    //caso seja a primeira fase e o primeiro dialogo faz as seguintes ações - ALCOOL
            {
                if (escolha)
                {
                    Analytics.CustomEvent("AceitouAlcool");
                    dialogManager.Alcool        = 1;
                    dialogManager.olhoVermelhoP = true;                     //muda os olhos para vermelho
                    dialogManager.choiceBox.SetActive(false);               //tira a escolha da tela
                    AceitaAlcool(true);                                     //habilita o controle do alcool e desativa o dialogo
                    AnimAlcool = ctrlAl.GetComponentInChildren <Animator> ();
                    AnimAlcool.Play("AceitaAlcool");
                    //AnimAlcool.SetBool ("aceita", true);//define que ele aceitou alcool na animação
                    //AnimAlcool.SetBool ("start", true);//define que vai começar a animação
                    Invoke("CarregaDialogoB", animClipAceitaAlcool.length);                                     //Prepara a função que carrega o dialogo B após as duas animações ocorrem
                }
                else
                {
                    Analytics.CustomEvent("RecusouAlcool");
                    dialogManager.Alcool = 0;
                    dialogManager.choiceBox.SetActive(false);               //tira a escolha da tela
                    AceitaAlcool(true);                                     //habilita o controle do alcool e desativa o dialogo
                    Invoke("CarregaDialogoC", animClipRecusaAlcool.length); //Prepara a função que carrega o dialogo C após a animação rodar
                    AnimAlcool = ctrlAl.GetComponentInChildren <Animator> ();
                    AnimAlcool.Play("RecusaAlcool");
                    //AnimAlcool.SetBool ("aceita", false);//define que ele nao aceitou o alcool na animação
                    //AnimAlcool.SetBool ("start", true);//define que vai começar a animação
                }
                break;
            }

            case "dialogo_1b":                    //caso seja a primeira fase e o dialogo seja depois de aceitar a bebida faz as seguintes ações - CIGARRO
            {
                if (escolha)                      //se ele aceitou fumar cigarro entra aqui
                {
                    Analytics.CustomEvent("AceitouCigarro");
                    dialogManager.Cigarro = 1;
                    dialogManager.choiceBox.SetActive(false);                  //tira a escolha da tela
                    AceitaCigarro(true);                                       //habilita o controle do cigarro
                    Invoke("CarregaConsAlcool", animAceitaClipCigarro.length); //Prepara a consequencia para aparecer após a animação do cigarro
                    AnimCigarro = ctrlCig.GetComponentInChildren <Animator> ();
                    AnimCigarro.Play("AceitaCigarro");
                    //Invoke ("CarregaConsCigarro", animClipConsAlcool.length + animAceitaClipCigarro.length);//Prepara a consequencia para aparecer após a animação da consequencia do alcool
                    //AnimCigarro.SetBool ("aceita", true);//define que ele aceitou alcool na animação
                    //AnimCigarro.SetBool ("start", true);//define que vai começar a animação
                    //Invoke ("CarregaFase2", animClipConsCigarro.length + animAceitaClipCigarro.length);//Prepara a função que carrega a proxima fase após as duas animações ocorrem
                }
                else
                {
                    Analytics.CustomEvent("RecusouCigarro");
                    dialogManager.Cigarro = 0;
                    dialogManager.choiceBox.SetActive(false);                  //tira a escolha da tela
                    AceitaCigarro(true);                                       //habilita o controle do cigarro e desativa o dialogo
                    Invoke("CarregaConsAlcool", animRecusaClipCigarro.length); //Prepara a consequencia para aparecer após a animação do cigarro
                    AnimCigarro = ctrlCig.GetComponentInChildren <Animator> ();
                    AnimCigarro.Play("RecusaCigarro");
                    //AnimCigarro.SetBool ("aceita", false);//define que ele nao aceitou o cigarro na animação
                    //AnimCigarro.SetBool ("start", true);//define que vai começar a animação
                }
                break;
            }

            case "dialogo_1c":                    //caso seja a primeira fase e o dialogo seja depois de recusar a bebida faz as seguintes ações - CIGARRO
            {
                if (escolha)                      //se ele aceitou fumar cigarro entra aqui
                {
                    Analytics.CustomEvent("AceitouCigarro");
                    dialogManager.Cigarro = 1;
                    dialogManager.choiceBox.SetActive(false);                  //tira a escolha da tela
                    AceitaCigarro(true);                                       //habilita o controle do cigarro
                    Invoke("CarregaConsAlcool", animAceitaClipCigarro.length); //Prepara a consequencia para aparecer após a animação do cigarro
                    AnimCigarro = ctrlCig.GetComponentInChildren <Animator> ();
                    AnimCigarro.Play("AceitaCigarro");
                    //Invoke ("CarregaConsCigarro", animAceitaClipCigarro.length);//Prepara a consequencia para aparecer após a animação do cigarro
                    //AnimCigarro.SetBool ("aceita", true);//define que ele aceitou alcool na animação
                    //AnimCigarro.SetBool ("start", true);//define que vai começar a animação
                    //Invoke ("CarregaFase2", animClipConsCigarro.length + animAceitaClipCigarro.length);//Prepara a função que carrega a proxima fase após as duas animações ocorrem
                }
                else
                {
                    Analytics.CustomEvent("RecusouCigarro");
                    dialogManager.Cigarro = 0;
                    dialogManager.choiceBox.SetActive(false);                  //tira a escolha da tela
                    AceitaCigarro(true);                                       //habilita o controle do cigarro e desativa o dialogo
                    Invoke("CarregaConsAlcool", animRecusaClipCigarro.length); //Prepara a função que carrega a próxima fase após a animação rodar
                    AnimCigarro = ctrlCig.GetComponentInChildren <Animator> ();
                    AnimCigarro.Play("RecusaCigarro");
                    //AnimCigarro.SetBool ("aceita", false);//define que ele nao aceitou o cigarro na animação
                    //AnimCigarro.SetBool ("start", true);//define que vai começar a animação
                }
                break;
            }

            default:
            {
                dialogManager.DisableDialogBox();
                break;
            }
            }
            break;
        }

        case 2:
        {
            switch (dialogManager.arqDialogo.name)
            {
            case "dialogo_2A1":                    //caso seja a segunda fase e o primeiro dialogo faz as seguintes ações - MACONHA
            {
                AtivaMaconha(escolha, "A");
                break;
            }

            case "dialogo_2B1":                    //caso seja a segunda fase e o primeiro dialogo faz as seguintes ações - MACONHA
            {
                AtivaMaconha(escolha, "B");
                break;
            }

            case "dialogo_2C1":                    //caso seja a segunda fase e o primeiro dialogo faz as seguintes ações - MACONHA
            {
                AtivaMaconha(escolha, "C");
                break;
            }

            case "dialogo_2D1":                    //caso seja a segunda fase e o primeiro dialogo faz as seguintes ações - MACONHA
            {
                AtivaMaconha(escolha, "D");
                break;
            }

            case "dialogo_2A2":                    //caso seja a segunda fase e o dialogo seja depois de aceitar a maconha faz as seguintes ações
            {
                switch (dialogManager.Estilo)      //dependendo dos estilos terá acesso a tipos diferentes de drogas
                {
                case 1:                            //Funk - Inalantes
                {
                    AtivaInalantes(escolha);
                    break;
                }

                case 2:                                 //Rock
                {
                    AtivaCocaina(escolha);
                    break;
                }

                case 3:                                 //Reggae
                {
                    AtivaAlucinogeno(escolha);
                    break;
                }

                case 4:                                 //Eletronica
                {
                    AtivaEcstasy(escolha);
                    break;
                }
                }
                break;
            }

            case "dialogo_2B2":                    //caso seja a segunda fase e o dialogo seja depois de aceitar a maconha faz as seguintes ações
            {
                switch (dialogManager.Estilo)      //dependendo dos estilos terá acesso a tipos diferentes de drogas
                {
                case 1:                            //Funk - Inalantes
                {
                    AtivaInalantes(escolha);
                    break;
                }

                case 2:                                 //Rock
                {
                    AtivaCocaina(escolha);
                    break;
                }

                case 3:                                 //Reggae
                {
                    AtivaAlucinogeno(escolha);
                    break;
                }

                case 4:                                 //Eletronica
                {
                    AtivaEcstasy(escolha);
                    break;
                }
                }
                break;
            }

            case "dialogo_2C2":                    //caso seja a segunda fase e o dialogo seja depois de aceitar a maconha faz as seguintes ações
            {
                switch (dialogManager.Estilo)      //dependendo dos estilos terá acesso a tipos diferentes de drogas
                {
                case 1:                            //Funk - Inalantes
                {
                    AtivaInalantes(escolha);
                    break;
                }

                case 2:                                 //Rock
                {
                    AtivaCocaina(escolha);
                    break;
                }

                case 3:                                 //Reggae
                {
                    AtivaAlucinogeno(escolha);
                    break;
                }

                case 4:                                 //Eletronica
                {
                    AtivaEcstasy(escolha);
                    break;
                }
                }
                break;
            }

            case "dialogo_2D2":                    //caso seja a segunda fase e o dialogo seja depois de aceitar a maconha faz as seguintes ações
            {
                switch (dialogManager.Estilo)      //dependendo dos estilos terá acesso a tipos diferentes de drogas
                {
                case 1:                            //Funk - Inalantes
                {
                    AtivaInalantes(escolha);
                    break;
                }

                case 2:                                 //Rock
                {
                    AtivaCocaina(escolha);
                    break;
                }

                case 3:                                 //Reggae
                {
                    AtivaAlucinogeno(escolha);
                    break;
                }

                case 4:                                 //Eletronica
                {
                    AtivaEcstasy(escolha);
                    break;
                }
                }
                break;
            }

            case "dialogo_2A3":
            {
                switch (dialogManager.Estilo)
                {
                case 1:                                 //Funk - Inalantes
                {
                    AtivaInalantes(escolha);
                    break;
                }

                case 2:                                 //Rock
                {
                    AtivaCocaina(escolha);
                    break;
                }

                case 3:                                 //Reggae
                {
                    AtivaAlucinogeno(escolha);
                    break;
                }

                case 4:                                 //Eletronica
                {
                    AtivaEcstasy(escolha);
                    break;
                }
                }
                break;
            }

            case "dialogo_2B3":
            {
                switch (dialogManager.Estilo)
                {
                case 1:                                 //Funk - Inalantes
                {
                    AtivaInalantes(escolha);
                    break;
                }

                case 2:                                 //Rock
                {
                    AtivaCocaina(escolha);
                    break;
                }

                case 3:                                 //Reggae
                {
                    AtivaAlucinogeno(escolha);
                    break;
                }

                case 4:                                 //Eletronica
                {
                    AtivaEcstasy(escolha);
                    break;
                }
                }
                break;
            }

            case "dialogo_2C3":
            {
                switch (dialogManager.Estilo)
                {
                case 1:                                 //Funk - Inalantes
                {
                    AtivaInalantes(escolha);
                    break;
                }

                case 2:                                 //Rock
                {
                    AtivaCocaina(escolha);
                    break;
                }

                case 3:                                 //Reggae
                {
                    AtivaAlucinogeno(escolha);
                    break;
                }

                case 4:                                 //Eletronica
                {
                    AtivaEcstasy(escolha);
                    break;
                }
                }
                break;
            }

            case "dialogo_2D3":
            {
                switch (dialogManager.Estilo)
                {
                case 1:                                 //Funk - Inalantes
                {
                    AtivaInalantes(escolha);
                    break;
                }

                case 2:                                 //Rock
                {
                    AtivaCocaina(escolha);
                    break;
                }

                case 3:                                 //Reggae
                {
                    AtivaAlucinogeno(escolha);
                    break;
                }

                case 4:                                 //Eletronica
                {
                    AtivaEcstasy(escolha);
                    break;
                }
                }

                break;
            }

            default:
            {
                dialogManager.DisableDialogBox();
                break;
            }
            }

            break;
        }

        case 3:
        {
            AtivaCrack(escolha);
            break;
        }

        default:
        {
            dialogManager.DisableDialogBox();
            break;
        }
        }
        dialogManager.Salvar();
    }
 public void FinalAnimacao()
 {
     Cons [index].SetActive(false);
     Analytics.CustomEvent("Fim");
     esco.FinalDoJogo();
 }
Esempio n. 5
0
 public void ShowAd()
 {
     Analytics.CustomEvent("Accept Reward Ad");
     StartCoroutine(loadAds());
 }
 public void GameOver()
 {
     Analytics.CustomEvent("gameComplete", new Dictionary <string, object>());
 }
    public void TakeDamage(int damageAmount)
    {
        Destroy(this.gameObject);

        Analytics.CustomEvent("Caterpillar dead");
    }
Esempio n. 8
0
// Use this for initialization
    public static void sendMsg(string key)
    {
        if (key != "bones_purchased_100" &&
            key != "bones_purchased_300" &&
            key != "bones_purchased_700" &&
            key != "bones_purchased_1000" &&
            key != "bones_ad_10" &&

            key != "hero_get_bone" &&
            key != "hero_get_bacon" &&
            key != "hero_jump" &&
            key != "hero_attack" &&
            key != "hero_lazarus" &&

            key != "hero_damage_cat" &&
            key != "hero_damage_bat" &&
            key != "hero_damage_ant" &&
            key != "hero_damage_hazard" &&
            key != "hero_damage_boss" &&

            key != "gate_open_attic" &&
            key != "gate_open_basement" &&
            key != "gate_open_window" &&

            key != "enemy_killed_cat" &&
            key != "enemy_killed_ant" &&
            key != "enemy_killed_bat" &&

            key != "boss_killed_mercurial" &&
            key != "boss_killed_gencat" &&

            key != "cutscene_warroom_intro" &&
            key != "cutscene_couchistan_intro" &&
            key != "cutscene_couchistan_boss_mercurial_intro" &&
            key != "cutscene_couchistan_boss_mercurial_death" &&
            key != "cutscene_couchistan_boss_gencat_intro" &&
            key != "cutscene_couchistan_boss_gencat_death" &&
            key != "cutscene_couchistan_complete" &&
            key != "attack" &&
            key != "jump"

            )
        {
            Debug.Log("Analytics ERROR - invalid key: " + key);
            //GameManager.log("Analytics ERROR - invalid key: " + key);
            return;
        }

        Debug.Log("Analytics - PROCESSING key: " + key);

        int tmpV = 1;

        switch (key)
        {
        case "bones_purchased_100":
            Analytics.CustomEvent("bones_purchased_100", new Dictionary <string, object> {
                { "bones_purchased_100", tmpV }
            });
            break;

        case "bones_purchased_300":
            Analytics.CustomEvent("bones_purchased_300", new Dictionary <string, object> {
                { "bones_purchased_300", tmpV }
            });
            break;

        case "bones_purchased_700":
            Analytics.CustomEvent("bones_purchased_700", new Dictionary <string, object> {
                { "bones_purchased_700", tmpV }
            });
            break;

        case "bones_purchased_1000":
            Analytics.CustomEvent("bones_purchased_1000", new Dictionary <string, object> {
                { "bones_purchased_1000", tmpV }
            });
            break;

        case "bones_ad_10":
            Analytics.CustomEvent("bones_ad_10", new Dictionary <string, object> {
                { "bones_ad_10", tmpV }
            });
            break;



        case "hero_get_bone":
            Analytics.CustomEvent("hero_get_bone", new Dictionary <string, object> {
                { "hero_get_bone", tmpV }
            });
            break;

        case "hero_get_bacon":
            Analytics.CustomEvent("hero_get_bacon", new Dictionary <string, object> {
                { "hero_get_bacon", tmpV }
            });
            break;

        case "hero_jump":
            Analytics.CustomEvent("hero_jump", new Dictionary <string, object> {
                { "hero_jump", tmpV }
            });
            break;

        case "hero_attack":
            Analytics.CustomEvent("hero_attack", new Dictionary <string, object> {
                { "hero_attack", tmpV }
            });
            break;

        case "hero_lazarus":
            Analytics.CustomEvent("hero_lazarus", new Dictionary <string, object> {
                { "hero_lazarus", tmpV }
            });
            break;



        case "hero_damage_cat":
            Analytics.CustomEvent("hero_damage_cat", new Dictionary <string, object> {
                { "hero_damage_cat", tmpV }
            });
            break;

        case "hero_damage_bat":
            Analytics.CustomEvent("hero_damage_bat", new Dictionary <string, object> {
                { "hero_damage_bat", tmpV }
            });
            break;

        case "hero_damage_ant":
            Analytics.CustomEvent("hero_damage_ant", new Dictionary <string, object> {
                { "hero_damage_ant", tmpV }
            });
            break;

        case "hero_damage_hazard":
            Analytics.CustomEvent("hero_damage_hazard", new Dictionary <string, object> {
                { "hero_damage_hazard", tmpV }
            });
            break;

        case "hero_damage_boss":
            Analytics.CustomEvent("hero_damage_boss", new Dictionary <string, object> {
                { "hero_damage_boss", tmpV }
            });
            break;



        case "gate_open_attic":
            Analytics.CustomEvent("gate_open_attic", new Dictionary <string, object> {
                { "gate_open_attic", tmpV }
            });
            break;

        case "gate_open_basement":
            Analytics.CustomEvent("gate_open_basement", new Dictionary <string, object> {
                { "gate_open_basement", tmpV }
            });
            break;

        case "gate_open_window":
            Analytics.CustomEvent("gate_open_window", new Dictionary <string, object> {
                { "gate_open_window", tmpV }
            });
            break;



        case "enemy_killed_cat":
            Analytics.CustomEvent("enemy_killed_cat", new Dictionary <string, object> {
                { "enemy_killed_cat", tmpV }
            });
            break;

        case "enemy_killed_ant":
            Analytics.CustomEvent("enemy_killed_ant", new Dictionary <string, object> {
                { "enemy_killed_ant", tmpV }
            });
            break;

        case "enemy_killed_bat":
            Analytics.CustomEvent("enemy_killed_bat", new Dictionary <string, object> {
                { "enemy_killed_bat", tmpV }
            });
            break;



        case "boss_killed_mercurial":
            Analytics.CustomEvent("boss_killed_mercurial", new Dictionary <string, object> {
                { "boss_killed_mercurial", tmpV }
            });
            break;

        case "boss_killed_gencat":
            Analytics.CustomEvent("boss_killed_gencat", new Dictionary <string, object> {
                { "boss_killed_gencat", tmpV }
            });
            break;



        case "cutscene_warroom_intro":
            Analytics.CustomEvent("cutscene_warroom_intro", new Dictionary <string, object> {
                { "cutscene_warroom_intro", tmpV }
            });
            break;

        case "cutscene_couchistan_intro":
            Analytics.CustomEvent("cutscene_couchistan_intro", new Dictionary <string, object> {
                { "cutscene_couchistan_intro", tmpV }
            });
            break;

        case "cutscene_couchistan_boss_mercurial_intro":
            Analytics.CustomEvent("cutscene_couchistan_boss_mercurial_intro", new Dictionary <string, object> {
                { "cutscene_couchistan_boss_mercurial_intro", tmpV }
            });
            break;

        case "cutscene_couchistan_boss_mercurial_death":
            Analytics.CustomEvent("cutscene_couchistan_boss_mercurial_death", new Dictionary <string, object> {
                { "cutscene_couchistan_boss_mercurial_death", tmpV }
            });
            break;

        case "cutscene_couchistan_boss_gencat_intro":
            Analytics.CustomEvent("cutscene_couchistan_boss_gencat_intro", new Dictionary <string, object> {
                { "cutscene_couchistan_boss_gencat_intro", tmpV }
            });
            break;

        case "cutscene_couchistan_boss_gencat_death":
            Analytics.CustomEvent("cutscene_couchistan_boss_gencat_death", new Dictionary <string, object> {
                { "cutscene_couchistan_boss_gencat_death", tmpV }
            });
            break;

        case "cutscene_couchistan_complete":
            Analytics.CustomEvent("cutscene_couchistan_complete", new Dictionary <string, object> {
                { "cutscene_couchistan_complete", tmpV }
            });
            break;


        default:
            break;
        } //end switch
    }     //end f
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        // Getting stats
        m_PlayerStats = GameObject.FindGameObjectWithTag("Player Statistics").GetComponent <PlayerStatistics>();
        m_Score.GetComponent <Text> ().text = m_CountUp_Score.ToString();
        m_CountUp_Progress = -1;
        m_fPreCountUp      = 0.0f;

        m_CountUp_Gems = new int[4];

        int gemDestroyed = 0;

        for (int i = 0; i < m_PlayerStats.m_aDestroyCount.Length; ++i)
        {
            m_CountUp_Gems[i] = 0;
            gemDestroyed     += m_PlayerStats.m_aDestroyCount[i];
        }

        // Find the score without boosters, to use for gold calc
        int realScore = (int)Mathf.Round(m_PlayerStats.m_nScore / BoosterManager.Instance.GetBoostValue(BOOSTERTYPE.ScoreMult) / BoosterManager.Instance.GetScoreMultOnce());

        m_GoldEarned = (int)Mathf.Round(realScore / 100 * BoosterManager.Instance.GetBoostValue(BOOSTERTYPE.GoldMult) * BoosterManager.Instance.GetGoldMultOnce());
        if (GameData.Instance.m_Boost_GoldMultOnce)
        {
            GameData.Instance.m_Boost_GoldMultOnce = false;
        }
        if (GameData.Instance.m_Boost_MoreHealthOnce)
        {
            GameData.Instance.m_Boost_MoreHealthOnce = false;
        }
        if (GameData.Instance.m_Boost_ScoreMultOnce)
        {
            GameData.Instance.m_Boost_ScoreMultOnce = false;
        }

        m_CoinsThisRound.GetComponent <Text>().text = m_CountUp_Gold.ToString();
        m_LeakedCounter.GetComponent <Text>().text  = m_CountUp_GemGrey.ToString();
        m_ComboCounter.GetComponent <Text> ().text  = m_CountUp_Combo.ToString();

        m_HighScoreText.SetActive(false);
        if (GameData.Instance.m_HighScore < m_PlayerStats.m_nScore)
        {
            GameData.Instance.m_HighScore = m_PlayerStats.m_nScore;
            m_HighScoreText.SetActive(true);
        }

        if (GameData.Instance.m_HighestCombo < m_PlayerStats.m_nMaxCombo)
        {
            GameData.Instance.m_HighestCombo = m_PlayerStats.m_nMaxCombo;
        }

        m_BestScore.GetComponent <Text>().text = "Best " + GameData.Instance.m_HighScore.ToString();

        // Initialising animation timer
        m_nFrameNum = m_PlayerStats.m_aGems[0].GetComponent <GemSpriteContainer>().m_Sprites.Length;
        for (int i = 1; i < m_PlayerStats.m_aGems.Length; ++i)
        {
            int num = m_PlayerStats.m_aGems[i].GetComponent <GemSpriteContainer>().m_Sprites.Length;
            m_nFrameNum = m_nFrameNum > num ? num : m_nFrameNum;
        }
        m_fAnimationIntervalTimer = 0.0f;
        m_fAnimationTimer         = 0.0f;
        m_bAnimating      = false;
        m_nAnimatingFrame = -1;

        if (m_PlayerStats.m_nScore > 0)
        {
            AchievementManager.Instance.AddGamesPlayed();
            AchievementManager.Instance.AddCoinsEarned(m_GoldEarned);
            AchievementManager.Instance.AddScoreEarned(m_PlayerStats.m_nScore);
            AchievementManager.Instance.AddLinkedGems(1, m_PlayerStats.m_aDestroyCount[0]);
            AchievementManager.Instance.AddLinkedGems(2, m_PlayerStats.m_aDestroyCount[1]);
            AchievementManager.Instance.AddLinkedGems(3, m_PlayerStats.m_aDestroyCount[2]);
            AchievementManager.Instance.AddLinkedGems(4, m_PlayerStats.m_aDestroyCount[3]);

            AchievementManager.Instance.AddCombo(m_PlayerStats.m_nMaxCombo);
            AchievementManager.Instance.AddCoinsEarned_PerGame(m_GoldEarned);
            AchievementManager.Instance.AddScoreEarned_PerGame(m_PlayerStats.m_nScore);
        }

        Analytics.CustomEvent("Scorecard", new Dictionary <string, object>
        {
            { "Score", m_PlayerStats.m_nScore },
            { "RedGem", m_PlayerStats.m_aDestroyCount[0] },
            { "BlueGem", m_PlayerStats.m_aDestroyCount[1] },
            { "GreenGem", m_PlayerStats.m_aDestroyCount[2] },
            { "YellowGem", m_PlayerStats.m_aDestroyCount[3] },
            { "GreyGem", m_PlayerStats.m_nLeakCount.ToString() },
            { "Combo", m_PlayerStats.m_nMaxCombo },
            { "GoldEarned", m_GoldEarned }
        });

#if LINKIT_COOP
        if (NetworkManager.IsConnected())
        {
            NetworkManager.Disconnect();
        }
#endif   // LINKIT_COOP

        GameData.Instance.m_Coin += m_PlayerStats.m_nCoinsGain;
        m_CurrentCoins            = GameData.Instance.m_Coin;
        m_nShowingCoins           = GameData.Instance.m_Coin;
        m_nPrevCoins              = GameData.Instance.m_Coin;
        m_fCoinsTimer             = 0.0f;
        GameData.Instance.m_Coin += m_GoldEarned;

        Text coinsText = m_Coins.GetComponent <Text>();
        coinsText.text = m_nShowingCoins.ToString();        // + " (+" + m_PlayerStats.m_nCoinsGain + ")";

#if UNITY_ANDROID
        GooglePlayService.PostHighScore(m_PlayerStats.m_nScore);
#elif UNITY_IOS
        GameCenterService.PostHighScore(m_PlayerStats.m_nScore);
#endif

        AchievementManager.Instance.BoosterGamesPlayed();
        AchievementManager.Instance.BoosterPointsEarned(m_PlayerStats.m_nScore);

        // Save
        //SaveLoad.Save();
        SaveDataLoader.SaveGame();

        if (GameObject.FindGameObjectWithTag("Gem Details") != null)
        {
            m_GemDetails = GameObject.FindGameObjectWithTag("Gem Details").GetComponent <GemDetails>();
        }

        m_bIsCurrentScreenScore = true;
        m_bScreenAnimate        = false;
        m_fScreenAnimateTimer   = 0.0f;
        m_fScreenWidth          = m_ScoreCanvas.GetComponent <RectTransform>().sizeDelta.x;
        GoToScore();
    }
Esempio n. 10
0
 /// <summary>
 /// Used to track how many times a screen has been viewed
 /// </summary>
 public static void ScreenView(string screenName)
 {
     Analytics.CustomEvent(screenName + " Screen View");
 }
Esempio n. 11
0
    /// <summary>
    /// Call to check if analytics are firering correctly
    /// </summary>
    public static void TestAnalyitc()
    {
        AnalyticsResult ar = Analytics.CustomEvent("MyEvent");

        Debug.Log("Result = " + ar.ToString());
    }
Esempio n. 12
0
 /// <summary>
 /// Triggerd when the player starts a game
 /// </summary>
 public static void GameStarted()
 {
     Analytics.CustomEvent("GameStarted");
 }
Esempio n. 13
0
 void SendCustomEvent(string pCustomEventName, Dictionary <string, object> pObject)
 {
     Analytics.CustomEvent(pCustomEventName, pObject);
 }
Esempio n. 14
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     Analytics.CustomEvent("Lvl5Winner");
 }
Esempio n. 15
0
 public static void StartGame()
 {
     startTimeGame = System.DateTime.Now;
     Analytics.CustomEvent("StartGame", null);
 }
Esempio n. 16
0
    public void TakeDamage(Attack attack)
    {
        health -= attack.damage;

        if (health <= 0)
        {
            legs.SetActive(false);
            health = 0;
            if (!dead)
            {
                dead = true;

                Debug.Log("Evento Matar <" +
                          " nivel: " + (GameObject.FindGameObjectWithTag("Portal").GetComponent <NextLevel>().nextLevel - 1) +
                          " tiempo: " + (Time.time - GameObject.FindGameObjectWithTag("Score").GetComponent <Score>().tiempoLevel) +
                          " enemigo: " + (this.name) +
                          " arma:" + attack.arma +
                          " CordenadasX: " + GameObject.FindGameObjectWithTag("Player").transform.position.x +
                          " CordenadasY: " + GameObject.FindGameObjectWithTag("Player").transform.position.y + ">");

                Analytics.CustomEvent("Matar", new Dictionary <string, object> {
                    { "nivel", (GameObject.FindGameObjectWithTag("Portal").GetComponent <NextLevel>().nextLevel - 1) },
                    { "tiempo", (Time.time - GameObject.FindGameObjectWithTag("Score").GetComponent <Score>().tiempoLevel) },
                    { "enemigo", (this.name) },
                    { "arma", attack.arma },
                    { "CordenadasX", (GameObject.FindGameObjectWithTag("Enemy").transform.position.x) },
                    { "CordenadasY", (GameObject.FindGameObjectWithTag("Enemy").transform.position.y) }
                });
            }
            animator.SetBool("Dead", true);

            if (sprite)
            {
                sprite.sortingLayerName = "Dead";
            }
            if (child_sprite)
            {
                child_sprite.sortingLayerName = "Dead";
            }

            if (portal != null)
            {
                portal.GetComponent <NextLevel>().enemiesAlive -= 1;
            }

            if (score != null)
            {
                if (score.GetComponent <Score>().lastWeaponUsed != player.GetComponent <Equipment>().equippedWeapon)
                {
                    score.GetComponent <Score>().score += 500;
                }
                else
                {
                    score.GetComponent <Score>().score += 100;
                }
                score.GetComponent <Score>().lastWeaponUsed = player.GetComponent <Equipment>().equippedWeapon;
            }
            if ((GetComponent <WeaponPickup>()) != null)
            {
                if (GetComponent <WeaponPickup>().weaponEquipped != null)
                {
                    weaponPickup.weaponEquipped.transform.position = transform.position;
                    weaponPickup.weaponEquipped.SetActive(true);
                    weaponPickup.weaponEquipped = null;
                    animator.SetBool("has weapon", false);
                }
            }
        }
        else
        {
            legs.SetActive(false);
            // Si sobrevivio al ataque, queda noqueado

            gameObject.GetComponent <Animator>().SetBool("Knocked", true);

            //Debug.Log("Got Knocked.");
            transform.Translate(new Vector3(0, 0, 0));

            //Knocked = true;
            Debug.Log("Evento Noqueado <" + "nivel: " + (GameObject.FindGameObjectWithTag("Portal").GetComponent <NextLevel>().nextLevel - 1) +
                      " tiempo: " + (Time.time - GameObject.FindGameObjectWithTag("Score").GetComponent <Score>().tiempoLevel) +
                      " enemigo: " + (this.name) +
                      " arma;" + attack.arma +
                      " CordenadasX: " + GameObject.FindGameObjectWithTag("Enemy").transform.position.x +
                      " CordenadasY:" + GameObject.FindGameObjectWithTag("Enemy").transform.position.y + ">");
            Analytics.CustomEvent("Noqueado", new Dictionary <string, object>
            {
                { "nivel", (GameObject.FindGameObjectWithTag("Portal").GetComponent <NextLevel>().nextLevel - 1) },
                { "tiempo", (Time.time - GameObject.FindGameObjectWithTag("Score").GetComponent <Score>().tiempoLevel) },
                { "enemigo", (this.name) },
                { "arma", attack.arma },
                { "CordenadasX", (GameObject.FindGameObjectWithTag("Enemy").transform.position.x) },
                { "CordenadasY", (GameObject.FindGameObjectWithTag("Enemy").transform.position.y) }
            });

            if (GetComponent <WeaponPickup>().weaponEquipped != null)
            {
                weaponPickup.weaponEquipped.transform.position = transform.position;
                weaponPickup.weaponEquipped.SetActive(true);
                weaponPickup.weaponEquipped = null;
                animator.SetBool("has weapon", false);
            }
        }



        //Debug.Log("Got Hit.");
    }
Esempio n. 17
0
    public virtual void Show(bool isWon, float time, int points = 0, ChallengeManager.GameStates gameState = ChallengeManager.GameStates.Leaved, ChallengeManager.GameStateMessage message = null)
    {
        _multiplayer = GameSparksManager.Instance.GetGameMode() == GameMode.Multi;

        _buttonPurchaseObject = GameObject.Find("PurchaseButton");

        if (_buttonPurchaseObject != null && !_multiplayer)
        {
            _inviteOriginalParent   = _buttonPurchaseObject.transform.parent.gameObject;
            _inviteOriginalPosition = _buttonPurchaseObject.transform.position;

            _inviteButtonObject = gameObject;
            DialogInstance _inviteDialogInstance = gameObject.GetComponent <DialogInstance>();

            GameObjectUtils.MoveObjectToAtIndex(_buttonPurchaseObject, _inviteDialogInstance.Target, 1);
        }

        pointsView      = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "PointsView", true);
        shareView       = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "SharingView", true);
        multiplayerView = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "MultiplayerPointsView", true);

        if (_multiplayer)
        {
            pointsView.SetActive(false);
            multiplayerView.SetActive(true);

            if (gameState == ChallengeManager.GameStates.Won || gameState == ChallengeManager.GameStates.Draw)
            {
                ButtonUtils.PlayWinSound();
            }
            else
            {
                ButtonUtils.PlayLoseSound();
            }
        }
        else
        {
            pointsView.SetActive(true);
            multiplayerView.SetActive(false);

            ButtonUtils.PlayWinSound();
        }

        var currentLevel = GameManager.Instance.Levels.Selected;

        int  coins           = 0;
        bool firstTimePlayed = _multiplayer ? true : currentLevel.ProgressBest < 0.9f;

        LevelManager.Instance.EndLevel();

        this.Coins = coins;

        if (firstTimePlayed && !_multiplayer)
        {
            currentLevel.AddPoints(points);
            currentLevel.ProgressBest = 1.0f;
        }

        if (_multiplayer && gameState == ChallengeManager.GameStates.Lost)
        {
            points *= -1;
        }

        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Dialog", true), false);

        Assert.IsTrue(LevelManager.IsActive, "Ensure that you have a LevelManager component attached to your scene.");

        if (coins > 0 && !_multiplayer)
        { // add coins for this level
            currentLevel.AddCoins(coins);
            GameManager.Instance.Player.AddCoins(coins);
        }

        GameManager.Instance.Player.AddPoints(points);

        // update the player coins if necessary
        if (((UpdatePlayerCoins == CopyType.Always) || (UpdatePlayerCoins == CopyType.OnWin && isWon)) && !_multiplayer)
        {
            GameManager.Instance.Player.AddCoins(currentLevel.Coins);
        }

        // show won / lost game objects as appropriate
        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Lost", true), !isWon);

        // see if the world or game is won and also if we should unlock the next world / level
        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "GameWon", true), false);
        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "WorldWon", true), false);
        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "LevelWon", true), false);
        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Won", true), false);

        GameObject levelName = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "LevelName", true);

        if (_multiplayer)
        {
            levelName.GetComponent <Text>().text = LocaliseText.Get("LevelCompleted.Match");
        }
        else
        {
            levelName.GetComponent <Text>().text = LocaliseText.Format("LevelCompleted.LevelName", currentLevel.Number);
        }

        GameObjectHelper.SafeSetActive(levelName, true);

        if (!_multiplayer && isWon)
        {
            GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Won", true), true);

            // process and update game state - do this last so we can check some bits above.
            GameHelper.ProcessCurrentLevelComplete();
        }

        // set some text based upon the result
        UIHelper.SetTextOnChildGameObject(DialogInstance.gameObject, "AchievementText", LocaliseText.Format(LocalisationBase + ".Achievement", currentLevel.Score, currentLevel.Name));

        // setup stars
        var starsGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Stars", true);

        GameObjectHelper.SafeSetActive(starsGameObject, ShowStars);
        if (ShowStars && !_multiplayer)
        {
            Assert.IsNotNull(starsGameObject, "GameOver->ShowStars is enabled, but could not find a 'Stars' gameobject. Disable the option or fix the structure.");
            starsGameObject.SetActive(ShowStars);
            var newStarsWon = GetNewStarsWon();
            currentLevel.StarsWon |= newStarsWon;
            var star1WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star1", true);
            var star2WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star2", true);
            var star3WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star3", true);
            StarWon(currentLevel.StarsWon, newStarsWon, star1WonGameObject, 1, coins);
            StarWon(currentLevel.StarsWon, newStarsWon, star2WonGameObject, 2, coins);
            StarWon(currentLevel.StarsWon, newStarsWon, star3WonGameObject, 4, coins);
            GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(starsGameObject, "StarWon", true), newStarsWon != 0);
        }

        // set time

        var timeGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Time", true);

        GameObjectHelper.SafeSetActive(timeGameObject, ShowTime);
        if (!_multiplayer && ShowTime)
        {
            TimeSpan timeSpan = TimeSpan.FromSeconds(time);

            string timeText = LocaliseText.Format("LevelCompleted.Time", timeSpan.Minutes, timeSpan.Seconds);

            Assert.IsNotNull(timeGameObject, "GameOver->ShowTime is enabled, but could not find a 'Time' gameobject. Disable the option or fix the structure.");

            UIHelper.SetTextOnChildGameObject(timeGameObject, "TimeResult", timeText, true);
        }

        if (!_multiplayer && currentLevel.TimeBest < 0.05)
        { // save only first time played
            currentLevel.TimeBest = time;
        }

        // set coins
        if (ShowCoins && coins > 0)
        {
            var coinsGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Coins", true);
            GameObjectHelper.SafeSetActive(coinsGameObject, ShowCoins);

            Assert.IsNotNull(coinsGameObject, "GameOver->ShowCoins is enabled, but could not find a 'Coins' gameobject. Disable the option or fix the structure.");
            UIHelper.SetTextOnChildGameObject(coinsGameObject, "CoinsResult", coins.ToString(), true);
        }

        if (!_multiplayer)
        {
            if (firstTimePlayed)
            {
                GameObject DoubleButton = GameObjectHelper.GetChildNamedGameObject(pointsView, "DoubleButton", true);
                DoubleButton.SetActive(Reachability.Instance.IsReachable());
            }
            else
            {
                GameObject ShareButton = GameObjectHelper.GetChildNamedGameObject(pointsView, "ShareButton", true);
                ShareButton.SetActive(true);
            }
        }

        // set score
        var scoreGameObject = GameObjectHelper.GetChildNamedGameObject(_multiplayer ? multiplayerView : pointsView, "Score", true);

        GameObjectHelper.SafeSetActive(scoreGameObject, ShowScore);

        if (!firstTimePlayed)
        {
            GameObjectHelper.SafeSetActive(scoreGameObject, false);
        }

        if (!_multiplayer && firstTimePlayed)
        {
            GameObject adsObject  = GameObjectHelper.GetChildNamedGameObject(pointsView, "Ads", true);
            Text       unlockText = GameObjectHelper.GetChildComponentOnNamedGameObject <Text>(pointsView, "UnlockText", true);

            if (LevelController.Instance.LastLevelInPack(currentLevel))
            {
                Pack pack     = LevelController.Instance.PackForLevel(currentLevel);
                Pack nextPack = LevelController.Packs().GetItem(pack.Number + 1);

                if (nextPack)
                {
                    nextPack.LoadData();

                    adsObject.SetActive(false);
                    unlockText.gameObject.SetActive(true);

                    unlockText.text = LocaliseText.Format("LevelCompleted.LastLevelInPack", LocaliseText.Get(nextPack.JsonData.GetString("name")));
                }
            }

            if (LevelController.Instance.LastLevelInRank(currentLevel))
            {
                Rank rank     = LevelController.Instance.RankForLevel(currentLevel);
                Rank nextRank = LevelController.Ranks().GetItem(rank.Number + 1);

                if (nextRank)
                {
                    nextRank.LoadData();

                    adsObject.SetActive(false);
                    unlockText.gameObject.SetActive(true);

                    unlockText.text = LocaliseText.Format("LevelCompleted.LastLevelInRank", LocaliseText.Get(nextRank.JsonData.GetString("name")));
                }
            }
        }

        if (ShowScore)
        {
            Assert.IsNotNull(scoreGameObject, "GameOver->ShowScore is enabled, but could not find a 'Score' gameobject. Disable the option or fix the structure.");

            UIHelper.SetTextOnChildGameObject(scoreGameObject, "ScoreResult", LocaliseText.Format("LevelCompleted.Score", "0"), true);

            AnimateScoreText(points);
        }

        if (_multiplayer)
        {
            var resultStateObject = GameObjectHelper.GetChildNamedGameObject(multiplayerView, "ResultState", true);
            GameObjectHelper.SafeSetActive(resultStateObject, true);

            string text = "";

            switch (gameState)
            {
            case ChallengeManager.GameStates.Won:
                text = LocaliseText.Get("Game.YouWon");
                break;

            case ChallengeManager.GameStates.Lost:
                text = LocaliseText.Get("Game.YouLost");
                break;

            case ChallengeManager.GameStates.Draw:
                text = LocaliseText.Get("Game.ItsDrawn");
                break;
            }

            resultStateObject.GetComponent <Text>().text = text;
        }

        if (!_multiplayer)
        {
            UpdateNeededCoins();

            LevelController.Instance.PackProgressCompleted(currentLevel);
            UnlockNextLevel();

            //

            int StartupLevels = ((CustomGameManager)CustomGameManager.Instance).StartupLevels;

            if (StartupLevels == currentLevel.Number)
            {
                GameObject adsObject = GameObjectHelper.GetChildNamedGameObject(pointsView, "Ads", true);

                Text adsText = adsObject.GetComponent <Text>();

                adsText.text                 = LocaliseText.Get("Text.PlayedAllLevels");
                adsText.fontSize             = 39;
                adsText.resizeTextForBestFit = false;

                if (!Debug.isDebugBuild)
                {
                    Flurry.Flurry.Instance.LogEvent("Game_LastLevel", new Dictionary <string, string>()
                    {
                        { "Level", currentLevel.Number.ToString() }
                    });
                    Fabric.Answers.Answers.LogCustom("Game_LastLevel", new Dictionary <string, object>()
                    {
                        { "Level", currentLevel.Number.ToString() }
                    });
                }
            }
        }

        if (!_multiplayer && firstTimePlayed)
        {
            JSONObject pointsData = new JSONObject();
            pointsData.Add("Level", currentLevel.Number.ToString());
            pointsData.Add("Language", LocaliseText.Language);
            pointsData.Add("RealLanguage", LanguageUtils.RealLanguage(LocaliseText.Language));
            pointsData.Add("Time", time.ToString());
            pointsData.Add("UsedHints", GameController.Instance.usedHintsCount);
            pointsData.Add("UserCoins", GameManager.Instance.Player.Coins);
            pointsData.Add("Words", JsonUtils.ListToArray(GameController.Instance.GetFoundWords()));
            pointsData.Add("Date", DateTimeUtils.DateTimeToISO8601(UnbiasedTime.Instance.UTCNow()));

            GameSparksManager.Instance.SendPoints(points, "LevelComplete", pointsData);
        }

        //

        GameObject completeTextGameObject = GameObjectHelper.GetChildNamedGameObject(_multiplayer ? multiplayerView : pointsView, "CompleteText", true);

        // save game state.
        GameManager.Instance.Player.UpdatePlayerPrefs();

        if (!_multiplayer)
        {
            currentLevel.UpdatePlayerPrefs();
        }

        PreferencesFactory.Save();

        GameObject NameContainer = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "NameContainer", true);
        GameObject LevelName     = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "LevelName", true);
        GameObject Results       = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "Results", true);
        GameObject Buttons       = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "Buttons", true);
        GameObject CloseButton   = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "Close", true);

        GameObject parent = DialogInstance.Content.transform.parent.gameObject;

        Vector3 currentScale = parent.transform.localScale;

        parent.transform.DOScale(new Vector3(0, 0, 0), 0.0f);
        NameContainer.transform.localScale          = new Vector3(0, 0, 0);
        LevelName.transform.localScale              = new Vector3(0, 0, 0);
        Results.transform.localScale                = new Vector3(0, 0, 0);
        Buttons.transform.localScale                = new Vector3(0, 0, 0);
        completeTextGameObject.transform.localScale = new Vector3(0, 0, 0);

        CloseButton.GetComponent <Image>().color = new Color(1, 1, 1, 0);

        //show dialog
        DialogInstance.Show();

        parent.transform.DOScale(currentScale, 1.0f).SetEase(Ease.OutElastic);
        NameContainer.transform.DOScale(new Vector3(1, 1, 1), 1.5f).SetDelay(0.1f).SetEase(Ease.OutElastic);
        LevelName.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.2f).SetEase(Ease.OutElastic);
        Results.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.2f).SetEase(Ease.OutElastic);
        Buttons.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.2f).SetEase(Ease.OutElastic);
        completeTextGameObject.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.35f).SetEase(Ease.OutElastic);

        CloseButton.GetComponent <Image>().DOFade(1, 0.5f).SetDelay(0.7f);

        GameObject Light = GameObjectHelper.GetChildNamedGameObject(completeTextGameObject, "Light", true);

        Light.transform.DOLocalRotate(new Vector3(0, 0, -360), 10, RotateMode.LocalAxisAdd).SetLoops(-1).SetEase(Ease.Linear);

        //TODO bug - as we increase TimesPlayedForRatingPrompt on both game start (GameManager) and level finish we can miss this comparison.
        if (GameManager.Instance.TimesPlayedForRatingPrompt == TimesPlayedBeforeRatingPrompt)
        {
            GameFeedback gameFeedback = new GameFeedback();
            gameFeedback.GameFeedbackAssumeTheyLikeOptional();
        }

#if UNITY_ANALYTICS
        // record some analytics on the level played
        if (!_multiplayer)
        {
            var values = new Dictionary <string, object>
            {
                { "score", currentLevel.Score },
                { "Coins", coins },
                { "time", time },
                { "level", currentLevel.Number }
            };
            Analytics.CustomEvent("LevelCompleted", values);
        }
#endif

#if UNITY_EDITOR
        if (!_multiplayer)
        {
            GameSparksManager.Instance.SyncProgressCoroutine();
        }
#endif

#if !UNITY_EDITOR
        AdColonyManager.Instance.RequestAd();
        AdColonyManager.Instance.RequestAd(Constants.AdColonyDoubleCoins);

        LoadInterstitialAd();
        LoadAdmobRewarderVideo();
#endif

        // co routine to periodic updates of display (don't need to do this every frame)
        if (!Mathf.Approximately(PeriodicUpdateDelay, 0))
        {
            StartCoroutine(PeriodicUpdate());
        }
    }
Esempio n. 18
0
        public void Update()
        {
            if (_updateNeeded == true && _callback != null)
            {
                var segmentConfig = _cachedSegmentConfig;
                var deviceInfo    = _deviceInfo;
                try
                {
                    var roundtripTime = Time.time - _startTime;
                    Debug.LogFormat("autotune roundtrip: {0}", roundtripTime);
                    _callback(segmentConfig.settings, segmentConfig.group_id);

                    // should not happen but do not want to write null checks in code below this
                    if (deviceInfo == null)
                    {
                        deviceInfo = new DeviceInfo(_sheetId, _buildVersion);
                    }

                    // device information data should reuse the same naming convention as DeviceInfo event
                    var status = Analytics.CustomEvent("autotune.SegmentRequestInfo", new Dictionary <string, object>()
                    {
                        { "segment_id", segmentConfig.segment_id },
                        { "group_id", segmentConfig.group_id },
                        { "error", _isError },
                        { "player_override", _isPlayerOverride },
                        { "request_latency", roundtripTime },
                        { "model", deviceInfo.model },
                        { "ram", deviceInfo.ram },
                        { "cpu", deviceInfo.cpu },
                        { "cpu_count", deviceInfo.cpu_count },
                        { "gfx_name", deviceInfo.gfx_name },
                        { "gfx_vendor", deviceInfo.gfx_vendor },
                        { "screen", deviceInfo.screen },
                        { "dpi", deviceInfo.dpi },
                        { "gfx_ver", deviceInfo.gfx_ver },
                        { "gfx_shader", deviceInfo.gfx_shader },
                        { "max_texture_size", deviceInfo.max_texture_size },
                        { "os_ver", deviceInfo.os_ver },
                        { "platformid", deviceInfo.platformid },
                        { "app_build_version", _buildVersion },
                        { "plugin_version", AutoTuneMeta.version },
                        { "sheet_id", deviceInfo.sheet_id }
                    });

                    Debug.Log("autotune.SegmentRequestInfo event status: " + status);
                    FirebaseConnection.GetInstance().PushEventStatus(status);

                    var dic = new Dictionary <string, object>()
                    {
                        { "segment_id", segmentConfig.segment_id },
                        { "group_id", segmentConfig.group_id },
                        { "error", _isError },
                        { "player_override", _isPlayerOverride },
                        { "request_latency", roundtripTime },
                        { "model", deviceInfo.model },
                        { "ram", deviceInfo.ram },
                        { "cpu", deviceInfo.cpu },
                        { "cpu_count", deviceInfo.cpu_count },
                        { "gfx_name", deviceInfo.gfx_name },
                        { "gfx_vendor", deviceInfo.gfx_vendor },
                        { "screen", deviceInfo.screen },
                        { "dpi", deviceInfo.dpi },
                        { "gfx_ver", deviceInfo.gfx_ver },
                        { "gfx_shader", deviceInfo.gfx_shader },
                        { "max_texture_size", deviceInfo.max_texture_size },
                        { "os_ver", deviceInfo.os_ver },
                        { "platformid", deviceInfo.platformid },
                        { "app_build_version", _buildVersion },
                        { "plugin_version", AutoTuneMeta.version },
                        { "sheet_id", deviceInfo.sheet_id }
                    };

                    FirebaseConnection.GetInstance().PushAutotuneDic(dic);
                }
                catch (System.Exception e)
                {
                    Debug.LogError(e);
                }
                finally
                {
                    _isError      = false;
                    _updateNeeded = false;
                }
            }
        }
Esempio n. 19
0
    public void Update()
    {
        if ((knocked) || (dead))
        {
            if (sprite)
            {
                sprite.sortingLayerName = "Dead";
            }
            if (child_object)
            {
                child_object.SetActive(false);
            }
            GetComponent <Animator>().SetBool("Knocked", true);
            GetComponent <RotateToCursor>().enabled = false;
            GetComponent <Movement>().enabled       = false;
            GetComponent <PlayerInteract>().enabled = false;
        }
        else
        if (!knocked)
        {
            if (sprite)
            {
                sprite.sortingLayerName = "Player";
            }
            if (child_object)
            {
                child_object.SetActive(true);
            }
            GetComponent <Animator>().SetBool("Knocked", false);
            GetComponent <RotateToCursor>().enabled = true;
            GetComponent <Movement>().enabled       = true;
            GetComponent <PlayerInteract>().enabled = true;
        }

        ///Knocked Logic
        if (knocked)
        {
            if (Time.time > knockedTimer + 2)
            {
                knocked      = false;
                knockedTimer = Time.time;
            }
            equipment.DropWeapon();
        }



        if (dead == true)
        {
            RestartButton.gameObject.SetActive(true);
            Time.timeScale = 0f;


            if (Input.GetKeyDown(KeyCode.R))
            {
                Globales.muertes++;
                Debug.Log("Evento ReiniciarNivel <"
                          + " nivel: " + (GameObject.FindGameObjectWithTag("Portal").GetComponent <NextLevel>().nextLevel - 1)
                          + " tiempo: " + GameObject.FindGameObjectWithTag("Score").GetComponent <Score>().tiempoLevel
                          + " puntos: " + GameObject.FindGameObjectWithTag("Score").GetComponent <Score>().score
                          + " muertes: " + Globales.muertes + " >");
                Analytics.CustomEvent("ReiniciarNivel", new Dictionary <string, object>
                {
                    { "nivel", (GameObject.FindGameObjectWithTag("Portal").GetComponent <NextLevel>().nextLevel - 1) },
                    { "tiempo", (GameObject.FindGameObjectWithTag("Score").GetComponent <Score>().tiempoLevel) },
                    { "puntos", (GameObject.FindGameObjectWithTag("Score").GetComponent <Score>().score) },
                    { "muertes", Globales.muertes }
                });
                SceneManager.LoadScene(SceneManager.GetActiveScene().name); //remember to mention new scene manager using thing
                Time.timeScale = 1f;
            }
        }

        if (dead == false)
        {
            RestartButton.gameObject.SetActive(false);
        }
    }
Esempio n. 20
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            attacked = col.gameObject.GetComponent <EnemyAttacked> ();
            //attacked.killBullet (); // Llama a la funcion para matar con arma

            // EL SIGUIENTE CODIGO ES PARA QUE MIRTHA TENGA MAS VIDA

            if (GameManager.lifeBoss > 0 && col.gameObject.name == "Mirtha")
            {
                GameManager.lifeBoss -= 1;
            }
            else
            {
                attacked.killBullet(this);
            }

            // AQUI TERMINA EL CODIGO PARA MIRTHA

            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
            Destroy(this.gameObject);
        }
        else if (col.gameObject.tag == "Enemy" && creator == "Enemy")
        {
        }
        else if (col.gameObject.tag == "Heavy")
        {
            ha = col.gameObject.GetComponent <HeavyAttacked> ();
            ha.hitByBullet();
            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
            Destroy(this.gameObject);
        }
        else if (col.gameObject.tag == "Player")
        {
            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
            Debug.Log("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* Bullet");

            if (!PlayerHealth.dead)
            {
                PlayerHealth.dead = true;//new for 10
                //Debug.Log("me mato con el arma " + arma);
                int level;
                if (sceneName == "Tutorial")
                {
                    level = 0;
                }
                else
                {
                    level = Utils.LevelFromSceneName(sceneName);
                }
                Debug.Log("nivel de Morir: " + level);
                Debug.Log("enemigo de Morir: " + asesino);
                Debug.Log("tiempo de Morir: " + Time.timeSinceLevelLoad);
                Debug.Log("coordenada X de Morir: " + col.gameObject.transform.position.x);
                Debug.Log("coordenada Y de Morir: " + col.gameObject.transform.position.y);
                Debug.Log("arma de Morir: " + arma);
                Debug.Log("Insertar evento de morir");

                Analytics.CustomEvent("Morir", new Dictionary <string, object>
                {
                    { "nivel", level },
                    { "enemigo", asesino },
                    { "tiempo", Time.timeSinceLevelLoad },
                    { "CordenadasX", col.gameObject.transform.position.x },
                    { "CordenadasY", col.gameObject.transform.position.y },
                    { "Arma", arma }
                }
                                      );

                // Morir
            }

            Destroy(this.gameObject);
        }
        else if (col.gameObject.tag != "Enemy" && col.gameObject.tag != "Player" && col.gameObject.tag != "Dog" && col.gameObject.tag != "Heavy")
        {
            //Debug.Log ("hit");
            Instantiate(wallImpact, this.transform.position, this.transform.rotation);
            Destroy(this.gameObject);
        }
        else if (col.gameObject.tag == "Dog")
        {
            Instantiate(bloodImpact, this.transform.position, this.transform.rotation);
            col.gameObject.GetComponent <DogHealth> ().killDog();
        }
    }
    public void IniciaAnimacao()
    {
        if (dialog.Alcool == 1)
        {
            if (dialog.Cigarro == 1)
            {
                if (dialog.Maconha == 1)
                {
                    if (dialog.Cocaina == 1 || dialog.Inalantes == 1 || dialog.Alucinogeno == 1 || dialog.Ecstasy == 1)
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 0;
                            Analytics.CustomEvent("Final: 3A1");
                        }
                        else                            //else crack
                        {
                            index = 1;
                            Analytics.CustomEvent("Final: 3A2");
                        }
                    }
                    else                        //else 4ª droga
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 2;
                            Analytics.CustomEvent("Final: 3B1");
                        }
                        else                            //else crack
                        {
                            index = 3;
                            Analytics.CustomEvent("Final: 3B2");
                        }
                    }
                }
                else                    //else maconha
                {
                    if (dialog.Cocaina == 1 || dialog.Inalantes == 1 || dialog.Alucinogeno == 1 || dialog.Ecstasy == 1)
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 4;
                            Analytics.CustomEvent("Final: 3C1");
                        }
                        else                            //else crack
                        {
                            index = 5;
                            Analytics.CustomEvent("Final: 3C2");
                        }
                    }
                    else                        //else 4ª droga
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 6;
                            Analytics.CustomEvent("Final: 3D1");
                        }
                        else                            //else crack
                        {
                            index = 7;
                            Analytics.CustomEvent("Final: 3D2");
                        }
                    }
                }
            }
            else                //else cigarro
            {
                if (dialog.Maconha == 1)
                {
                    if (dialog.Cocaina == 1 || dialog.Inalantes == 1 || dialog.Alucinogeno == 1 || dialog.Ecstasy == 1)
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 8;
                            Analytics.CustomEvent("Final: 3E1");
                        }
                        else                            //else crack
                        {
                            index = 9;
                            Analytics.CustomEvent("Final: 3E2");
                        }
                    }
                    else                        //else 4ª droga
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 10;
                            Analytics.CustomEvent("Final: 3F1");
                        }
                        else                            //else crack
                        {
                            index = 11;
                            Analytics.CustomEvent("Final: 3F2");
                        }
                    }
                }
                else                    //else maconha
                {
                    if (dialog.Cocaina == 1 || dialog.Inalantes == 1 || dialog.Alucinogeno == 1 || dialog.Ecstasy == 1)
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 12;
                            Analytics.CustomEvent("Final: 3G1");
                        }
                        else                            //else crack
                        {
                            index = 13;
                            Analytics.CustomEvent("Final: 3G2");
                        }
                    }
                    else                        //else 4ª droga
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 14;
                            Analytics.CustomEvent("Final: 3H1");
                        }
                        else                            //else crack
                        {
                            index = 15;
                            Analytics.CustomEvent("Final: 3H2");
                        }
                    }
                }
            }
        }
        else            //else alcool
        {
            if (dialog.Cigarro == 1)
            {
                if (dialog.Maconha == 1)
                {
                    if (dialog.Cocaina == 1 || dialog.Inalantes == 1 || dialog.Alucinogeno == 1 || dialog.Ecstasy == 1)
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 16;
                            Analytics.CustomEvent("Final: 3I1");
                        }
                        else                            //else crack
                        {
                            index = 17;
                            Analytics.CustomEvent("Final: 3I2");
                        }
                    }
                    else                        //else 4ª droga
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 18;
                            Analytics.CustomEvent("Final: 3J1");
                        }
                        else                            //else crack
                        {
                            index = 19;
                            Analytics.CustomEvent("Final: 3J2");
                        }
                    }
                }
                else                    //else maconha
                {
                    if (dialog.Cocaina == 1 || dialog.Inalantes == 1 || dialog.Alucinogeno == 1 || dialog.Ecstasy == 1)
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 20;
                            Analytics.CustomEvent("Final: 3K1");
                        }
                        else                            //else crack
                        {
                            index = 21;
                            Analytics.CustomEvent("Final: 3K2");
                        }
                    }
                    else                        //else 4ª droga
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 22;
                            Analytics.CustomEvent("Final: 3L1");
                        }
                        else                            //else crack
                        {
                            index = 23;
                            Analytics.CustomEvent("Final: 3L2");
                        }
                    }
                }
            }
            else                //else cigarro
            {
                if (dialog.Maconha == 1)
                {
                    if (dialog.Cocaina == 1 || dialog.Inalantes == 1 || dialog.Alucinogeno == 1 || dialog.Ecstasy == 1)
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 24;
                            Analytics.CustomEvent("Final: 3M1");
                        }
                        else                            //else crack
                        {
                            index = 25;
                            Analytics.CustomEvent("Final: 3M2");
                        }
                    }
                    else                        //else 4ª droga
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 26;
                            Analytics.CustomEvent("Final: 3N1");
                        }
                        else                            //else crack
                        {
                            index = 27;
                            Analytics.CustomEvent("Final: 3N2");
                        }
                    }
                }
                else                    //else maconha
                {
                    if (dialog.Cocaina == 1 || dialog.Inalantes == 1 || dialog.Alucinogeno == 1 || dialog.Ecstasy == 1)
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 28;
                            Analytics.CustomEvent("Final: 3O1");
                        }
                        else                            //else crack
                        {
                            index = 29;
                            Analytics.CustomEvent("Final: 3O2");
                        }
                    }
                    else                        //else 4ª droga
                    {
                        if (dialog.Crack == 1)
                        {
                            index = 30;
                            Analytics.CustomEvent("Final: 3P1");
                        }
                        else                            //else crack
                        {
                            index = 31;
                            Analytics.CustomEvent("Final: 3P2");
                        }
                    }
                }
            }
        }

        Cons [index].SetActive(true);
        AnimConsCrack = Cons [index].GetComponentInChildren <Animator> ();
        AnimConsCrack.SetBool("start", true);
        if (index == 0)
        {
            Invoke("FinalAnimacao", 90);
        }
        else
        {
            Invoke("FinalAnimacao", 120);
        }
    }
Esempio n. 22
0
    public void CmdEndGame()
    {
        List <CaptainsMessPlayer> players     = GetPlayers();
        NetworkedPlayerScript     bonusPlayer = null;
        float      longestMatchTime           = -1;
        List <int> scoringSongs = new List <int>();

        foreach (CaptainsMessPlayer player in players)
        {
            NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>();

            int sid = nps.GetSongID();

            if (nps.scored_GuessedCorrect)
            {
                float currentMatchTime = nps.matchTime;

                nps.RpcAddScore(5 * Mathf.FloorToInt(currentMatchTime), (int)Score.Time);

                if (currentMatchTime > longestMatchTime)
                {
                    longestMatchTime = currentMatchTime;
                    bonusPlayer      = nps;
                }

                scoringSongs.Add(sid);

                Analytics.CustomEvent("guessedCorrect", new Dictionary <string, object>
                {
                    { "matchTime", currentMatchTime },
                    { "songID", sid }
                });
            }
            else
            {
                for (int i = 0; i < players.Count; i++)
                {
                    NetworkedPlayerScript other_nps = players[i].GetComponent <NetworkedPlayerScript>();

                    if (sid == other_nps.GetSongID())
                    {
                        if (nps.color != other_nps.color)
                        {
                            nps.match_color    = other_nps.color;
                            nps.match_nameText = other_nps.nameText;
                            break;
                        }
                    }
                }
            }
        }

        //Bonus for player who guessed first.
        if (bonusPlayer != null) //If this is null, nobody guessed anything. Lame!
        {
            bonusPlayer.RpcAddScore(100, (int)Score.First);
        }

        foreach (CaptainsMessPlayer player in players)
        {
            NetworkedPlayerScript nps = player.GetComponent <NetworkedPlayerScript>();

            if (nps.scored_GuessedCorrect)
            {
                nps.RpcAddScore(250, (int)Score.Correct);
            }
            if (scoringSongs.Contains(nps.songID))
            {
                nps.RpcAddScore(500, (int)Score.WasGuessed);
            }

            nps.RpcEndGame();
        }

        mess.FinishGame();
    }
Esempio n. 23
0
    public void ProcessPurchase(string productIdentifier)
    {
        if (m_ProductParamMap.ContainsKey(productIdentifier))
        {
            ProductParam productParam = m_ProductParamMap[productIdentifier];

            switch (productParam.m_ProductType)
            {
            case InAppProductList.ProductType.COIN:
                GameData.current.coin += productParam.m_nProductParam;
                Debug.Log(string.Format("InAppProcessor::ProcessPurchase: PASS. Product: '{0}'", productIdentifier));

                // @todo Some feedback
                break;

            case InAppProductList.ProductType.AVATAR:
                Debug.Log(string.Format("InAppProcessor::ProcessPurchase: PASS. Product: '{0}'", productIdentifier));

                GameObject  go    = GameObject.FindGameObjectWithTag("Gacha");
                GachaScript gacha = go.GetComponent <GachaScript>();
                gacha.ProcessBuyIcon(productParam.m_nProductParam);

                Analytics.CustomEvent("Bought_Tac", new Dictionary <string, object>
                {
                    { ((Defines.ICONS)productParam.m_nProductParam).ToString().Substring(0, 4), 1 }
                });
                break;

            case InAppProductList.ProductType.ADS:
                Defines.AdsInAppPurchase adsProductParam = (Defines.AdsInAppPurchase)productParam.m_nProductParam;

                switch (adsProductParam)
                {
                case Defines.AdsInAppPurchase.DISABLE:
                    Debug.Log(string.Format("InAppProcessor::ProcessPurchase: PASS. Product: '{0}'", productIdentifier));
                    Adverts.Instance.RemoveAds();

                    // Disable disable ads button
                    MainMenuScript mainMenu = Camera.main.GetComponent <MainMenuScript>();
                    mainMenu.EnableDisableAdsButton(true);
                    mainMenu.DisableDisableAdsButton();

                    Analytics.CustomEvent("Bought_Ads", new Dictionary <string, object> {
                    });
                    break;

                default:
                    Debug.Log(string.Format("InAppProcessor::ProcessPurchase: FAIL. Unrecognized Ads Product Params: '{0}'", productIdentifier));
                    break;
                }

                break;

            default:
                Debug.Log(string.Format("InAppProcessor::ProcessPurchase: FAIL. Invalid product type: '{0}'", productParam.m_ProductType.ToString()));
                return;
            }

            SaveLoad.Save();
        }
        else
        {
            Debug.Log(string.Format("InAppProcessor::ProcessPurchase: FAIL. Unrecognized product: '{0}'", productIdentifier));
        }
    }
Esempio n. 24
0
        private void OnPuzzleWin(int level)
        {
            var puzzleState = _levels[_selectedLevel].GetComponent <PuzzleState>();

            puzzleState.BoardEnabled = false;
            _levels[_selectedLevel].GetComponent <GameBoardAudio>().enabled  = true;
            _levels[_selectedLevel].GetComponent <PuzzleScale>().PuzzleInit -= OnPuzzleInit;
            _levels[_selectedLevel].GetComponent <BoardAction>().PuzzleWin  -= OnPuzzleWin;
            puzzleState.LevelStateChanged -= OnLevelStateChanged;

            // Unity Analytics
            Analytics.CustomEvent("nodulus.level.complete", new Dictionary <string, object> {
                { "level.name", puzzleState.Metadata.Name },
                { "level.moves", puzzleState.NumMoves },
                { "level.movesBestScore", puzzleState.Metadata.MovesBestScore },
                { "level.timeElapsed", puzzleState.TimeElapsed },
                { "level.winCount", puzzleState.Metadata.WinCount }
            });

            _selectedLevel = level >= _levels.Length - 1 ? _levels.Length - 1 : level + 1;

            puzzleState = _levels[_selectedLevel].GetComponent <PuzzleState>();

            _levels[_selectedLevel].GetComponent <PuzzleState>().BoardEnabled       = false;
            _levels[_selectedLevel].GetComponent <PuzzleScale>().PuzzleInit        += OnPuzzleInit;
            _levels[_selectedLevel].GetComponent <BoardAction>().PuzzleWin         += OnPuzzleWin;
            _levels[_selectedLevel].GetComponent <PuzzleState>().LevelStateChanged += OnLevelStateChanged;

            // Move to the new board
            var bounds = _levelBounds[_selectedLevel];
            var mid    = (bounds.Item1 + bounds.Item2) / 2f;

            // TODO: make configurable
            const float time      = 0.5f;
            const float moveDelay = 1f;

            LeanTween.moveLocal(gameObject, Vector3.up * mid, time)
            .setEase(LeanTweenType.easeInOutSine)
            .setDelay(moveDelay);

            // Initialize the new board
            // TODO: make configurable
            const float initDelay = 0.5f;

            LeanTween.delayedCall(initDelay, () => {
                puzzleState.GetComponent <PuzzleState>().BoardEnabled = true;
                puzzleState.Init(_selectedLevel);

                _levels[_selectedLevel].GetComponent <PuzzleView>().ResumeView();
            });

            if (_selectedLevel >= _levels.Length - 1)
            {
                return;
            }

            var next = _levels[_selectedLevel + 1];

            next.GetComponent <PuzzleState>().DestroyBoard(false);
            next.GetComponentInChildren <PuzzleInfo>().Hide();
        }
Esempio n. 25
0
    public void InitializeGameAnalytics()
    {
        if (!base.Inited)
        {
            AnalyticsService analytics      = PersistentSingleton <AnalyticsService> .Instance;
            IAPService       instance       = PersistentSingleton <IAPService> .Instance;
            AdService        instance2      = PersistentSingleton <AdService> .Instance;
            SessionService   sessionService = PersistentSingleton <SessionService> .Instance;
            PlayerData       playerData     = PlayerData.Instance;
            instance.IAPCompleted.Subscribe(delegate(IAPTransactionState iapCompleted)
            {
                analytics.TrackEvent("IAP_Complete", iapCompleted.asDictionary(), string.Empty);
            });
            instance.IAPNotCompleted.Subscribe(delegate(IAPNotCompleted iapNotCompleted)
            {
                analytics.TrackEvent("IAP_Not_Complete", iapNotCompleted.asDictionary(), string.Empty);
            });
            instance.IAPValidated.Subscribe(delegate(IAPTransactionState iapValidated)
            {
                analytics.TrackEvent("IAP_Validated", iapValidated.asDictionary(), string.Empty);
            });
            instance2.AdStarted.Subscribe(delegate(AdWatched adStarted)
            {
                analytics.TrackEvent("Ad_Started", adStarted.asDictionary(), string.Empty);
            });
            (from adResult in instance2.AdResults
             where adResult.result == AdService.V2PShowResult.Finished
             select adResult).Subscribe(delegate(AdWatched adWatched)
            {
                analytics.TrackEvent("Ad_Watched", adWatched.asDictionary(), "fb_mobile_content_view");
            });
            (from adResult in instance2.AdResults
             where adResult.result == AdService.V2PShowResult.Failed || adResult.result == AdService.V2PShowResult.Skipped
             select adResult).Subscribe(delegate(AdWatched adFailed)
            {
                analytics.TrackEvent("Ad_Failed", adFailed.asDictionary(), string.Empty);
            });
            (from a in instance2.AdLoadRequests
             select a.asDictionary(ServerTimeService.NowTicks())).Subscribe(delegate(Dictionary <string, string> adLoadRequest)
            {
                analytics.TrackEvent("Ad_Load", adLoadRequest, string.Empty);
            });
            (from isNewUser in sessionService.newUser
             where isNewUser
             select isNewUser).Subscribe(delegate
            {
                analytics.TrackEvent("New_User", new Dictionary <string, string>(), string.Empty);
            });
            playerData.SessionNumber.Subscribe(delegate
            {
                analytics.TrackEvent("Session_Started", new Dictionary <string, string>
                {
                    {
                        "LastSavedBy",
                        playerData.LastSavedBy
                    },
                    {
                        "HoursSinceLastSession",
                        ((int)TimeSpan.FromTicks(sessionService.TicksSinceLastSave()).TotalHours).ToString()
                    },
                    {
                        "Lifetime_BlocksDestroyed",
                        CountLifetimeBlocksDestroyed()
                    }
                }, string.Empty);
            });
            playerData.SessionNumber.Subscribe(delegate
            {
                analytics.TrackEvent("Session_Balance", new Dictionary <string, string>
                {
                    {
                        "Material_Grass",
                        playerData.BlocksCollected[0].Value.ToString()
                    },
                    {
                        "Material_Dirt",
                        playerData.BlocksCollected[1].Value.ToString()
                    },
                    {
                        "Material_Wood",
                        playerData.BlocksCollected[2].Value.ToString()
                    },
                    {
                        "Material_Stone",
                        playerData.BlocksCollected[3].Value.ToString()
                    },
                    {
                        "Material_Metal",
                        playerData.BlocksCollected[4].Value.ToString()
                    },
                    {
                        "Material_Gold",
                        playerData.BlocksCollected[5].Value.ToString()
                    },
                    {
                        "Material_Jelly",
                        playerData.BlocksCollected[6].Value.ToString()
                    }
                }, string.Empty);
            });
            (from ord in PrestigeTriggered
             where ord == PrestigeOrder.PrestigeStart
             select ord).Subscribe(delegate
            {
                analytics.TrackEvent("Prestige", new Dictionary <string, string>
                {
                    {
                        "Material_Grass",
                        ((double)playerData.BlocksInBackpack[0].Value * Singleton <CumulativeBonusRunner> .Instance.BonusMult[13].Value.ToDouble()).ToString()
                    },
                    {
                        "Material_Dirt",
                        ((double)playerData.BlocksInBackpack[1].Value * Singleton <CumulativeBonusRunner> .Instance.BonusMult[14].Value.ToDouble()).ToString()
                    },
                    {
                        "Material_Wood",
                        ((double)playerData.BlocksInBackpack[2].Value * Singleton <CumulativeBonusRunner> .Instance.BonusMult[15].Value.ToDouble()).ToString()
                    },
                    {
                        "Material_Stone",
                        ((double)playerData.BlocksInBackpack[3].Value * Singleton <CumulativeBonusRunner> .Instance.BonusMult[16].Value.ToDouble()).ToString()
                    },
                    {
                        "Material_Metal",
                        ((double)playerData.BlocksInBackpack[4].Value * Singleton <CumulativeBonusRunner> .Instance.BonusMult[17].Value.ToDouble()).ToString()
                    },
                    {
                        "Material_Gold",
                        ((double)playerData.BlocksInBackpack[5].Value * Singleton <CumulativeBonusRunner> .Instance.BonusMult[18].Value.ToDouble()).ToString()
                    },
                    {
                        "Material_Jelly",
                        ((double)playerData.BlocksInBackpack[6].Value * Singleton <CumulativeBonusRunner> .Instance.BonusMult[19].Value.ToDouble()).ToString()
                    }
                }, string.Empty);
            });
            playerData.TutorialStep.Skip(1).Subscribe(delegate(int step)
            {
                analytics.TrackEvent("FTUE_Stage_Done", new Dictionary <string, string>
                {
                    {
                        "FTUE_Stage",
                        Singleton <TutorialGoalCollectionRunner> .Instance.GetOrCreatePlayerGoalRunner(step - 1).GoalConfig.ID
                    },
                    {
                        "FTUE_Stage_ID",
                        (step - 1).ToString()
                    }
                }, (step < Singleton <EconomyHelpers> .Instance.GetTutorialGoalAmount() - 1) ? string.Empty : "fb_mobile_tutorial_completion");
            });
            playerData.TutorialStep.Skip(1).Subscribe(delegate(int step)
            {
                Analytics.CustomEvent("FTUE_Stage_Done", new Dictionary <string, object>
                {
                    {
                        "FTUE_Stage",
                        Singleton <TutorialGoalCollectionRunner> .Instance.GetOrCreatePlayerGoalRunner(step - 1).GoalConfig.ID
                    },
                    {
                        "FTUE_Stage_ID",
                        (step - 1).ToString()
                    }
                });
            });
            GemTransactions.Subscribe(delegate(GemTransaction transaction)
            {
                analytics.TrackEvent("Gem_Transaction", transaction.asDictionary(), (!(transaction.transaction == "spendFunds")) ? string.Empty : "fb_mobile_spent_credits", transaction.amount);
            });
            ChestTransactions.Subscribe(delegate(ChestTransaction transaction)
            {
                analytics.TrackEvent("Chest_Transaction", transaction.asDictionary(), string.Empty);
            });
            KeyTransactions.Subscribe(delegate(KeyTransaction transaction)
            {
                analytics.TrackEvent("Key_Added", transaction.asDictionary(), string.Empty);
            });
            BerryTransaction.Subscribe(delegate(BerryTransaction transaction)
            {
                analytics.TrackEvent("Berry_Added", transaction.asDictionary(), string.Empty);
            });
            PopupDecisions.Subscribe(delegate(PopupDecision decision)
            {
                analytics.TrackEvent("Popup_Decision", decision.asDictionary(), string.Empty);
            });
            (from coins in playerData.LifetimeCoins.Pairwise()
             where coins.Previous.exponent != coins.Current.exponent
             select coins).Subscribe(delegate
            {
                analytics.TrackEvent("New_LTE_Digit", new Dictionary <string, string>(), string.Empty);
            });
            playerData.LifetimeChunk.Skip(1).Subscribe(delegate
            {
                analytics.TrackEvent("New_Max_Chunk", new Dictionary <string, string>(), string.Empty);
            });
            playerData.LifetimeCreatures.Skip(1).Subscribe(delegate
            {
                analytics.TrackEvent("New_Max_Companions", new Dictionary <string, string>(), string.Empty);
            });
            HeroStateFactory.GetOrCreateHeroState(0).LifetimeLevel.Skip(1).Subscribe(delegate
            {
                analytics.TrackEvent("New_Max_Hero_Level", new Dictionary <string, string>(), string.Empty);
            });
            GoalCompleted.Subscribe(delegate(PlayerGoalRunner goal)
            {
                analytics.TrackEvent("Achievement_Completed", new Dictionary <string, string>
                {
                    {
                        "Goal_ID",
                        goal.GoalConfig.ID
                    }
                }, "fb_mobile_achievement_unlocked");
            });
            NewBundle.Subscribe(delegate(IAPProductEnum bundle)
            {
                analytics.TrackEvent("Offer_Given", new Dictionary <string, string>
                {
                    {
                        "Offer",
                        bundle.ToString()
                    }
                }, string.Empty);
            });
            GearUpgraded.Subscribe(delegate(GearRunner gear)
            {
                analytics.TrackEvent("Gear_Upgrade", new Dictionary <string, string>
                {
                    {
                        "GearLevel",
                        gear.Level.ToString()
                    },
                    {
                        "GearID",
                        gear.GearIndex.ToString()
                    }
                }, string.Empty);
            });
            SkillUsed.Subscribe(delegate(SkillsEnum skill)
            {
                analytics.TrackEvent("Skill_Used", new Dictionary <string, string>
                {
                    {
                        "Skill",
                        skill.ToString()
                    },
                    {
                        "Lifetime_Used",
                        playerData.SkillStates[(int)skill].LifetimeUsed.Value.ToString()
                    }
                }, string.Empty);
            });
            BossBattleResult.Skip(1).Subscribe(delegate(bool result)
            {
                analytics.TrackEvent("BossBattleResult", new Dictionary <string, string>
                {
                    {
                        "Result",
                        result.ToString()
                    },
                    {
                        "Current_Chunk",
                        playerData.MainChunk.Value.ToString()
                    }
                }, string.Empty);
            });
            ObjectTapped.Subscribe(delegate(string obj)
            {
                analytics.TrackEvent("Object_Tapped", new Dictionary <string, string>
                {
                    {
                        "Object_Tapped",
                        obj
                    }
                }, string.Empty);
            });

            /*XPromoPlugin.XPromoActions.Subscribe(delegate(XPromoAction XPromoAction)
             * {
             *      analytics.TrackEvent("X_Promo_Action", XPromoAction.asDictionary(), string.Empty);
             * });*/
            PersistentSingleton <ARService> .Instance.LevelEditorEvent.Subscribe(delegate(string editorEvent)
            {
                analytics.TrackEvent("Level_Editor", new Dictionary <string, string>
                {
                    {
                        "Event",
                        editorEvent
                    }
                }, string.Empty);
            });

            PersistentSingleton <AnalyticsService> .Instance.FortunePodsResult.Subscribe(delegate(FortunePodResult result)
            {
                analytics.TrackEvent("Fortune_Pod_Result", result.asDictionary(), string.Empty);
            });

            (from chunk in playerData.MainChunk.Skip(1)
             where chunk == 22 && PlayerData.Instance.LifetimePrestiges.Value == 0 && !Singleton <QualitySettingsRunner> .Instance.LowFPS.Value
             select chunk).Subscribe(delegate
            {
                SceneLoader.Instance.StartCoroutine(TrackFpsRuotine());
            });
            (from hr in playerData.HasReviewed.Skip(1)
             where hr
             select hr).Subscribe(delegate
            {
                analytics.TrackEvent("fb_mobile_rate", new Dictionary <string, string>
                {
                    {
                        "fb_max_rating_value",
                        "5"
                    }
                }, "fb_mobile_rate", 5f);
            });
            playerData.Trophies.Skip(1).Subscribe(delegate(int trophies)
            {
                AnalyticsService analyticsService       = analytics;
                Dictionary <string, string> dictionary  = new Dictionary <string, string>();
                Dictionary <string, string> dictionary2 = dictionary;
                TournamentTier tournamentTier           = (TournamentTier)trophies;
                dictionary2.Add("RewardType", tournamentTier.ToString());
                analyticsService.TrackEvent("TournamentReward", dictionary, string.Empty);
            });
            (from tour in TournamentEvent
             where tour
             select tour).Subscribe(delegate
            {
                analytics.TrackEvent("TournamentStarted", new Dictionary <string, string>
                {
                    {
                        "Current_Chunk",
                        playerData.MainChunk.Value.ToString()
                    }
                }, string.Empty);
            });
            (from tour in TournamentEvent
             where !tour
             select tour).Subscribe(delegate
            {
                analytics.TrackEvent("TournamentEnded", new Dictionary <string, string>
                {
                    {
                        "Current_Chunk",
                        playerData.MainChunk.Value.ToString()
                    },
                    {
                        "Highest_Chunk_Reached",
                        Singleton <TournamentRunner> .Instance.PlayerHighestWorld.Value.ToString()
                    },
                    {
                        "Position",
                        Singleton <TournamentRunner> .Instance.PlayerRank.Value.ToString()
                    }
                }, string.Empty);
            });
            (from p in Observable.EveryApplicationPause()
             where !p && FB.IsInitialized
             select p).Subscribe(delegate
            {
                FB.ActivateApp();
            });
            FirebaseAnalytics.SetUserId(playerData.PlayerId);
            FirebaseAnalytics.SetUserProperty("AppGenuine", (!Application.genuineCheckAvailable) ? "N/A" : Application.genuine.ToString());
            FirebaseAnalytics.SetUserProperty("Build_Number", Application.version);
            subscribeToUserProperty("Days_Retained", playerData.DaysRetained);
            // FirebaseAnalytics.SetUserProperty("Games_Installed", XPromoPlugin.InstalledApps());
            FirebaseAnalytics.SetUserProperty("Friends_Giftable", PersistentSingleton <FacebookAPIService> .Instance.FBPlayers.Count.ToString());
            FirebaseAnalytics.SetUserProperty("Friends_Playing", PersistentSingleton <FacebookAPIService> .Instance.FBPlayers.Values.Count((FBPlayer p) => p.Playing).ToString());
            subscribeToUserProperty("Has_Reviewed", playerData.HasReviewed);
            FirebaseAnalytics.SetUserProperty("Hours_In_Lifetime", ((int)TimeSpan.FromTicks(sessionService.TicksPlayedInLifetime()).TotalHours).ToString());
            FirebaseAnalytics.SetUserProperty("Segments", string.Join(",", PersistentSingleton <GameSettings> .Instance.Segments.ToArray()));
            subscribeToUserProperty("Music", MusicVolume);
            subscribeToUserProperty("Notifications_Decided", playerData.NotificationDecision);
            subscribeToUserProperty("Online", ConnectivityService.InternetConnectionAvailable);
            subscribeToUserProperty("Review_State", playerData.ReviewState);
            subscribeToUserProperty("Sound", SFXVolume);
            subscribeToUserProperty("AR_Editor_Supported", ARSupported);
            FirebaseAnalytics.SetUserProperty("Language", playerData.Language);
            FirebaseAnalytics.SetUserProperty("PFID", playerData.PFId.Value);
            FirebaseAnalytics.SetUserProperty("FBID", playerData.FBId.Value);
            base.Inited = true;
        }
    }
 /// <inheritdoc cref="IUserReportingPlatform"/>
 public void SendAnalyticsEvent(string eventName, Dictionary <string, object> eventData)
 {
     Analytics.CustomEvent(eventName, eventData);
 }
Esempio n. 27
0
    private void AtivaMaconha(bool escolha, string tipoDialogo)
    {
        if (escolha)          //se aceitou
        {
            Analytics.CustomEvent("AceitouMaconha");
            dialogManager.Maconha       = 1;
            dialogManager.olhoVermelhoP = true;       //muda os olhos para vermelho
            dialogManager.choiceBox.SetActive(false); //tira a escolha da tela
            AceitaMaconha(true);                      //habilita o controle da maconha e desativa o dialogo
            AnimMaconha = ctrlMac.GetComponentInChildren <Animator> ();
            AnimMaconha.Play("AceitaMaconha");
            //Invoke ("CarregaConsMaconha", animAceitaClipMaconha.length);//Prepara a consequencia para aparecer após a animação da maconha
            //AnimMaconha.SetBool ("aceita", true);//define que ele aceitou maconha na animação
            //AnimMaconha.SetBool ("start", true);//define que vai começar a animação
            switch (tipoDialogo)
            {
            case "A":
            {
                StartCoroutine(CarregaDialogo2('A', 2, animAceitaClipMaconha.length));
                break;
            }

            case "B":
            {
                StartCoroutine(CarregaDialogo2('B', 2, animAceitaClipMaconha.length));
                break;
            }

            case "C":
            {
                StartCoroutine(CarregaDialogo2('C', 2, animAceitaClipMaconha.length));
                break;
            }

            case "D":
            {
                StartCoroutine(CarregaDialogo2('D', 2, animAceitaClipMaconha.length));
                break;
            }
            }
        }
        else
        {
            Analytics.CustomEvent("RecusouMaconha");
            dialogManager.Maconha       = 0;
            dialogManager.olhoVermelhoP = false;
            dialogManager.choiceBox.SetActive(false); //tira a escolha da tela
            AceitaMaconha(true);                      //habilita o controle da maconha e desativa o dialogo
            AnimMaconha = ctrlMac.GetComponentInChildren <Animator> ();
            AnimMaconha.Play("RecusaMaconha");
            //AnimMaconha.SetBool ("aceita", false);//define que ele não aceitou maconha na animação
            //AnimMaconha.SetBool ("start", true);//define que vai começar a animação
            switch (tipoDialogo)
            {
            case "A":
            {
                StartCoroutine(CarregaDialogo2('A', 3, animRecusaClipMaconha.length));
                break;
            }

            case "B":
            {
                StartCoroutine(CarregaDialogo2('B', 3, animRecusaClipMaconha.length));
                break;
            }

            case "C":
            {
                StartCoroutine(CarregaDialogo2('C', 3, animRecusaClipMaconha.length));
                break;
            }

            case "D":
            {
                StartCoroutine(CarregaDialogo2('D', 3, animRecusaClipMaconha.length));
                break;
            }
            }
        }
        per.TrocaOlho(false);
    }
Esempio n. 28
0
 public static void StartTutorial()
 {
     startTimeTutorial = System.DateTime.Now;
     Analytics.CustomEvent("StartTutorial", null);
 }
    public void attack()
    {
        //pa.attack ();
        if (gun == true)
        {
            //pa.attack ();
            Bullet bl = bullet.GetComponent <Bullet> ();

            Vector3 dir;
            dir.x = Vector2.right.x;
            dir.y = Vector2.right.y;
            dir.z = 0;

            if (oneHanded == true)
            {
                if (shotgun == false)                  //new for new weapons

                //Bullet bl = Instantiate(bullet, oneHandSpawn.transform.position, this.transform.rotation).GetComponent<Bullet>();
                {
                    bl.arma    = arma;
                    bl.asesino = this.gameObject.name;
                    Debug.Log("El arma del enemigo es: " + bl.arma);

                    Instantiate(bullet, oneHandSpawn.transform.position, this.transform.rotation);
                }
                else
                {
                    //Instantiate (shotgunBullet, oneHandSpawn.transform.position, this.transform.rotation);
                    GameObject go      = Instantiate(shotgunBullet, oneHandSpawn.transform.position, this.transform.rotation);
                    Bullet[]   bullets = go.GetComponentsInChildren <Bullet>();

                    foreach (Bullet b in bullets)
                    {
                        b.arma    = arma; // o el arma que sea
                        b.asesino = this.gameObject.name;
                        Debug.Log("El arma del enemigo es: " + b.arma);
                        Debug.Log("El enemigo es: " + b.asesino);
                    }
                }
                decideSFX();
            }
            else
            {
                if (shotgun == false)                  //new for new weapons
                //Bullet bl = Instantiate(bullet, oneHandSpawn.transform.position, this.transform.rotation).GetComponent<Bullet>();
                {
                    bl.arma = arma;
                    Debug.Log("El arma del enemigo es: " + bl.arma);
                    Instantiate(bullet, twoHandSpawn.transform.position, this.transform.rotation);
                }
                else
                {
                    //Instantiate (shotgunBullet, twoHandSpawn.transform.position, this.transform.rotation);
                    GameObject go      = Instantiate(shotgunBullet, oneHandSpawn.transform.position, this.transform.rotation);
                    Bullet[]   bullets = go.GetComponentsInChildren <Bullet>();

                    foreach (Bullet b in bullets)
                    {
                        b.arma = arma; // o el arma que sea
                        Debug.Log("El arma del enemigo es: " + b.arma);
                    }
                }
                decideSFX();
            }
            timer = timerReset;

            //if (Input.GetMouseButtonUp (0)) {
            //pa.resetCounter ();
            //}
        }
        else
        {
            //melee attack
            int layerMask = 1 << 8;
            layerMask = ~layerMask;
            //pa.attack ();
            RaycastHit2D ray = Physics2D.Raycast(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), 1.5f, layerMask);
            Debug.DrawRay(new Vector2(this.transform.position.x, this.transform.position.y), new Vector2(transform.right.x, transform.right.y), Color.green);
            Debug.Log("Attempting melee attack");
            if (curWeapon == null && ray.collider.gameObject.tag == "Player")
            {
                Debug.Log("Punching player");
                Debug.Log("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* EnemyWeaponController");
                PlayerHealth.dead = true;
                Instantiate(blood, player.transform.position, player.transform.rotation);
                //EnemyAttacked ea = ray.collider.gameObject.GetComponent<EnemyAttacked> ();
                //ea.knockDownEnemy ();
                decideSFX();
            }
            else if (ray.collider != null)
            {
                if (ray.collider.gameObject.tag == "Player")
                {
                    Debug.Log("Melee attacking player");
                    Debug.Log("*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* EnemyWeaponController");
                    PlayerHealth.dead = true;
                    //Debug.Log("el arma melee con el que me mato es " + arma);

                    int level;
                    if (sceneName == "Tutorial")
                    {
                        level = 0;
                    }
                    else
                    {
                        level = Utils.LevelFromSceneName(sceneName);
                    }
                    Debug.Log("nivel de Morir es: " + level);
                    Debug.Log("enemigo de Morir: " + this.gameObject.name);
                    Debug.Log("tiempo de Morir: " + Time.timeSinceLevelLoad);
                    Debug.Log("coordenada X de Morir: " + player.transform.position.x);
                    Debug.Log("coordenada Y de Morir: " + player.transform.position.y);
                    Debug.Log("arma de Morir: " + arma);
                    Debug.Log("Insertar evento de morir");

                    Analytics.CustomEvent("Morir", new Dictionary <string, object>
                    {
                        { "nivel", level },
                        { "enemigo", this.gameObject.name },
                        { "tiempo", Time.timeSinceLevelLoad },
                        { "CordenadasX", player.transform.position.x },
                        { "CordenadasY", player.transform.position.y },
                        //{ "Arma", arma }
                    }
                                          );

                    //Aca insertar variable de morir con arma pero melee.
                    Instantiate(blood, player.transform.position, player.transform.rotation);
                    decideSFX();
                    //EnemyAttacked ea = ray.collider.gameObject.GetComponent<EnemyAttacked> ();
                    //ea.killMelee ();
                }
            }

            timer = timerReset;
        }
    }
Esempio n. 30
0
    public void gameover()
    {
        int tim = (int)(M.GTIME - Time.timeSinceLevelLoad + M.STIME);



        MusicCiran.Pause();
        Transform goscr = transform.Find("GameOver").transform;

        goscr.Find("Watch/Score").GetComponent <Text> ().text = (int)(M.DISTANCE * 79) + "";


        float getstars = (tim / M.GTIME) * 100f;

        goscr.Find("SCORE/UNIT/DIS").GetComponent <Text> ().text   = (int)(M.DISTANCE / 1000) + "." + ((int)(M.DISTANCE) % 1000) / 100 + " km";
        goscr.Find("SCORE/UNIT/TIME").GetComponent <Text> ().text  = ((tim / 60 < 10 ? "0" : "") + tim / 60 + (tim % 60 < 10 ? ":0" : ":") + tim % 60) + " min";
        goscr.Find("SCORE/UNIT/WOTER").GetComponent <Text> ().text = (int)(transform.Find("Gameplay/P1/TOP/Woter/Image").GetComponent <Image> ().fillAmount *M.MAXWOTER) + "L";
        int tim2 = (int)M.HTIME;

        goscr.Find("SCORE/UNIT/SPEED").GetComponent <Text> ().text = ((tim2 / 60 < 10 ? "0" : "") + tim2 / 60 + (tim2 % 60 < 10 ? ":0" : ":") + tim2 % 60) + " min";


        goscr.Find("SCORE/CASH/DIS").GetComponent <Text> ().text   = (int)(M.DISTANCE / 30) + "";
        goscr.Find("SCORE/CASH/SPEED").GetComponent <Text> ().text = (tim2 * 40) + "";
        int total = 0;

        if (M.GAMEWIN == M.GameScreen)
        {
            goscr.Find("SCORE/CASH/TIME").GetComponent <Text> ().text  = (tim * 5) + "";
            goscr.Find("SCORE/CASH/WOTER").GetComponent <Text> ().text = (int)(transform.Find("Gameplay/P1/TOP/Woter/Image").GetComponent <Image> ().fillAmount *M.MAXWOTER *.4f) + "";
            total = (int)(M.DISTANCE / 30) + (tim * 5) + (int)(transform.Find("Gameplay/P1/TOP/Woter/Image").GetComponent <Image> ().fillAmount *M.MAXWOTER *.4f) + (tim2 * 40);
        }
        else
        {
            goscr.Find("SCORE/CASH/TIME").GetComponent <Text> ().text  = (tim * 10) + "0";
            goscr.Find("SCORE/CASH/WOTER").GetComponent <Text> ().text = "0";
            total = (int)(M.DISTANCE / 30) + (tim2 * 40);
        }


        goscr.Find("SCORE/TOTAL/CASH").GetComponent <Text> ().text = total + "$";

        M.COINS += total;

        goscr.Find("Watch/totleCoin").GetComponent <Text> ().text = M.COINS + "";

        goscr.Find("Watch/title").GetComponent <Text> ().text = (M.GameScreen == M.GAMEWIN) ? "GAME WIN" : "GAME OVER";

        if (M.GameScreen == M.GAMEWIN)
        {
            if (M.UNLOCKLEVEL <= M.LEVEL_NO + 1)
            {
                M.UNLOCKLEVEL = M.LEVEL_NO + 2;
            }
            M.STARS [M.LEVEL_NO] = (getstars > 20) ? 5 : ((int)(getstars / 5) + 1);

            Debug.Log(M.STARS [M.LEVEL_NO] + "   ! " + M.LEVEL_NO + " ! " + M.UNLOCKLEVEL);

            MusicOver.clip = (AudioClip)Resources.Load("sound/level_win");
            MusicOver.Play();

            Analytics.CustomEvent("GameWin_" + M.LEVEL_NO);
        }
        else
        {
            Analytics.CustomEvent("GameOver_" + M.LEVEL_NO);
            if (M.setSound)
            {
                MusicOver.clip = (AudioClip)Resources.Load("sound/game_over");
                MusicOver.Play();
            }
        }

        M.isWoter = 0;
        goscr.Find("Bottom/Next").gameObject.SetActive(M.LEVEL_NO < M.STARS.GetLength(0) - 1 && M.GameScreen == M.GAMEWIN);
        M.Save();
        ShowInterstitial();
    }