Exemplo n.º 1
0
    // Update is called once per frame
    private void Update()
    {
        BaseUpdate();

        closedness += Time.deltaTime * closingPower;

        closedness = Mathf.Clamp(closedness, 0, maxClosedness);

        if (
            CommandsStartedThisFrame.ContainsKey(Command.Fire) ||
            CommandsStartedThisFrame.ContainsKey(Command.Down) ||
            CommandsStartedThisFrame.ContainsKey(Command.Up)
            )
        {
            closedness -= eyeOpeningPowerPerKeystroke;
        }

        topLid.transform.position =
            Vector3.Lerp
                (topLid.openPosition.position,
                topLid.closedPosition.position,
                closedness / maxClosedness);

        botLid.transform.position =
            Vector3.Lerp
                (botLid.openPosition.position,
                botLid.closedPosition.position,
                closedness / maxClosedness);

        if (closedness < 0f)
        {
            LoadRegularScene();
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// Kick off something the player needs to interact with
    /// </summary>
    /// <param name="myHurdleIndex"></param>
    /// <param name="myHurdle"></param>
    /// <returns></returns>
    private IEnumerator KickOffHurdle(int myHurdleIndex, Hurdle myHurdle, List <float> times, Transform start, Transform end, Transform disappearSpot = null, bool isFish = false)
    {
        bool madeYellow = false;

        float visualStartTime = times[myHurdleIndex] - beatRadiusVisualHint;
        float visualEndTime   = times[myHurdleIndex] + beatRadiusVisualHint;

        float inputStartTime = times[myHurdleIndex] - beatInputLead;
        float inputEndTime   = times[myHurdleIndex] + beatInputLag;

        bool inputSuccess = false;
        bool missed       = false;

        Command correctCode = Command.Fire;

        if (myHurdle.CorrectCommand == "up")
        {
            correctCode = Command.Up;
        }
        else if (myHurdle.CorrectCommand == "down")
        {
            correctCode = Command.Down;
        }
        else
        {
            Debug.LogError("unhandled direction!");
        }

        while (currentTime < visualEndTime)
        {
            if (currentTime > inputStartTime && !madeYellow)
            {
                madeYellow = true;
                myHurdle.MakeReady();
            }

            // success
            if (currentTime > inputStartTime && currentTime < inputEndTime &&
                (CommandsStartedThisFrame.ContainsKey(correctCode)))
            {
                success.Play();
                inputSuccess = true;

                myHurdle.MakeCorrect();

                // shout a success shout
                int successShoutIndex = Random.Range(0, successShouts.Count);
                if (lastSuccessShout == successShoutIndex)
                {
                    successShoutIndex++;
                    if (successShoutIndex >= successShouts.Count)
                    {
                        successShoutIndex = 0;
                    }
                }
                outputText.text  = successShouts[successShoutIndex];
                lastSuccessShout = successShoutIndex;
            }

            // miss..
            else if (currentTime > inputEndTime && !inputSuccess && !missed)
            {
                missed = true;

                // todo toss the hurdle
                myHurdle.MakeWrong();

                // shout a miss shout
                int missShoutIndex = Random.Range(0, missShouts.Count);
                if (lastMissShout == missShoutIndex)
                {
                    missShoutIndex++;
                    if (missShoutIndex >= missShouts.Count)
                    {
                        missShoutIndex = 0;
                    }
                }
                outputText.text = missShouts[missShoutIndex];
                lastMissShout   = missShoutIndex;

                numMistakes++;
                mistake.Play();
            }

            float hurdleProgress = (currentTime - visualStartTime) / (visualEndTime - visualStartTime);
            myHurdle.transform.position = Vector3.Lerp(start.position, end.position, hurdleProgress);

            // disappear when you move past the spot and you're successful
            if (disappearSpot != null && myHurdle.GetState() == Hurdle.HurdleState.Correct)
            {
                // objects moving right
                if (disappearSpot.position.x > start.position.x)
                {
                    if (myHurdle.transform.position.x > disappearSpot.position.x)
                    {
                        // disappear
                        myHurdle.SetVisible(false);
                    }
                }
                else
                {
                    if (myHurdle.transform.position.x < disappearSpot.position.x)
                    {
                        // disappear
                        myHurdle.SetVisible(false);
                    }
                }
            }

            yield return(0);
        }

        if (numMistakes > allowedMistakes)
        {
            StartCoroutine(Failure());
        }

        yield return(new WaitForSeconds(0.2f));

        Destroy(myHurdle.gameObject);
    }
Exemplo n.º 3
0
    /// <summary>
    /// Kick off something the player needs to interact with
    /// </summary>
    /// <param name="myHurdleIndex"></param>
    /// <param name="myHurdle"></param>
    /// <returns></returns>
    private IEnumerator KickOffHurdle(int myHurdleIndex, Hurdle myHurdle, List <float> times, Transform start, Transform end, bool isFish)
    {
        Hurdle  mirrorHurdle = Instantiate(myHurdle.gameObject).GetComponent <Hurdle>();
        Vector3 mirrorStart  = new Vector3(-start.position.x, start.position.y, start.position.z);
        Vector3 mirrorEnd    = new Vector3(-end.position.x, end.position.y, end.position.z);

        mirrorHurdle.transform.localScale = new Vector3(-1, 1, 1);

        bool madeYellow = false;

        float visualStartTime = times[myHurdleIndex] - beatRadiusVisualHint;
        float visualEndTime   = times[myHurdleIndex] + beatRadiusVisualHint;

        float inputStartTime = times[myHurdleIndex] - beatInputLead;
        float inputEndTime   = times[myHurdleIndex] + beatInputLag;

        bool inputSuccess = false;
        bool missed       = false;

        Command correctCode = Command.Fire;

        if (myHurdle.CorrectCommand == "up")
        {
            correctCode = Command.Up;
        }
        else if (myHurdle.CorrectCommand == "down")
        {
            correctCode = Command.Down;
        }
        else
        {
            Debug.LogError("unhandled code!");
        }

        while (currentTime < visualEndTime)
        {
            if (currentTime > inputStartTime && !madeYellow)
            {
                madeYellow = true;
                myHurdle.MakeReady();
                mirrorHurdle.MakeReady();
            }

            // success
            if (currentTime > inputStartTime && currentTime < inputEndTime &&
                (CommandsStartedThisFrame.ContainsKey(correctCode)))
            {
                success.Play();
                inputSuccess = true;

                // make the hurdle green
                if (isFish)
                {
                    // they do the fish flippy thing instead of just disappearing, flying into moxie's mouth
                    ((FishHurdle)myHurdle).SetGoSpot(fishEatSpot.transform.position);
                    ((FishHurdle)myHurdle).MakeCorrect();
                    ((FishHurdle)mirrorHurdle).SetGoSpot(fishEatSpot.transform.position);
                    ((FishHurdle)mirrorHurdle).MakeCorrect();
                }
                else
                {
                    myHurdle.MakeCorrect();
                    mirrorHurdle.MakeCorrect();
                }

                // shout a success shout
                int successShoutIndex = Random.Range(0, successShouts.Count);
                if (lastSuccessShout == successShoutIndex)
                {
                    successShoutIndex++;
                    if (successShoutIndex >= successShouts.Count)
                    {
                        successShoutIndex = 0;
                    }
                }
                outputText.text  = successShouts[successShoutIndex];
                lastSuccessShout = successShoutIndex;
            }

            // miss..
            else if (currentTime > inputEndTime && !inputSuccess && !missed)
            {
                missed = true;

                myHurdle.MakeWrong();
                mirrorHurdle.MakeWrong();

                // shout a miss shout
                int missShoutIndex = Random.Range(0, missShouts.Count);
                if (lastMissShout == missShoutIndex)
                {
                    missShoutIndex++;
                    if (missShoutIndex >= missShouts.Count)
                    {
                        missShoutIndex = 0;
                    }
                }
                outputText.text = missShouts[missShoutIndex];
                lastMissShout   = missShoutIndex;

                numMistakes++;
                mistake.Play();
            }


            if (isFish && myHurdle.GetState() == Hurdle.HurdleState.Correct)
            {
                // if you're a fish and you're correctly answered, do nothing
            }
            else
            {
                // move the hurdle
                float hurdleProgress = (currentTime - visualStartTime) / (visualEndTime - visualStartTime);
                myHurdle.transform.position     = Vector3.Lerp(start.position, end.position, hurdleProgress);
                mirrorHurdle.transform.position = Vector3.Lerp(mirrorStart, mirrorEnd, hurdleProgress);
            }

            yield return(0);
        }

        if (numMistakes > allowedMistakes)
        {
            StartCoroutine(Failure());
        }

        yield return(new WaitForSeconds(0.2f));

        Destroy(myHurdle.gameObject);
        Destroy(mirrorHurdle.gameObject);
    }
Exemplo n.º 4
0
    /// <summary>
    /// Kick off something the player needs to interact with
    /// </summary>
    /// <param name="myHurdleIndex"></param>
    /// <param name="myHurdle"></param>
    /// <returns></returns>
    private IEnumerator KickOffHurdle(int myHurdleIndex, PunchingBag myHurdle, List <float> times, Transform start, Transform end)
    {
        bool madeYellow = false;

        float visualStartTime = times[myHurdleIndex] - beatRadiusVisualHint;
        float visualEndTime   = times[myHurdleIndex] + beatRadiusVisualHint;

        float inputStartTime = times[myHurdleIndex] - beatInputLead;
        float inputEndTime   = times[myHurdleIndex] + beatInputLag;

        bool inputSuccess = false;
        bool missed       = false;

        Command correctCode = Command.Fire;

        if (myHurdle.CorrectCommand == "up")
        {
            correctCode = Command.Up;
        }
        else if (myHurdle.CorrectCommand == "down")
        {
            correctCode = Command.Down;
        }
        else
        {
            Debug.LogError("unhandled code!");
        }

        while (currentTime < visualEndTime)
        {
            if (currentTime > inputStartTime && !madeYellow)
            {
                madeYellow = true;
                myHurdle.MakeReady();
            }

            // success
            if (currentTime > inputStartTime && currentTime < inputEndTime &&
                (CommandsStartedThisFrame.ContainsKey(correctCode)))
            {
                success.Play();
                inputSuccess = true;

                // make the hurdle green
                myHurdle.MakeCorrect();
                myHurdle.TakeDamage();

                // shout a success shout
                int successShoutIndex = Random.Range(0, successShouts.Count);
                if (lastSuccessShout == successShoutIndex)
                {
                    successShoutIndex++;
                    if (successShoutIndex >= successShouts.Count)
                    {
                        successShoutIndex = 0;
                    }
                }
                outputText.text  = successShouts[successShoutIndex];
                lastSuccessShout = successShoutIndex;
            }

            // miss..
            else if (currentTime > inputEndTime && !inputSuccess && !missed)
            {
                missed = true;

                // todo toss the hurdle
                myHurdle.MakeWrong();

                // shout a miss shout
                int missShoutIndex = Random.Range(0, missShouts.Count);
                if (lastMissShout == missShoutIndex)
                {
                    missShoutIndex++;
                    if (missShoutIndex >= missShouts.Count)
                    {
                        missShoutIndex = 0;
                    }
                }
                outputText.text = missShouts[missShoutIndex];
                lastMissShout   = missShoutIndex;

                numMistakes++;
                mistake.Play();
            }

            // the punching bag hurdle moves up and then down, it's at the end in middle time

            float hurdleProgress = (currentTime - visualStartTime) / (visualEndTime - visualStartTime);

            float prog = hurdleCurve.Evaluate(hurdleProgress);

            myHurdle.transform.position = Vector3.Lerp(start.position, end.position, prog);

            yield return(0);
        }

        if (numMistakes > allowedMistakes)
        {
            StartCoroutine(Failure());
        }

        yield return(new WaitForSeconds(0.2f));
    }
Exemplo n.º 5
0
    public void Update()
    {
        BaseUpdate();

        if (shantyIsSaiyan)
        {
            saiyanElapsed += Time.deltaTime;
            if (saiyanElapsed > gunDestroyTime &&
                laser.IsTouching(SternCollider))
            {
                //todo explosions
                LoadNextScene();
            }


            if (CommandsHeldThisFrame.ContainsKey(Command.Up))
            {
                UpdateFloat(MoveDirection.Up);
            }
            else if (CommandsHeldThisFrame.ContainsKey(Command.Down))
            {
                UpdateFloat(MoveDirection.Down);
            }

            if (CommandsHeldThisFrame.ContainsKey(Command.Left))
            {
                UpdateFloat(MoveDirection.Left);
            }
            else if (CommandsHeldThisFrame.ContainsKey(Command.Right))
            {
                UpdateFloat(MoveDirection.Right);
            }
        }
        else
        {
            invincibilityCooldownElapsed += Time.deltaTime;
            timeSinceLastJump            += Time.deltaTime;
            timeSinceLastBite            += Time.deltaTime;

            if (!shantyIsSaiyan && timeSinceLastBite > biteTime)
            {
                ActivateShantyAnimation(ShantyAnimStateM70.Idle);
            }


            bool didSomething = false;

            if (!shantyIsSaiyan && BiteCollider.IsTouching(SternCollider) && timeSinceLastBite > biteCooldown)
            {
                // play shanty's bite animation and bounce backwards
                BiteStern();
            }

            if (CommandsStartedThisFrame.ContainsKey(Command.Up) || CommandsStartedThisFrame.ContainsKey(Command.Fire))
            {
                didSomething = true;

                AttemptJump();
            }

            if (CommandsHeldThisFrame.ContainsKey(Command.Left))
            {
                didSomething = true;
                UpdateMoveLeftRight(MoveDirection.Left);
            }
            else if (CommandsHeldThisFrame.ContainsKey(Command.Right))
            {
                didSomething = true;
                UpdateMoveLeftRight(MoveDirection.Right);
            }
        }
    }
Exemplo n.º 6
0
    public void Update()
    {
        timeSinceLastJump += Time.deltaTime;

        BaseUpdate();


        if (struckSand && !escaped)
        {
            wiggleElapsed += Time.deltaTime;
            if (
                CommandsStartedThisFrame.ContainsKey(Command.Fire)
                ||
                CommandsStartedThisFrame.ContainsKey(Command.Left)
                ||
                CommandsStartedThisFrame.ContainsKey(Command.Right)
                ||
                CommandsStartedThisFrame.ContainsKey(Command.Up)
                ||
                CommandsStartedThisFrame.ContainsKey(Command.Down)
                )
            {
                if (wiggleElapsed > WiggleCooldown)
                {
                    //wiggle
                    numWiggles++;
                    SandHitSFX.Play();
                    wiggleElapsed = 0f;
                    this.transform.localPosition += WiggleOffset;
                    if (numWiggles > EscapeWiggles)
                    {
                        Container.gameObject.SetActive(true);
                        BonkedMoxie.SetActive(false);
                        Sandpile.SetActive(false);

                        AlbaStarsAnimation.gameObject.SetActive(false);

                        currentlyFlippingOut = true;

                        PopOutSfx.Play();
                        escaped = true;
                        this.myRigidbody.gravityScale = 1;

                        // enable this in a little bit
                        ActivateAnimation(MaoxunAnimState23.Idle);
                        StartCoroutine(EnableMyColliderInABit());

                        myRigidbody.AddForce(EscapeForce);
                        myRigidbody.AddTorque(EscapeTorque);
                    }
                }
            }
        }
        else if (currentlyFlippingOut)
        {
            // wait until you land then give back control to the player and right moxie
            if (myCollider.IsTouching(GroundCollider))
            {
                // right her
                this.transform.rotation = InitialRotation;
                SetMobile(true);
                currentlyFlippingOut = false;
            }
        }
        else
        {
            scareElapsed += Time.deltaTime;

            if (!doneScared && scareElapsed > ScareTime)
            {
                doneScared = true;
                ScareSprite.gameObject.SetActive(false);
                this.Container.gameObject.SetActive(true);
                this.myRigidbody.gravityScale = 1f;
            }

            // if ur airborne and hit space, jumpkick
            if (doneScared && !currentlyFlippingOut)
            {
                var didSomething = false;

                if (this.myCollider.IsTouching(GroundCollider))
                {
                    airborne = false;
                    kicking  = false;
                }
                else
                {
                    didSomething = true;
                    airborne     = true;
                }

                if (kicking &&
                    footCollider.IsTouching(island.TreeCollider) &&
                    island.IsReady()
                    )
                {
                    int nutIndex = island.ShakeTree();
                    if (nutIndex > 5 && !released)
                    {
                        released = true;
                        Ball.Release();
                        //LoadNextScene();
                    }
                    //kicking = false;
                    // push her away a little bit
                }

                if (!part3 && part2 && kicking && footCollider.IsTouching(YesCollider))
                {
                    StartYes();
                }
                else if (!part3 && part2 && kicking && footCollider.IsTouching(NoCollider))
                {
                    StartNo();
                }

                if (CommandsStartedThisFrame.ContainsKey(Command.Up) || CommandsStartedThisFrame.ContainsKey(Command.Fire))
                {
                    didSomething = true;

                    if (airborne)
                    {
                        AttemptKick();
                    }
                    else
                    {
                        AttemptJump();
                    }
                }

                if (CommandsHeldThisFrame.ContainsKey(Command.Left))
                {
                    didSomething = true;
                    UpdateMoveLeftRight(MoveDirection.Left);
                }
                else if (CommandsHeldThisFrame.ContainsKey(Command.Right))
                {
                    didSomething = true;
                    UpdateMoveLeftRight(MoveDirection.Right);
                }

                if (!didSomething)
                {
                    UpdateIdle();
                }
            }
        }
    }
Exemplo n.º 7
0
    public void Update()
    {
        timeSinceLastJump += Time.deltaTime;

        BaseUpdate();

        if (!struckSand &&
            this.myCollider.IsTouching(SandCollider))
        {
            struckSand = true;
            SandHitSFX.Play();
            this.myRigidbody.gravityScale   = 0;
            this.myRigidbody.freezeRotation = true;
            this.myRigidbody.velocity       = Vector2.zero;
        }

        if (!toldBoatToDrown && struckSand)
        {
            if (Stern.IsSternGone())
            {
                toldBoatToDrown = true;
                MyBoatM20.Drown();
            }
        }

        if (struckSand && !escaped)
        {
            wiggleElapsed += Time.deltaTime;
            if (
                CommandsStartedThisFrame.ContainsKey(Command.Fire)
                ||
                CommandsStartedThisFrame.ContainsKey(Command.Left)
                ||
                CommandsStartedThisFrame.ContainsKey(Command.Right)
                ||
                CommandsStartedThisFrame.ContainsKey(Command.Up)
                ||
                CommandsStartedThisFrame.ContainsKey(Command.Down)
                )
            {
                if (wiggleElapsed > WiggleCooldown)
                {
                    //wiggle
                    numWiggles++;
                    SandHitSFX.Play();
                    wiggleElapsed = 0f;
                    this.transform.localPosition += WiggleOffset;
                    if (numWiggles > EscapeWiggles)
                    {
                        PopOutSfx.Play();
                        escaped = true;

                        this.myRigidbody.gravityScale   = 1;
                        this.myRigidbody.freezeRotation = false;
                        myRigidbody.AddForce(EscapeForce);
                        myRigidbody.AddTorque(EscapeTorque);
                    }
                }
            }
        }

        if (escaped)
        {
            escapeElapsed += Time.deltaTime;
            if (!landed && escapeElapsed > EscapeCooldown && myCollider.IsTouching(ColliderStand))
            {
                landed = true;
                SandHitSFX.Play();
                this.myRigidbody.gravityScale   = 0;
                this.myRigidbody.freezeRotation = true;
                this.myRigidbody.velocity       = Vector2.zero;

                Nut.gravityScale = 1f;

                HeadCollider.enabled = true;
            }
        }

        if (landed && !struck)
        {
            if (NutCollider.IsTouching(HeadCollider))
            {
                struck = true;
                Nut.AddForce(NutForce);
                Nut.AddTorque(NutTorque);
                NutSFX.Play();
                this.transform.localPosition += CoconutStruckOffset;
                this.myRigidbody.velocity     = Vector2.zero;
                LoadNextScene(NextSceneTime);
            }
        }

        var didSomething = false;

        if (!didSomething)
        {
            UpdateIdle();
        }
    }
Exemplo n.º 8
0
    /// <summary>
    /// Kick off something the player needs to interact with
    /// </summary>
    /// <param name="myHurdleIndex"></param>
    /// <param name="myHurdle"></param>
    /// <returns></returns>
    protected IEnumerator KickOffHurdle(int myHurdleIndex, Hurdle myHurdle)
    {
        bool madeYellow = false;

        float visualStartTime = beatTimes[myHurdleIndex] - beatRadiusVisualHint;
        float visualEndTime   = beatTimes[myHurdleIndex] + beatRadiusVisualHint;

        float inputStartTime = beatTimes[myHurdleIndex] - beatInputLead;
        float inputEndTime   = beatTimes[myHurdleIndex] + beatInputLag;

        bool inputSuccess = false;
        bool missed       = false;

        while (currentTime < visualEndTime)
        {
            if (currentTime > inputStartTime && !madeYellow)
            {
                madeYellow = true;
                myHurdle.MakeReady();
            }

            // success
            if (currentTime > inputStartTime && currentTime < inputEndTime &&
                CommandsStartedThisFrame.ContainsKey(Command.Up))
            {
                success.Play();
                inputSuccess = true;

                // make the hurdle green
                myHurdle.MakeCorrect();

                // shout a success shout
                int successShoutIndex = Random.Range(0, successShouts.Count);
                if (lastSuccessShout == successShoutIndex)
                {
                    successShoutIndex++;
                    if (successShoutIndex >= successShouts.Count)
                    {
                        successShoutIndex = 0;
                    }
                }
                outputText.text  = successShouts[successShoutIndex];
                lastSuccessShout = successShoutIndex;
            }

            // miss..
            else if (currentTime > inputEndTime && !inputSuccess && !missed)
            {
                missed = true;

                // todo toss the hurdle
                myHurdle.MakeWrong();

                // shout a miss shout
                int missShoutIndex = Random.Range(0, missShouts.Count);
                if (lastMissShout == missShoutIndex)
                {
                    missShoutIndex++;
                    if (missShoutIndex >= missShouts.Count)
                    {
                        missShoutIndex = 0;
                    }
                }
                outputText.text = missShouts[missShoutIndex];
                lastMissShout   = missShoutIndex;

                numMistakes++;
                mistake.Play();
            }

            float hurdleProgress = (currentTime - visualStartTime) / (visualEndTime - visualStartTime);
            myHurdle.transform.position = Vector3.Lerp(rightEdge.transform.position, leftEdge.transform.position, hurdleProgress);

            yield return(0);
        }

        if (numMistakes > allowedMistakes)
        {
            StartCoroutine(Failure());
        }

        yield return(new WaitForSeconds(0.2f));

        Destroy(myHurdle.gameObject);
    }