Пример #1
0
    IEnumerator countDown()
    {
        for (int a = 0; a < count123.Length; a++)
        {
            count123[a].GetComponent <Animation>().Play();
            if (a > 0)
            {
                hornAudioS.PlayOneShot(hornAudioS.clip);
            }
            yield return(new WaitForSeconds(0.85f));
        }
        go.GetComponent <Animation>().Play();
        hornAudioS.pitch  = 1.3f;
        hornAudioS.volume = 0.85f;
        hornAudioS.PlayOneShot(hornAudioS.clip);
        yield return(new WaitForSeconds(0.5f));

        upSc.started = true;
        StartCoroutine(upSc.molePoper());
    }
Пример #2
0
    void Start()
    {
        Application.targetFrameRate = 60;

        pauseCan = GameObject.FindGameObjectWithTag("pauseCan").GetComponent <Canvas>();
        pauseCan.GetComponent <Canvas>().worldCamera = Camera.main;
        hitSc      = GetComponent <moleHit>();
        hornAudioS = GameObject.FindGameObjectWithTag("hornS").GetComponent <AudioSource>();
        upSc       = GetComponent <moleUp>();
        if (SceneManager.GetActiveScene().buildIndex == 0 || SceneManager.GetActiveScene().name == "S 1 lvl 4" || SceneManager.GetActiveScene().name == "S 2 lvl 4" || SceneManager.GetActiveScene().name == "S 3 lvl 4" || SceneManager.GetActiveScene().name == "S 4 lvl 4")
        {
            startCan.SetActive(true);
        }
        else if (SceneManager.GetActiveScene().name == "S 1 lvl 1" || SceneManager.GetActiveScene().name == "S 2 lvl 1" || SceneManager.GetActiveScene().name == "S 3 lvl 1" || SceneManager.GetActiveScene().name == "S 4 lvl 1")
        {
            StartCoroutine(countDown());
        }
        else
        {
            upSc.started = true;
            StartCoroutine(upSc.molePoper());
        }
    }
