Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        string mode = "";

        switch (SCR_Gameplay.gameMode)
        {
        case GameMode.ADDITION:
            mode = "(+)";
            break;

        case GameMode.SUBTRACTION:
            mode = "(-)";
            break;

        case GameMode.MULTIPLICATION:
            mode = "(*)";
            break;

        case GameMode.DIVISION:
            mode = "(/)";
            break;

        case GameMode.EXPONENTIATION:
            mode = "(^)";
            break;

        case GameMode.SQUARE_ROOT:
            mode = "(√)";
            break;
        }

        score.text = "Score: " + SCR_Gameplay.s_score.ToString();
        best.text  = "Best " + mode + ": " + SCR_Profile.GetBestScore(SCR_Gameplay.gameMode);
    }
Beispiel #2
0
 public void OnSound()
 {
     SCR_Profile.ToggleSound();
     RefreshSoundButtonStatus();
     RefreshSoundStatus();
     SCR_Audio.PlayClickSound();
 }
Beispiel #3
0
    private void Start()
    {
        // Set up game's stuff
        Application.targetFrameRate = 60;
        Screen.orientation          = ScreenOrientation.Portrait;
        //Screen.SetResolution(540, 960, false);

        // Load profile
        SCR_Profile.Init();
        SCR_Profile.LoadProfile();

        bossSelecting = SCR_Profile.bossSelecting;

        RefreshSoundButtonStatus();
        UpdateMoneyNumber();
        UpdateBoss();

        dgbBoss[0].GetComponentInChildren <MeshRenderer>().sharedMaterial.SetFloat("_FlashAmount", 0);

        // Music
        SCR_WaitMusic.FadeIn();
        SCR_PunchMusic.FadeOut();
        SCR_RunSound.Stop();

        // OK, confirm that menu is now the first state
        menuLoaded = true;

        // Skip right into gameplay for tutorial

        /*
         * if (SCR_Profile.showTutorial == 1) {
         *      SceneManager.LoadScene("GSGameplay/SCN_Gameplay");
         * }
         */
    }
Beispiel #4
0
 public void OnPlay()
 {
     // Load latest level
     SCR_Profile.SelectBoss(bossSelecting);
     SCR_Audio.PlayClickSound();
     SceneManager.LoadScene("GSGameplay/SCN_Gameplay");
 }
Beispiel #5
0
 public void OnReset()
 {
     SCR_Profile.ResetProfile();
     SCR_Audio.PlayClickSound();
     UpdateMoneyNumber();
     UpdateBoss();
 }
Beispiel #6
0
 public void OnCheatMoney()
 {
     SCR_Profile.CheatMoney();
     SCR_Audio.PlayClickSound();
     UpdateMoneyNumber();
     UpdateBoss();
 }
Beispiel #7
0
    void Start()
    {
        SCR_Profile.Load();

        s_score = 0;

        NextQuestion();
    }
Beispiel #8
0
 public void DecreaseBrain(int amount)
 {
     SCR_Profile.brain -= amount;
     txtBrain.text      = FormatNumber(SCR_Profile.brain);
     SCR_Profile.SaveBrain();
     scrZombieShop.UpdateBrain();
     scrUpgradeShop.UpdateBrain();
 }
Beispiel #9
0
 public void OnBuy()
 {
     if (bossSelecting <= 2)
     {
         SCR_Profile.BuyBoss(bossSelecting);
         UpdateBoss();
         UpdateMoneyNumber();
     }
     SCR_Audio.PlayBuySound();
 }
    public void AddMoneyAtPosition(int money, float x, float y)
    {
        txtMoneyAdd.GetComponent <SCR_MoneyAdd>().Spawn(money.ToString(), x, y + PUNCH_TEXT_OFFSET_Y);
        txtMoneyAdd.GetComponent <RectTransform>().anchorMin = Vector2.zero;
        txtMoneyAdd.GetComponent <RectTransform>().anchorMax = Vector2.zero;
        txtMoneyAdd.GetComponent <Text>().alignment          = TextAnchor.MiddleCenter;
        txtMoneyAdd.GetComponent <Text>().fontSize           = 80;
        SCR_Profile.AddMoney(money);

        totalReward += money;
    }
    public void OnMainMenu()
    {
        if (imgNotice.activeSelf)
        {
            SCR_Profile.SelectBoss(shouldSelect);
            SCR_Profile.bosses[shouldSelect].recommended = 1;
            SCR_Profile.SaveProfile();
        }

        SCR_Audio.PlayClickSound();
        SceneManager.LoadScene("GSMenu/SCN_Menu");
    }
    public void AddMoney(int money)
    {
        txtMoneyAdd.GetComponent <SCR_MoneyAdd>().SetText(money.ToString());
        txtMoneyAdd.GetComponent <RectTransform>().anchorMin        = txtMoneyAddOriginalAnchorMin;
        txtMoneyAdd.GetComponent <RectTransform>().anchorMax        = txtMoneyAddOriginalAnchorMax;
        txtMoneyAdd.GetComponent <RectTransform>().anchoredPosition = txtMoneyAddOriginalPosition;
        txtMoneyAdd.GetComponent <Text>().alignment = txtMoneyAddOriginalAlignment;
        txtMoneyAdd.GetComponent <Text>().fontSize  = txtMoneyAddOriginalFontSize;
        SCR_Profile.AddMoney(money);

        totalReward += money;
    }
