Beispiel #1
0
    public override void Init()
    {
        Analytic.EventProperties("Other", "RateApp", "Show");
        PlayerPrefs.SetInt("RateApp", user.gameSessions);

        previous = ui.prepare;
    }
Beispiel #2
0
    void FacebookLoginCallback()
    {
        ui.LoadingHide();

        if (fb.isLogin)
        {
            Analytic.EventPropertiesImportant("Facebook", "Login", "Success");

            if (Missions.isTournament || Missions.isChampionship)
            {
                ui.PopupShow(ui.main);
            }
            else if (user.level > 0)
            {
                ui.PopupShow(ui.prepare);
            }
            else
            {
                ui.PopupShow(ui.intro);
            }
        }
        else
        {
            Analytic.EventProperties("Facebook", "Login", "Failed");
        }
    }
Beispiel #3
0
    public void Email()
    {
        Analytic.EventProperties("Other", "RateApp", "Email");

        PlayerPrefs.SetInt("RateApp", int.MaxValue); // Флаг, чтобы это окно больше не вылезало

        ui.options.SendEmail();
        ui.PopupClose();
    }
Beispiel #4
0
    public void Buy()
    {
        ObscuredPrefs.SetString("rentCatBuyName", catItem.type.name);
        ObscuredPrefs.SetInt("rentCatBuyLavel", catItem.level);

        iapManager.Purchase(iapManager.cat, purchaseSuccess =>
        {
            if (purchaseSuccess)
            {
                Analytic.EventProperties("RentCat", catItem.type.name, "BUY");

                Hide();
            }
        });
    }
Beispiel #5
0
    public void ShowAds()
    {
        Analytic.EventProperties("Ads", "VideoRewarded Label", "Click");

        ads.ShowVideoRewarded(
            () =>
        {
            ++showedTimes;
            user.UpdateCoins(reward, true);
            ui.header.ShowCoinsIn(rewardText.transform.position, 6, ui.canvas[3].transform, shift: 0.4f, delay: 0.2f);
            Hide();
        },
            () =>
        {
            ++showedTimes;
            Hide();
        });
    }
Beispiel #6
0
    public void OnGetReply(Advisor.Status status, Advisor.Response response, Advisor.Request request)
    {
        if (status == Advisor.Status.NoConnection)
        {
            ReplyBubbleShow(Localization.Get("advisorReplyNoConnection"));
            return;
        }

        if (status != Advisor.Status.Success || response == null)
        {
            ReplyBubbleShow(Localization.Get("advisorReplyError"));
            return;
        }

        Analytic.EventProperties("Advisor", response.input, request.text);

        ReplyBubbleShow(response.output);

        if (!string.IsNullOrEmpty(response.imageUrl))
        {
            server.DownloadPic(replyBubble.bubbleContentImage, response.imageUrl);
        }

        if (!string.IsNullOrEmpty(response.url))
        {
            SG_Utils.OpenLink(response.url, response.output);
        }

        var replies = response.replies;

        while (replies.Count > 3)
        {
            replies.Remove(replies[Random.Range(0, replies.Count)]);
        }
        foreach (var reply in replies)
        {
            askButtons.Add(askButtonPrefab.Copy(reply));
        }

        misunderstandingsCount = response.input == "All" ? misunderstandingsCount + 1 : 0;
    }
Beispiel #7
0
    public void Show(CatSlot slot)
    {
        if (!AddCat())
        {
            return;
        }

        rentCatNextSession = user.gameSessions + balance.rentCat.frequency +
                             rentCats[catItem.type] * (int)((float)balance.rentCat.frequency * 0.3f);

        descriptionText.text = Localization.Get("rentCat", catItem.type.localizedName, catItem.level);

        catView = Instantiate(catItem.type.itemViewPrefab);
        catView.transform.SetParent(catParent, false);
        catView.transform.localScale = 2 * Vector3.one;
        catView.footer.SetActive(false);

        gameObject.SetActive(true);

        Analytic.EventProperties("RentCat", catItem.type.name, "RENT");
    }
Beispiel #8
0
    void Show()
    {
        if (ui.current != ui.prepare || !needShow)
        {
            return;
        }
        needShow = false;

        Analytic.EventProperties("Ads", "VideoRewarded Label", "Show");

        reward          = balance.reward.coinsForAdView + Random.Range(0, 4) * 50;
        rewardText.text = reward.ToString();

        transform.localScale = new Vector3(1f, 0f, 1f);
        gameObject.SetActive(true);
        transform.DOScaleY(1f, 0.3f).SetEase(Ease.OutBack).OnComplete(() =>
        {
            if (!user.IsTutorialShown(Tutorial.Part.VideoRewarded))
            {
                ui.tutorial.Show(Tutorial.Part.VideoRewarded, new Transform[] { label.transform }, reward.SpaceFormat());
            }
        });
    }