Пример #3
0
    void Update()
    {
        ////Auto
        //if (!gameOver && upSc.started && !bSc.paused && !paused)
        //{
        //    if (autoTimer > upSc.outSpeed[upSc.moleNum] + Random.Range(0.35f, 0.5f))
        //    {
        //        for (int a = 0; a < upSc.moles.Length; a++)
        //        {
        //            if (hitNow[a])
        //            {
        //                if (upSc.twoOn && a == 8)
        //                {
        //                    upSc.twoOn = false;
        //                    upSc.pressed2 = true;
        //                    hitNow[a] = false;
        //                    upSc.moleTime2 = 0;

        //                    if (upSc.lastMole)
        //                    {
        //                        lastHit = true;
        //                        gameEnded();
        //                    }
        //                    else
        //                    {
        //                        if (!twoMolesHit)
        //                        {
        //                            twoMolesHit = true;
        //                        }
        //                        else
        //                        {
        //                            StartCoroutine(upSc.molePoper());
        //                            twoMolesHit = false;
        //                        }
        //                    }
        //                }
        //                else
        //                {
        //                    upSc.pressed = true;
        //                    hitNow[a] = false;

        //                    sScript.score += 150;
        //                    scoreText.GetComponent<Animation>().Play();
        //                    scoreText.GetComponent<Text>().text = sScript.score.ToString();
        //                    scoreText.transform.GetChild(0).GetComponent<Text>().text = sScript.score.ToString();
        //                    upSc.missMole = 0;

        //                    if (upSc.lastMole)
        //                    {
        //                        lastHit = true;
        //                        gameEnded();
        //                    }
        //                    else
        //                    {
        //                        if (!upSc.twoOn)
        //                        {
        //                            StartCoroutine(upSc.molePoper());
        //                        }
        //                        else if (!twoMolesHit)
        //                        {
        //                            twoMolesHit = true;
        //                        }
        //                        else
        //                        {
        //                            StartCoroutine(upSc.molePoper());
        //                            twoMolesHit = false;
        //                        }
        //                    }
        //                }

        //                sound.GetComponent<AudioSource>().PlayOneShot(hitSound, 0.9f);
        //                cam.GetComponent<Animation>().Play();
        //                upSc.moles[a].transform.parent.parent.GetChild(0).GetComponent<Animation>().Play();
        //                upSc.moles[a].GetComponent<Animation>().Play("goInFast");
        //                starPar.transform.position = new Vector3(upSc.moles[a].transform.parent.parent.GetChild(0).transform.position.x - 0.56f, upSc.moles[a].transform.parent.parent.GetChild(0).transform.position.y - 0.25f, 0);
        //                starPar.GetComponent<ParticleSystem>().Emit(10);

        //                comboHits++;
        //                upSc.moles[a].transform.parent.parent.GetChild(3).GetChild(0).GetChild(0).GetComponent<Text>().text = comboHits + "X";
        //                upSc.moles[a].transform.parent.parent.GetChild(3).GetChild(0).GetChild(1).GetComponent<Text>().text = comboHits + "X";
        //                upSc.moles[a].transform.parent.parent.GetChild(3).GetChild(0).GetComponent<Animation>().Play();

        //                for (int x = 0; x < 5; x++)
        //                {
        //                    if (sScript.gaugeNum == x)
        //                    {
        //                        if (sScript.gaugeNum < 5)
        //                        {
        //                            sScript.gaugeScore++;
        //                            bonusGauge.transform.GetChild(sScript.gaugeNum).GetComponent<Slider>().value = sScript.gaugeScore;

        //                            if (bonusGauge.transform.GetChild(sScript.gaugeNum).GetComponent<Slider>().value >= bonusGauge.transform.GetChild(sScript.gaugeNum).GetComponent<Slider>().maxValue)
        //                            {
        //                                if (sScript.gaugeNum < 5)
        //                                {
        //                                    bonusGauge.transform.GetChild(sScript.gaugeNum).transform.GetChild(3).GetChild(0).GetComponent<Image>().color = new Color(bonusGauge.transform.GetChild(sScript.gaugeNum).transform.GetChild(3).GetChild(0).GetComponent<Image>().color.r,
        //                                        bonusGauge.transform.GetChild(sScript.gaugeNum).transform.GetChild(3).GetChild(0).GetComponent<Image>().color.g,
        //                                        bonusGauge.transform.GetChild(sScript.gaugeNum).transform.GetChild(3).GetChild(0).GetComponent<Image>().color.b, 1);

        //                                    bonusGauge.transform.GetChild(sScript.gaugeNum).transform.GetChild(4).gameObject.SetActive(true);
        //                                    sScript.gaugeScore = 0;
        //                                    sScript.gaugeNum++;
        //                                    x = 5;
        //                                    comboHits = 0;

        //                                    if (sScript.firstSegment)
        //                                    {
        //                                        sScript.firstSegment = false;
        //                                        StartCoroutine("firstSegWait");
        //                                    }
        //                                }
        //                            }
        //                        }
        //                        else
        //                        {
        //                            sScript.gaugeScore++;
        //                        }
        //                    }
        //                }
        //                checkRank();
        //                autoTimer = 0;
        //            }
        //        }
        //    }
        //    else
        //    {
        //        Debug.Log(autoTimer);
        //        autoTimer += Time.deltaTime;
        //    }
        //}


        //Clicking
        if (Input.touchCount > 0 && Input.touchCount <= 5 && !gameOver && upSc.started && !bSc.paused && !paused /* && Input.GetMouseButtonDown(0)*/)
        {
            touch = Input.GetTouch(Input.touchCount - 1);
            hit[Input.touchCount] = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(touch.position /*Input.mousePosition*/), Vector2.zero);

            if (touch.phase == TouchPhase.Began || Application.platform == RuntimePlatform.WindowsEditor)
            {
                for (int a = 0; a < upSc.moles.Length; a++)
                {
                    if (hit[Input.touchCount].collider != null && hit[Input.touchCount].collider.gameObject == upSc.moles[a].transform.parent.parent.gameObject)
                    {
                        if (hitNow[a])
                        {
                            if (upSc.twoOn && upSc.moles[a].GetComponent <multiMole>().multiPop)
                            {
                                upSc.moles[a].GetComponent <multiMole>().multiPop = false;
                                hitNow[a]  = false;
                                upSc.twoOn = false;

                                if (multiMoleHits > 1)
                                {
                                    if (upSc.twoHits)
                                    {
                                        upSc.twoOn    = false;
                                        multiMoleHits = 0;
                                        upSc.twoHits  = false;

                                        if (upSc.moleLimit < upSc.moleMax)
                                        {
                                            StartCoroutine(upSc.molePoper());
                                        }
                                        else
                                        {
                                            gameEnded();
                                        }
                                    }
                                }
                                else
                                {
                                    upSc.twoHits = true;
                                    multiMoleHits++;
                                }
                            }
                            else if (upSc.threeOn && upSc.moles[a].GetComponent <multiMole>().multiPop)
                            {
                                upSc.moles[a].GetComponent <multiMole>().multiPop = false;
                                hitNow[a] = false;

                                if (multiMoleHits >= 2)
                                {
                                    multiMoleHits = 0;
                                    upSc.threeOn  = false;

                                    if (upSc.moleLimit >= upSc.moleMax)
                                    {
                                        gameEnded();
                                        lastHit = true;
                                    }
                                    else
                                    {
                                        StartCoroutine(upSc.molePoper());
                                    }
                                }
                                else
                                {
                                    multiMoleHits++;
                                }
                            }
                            else if (upSc.fourOn && upSc.moles[a].GetComponent <multiMole>().multiPop)
                            {
                                upSc.moles[a].GetComponent <multiMole>().multiPop = false;
                                hitNow[a] = false;

                                if (multiMoleHits >= 3)
                                {
                                    multiMoleHits = 0;
                                    upSc.fourOn   = false;

                                    if (upSc.moleLimit >= upSc.moleMax)
                                    {
                                        gameEnded();
                                        lastHit = true;
                                    }
                                    else
                                    {
                                        StartCoroutine(upSc.molePoper());
                                    }
                                }
                                else
                                {
                                    multiMoleHits++;
                                }
                            }
                            else if (upSc.fiveOn && upSc.moles[a].GetComponent <multiMole>().multiPop)
                            {
                                upSc.moles[a].GetComponent <multiMole>().multiPop = false;
                                hitNow[a] = false;

                                if (multiMoleHits >= 4)
                                {
                                    multiMoleHits = 0;
                                    upSc.fiveOn   = false;

                                    if (upSc.moleLimit >= upSc.moleMax)
                                    {
                                        gameEnded();
                                        lastHit = true;
                                    }
                                    else
                                    {
                                        StartCoroutine(upSc.molePoper());
                                    }
                                }
                                else
                                {
                                    multiMoleHits++;
                                }
                            }
                            else
                            {
                                multiMoleHits++;
                                if (upSc.twoOn && !upSc.twoHits)
                                {
                                    upSc.twoHits = true;

                                    if (upSc.moleLimit < upSc.moleMax)
                                    {
                                        StartCoroutine(upSc.molePoper());
                                    }
                                    else
                                    {
                                        gameEnded();
                                    }
                                }
                                else
                                {
                                    upSc.moles[a].GetComponent <multiMole>().multiPop = false;
                                    hitNow[a] = false;

                                    if (upSc.twoOn)
                                    {
                                        if (upSc.twoHits)
                                        {
                                            upSc.twoOn    = false;
                                            multiMoleHits = 0;
                                            upSc.twoHits  = false;

                                            if (upSc.moleLimit < upSc.moleMax)
                                            {
                                                StartCoroutine(upSc.molePoper());
                                            }
                                            else
                                            {
                                                gameEnded();
                                            }
                                        }
                                        else
                                        {
                                            multiMoleHits++;
                                            upSc.twoHits = true;
                                        }
                                    }
                                    else
                                    {
                                        if (upSc.moleLimit < upSc.moleMax)
                                        {
                                            StartCoroutine(upSc.molePoper());
                                        }
                                        else
                                        {
                                            gameEnded();
                                        }
                                    }
                                }
                            }
                            sScript.score += 150;
                            scoreText.GetComponent <Animation>().Play();
                            scoreText.GetComponent <Text>().text = sScript.score.ToString();
                            scoreText.transform.GetChild(0).GetComponent <Text>().text = sScript.score.ToString();
                            upSc.missMole = 0;

                            sound.GetComponent <AudioSource>().PlayOneShot(hitSound, 0.9f);
                            cam.GetComponent <Animation>().Play();
                            upSc.moles[a].transform.parent.parent.GetChild(0).GetComponent <Animation>().Play();
                            upSc.moles[a].GetComponent <Animation>().Play("goInFast");
                            starPar.transform.position = new Vector3(upSc.moles[a].transform.parent.parent.GetChild(0).transform.position.x - 0.56f, upSc.moles[a].transform.parent.parent.GetChild(0).transform.position.y - 0.25f, 0);
                            starPar.GetComponent <ParticleSystem>().Emit(10);

                            comboHits++;
                            upSc.moles[a].transform.parent.parent.GetChild(3).GetChild(0).GetChild(0).GetComponent <Text>().text = comboHits + "X";
                            upSc.moles[a].transform.parent.parent.GetChild(3).GetChild(0).GetChild(1).GetComponent <Text>().text = comboHits + "X";
                            upSc.moles[a].transform.parent.parent.GetChild(3).GetChild(0).GetComponent <Animation>().Play();

                            for (int x = 0; x < 5; x++)
                            {
                                if (sScript.gaugeNum == x)
                                {
                                    if (sScript.gaugeNum < 5)
                                    {
                                        sScript.gaugeScore++;
                                        bonusGauge.transform.GetChild(sScript.gaugeNum).GetComponent <Slider>().value = sScript.gaugeScore;

                                        if (bonusGauge.transform.GetChild(sScript.gaugeNum).GetComponent <Slider>().value >= bonusGauge.transform.GetChild(sScript.gaugeNum).GetComponent <Slider>().maxValue)
                                        {
                                            if (sScript.gaugeNum < 5)
                                            {
                                                bonusGauge.transform.GetChild(sScript.gaugeNum).transform.GetChild(3).GetChild(0).GetComponent <Image>().color = new Color(bonusGauge.transform.GetChild(sScript.gaugeNum).transform.GetChild(3).GetChild(0).GetComponent <Image>().color.r,
                                                                                                                                                                           bonusGauge.transform.GetChild(sScript.gaugeNum).transform.GetChild(3).GetChild(0).GetComponent <Image>().color.g,
                                                                                                                                                                           bonusGauge.transform.GetChild(sScript.gaugeNum).transform.GetChild(3).GetChild(0).GetComponent <Image>().color.b, 1);

                                                bonusGauge.transform.GetChild(sScript.gaugeNum).transform.GetChild(4).gameObject.SetActive(true);
                                                sScript.gaugeScore = 0;
                                                sScript.gaugeNum++;
                                                x         = 5;
                                                comboHits = 0;

                                                if (sScript.firstSegment)
                                                {
                                                    sScript.firstSegment = false;
                                                    StartCoroutine("firstSegWait");
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        sScript.gaugeScore++;
                                    }
                                }
                            }
                            checkRank();
                        }
                        else
                        {
                            upSc.moles[a].transform.parent.parent.GetChild(0).GetComponent <Animation>().Play();

                            //lose Streak
                            //gaugeScore = 0;
                            //if (sScript.gaugeNum < 5)
                            //{
                            //    bonusGauge.transform.GetChild(sScript.gaugeNum).GetComponent<Slider>().value = gaugeScore;
                            //}
                            //comboHits = 0;
                        }
                    }
                }
            }
        }
    }
Пример #4
0
    void Update()
    {
        if (multiPop)
        {
            moleDownTime += Time.deltaTime;
        }
        if (moleDownTime >= moleTimeLimit && multiTimeNow)
        {
            moleDownTime = 0;
            multiPop     = false;
            multiTimeNow = false;
            GetComponent <Animation>().Play("goIn");

            for (int a = 0; a < upSc.moles.Length; a++)
            {
                if (upSc.moles[a] == gameObject)
                {
                    hitSc.hitNow[a] = false;
                }
            }

            transform.parent.parent.GetChild(2).GetChild(0).GetChild(0).GetComponent <Text>().text = "Missed";
            transform.parent.parent.GetChild(2).GetChild(0).GetChild(1).GetComponent <Text>().text = "Missed";
            transform.parent.parent.GetChild(2).GetChild(0).GetComponent <Animation>().Play();

            hitSc.multiMoleHits++;

            hitSc.comboHits = 0;

            sScript.gaugeScore = 0;
            if (sScript.gaugeNum < 5)
            {
                hitSc.bonusGauge.transform.GetChild(sScript.gaugeNum).GetComponent <Slider>().value = sScript.gaugeScore;
            }

            if (hitSc.multiMoleHits > 4 && upSc.fiveOn)
            {
                upSc.fiveOn         = false;
                hitSc.multiMoleHits = 0;

                if (upSc.moleLimit < upSc.moleMax)
                {
                    StartCoroutine(upSc.molePoper());
                }
                else
                {
                    hitSc.gameEnded();
                }
            }
            else if (hitSc.multiMoleHits > 3 && upSc.fourOn)
            {
                upSc.fourOn         = false;
                hitSc.multiMoleHits = 0;

                if (upSc.moleLimit < upSc.moleMax)
                {
                    StartCoroutine(upSc.molePoper());
                }
                else
                {
                    hitSc.gameEnded();
                }
            }
            else if (hitSc.multiMoleHits > 2 && upSc.threeOn)
            {
                upSc.threeOn        = false;
                hitSc.multiMoleHits = 0;

                if (upSc.moleLimit < upSc.moleMax)
                {
                    StartCoroutine(upSc.molePoper());
                }
                else
                {
                    hitSc.gameEnded();
                }
            }
            else if (hitSc.multiMoleHits > 1 && upSc.twoOn)
            {
                if (upSc.twoHits)
                {
                    upSc.twoOn          = false;
                    hitSc.multiMoleHits = 0;
                    upSc.twoHits        = false;

                    if (upSc.moleLimit < upSc.moleMax)
                    {
                        StartCoroutine(upSc.molePoper());
                    }
                    else
                    {
                        hitSc.gameEnded();
                    }
                }
                else
                {
                    upSc.twoHits = true;
                }
            }
            else
            {
                if (upSc.twoOn)
                {
                    if (upSc.twoHits)
                    {
                        upSc.twoOn          = false;
                        hitSc.multiMoleHits = 0;
                        upSc.twoHits        = false;

                        if (upSc.moleLimit < upSc.moleMax)
                        {
                            StartCoroutine(upSc.molePoper());
                        }
                        else
                        {
                            hitSc.gameEnded();
                        }
                    }
                    else
                    {
                        upSc.twoHits = true;
                    }
                }
                else
                {
                    if (upSc.moleLimit < upSc.moleMax)
                    {
                        StartCoroutine(upSc.molePoper());
                    }
                    else
                    {
                        hitSc.gameEnded();
                    }
                }
            }
        }
    }