Beispiel #13
0
    public void OnUpgradeZombie(int index)
    {
        if (SCR_Config.GetUpgradePrice(index) <= SCR_Profile.brain)
        {
            SCR_Gameplay.instance.DecreaseBrain(SCR_Config.GetUpgradePrice(index));

            SCR_Profile.upgradeZombies[index]++;
            SCR_Profile.SaveUpgradeZombies();

            RefreshUpgradeInfo();
        }
    }
    public void TriggerTutorial(TutorialStep step, bool force = false)
    {
        if (SCR_Profile.showTutorial == 1)
        {
            if (step == tutorialStep + 1 || force == true)
            {
                tutorialStep = step;


                if (step == TutorialStep.GRAB)
                {
                    tutorialAlpha = 1;
                    txtTutorial.SetActive(true);
                    txtTutorial.GetComponent <Text>().text = "Tap anywhere to start";
                    SCR_UnityAnalytics.StartTutorial();
                }
                else if (step == TutorialStep.THROW)
                {
                    txtTutorial.SetActive(false);
                }
                else if (step == TutorialStep.AIM)
                {
                    txtTutorial.SetActive(true);
                    txtTutorial.GetComponent <Text>().text = "Tap and hold to aim";
                }
                else if (step == TutorialStep.PUNCH)
                {
                    txtTutorial.SetActive(true);
                    txtTutorial.GetComponent <Text>().text = "Release to start punching";
                }
                else if (step == TutorialStep.FLY_UP)
                {
                    txtTutorial.GetComponent <Text>().text = "Keep on punching (0/3)";
                    Time.timeScale = 0.05f;
                }
                else if (step == TutorialStep.CONTINUE)
                {
                }
                else if (step == TutorialStep.FINISH)
                {
                    txtTutorial.GetComponent <Text>().text = "Well done!";
                    SCR_Profile.showTutorial = 0;
                    SCR_Profile.SaveProfile();

                    SCR_UnityAnalytics.FinishTutorial();
                }
            }
        }
    }
Beispiel #15
0
    public void BuyZombie(int index)
    {
        if (!showingTutorial || tutorialPhase == TutorialPhase.BUY_ZOMBIE)
        {
            int map = GetMapFromZombieIndex(index);

            if (numberUnits[map] < SCR_Config.MAX_NUMBER_ZOMBIES && SCR_Profile.brain >= SCR_Config.ZOMBIE_INFO[index].price)
            {
                GameObject zombie = SpawnZombie(index);
                SCR_Profile.numberZombies[index]++;
                SCR_Profile.SaveNumberZombies();

                UpdateTotalProductionRate();

                DecreaseBrain(SCR_Config.ZOMBIE_INFO[index].price);

                if (showingTutorial)
                {
                    if (tutorialPhase == TutorialPhase.BUY_ZOMBIE)
                    {
                        if (index == 0)
                        {
                            tutorialZombie2 = zombie.transform;
                            ShowTutorial(TutorialPhase.CLOSE_ZOMBIE_SHOP);
                        }
                    }
                }

                source.PlayOneShot(sndBuyZombie);
            }
            else
            {
                grpAreaIsFull.GetComponent <SCR_AutoFade>().txtTitle.text = "AREA IS FULL!";
                grpAreaIsFull.SetActive(true);

                source.PlayOneShot(sndButton);
            }
        }
    }