Beispiel #9
0
    public CatItem GetCat(CatType type, int level = 1)
    {
        if (type == null)
        {
            return(null);
        }

        CatItem catItem = null;

        if (isOwned(type))
        {
            isLastGetCatLevelUp = true;

            catItem = GetItem(type);

            catItem.LevelUp(resetExp: false);
        }
        else
        {
            isLastGetCatLevelUp = false;

            catItem = new CatItem(type, level, 0);
            collection.Add(catItem);
            Log("Player get " + type.name + " Cat");

            Analytic.EventProperties("Progress", "OpenCatBox", catItem.type.name);
            Analytic.EventProperties("Progress", "Collection", collection.Count.ToString());
            achievements.OnGetSuperCat();
        }

        lastGetCat = catItem;

        CollectionSave(true);

        return(catItem);
    }
Beispiel #10
0
    public void CreateTournamentSlots(List <Rival> rivals, int coins)
    {
        (tournamentGrid.transform as RectTransform).sizeDelta =
            new Vector2((tournamentGrid.transform as RectTransform).sizeDelta.x, 20 + rivals.Count * tournamentGrid.cellSize.y);

        rivalsCount = rivals.Count;
        playerPlace = 0;
        int  i          = 0;
        long lastRecord = long.MaxValue;

        foreach (var rival in rivals)
        {
            var slot = Instantiate(tournamentSlotPrefab) as LeaderboardSlot;
            slot.transform.SetParent(tournamentGrid.transform, false);
            tournamentSlots.Add(slot);

            slot.Setup(rival);

            if (rival.record < lastRecord)
            {
                i++;
            }
            slot.placeText.text = i.ToString();
            lastRecord          = rival.record;

            if (rival.isPlayer)
            {
                playerPlace = i;
            }

            if (i > 0 && i < 4)
            {
                slot.crownImage.gameObject.SetActive(true);
                slot.crownImage.sprite = pics.crowns[i - 1];
                if (slot.frameImage != null)
                {
                    slot.frameImage.color = pics.crownColors[i - 1];
                }
            }
        }

        int prizeFund = 0;

        for (int j = 1; j <= rivalsCount - playerPlace; j++)
        {
            prizeFund += j;
        }
        coinsText.text = prizeFund > 0 ? (prizeFund * 100).ToString() : "0";

        if (rivalsCount == 1)
        {
            rewardText.text = Localization.Get("placeOnlyPlayer");
            buttonText.text = Localization.Get("next");
        }
        else if (playerPlace == rivalsCount)
        {
            rewardText.text = Localization.Get("placeLast");
            buttonText.text = Localization.Get("next");
        }
        else
        {
            rewardText.text = Localization.Get("placeNotLast", rivalsCount - playerPlace);
            buttonText.text = Localization.Get("collect");
        }

        user.AddWonTournament(playerPlace, rivalsCount);

        Analytic.EventProperties("Other", "TournamentEnd", rivalsCount.ToString());

        ShareBlock(fb.isLogin && rivalsCount - playerPlace > 0);
    }
Beispiel #11
0
    public void LevelUp()
    {
        if (level >= Missions.MAX_LEVEL)
        {
            return;
        }

        Level l = Missions.LEVELS[level];

        foreach (Mission mission in l.missions)
        {
            Analytic.EventProperties("Missions", mission.name + " " + mission.target, Analytic.Round(mission.current()).ToString());
        }

        foreach (Mission mission in l.missions)
        {
            if (mission.clear != null)
            {
                mission.clear();
            }
        }

        if (l.gift == Gifts.catbox && !isCanGetSimpleBox)
        {
            Missions.AddGift(level, Gifts.aquariumSmall, 10);
        }

        if (l.gift == Gifts.aquariumSmall)
        {
            UpdateCoins(l.giftCount, true);
        }
        else if (l.gift == Gifts.sausage)
        {
            UpdateSpins(l.giftCount, true);
        }
        else if (l.gift == Gifts.catbox)
        {
            GetSimpleCatbox();
        }
        else if (l.gift == Gifts.boosterbox)
        {
            GetBonusBox();
        }

        if (l.giftSprite == gameplay.boosts.time.sprite)
        {
            GetBoost(gameplay.boosts.time, 3);
        }
        else if (l.giftSprite == gameplay.boosts.experience.sprite)
        {
            GetBoost(gameplay.boosts.experience, 3);
        }
        else if (l.giftSprite == gameplay.boosts.multiplier.sprite)
        {
            GetBoost(gameplay.boosts.multiplier, 3);
        }
        else if (l.giftSprite == gameplay.boosts.firework.sprite)
        {
            GetBoost(gameplay.boosts.firework, 3);
        }

        UpdateLevel(level + 1, true);

        ui.header.UpdateLevel();

        achievements.OnLevelUp();

        Analytic.EventLevelUp(level);
    }
