コード例 #1
0
    void Update()
    {
        #region For Testing
        // - FOR TESTING - //
        // if (Input.GetKeyDown("space"))
        // {
        //  if (!inGoldenEggSequence)
        //  {
        //      inGoldenEggSequence = true;
        //  }
        //  else
        //  {
        //      inGoldenEggSequence = false;
        //      coverAlpha = 0;
        //      coverScreen.color = new Color (coverScreen.color.r, coverScreen.color.g, coverScreen.color.b, coverAlpha);
        //      anim.Play("Nothing", 0);
        //      eggAnimTimer = 0;
        //      eggAnimStarted = false;
        //      partGlow.Stop(true);
        //      partShafts.Stop(true);
        //      partSparkles.Stop(true);
        //      partPop.Stop(true);
        //      partTrail.Stop(true);
        //      partGlow.Clear(true);
        //      partShafts.Clear(true);
        //      partSparkles.Clear(true);
        //      partPop.Clear(true);
        //      partTrail.Clear(true);
        //  }
        // }

        // if (Input.GetMouseButtonDown(0))
        // {
        //  clickDown = true;
        //  Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        //  hit = Physics2D.Raycast(mousePos, Vector3.forward, 50f);
        //      if (hit)
        //      {
        //          if (hit.collider.CompareTag("GoldenEgg"))
        //          {
        //              Debug.Log("Hit Golden Egg yo.");

        //              //anim.SetTrigger("TapAnim");

        //              //goldenEggCollider.enabled = false;

        //              //inGoldenEggSequence = false;

        //              //if (anim.enabled) anim.enabled = false;
        //              //else { anim.enabled = true; }
        //          }
        //      }
        // }

        // if (Input.GetMouseButtonUp(0))
        // {
        //  clickDown = false;
        // }
        // - END TESTING - //
        #endregion
        // Wait until no other sequences are playing to start the Golden Egg sequence.
        if (waitingToStartSeq && !ClickOnEggs.inASequence)
        {
            inGoldenEggSequence = true;
            // In a sequence.
            ClickOnEggs.inASequence = true;
            waitingToStartSeq       = false;
            lvlTapManScript.ZoomOutCameraReset();
        }

        // -- START GOLDEN EGG SEQUENCE -- //
        if (inGoldenEggSequence)
        {
            seqTimer += Time.deltaTime;
            // Set the GoldenEgg as found and save
            if (!eggGoToCornerScript.eggFound)
            {
                eggGoToCornerScript.eggFound = true;
                eggGoToCornerScript.SaveEggToCorrectFile();
            }
            // Start things according to the sequence timer.
            if (seqTimer >= startCover && !coverB)
            {
                DarkenScreen();
                coverB = true;
            }
            if (seqTimer >= startText && !textB)
            {
                titleAnim.SetTrigger("PopIn");
                //textWarpScript.StartAnimatedWarp = true;
                textFadeScript.startFadeIn = true;
                //textSplineWScript.isPlaying = true;
                //textFX.Play();
                textB = true;

                //sound text pop
                audioRiddleSolvedAnimScript.riddleSolvedTextSnd();
            }
            if (seqTimer >= startFireWorks && !fireWorksB)
            {
                firework01.Play(true);
                firework02.Play(true);
                fireWorksB = true;

                //explosion sounds tests
                audioRiddleSolvedAnimScript.fireworkTrailBurstSnd();
                //audioRiddleSolvedAnimScript.fireworkTrailBurstSnd();
            }
            if (seqTimer >= startEgg && !eggB)
            {
                StartEgg();
                eggB = true;
            }

            // Fade in the Glow up to its desired value over 1 second (+= Time.deltaTime * partGlowMaxAplha & alpha's max value is 1)
            if (partGlow.isPlaying)
            {
                var main = partGlow.main;
                if (partGlowMaxAplha <= 0)
                {
                    partGlowMaxAplha = main.startColor.color.a;
                }

                if (partGlowA < partGlowMaxAplha)
                {
                    partGlowA      += Time.deltaTime * partGlowMaxAplha;
                    main.startColor = new Color(main.startColor.color.r, main.startColor.color.g, main.startColor.color.b, partGlowA);
                }
            }
            else
            {
                partGlowA = 0; partGlowMaxAplha = 0;
            }
            // Fade in the shafts over 1 second (+= Time.deltaTime & alpha's max value is 1)
            if (partShafts.isPlaying)
            {
                if (partShaftsA < 1)
                {
                    partShaftsA += Time.deltaTime;
                    var main = partShafts.main;
                    main.startColor = new Color(main.startColor.color.r, main.startColor.color.g, main.startColor.color.b, partShaftsA);
                }
            }
            else
            {
                partShaftsA = 0;
            }
            // Increase the trail's size when the egg swoops in
            if (partTrail.isPlaying)
            {
                partTrailSize += Time.deltaTime;
                var main = partTrail.main;
                main.startSizeMultiplier = partTrailSize;
            }
            else
            {
                partTrailSize = 0;
            }
        }

        // After the player taps the Golden Egg, timeline sequence
        if (inSendingToCorner)
        {
            eggToCornerTimer += Time.deltaTime;
            if (eggToCornerTimer >= coverOffTime)
            {
                LightenScreen();
            }
            if (eggToCornerTimer >= congratsOffTime)
            {
                textFadeScript.startFadeOut = true;
                foreach (FadeInOutSprite starFadeScript in starFadeScripts)
                {
                    starFadeScript.FadeOut();
                }
            }
            if (eggToCornerTimer >= eggToCornerTime)
            {
                eggGoToCornerScript.GoToCorner(); clickOnEggsScript.eggMoving += 1; clickOnEggsScript.openEggPanel = true;
            }

            if (eggToCornerTimer > coverOffTime && eggToCornerTimer > congratsOffTime && eggToCornerTimer > eggToCornerTime)
            {
                inSendingToCorner = false;
                // Sequence finished.
                ClickOnEggs.inASequence = false;
            }
        }

        // Fade in darkened screen.
        if (coverOn)
        {
            coverAlpha       += Time.deltaTime;
            coverScreen.color = new Color(coverScreen.color.r, coverScreen.color.g, coverScreen.color.b, coverAlpha);
            if (coverAlpha >= coverMaxAlpha)
            {
                coverOn = false;
            }
        }
        // Fade out darkened screen.
        if (coverOff)
        {
            coverAlpha       -= Time.deltaTime;
            coverScreen.color = new Color(coverScreen.color.r, coverScreen.color.g, coverScreen.color.b, coverAlpha);
            if (coverAlpha <= 0)
            {
                coverOff = false;
            }
        }

        // //Fade in the "Congratulations" game objects at the same time (not sure about dividing for performance, but it gives the time in seconds)
        // if (congratsTxtOn) {
        //  textFadeScript.startFadeIn = true;
        //  congratsTxtOn = false;
        //  // congratsA += Time.deltaTime / congratsFadeTime;
        //  // foreach(SpriteRenderer obj in congratsObjs) { obj.color = new Color(obj.color.r, obj.color.g, obj.color.b, congratsA); }
        //  // if (congratsA >= 1) { congratsTxtOn = false; }
        // }
        // if (congratsTxtOff) {
        //  textFadeScript.startFadeOut = true;
        //  congratsTxtOff = false;
        //  // congratsA -= Time.deltaTime / congratsFadeTime;
        //  // foreach(SpriteRenderer obj in congratsObjs) { obj.color = new Color(obj.color.r, obj.color.g, obj.color.b, congratsA); }
        //  // if (congratsA <= 0) { congratsTxtOff = false; }
        // }

        // Trying to get rid of the shaft particles in a nice way
        if (partShaftsFade)
        {
            // DOES NOT WORK BECASUE THE CHOSEN PARTICLE MATERIAL SHADER DOES NOT HAVE _COLOR OR _TINTCOLOR TO MODIFY ON THE MATERIAL INSTANCE OF THE SHAFT PARTICLE.
            // partShaftsMatA -= Time.deltaTime * partShaftsFadeTime;
            // partShaftsMat.SetColor("_TintColor",new Color(partShaftsMat.color.r, partShaftsMat.color.g, partShaftsMat.color.b, partShaftsMatA));
            // if (partShaftsMatA <= 0) { partShaftsFade = false; }

            float shaftX = partShafts.transform.localScale.x;
            float shaftZ = partShafts.transform.localScale.z;
            shaftX -= Time.deltaTime * partShaftsShrinkTime;
            shaftZ -= Time.deltaTime * partShaftsShrinkTime;
            partShafts.transform.localScale = new Vector3(shaftX, 1, shaftZ);
            if (shaftX <= 0 || shaftZ <= 0)
            {
                partShaftsFade = false;
            }
        }

        // Set the GoldenEgg scale to 4 (its original scale) in x & y.
        if (eggGoToCornerScript.eggFound && !inGoldenEggSequence && this.transform.localScale.x != 4)
        {
            this.transform.localScale += new Vector3(4 - this.transform.localScale.x, 4 - this.transform.localScale.y, 0);
        }
    }