Beispiel #16
0
 void Start()
 {
     SCR_Profile.Load();
 }
Beispiel #17
0
 private void IncreaseScore()
 {
     s_score++;
     score.text = s_score.ToString();
     SCR_Profile.UpdateBestScore(s_score, gameMode);
 }
Beispiel #18
0
    public void FuseZombie(GameObject zombie1, GameObject zombie2)
    {
        int originalIndex = (int)zombie1.GetComponent <SCR_Zombie>().type;
        int zombieIndex   = originalIndex + 1;

        int originalMap = GetMapFromZombieIndex(originalIndex);
        int map         = GetMapFromZombieIndex(zombieIndex);

        if (map == originalMap || numberUnits[map] < SCR_Config.MAX_NUMBER_ZOMBIES)
        {
            Vector3 position = (zombie1.transform.position + zombie2.transform.position) * 0.5f;

            if (map != originalMap)
            {
                GameObject movedZombie = Instantiate(PFB_ZOMBIES[zombieIndex], backgrounds[originalMap].transform);
                movedZombie.transform.position = new Vector3(0, -movedZombie.GetComponent <BoxCollider2D>().offset.y, 0);
                movedZombie.GetComponent <SCR_Zombie>().SwitchMapEffect();

                if (zombieIndex > SCR_Profile.zombieUnlocked)
                {
                    pendingDiscover = true;
                    pendingIndex    = zombieIndex;
                }
            }

            GameObject zombie = Instantiate(PFB_ZOMBIES[zombieIndex], backgrounds[map].transform);
            zombie.transform.position = position;
            Instantiate(PFB_FUSE_EFFECT, position, PFB_FUSE_EFFECT.transform.rotation);

            Destroy(zombie1);
            Destroy(zombie2);

            numberUnits[map]++;
            numberUnits[originalMap] -= 2;

            SCR_Profile.numberZombies[zombieIndex]++;
            SCR_Profile.numberZombies[originalIndex] -= 2;
            SCR_Profile.SaveNumberZombies();

            UpdateTotalProductionRate();

            if (showingTutorial)
            {
                if (tutorialPhase == TutorialPhase.EVOLVE_ZOMBIE)
                {
                    hand.SetActive(false);
                    showingTutorial = false;
                    SCR_Profile.finishedTutorial = true;
                    SCR_Profile.SaveTutorial();
                }
            }

            if (zombieIndex > SCR_Profile.zombieUnlocked)
            {
                if (!pendingDiscover)
                {
                    cvsDiscover.GetComponent <SCR_DiscoverZombie>().ShowNewZombie(zombieIndex);
                    cvsDiscover.SetActive(true);
                    source.PlayOneShot(sndDiscover);
                }

                SCR_Profile.zombieUnlocked = zombieIndex;
                SCR_Profile.SaveZombieUnlocked();

                scrZombieShop.RefreshUnlocked();
                scrUpgradeShop.RefreshUnlocked();
            }

            source.PlayOneShot(sndEvolve);
        }
        else
        {
            grpAreaIsFull.GetComponent <SCR_AutoFade>().txtTitle.text = "NEXT AREA IS FULL!";
            grpAreaIsFull.SetActive(true);
        }
    }