Beispiel #12
0
    // public float[] t1 = new float[] { 0.2f, 0.3f, 0.4f, 1.2f, 1.3f, 1.4f };
    // public float[] t2 = new float[] { 0.1f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1f, 1.1f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2f };

    IEnumerator Spin()
    {
        spin = true;

        sound.Play(sound.luckyWheel);

        spinsText.text = (user.TotalSpins(DateTime.UtcNow) - 1).ToString();
        iTween.PunchScale(spinsImage.gameObject, new Vector3(0.5f, 0.5f, 0), 1);
        arrowImage.gameObject.SetActive(false);

        catAnimator.speed = 1f;
        catAnimator.SetBool("spin", true);
        catAnimator.SetBool("sausage", false);

        wheelAnimator.SetBool("spin", true);
        wheelAnimator.speed = 0.1f;
        while (wheelAnimator.speed < 1f)
        {
            wheelAnimator.speed = Mathf.Clamp(wheelAnimator.speed + 0.5f * Time.deltaTime, 0f, 1f);
            yield return(new WaitForEndOfFrame());
        }

        yield return(new WaitForSeconds(UnityEngine.Random.Range(0.5f, 3f)));

        sound.Play(sound.punch);
        catAnimator.SetBool("spin", false);
        while (wheelAnimator.speed > 0f)
        {
            wheelAnimator.speed = Mathf.Clamp(wheelAnimator.speed - 0.4f * Time.deltaTime, 0f, 1f);
            catAnimator.speed   = Mathf.Clamp(catAnimator.speed - 0.4f * Time.deltaTime, 0f, 1f);
            yield return(new WaitForEndOfFrame());
        }
        wheelAnimator.SetBool("spin", false);

        float angle = wheelImage.rectTransform.rotation.eulerAngles.z;

        if (intervals[0] <= angle && angle < intervals[1])
        {
            if (hatsPrize && hatsPrize.activeSelf)
            {
                user.newYearHats += 3;
                lastPrize         = Prizes.Hats;
                lastPrizeCount    = 3;
                Analytic.EventProperties("Other", "LuckyWheel", "3 Hats");
            }
            else if (heartsPrize && heartsPrize.activeSelf)
            {
                user.stValentinHearts += 3;
                lastPrize              = Prizes.Valentines;
                lastPrizeCount         = 3;
                Analytic.EventProperties("Other", "LuckyWheel", "3 Valentines");
            }
            else if (batsPrize && batsPrize.activeSelf)
            {
                user.halloweenBats += 3;
                lastPrize           = Prizes.Bats;
                lastPrizeCount      = 3;
                Analytic.EventProperties("Other", "LuckyWheel", "3 Bats");
            }
            else
            {
                lastPrize      = Prizes.Goldfishes;
                lastPrizeCount = 5000;
                user.UpdateCoins(lastPrizeCount, false);
                Analytic.EventProperties("Other", "LuckyWheel", "5 000 Goldfishes");
            }
        }
        else if (intervals[1] <= angle && angle < intervals[2])
        {
            lastPrize      = Prizes.Goldfishes;
            lastPrizeCount = 50;
            user.UpdateCoins(lastPrizeCount, false);
            Analytic.EventProperties("Other", "LuckyWheel", "50 Goldfishes");
        }
        else if (intervals[2] <= angle && angle < intervals[3])
        {
            if (user.isCanGetSimpleBox)
            {
                lastPrize      = Prizes.Catbox;
                lastPrizeCount = 1;
                user.GetSimpleCatbox();
                Analytic.EventProperties("Other", "LuckyWheel", "Catbox");
            }
            else
            {
                lastPrize      = Prizes.Goldfishes;
                lastPrizeCount = 20000;
                user.UpdateCoins(lastPrizeCount, false);
                Analytic.EventProperties("Other", "LuckyWheel", "20 000 Goldfishes");
            }
        }
        else if (intervals[3] <= angle && angle < intervals[4])
        {
            lastPrize      = Prizes.Goldfishes;
            lastPrizeCount = 100;
            user.UpdateCoins(lastPrizeCount, false);
            Analytic.EventProperties("Other", "LuckyWheel", "100 Goldfishes");
        }
        else if (intervals[4] <= angle && angle < intervals[5])
        {
            lastPrize      = Prizes.Sausage;
            lastPrizeCount = 1;
            user.UpdateSpins(lastPrizeCount, false);
            Analytic.EventProperties("Other", "LuckyWheel", "Sausage");
        }
        else // (intervals[5] <= angle || angle < intervals[1])
        {
            lastPrize      = Prizes.Goldfishes;
            lastPrizeCount = 500;
            user.UpdateCoins(lastPrizeCount, false);
            Analytic.EventProperties("Other", "LuckyWheel", "500 Goldfishes");
        }

        if (user.spins > 0)
        {
            user.UseSpin();
        }
        else
        {
            user.UseFreeSpin(utcDateTimeNow);
        }

        sound.Stop(sound.luckyWheel);
        spin = false;

        ui.PopupShow(ui.prize);
    }