コード例 #2
0
    void Update()
    {
        if (seqChecker != inASequence)           //delete this later plzzz ty
        {
            seqChecker = inASequence;
            //Debug.Log("Cmon just say inASequence is: " + seqChecker);
        }

        // initial delay  -> check silver eggs -> check lvl complete -> allow play
        if (iniSeq)
        {
            if (iniDelay > 0)
            {
                iniDelay -= Time.deltaTime;
            }
            else
            {
                iniSeqTimer += Time.deltaTime;
                if (iniSeqTimer > checkNewSilEggsF && !iniSilEggCheckB)
                {
                    sceneSilEggSpaScript.SpawnNewSilverEggs(); iniSilEggCheckB = true; allowTapF += checkLvlCompleteF;
                }
                if (iniSeqTimer > checkLvlCompleteF && !iniLvlCompCheckB)
                {
                    if (totalEggsFound == eggsNeeded && !levelComplete)
                    {
                        PlayLvlCompleteSeq();
                    }
                    ; iniLvlCompCheckB = true;
                }
                if (iniSeqTimer > allowTapF)
                {
                    if (!levelCompleteScript.inLvlCompSeqSetup)
                    {
                        sceneTapEnabScript.canTapEggRidPanPuz = true;
                        sceneTapEnabScript.canTapHelpBird     = true;
                        sceneTapEnabScript.canTapPauseBtn     = true;
                    }
                    iniSeq = false;
                }
            }
        }

        // -- ON CLICK/TAP -- //
        if (myInputDetector.Tapped)
        {
            mousePos   = Camera.main.ScreenToWorldPoint(myInputDetector.TapPosition);
            mousePos2D = new Vector2(mousePos.x, mousePos.y);
            hit        = Physics2D.Raycast(mousePos2D, Vector3.forward, 50f);
            if (hit)
            {
                if (sceneTapEnabScript.canTapEggRidPanPuz)                   // On regular eggs, puzzle, eggPanel
                // - Egg Tapped - //
                {
                    if (hit.collider.CompareTag("Egg"))
                    {
                        myInputDetector.cancelDoubleTap = true;
                        EggGoToCorner eggScript = hit.collider.gameObject.GetComponent <EggGoToCorner>();
                        eggScript.EggFound();
                        GlobalVariables.globVarScript.eggsFoundOrder[eggs.IndexOf(hit.collider.gameObject)] = eggsFound;
                        hit.collider.enabled = false;
                        eggsFound++;
                        eggMoving++;
                        openEggPanel = true;
                        // SFX Open Panel
                        if (!openEggPanel)
                        {
                            openEggPanel = true; audioSceneGenScript.openPanel();
                        }
                        // SFX Click Egg
                        audioSceneGenScript.ClickEggsSound(hit.collider.gameObject);
                        //Play egg  click sound
                        //audioSceneGenScript.
                        AddEggsFound();
                        eggScript.SaveEggToCorrectFile();
                    }
                    // - Go To Puzzle Scene - //
                    if (hit.collider.CompareTag("Puzzle"))
                    {
                        if (GlobalVariables.globVarScript.puzzIntroDone)
                        {
                            menuStatesScript.puzzleConfActive = true;
                            menuStatesScript.puzzleConfStates = MenuStatesManager.MenuStates.TurnOn;
                        }
                        else
                        {
                            LoadPuzzle();
                        }
                    }
                    // - Opening Egg Panel Manually - //
                    if (hit.collider.CompareTag("EggPanel"))
                    {
                        if (lockDropDownPanel)
                        {
                            openEggPanel      = false;
                            lockDropDownPanel = false;
                            //SFX Play close panel sound
                            audioSceneGenScript.closePanel();
                            return;
                        }
                        if (eggMoving <= 0)
                        {
                            openEggPanel      = true;
                            lockDropDownPanel = true;

                            //SFX Play close panel sound
                            audioSceneGenScript.openPanel();
                        }
                        if (eggMoving > 0)
                        {
                            lockDropDownPanel = true;
                        }
                    }
                }
                if (sceneTapEnabScript.canTapGoldEgg)
                {
                    // - Golden Egg Tapped - //
                    if ((hit.collider.CompareTag("GoldenEgg")))
                    {
                        EggGoToCorner eggScript = hit.collider.gameObject.GetComponent <EggGoToCorner>();
                        eggScript.EggFound();
                        hit.collider.enabled = false;
                        sceneTapEnabScript.canTapEggRidPanPuz = true;
                        sceneTapEnabScript.canTapHelpBird     = true;
                        sceneTapEnabScript.canTapPauseBtn     = true;
                        sceneTapEnabScript.canTapGoldEgg      = false;
                        //AdjustGoldenEggCount();
                        AddEggsFound();
                        eggScript.SaveEggToCorrectFile();
                        // SFX Click GOLD Egg
                        audioSceneGenScript.goldEggSound();
                        audioSceneGenScript.goldEggShimmerStopSound();
                    }
                }
            }
        }
        // -- Egg Panel Movement -- //
        if (eggMoving <= 0 && !lockDropDownPanel)
        {
            // - Hide Egg Panel - //
            if (timer <= basePanelOpenTime && openEggPanel)
            {
                timer += Time.deltaTime;
            }
            else
            {
                openEggPanel = false; timer = 0f;
            }

            eggPanel.transform.position         = Vector3.MoveTowards(eggPanel.transform.position, eggPanelHidden.transform.position, Time.deltaTime * panelMoveSpeed);
            dropDrowArrow.transform.eulerAngles = new Vector3(dropDrowArrow.transform.eulerAngles.x, dropDrowArrow.transform.eulerAngles.y, 180);
        }
        if (eggMoving > 0 || openEggPanel)
        {
            // - Show Egg Panel - //
            eggPanel.transform.position         = Vector3.MoveTowards(eggPanel.transform.position, eggPanelShown.transform.position, Time.deltaTime * panelMoveSpeed);
            dropDrowArrow.transform.eulerAngles = new Vector3(dropDrowArrow.transform.eulerAngles.x, dropDrowArrow.transform.eulerAngles.y, 0);
        }
    }