Beispiel #19
0
    public void Update()
    {
        if (!cvsDiscover.activeSelf &&
            !cvsUpgrade.activeSelf &&
            !cvsCollection.activeSelf &&
            !scrZombieShop.gameObject.activeSelf)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Vector3      pos     = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                RaycastHit2D bestHit = FindBestHit(pos);
                if (bestHit.transform != null)
                {
                    if (bestHit.transform.parent != null)
                    {
                        SCR_Tomb scrTomb = bestHit.transform.parent.GetComponent <SCR_Tomb>();
                        if (scrTomb != null)
                        {
                            GameObject zombie = SpawnZombie(0);                                 // numberUnits[0]++ in SpawnZombie(0)

                            numberUnits[0]--;

                            SCR_Profile.numberZombies[0]++;
                            SCR_Profile.SaveNumberZombies();

                            SCR_Profile.numberTombs--;
                            SCR_Profile.SaveNumberTombs();

                            UpdateTotalProductionRate();

                            zombie.transform.position = bestHit.transform.parent.position;
                            Destroy(bestHit.transform.parent.gameObject);

                            if (showingTutorial)
                            {
                                if (tutorialPhase == TutorialPhase.OPEN_TOMB)
                                {
                                    tutorialZombie1 = zombie.transform;
                                    ShowTutorial(TutorialPhase.OPEN_ZOMBIE_SHOP);
                                }
                            }

                            source.PlayOneShot(sndTapTomb);
                        }
                    }

                    if (!showingTutorial || tutorialPhase == TutorialPhase.EVOLVE_ZOMBIE)
                    {
                        SCR_Zombie scrZombie = bestHit.transform.GetComponent <SCR_Zombie>();
                        if (scrZombie != null)
                        {
                            selectedZombie = bestHit.transform;
                            offsetX        = selectedZombie.position.x - pos.x;
                            offsetY        = selectedZombie.position.y - pos.y;
                            selectedZombie.GetComponent <Collider2D>().enabled = false;

                            scrZombie.StopMoving();
                            scrZombie.state = ZombieState.USER_MOVE;
                        }
                    }
                }
            }

            if (Input.GetMouseButton(0))
            {
                if (selectedZombie != null)
                {
                    Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    float   x   = Mathf.Clamp(pos.x + offsetX, GARDEN_LEFT, GARDEN_RIGHT);
                    float   y   = Mathf.Clamp(pos.y + offsetY, GARDEN_BOTTOM, GARDEN_TOP);
                    float   z   = y;
                    selectedZombie.position = new Vector3(x, y, z);
                }
            }

            if (Input.GetMouseButtonUp(0))
            {
                if (selectedZombie != null)
                {
                    Vector3      pos     = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                    RaycastHit2D bestHit = FindBestHit(pos);
                    if (bestHit.transform != null)
                    {
                        SCR_Zombie scrZombie = bestHit.transform.GetComponent <SCR_Zombie>();
                        if (scrZombie != null)
                        {
                            if (selectedZombie.GetComponent <SCR_Zombie>().type == scrZombie.type)
                            {
                                if (scrZombie.type != SCR_Zombie.LAST_TYPE)
                                {
                                    FuseZombie(selectedZombie.gameObject, scrZombie.gameObject);
                                }
                                else
                                {
                                    grpPerfect.SetActive(true);
                                }
                            }
                        }
                    }

                    selectedZombie.GetComponent <SCR_Zombie>().state = ZombieState.AUTO_MOVE;

                    selectedZombie.GetComponent <Collider2D>().enabled = true;
                    selectedZombie = null;
                }
            }
        }

        if (!showingTutorial)
        {
            tombSpawnTime += Time.deltaTime;
            if (tombSpawnTime >= SCR_Config.TOMB_SPAWN_INTERVAL && numberUnits[0] < SCR_Config.MAX_NUMBER_ZOMBIES)
            {
                SpawnTomb();
                tombSpawnTime = 0;

                SCR_Profile.numberTombs++;
                SCR_Profile.SaveNumberTombs();
            }

            productionTime += Time.deltaTime;
            if (productionTime >= 1)
            {
                IncreaseBrain(totalProductionRate);
                productionTime = 0;
            }
        }
    }
Beispiel #20
0
    public void Start()
    {
        //SCR_Profile.Reset();
        SCREEN_HEIGHT = Camera.main.orthographicSize * 2;
        SCREEN_WIDTH  = SCREEN_HEIGHT * Screen.width / Screen.height;

        GARDEN_X = garden.transform.position.x;
        GARDEN_Y = garden.transform.position.y;

        GARDEN_WIDTH  = garden.transform.localScale.x;
        GARDEN_HEIGHT = garden.transform.localScale.y;

        GARDEN_LEFT   = GARDEN_X - GARDEN_WIDTH * 0.5f;
        GARDEN_RIGHT  = GARDEN_X + GARDEN_WIDTH * 0.5f;
        GARDEN_TOP    = GARDEN_Y + GARDEN_HEIGHT * 0.5f;
        GARDEN_BOTTOM = GARDEN_Y - GARDEN_HEIGHT * 0.5f;

        SCR_Profile.Load();

        if (!SCR_Profile.finishedTutorial)
        {
            SCR_Profile.Reset();
        }

        txtBrain.text = FormatNumber(SCR_Profile.brain);

        for (int i = 0; i < SCR_Profile.NUMBER_ZOMBIES; i++)
        {
            SpawnZombie(i, SCR_Profile.numberZombies[i]);
        }

        for (int i = 0; i < SCR_Profile.numberTombs; i++)
        {
            SpawnTomb();
        }

        showingTutorial = !SCR_Profile.finishedTutorial;

        backgrounds[0].SetActive(true);

        for (int i = 1; i < backgrounds.Length; i++)
        {
            backgrounds[i].SetActive(false);
        }

        grpAreaIsFull.SetActive(false);
        grpPerfect.SetActive(false);

        zombieShop.SetActive(false);

        if (showingTutorial)
        {
            ShowTutorial(TutorialPhase.OPEN_TOMB);
        }
        else
        {
            hand.SetActive(false);
        }

        cvsGameplay.SetActive(true);
        cvsUpgrade.SetActive(false);
        cvsCollection.SetActive(false);
        cvsCoin.SetActive(true);
        cvsDiscover.SetActive(false);

        scrZombieShop  = cvsGameplay.transform.Find("ZombieShop").GetComponent <SCR_ZombieShop>();
        scrUpgradeShop = cvsUpgrade.transform.Find("UpgradeShop").GetComponent <SCR_UpgradeShop>();

        UpdateTotalProductionRate();

        MobileAds.Initialize(appId);

        RequestBanner();
        SetBannerTop();

        started = true;
    }
Beispiel #21
0
 public void OnUpdateBossName()
 {
     SCR_Profile.ChangeName(bossSelecting, inpName.GetComponent <InputField>().text);
 }
    public void Lose()
    {
        iTween.Stop(imgSecurityProgressFG.gameObject);
        imgSecurityProgressFG.GetComponent <SCR_SecurityProgress>().UpdateFlashAmount(0);

        imgSecurityProgressBG.gameObject.SetActive(false);
        imgSecurityProgressFG.gameObject.SetActive(false);

        pnlResult.SetActive(true);
        btnReplay.SetActive(true);
        btnMainMenu.SetActive(true);

        //txtResultTitle.text = boss.GetComponent<SCR_Boss>().resultTitle[SCR_Profile.bossSelecting];
        //txtResultTitle.fontSize = boss.GetComponent<SCR_Boss>().resultTitleFontSize[SCR_Profile.bossSelecting];

        const int FONT_MIN   = 80;
        const int FONT_MAX   = 155;
        const int LENGTH_MIN = 8;
        const int LENGTH_MAX = 16;

        txtResultTitle.text = SCR_Profile.bosses[SCR_Profile.bossSelecting].name;
        int l = txtResultTitle.text.Length;

        if (l < LENGTH_MIN)
        {
            l = LENGTH_MIN;
        }
        if (l > LENGTH_MAX)
        {
            l = LENGTH_MAX;
        }
        float r = 1 - (float)(l - LENGTH_MIN) / (LENGTH_MAX - LENGTH_MIN);

        txtResultTitle.fontSize = (int)(FONT_MIN + (FONT_MAX - FONT_MIN) * r);

        SCR_WaitMusic.FadeIn();
        SCR_PunchMusic.FadeOut();

        if (maxBossY > SCR_Profile.highScore)
        {
            imgHighScore.SetActive(true);
        }
        else
        {
            imgHighScore.SetActive(false);
        }

        SCR_Profile.ReportScore(maxBossY);
        txtPunchNumber.GetComponent <Text>().text  = maxCombo.ToString();
        txtHeightNumber.GetComponent <Text>().text = maxBossY.ToString();
        txtBestNumber.GetComponent <Text>().text   = SCR_Profile.highScore.ToString();

        int money = (int)(maxBossY * 0.5);

        AddMoney(money);

        txtMoneyNumber.GetComponent <Text>().text = "$" + totalReward.ToString();

        imgSecurityProgressBG.color = new Color(1, 1, 1, 0);
        imgSecurityProgressFG.color = new Color(1, 1, 1, 0);

        // -- //
        bool found = false;

        for (int i = 0; i < SCR_Profile.bosses.Length; i++)
        {
            if (SCR_Profile.bosses[i].unlocked == 0 && SCR_Profile.money >= SCR_Profile.bosses[i].cost)
            {
                if (SCR_Profile.bosses[i].recommended == 0)
                {
                    shouldSelect = i;
                    found        = true;
                    break;
                }
            }
        }

        if (found)
        {
            imgNotice.SetActive(true);
        }
        // -- //

        SCR_UnityAnalytics.FinishGame(maxBossY);
    }