Пример #1
0
    void EndGame()
    {
        print("it's over");

        //Transition to results with necessary values
        int winners   = 0;
        int highscore = 0;

        bool[] didwin = new bool[4];

        for (int i = 0; i < 4; i++)
        {
            didwin[i] = false;
        }

        for (int i = 0; i < 4; i++)
        {
            if (PlayerScores[i] > highscore)
            {
                highscore = PlayerScores[i];
            }
        }

        for (int i = 0; i < 4; i++)
        {
            if (PlayerScores[i] == highscore)
            {
                didwin[i] = true;
                winners++;
            }
        }

        int winnercount = winners;

        ScoreKeeper.winMessage = "";
        for (int i = 0; i < 4; i++)
        {
            if (winners > 1)
            {
                if (didwin[i])
                {
                    if (winnercount > 1)
                    {
                        if (winnercount == winners)
                        {
                            ScoreKeeper.winMessage += "PLAYERS " + (i + 1).ToString() + ", ";
                        }
                        else
                        {
                            ScoreKeeper.winMessage += (i + 1).ToString() + ", ";
                        }
                        winnercount--;
                    }
                    else
                    {
                        ScoreKeeper.winMessage += (i + 1).ToString() + " WIN!";
                    }
                }
            }
            else
            {
                if (didwin[i])
                {
                    ScoreKeeper.winMessage = "PLAYER " + (i + 1).ToString() + " WINS!";
                }
            }
        }

        for (int i = 0; i < 4; i++)
        {
            if (didwin[i])
            {
                if (winners == 4)
                {
                    ScoreKeeper.roundScores[i + 1] = 5;
                }
                if (winners == 3)
                {
                    ScoreKeeper.roundScores[i + 1] = 10;
                }
                if (winners == 2)
                {
                    ScoreKeeper.roundScores[i + 1] = 15;
                }
                if (winners == 1)
                {
                    ScoreKeeper.roundScores[i + 1] = 20;
                }
            }
        }

        ScoreKeeper.DisplayResultsScreen();
    }
Пример #2
0
    private IEnumerator EndGameWaitRoutine(float waitAmount)
    {
        yield return(new WaitForSeconds(waitAmount));

        ScoreKeeper.DisplayResultsScreen();
    }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        readygoDelay++;

        if (tutorialOn)
        {
            tutorialScreenTime = Time.timeSinceLevelLoad;
            if (tutorialScreenTime > minTutTime)
            {
                tutorialButton.interactable = true;
            }
            if (tutorialButton.interactable && (Input.GetAxisRaw("Player1_buttonStart") > 0.2f || Input.GetAxisRaw("Player2_buttonStart") > 0.2f || Input.GetAxisRaw("Player3_buttonStart") > 0.2f || Input.GetAxisRaw("Player4_buttonStart") > 0.2f))
            {
                closeTutorial();
            }
        }
        for (int i = 0; i < numPlayers; i++)
        {
            //check for victory!
            if (!tutorialOn && roundScores [i] >= victoryAmount)
            {
                for (int j = 0; j < 4; j++)
                {
                    ScoreKeeper.roundScores [j + 1] = 0;
                }
                ScoreKeeper.roundScores [i + 1] = 10;
                ScoreKeeper.winMessage          = "PLAYER " + (i + 1).ToString() + " WINS!";
                ScoreKeeper.DisplayResultsScreen();
            }


            scoreTexts[i].text = roundScores[i].ToString();

            if (!drinking[i] && !resetDrink[i])
            {
                //--if not chugging, and the initiate button is pressed swap sprite to chugging one and initialize bar
                //--display waiting sprite (hand out to catch sliding beer)

                if (drinkUp[i])
                {
                    if (Input.GetAxisRaw("Player" + (i + 1) + "_buttonA") > .6f)
                    {
                        //--need to make an animation controller
                        //--this is where the slam would happen
                        activateReset(i);
                    }
                    else if (tutorialOn && drinkLevel[i] <= 0)
                    {
                        tutResetDelay[i]++;
                        if (tutResetDelay[i] >= 60)
                        {
                            activateReset(i);
                            tutResetDelay[i] = 0;
                        }
                    }
                }
                else
                {
                    if (!tutorialOn && readygoDelay < 200)
                    {
                        if (readygoDelay < 125)
                        {
                            readyBanner.GetComponent <SpriteRenderer>().enabled = true;
                        }
                        else if (readygoDelay < 185)
                        {
                            readyBanner.GetComponent <SpriteRenderer>().enabled = false;
                            goBanner.GetComponent <SpriteRenderer>().enabled    = true;
                        }
                        else
                        {
                            readyBanner.GetComponent <SpriteRenderer>().enabled = false;
                            goBanner.GetComponent <SpriteRenderer>().enabled    = false;
                        }
                        return;
                    }

                    //--*hums "raise your glass"*
                    //--pick it up to the drink position
                    drinking[i] = true;
                    drinkUp[i]  = true;
                    beers[i].GetComponent <SpriteRenderer>().sprite = beerAnimation[1];
                    Vector3 pos = beers[i].transform.position;
                    pos.y += 2;
                    beers[i].transform.position = pos;
                }
            }
            else if (drinking[i])
            {
                updateBarandBeer(i);
            }
            else if (resetDrink[i])
            {
                //Half second period to refill glass before allowing more chugging
                //--need a pour sound
                //--need a slam sound
                //--need a barkeep back and front sprite
                //--need to animate walking to and from bar
                //--need to make flashing slam A button
                animateReset(i);
            }
        }
    }
Пример #4
0
    // Update is called once per frame
    void Update()
    {
        //rotate the paddles appropriately!
        float lAnglePercent = (float)lCool / (float)paddleFrames;          //this is what percentage of a full paddle we've done!
        float rAnglePercent = (float)rCool / (float)paddleFrames;

        if (lAnglePercent < .2f && leftPrompt.sprite == aButton)
        {
            lAnglePercent = 1f - (5f * lAnglePercent);
        }
        if (rAnglePercent < .2f && rightPrompt.sprite == aButton)
        {
            rAnglePercent = 1f - (5f * rAnglePercent);
        }

        if (leftPrompt.sprite == bButton)
        {
            lAnglePercent = 1f - lAnglePercent;             //paddling backwards!
        }
        if (rightPrompt.sprite == bButton)
        {
            rAnglePercent = 1f - rAnglePercent;
        }

        float angleToRotateLeftPaddle  = lAnglePercent * 90f;
        float angleToRotateRightPaddle = rAnglePercent * 90f;

        Vector3 paddle1Angle = paddle1.transform.localEulerAngles;

        paddle1Angle.z = 80f - angleToRotateLeftPaddle;
        //print (paddle1Angle.z);
        paddle1.transform.localEulerAngles = paddle1Angle;

        Vector3 paddle2Angle = paddle2.transform.localEulerAngles;

        paddle2Angle.z = -80f + angleToRotateRightPaddle;
        //print (paddle1Angle.z);
        paddle2.transform.localEulerAngles = paddle2Angle;


        tutorialActive = TutorialGORef.GetComponent <RaftingTutorial>().tutorial.enabled;
        if (tutorialActive)
        {
            return;
        }


        //allow paddling!
        if ((Input.GetKeyDown(left) || Input.GetKeyDown(keyLeft) || Input.GetKeyDown(backLeft) || Input.GetKeyDown(keyBackLeft)) && lCool <= 0)
        {
            lCool = cooldownFrames;
            forwardPaddleSound.Play();
        }
        if (Input.GetKeyDown(right) || Input.GetKeyDown(keyRight) || Input.GetKeyDown(backRight) || Input.GetKeyDown(keyBackRight) && rCool <= 0)
        {
            rCool = cooldownFrames;
            forwardPaddleSound.Play();
            //rightPaddle.AddForce (rightPaddle.transform.up * paddleForce);
        }



        if (winnerExists && Time.time - victoryTime > victoryDelay)
        {
            ScoreKeeper.DisplayResultsScreen();              //leave the minigame
        }

        //Time to deal with powerups
        if (power1 == PowerUp.PowerUpType.None)
        {
            powerImage1.enabled = false;
        }
        if (power2 == PowerUp.PowerUpType.None)
        {
            powerImage2.enabled = false;
        }


        //Handle Cannon powerup
        if (power1 == PowerUp.PowerUpType.Cannon)
        {
            powerImage1.enabled = true;
            powerImage1.sprite  = cannonSprite;
            cannon1.SetActive(true);
            //rotate the cannon to match the control stick
            float controlStickAngle = Mathf.Rad2Deg * Mathf.Atan2(Input.GetAxis(leftAxisH), Input.GetAxis(leftAxisV));
            cannon1.transform.eulerAngles = new Vector3(0, 0, 180f - controlStickAngle);
            if (Mathf.Abs(Input.GetAxis(leftAxisH)) + Mathf.Abs(Input.GetAxis(leftAxisV)) < .1f)
            {
                cannon1.transform.localEulerAngles = new Vector3(0, 0, 180);
                //cannon1line.SetActive(false);
            }
            else
            {
                //cannon1line.SetActive(true);
            }
        }
        else
        {
            cannon1.SetActive(false);
        }

        if (power2 == PowerUp.PowerUpType.Cannon)
        {
            powerImage2.enabled = true;
            powerImage2.sprite  = cannonSprite;
            cannon2.SetActive(true);
            //rotate the cannon to match the control stick
            float controlStickAngle = Mathf.Rad2Deg * Mathf.Atan2(Input.GetAxis(rightAxisH), Input.GetAxis(rightAxisV));
            cannon2.transform.eulerAngles = new Vector3(0, 0, 180f - controlStickAngle);
            if (Mathf.Abs(Input.GetAxis(rightAxisH)) + Mathf.Abs(Input.GetAxis(rightAxisV)) < .2f)
            {
                cannon2.transform.eulerAngles = this.transform.eulerAngles;
                //cannon2line.SetActive(false);
            }
            else
            {
                //cannon2line.SetActive(true);
            }
        }
        else
        {
            cannon2.SetActive(false);
        }



        //allow player to fire powerups
        if (Input.GetKeyDown(fireLeft) || Input.GetKeyDown(keyFireLeft) ||
            Input.GetAxis(fireTriggerLeft) >= 0.9f)
        {
            if (power1 == PowerUp.PowerUpType.Cannon)
            {
                power1 = PowerUp.PowerUpType.None;
                cannon1.GetComponent <Cannon> ().fire();
                cannon1line.SetActive(false);
                cannonFire.Play();
            }
            if (power1 == PowerUp.PowerUpType.Grapple)
            {
                power1 = PowerUp.PowerUpType.None;
                grapple1.GetComponent <Grapple> ().fire();
                grapple1line.SetActive(false);
                grappleLaunch.Play();
            }
            if (power1 == PowerUp.PowerUpType.Sail)
            {
                power1 = PowerUp.PowerUpType.None;
                sailPole1.SetActive(false);
                StartCoroutine(Boost(sail1, sailPole1));
            }
        }
        if (Input.GetKeyDown(fireRight) || Input.GetKeyDown(keyFireRight) ||
            Input.GetAxis(fireTriggerRight) >= 0.9f)
        {
            if (power2 == PowerUp.PowerUpType.Cannon)
            {
                power2 = PowerUp.PowerUpType.None;
                cannon2.GetComponent <Cannon> ().fire();
                cannon2line.SetActive(false);
                cannonFire.Play();
            }
            if (power2 == PowerUp.PowerUpType.Grapple)
            {
                power2 = PowerUp.PowerUpType.None;
                grapple2.GetComponent <Grapple> ().fire();
                grapple2line.SetActive(false);
                grappleLaunch.Play();
            }
            if (power2 == PowerUp.PowerUpType.Sail)
            {
                power2 = PowerUp.PowerUpType.None;
                sailPole2.SetActive(false);
                StartCoroutine(Boost(sail2, sailPole2));
            }
        }

        //Handle Grapple powerup stuff
        if (power1 == PowerUp.PowerUpType.Grapple)
        {
            grapple1.SetActive(true);
            powerImage1.enabled = true;
            powerImage1.sprite  = grappleSprite;
            currentScaling      = .1f;        //for some reason having an active grapple makes you go way faster, so I manually nerfed it this way
            //rotate the grapple to match the control stick
            float controlStickAngle = Mathf.Rad2Deg * Mathf.Atan2(Input.GetAxis(leftAxisH), Input.GetAxis(leftAxisV));
            grapple1.transform.eulerAngles = new Vector3(0, 0, 180f - controlStickAngle);
            if (Mathf.Abs(Input.GetAxis(leftAxisH)) + Mathf.Abs(Input.GetAxis(leftAxisV)) < .1f)
            {
                grapple1.transform.localEulerAngles = new Vector3(0, 0, 180);
            }
        }
        else
        {
            currentScaling = 1f;             //un-nerf water speed
        }

        if (power2 == PowerUp.PowerUpType.Grapple)
        {
            grapple2.SetActive(true);
            powerImage2.enabled = true;
            powerImage2.sprite  = grappleSprite;
            currentScaling      = .1f;        //for some reason grapple makes you flow way faster, so I had to manually nerf the current
            //rotate the cannon to match the control stick
            float controlStickAngle = Mathf.Rad2Deg * Mathf.Atan2(Input.GetAxis(rightAxisH), Input.GetAxis(rightAxisV));
            grapple2.transform.eulerAngles = new Vector3(0, 0, 180f - controlStickAngle);
            if (Mathf.Abs(Input.GetAxis(rightAxisH)) + Mathf.Abs(Input.GetAxis(rightAxisV)) < .1f)
            {
                grapple2.transform.localEulerAngles = new Vector3(0, 0, 0);
            }
        }
        else
        {
            currentScaling = 1f;             //un-nerf when you don't have a grapple anymore
        }

        //Handle Sail powerup stuff
        if (power1 == PowerUp.PowerUpType.Sail)
        {
            powerImage1.enabled = true;
            powerImage1.sprite  = sailSprite;
            sailPole1.SetActive(true);
        }

        if (power2 == PowerUp.PowerUpType.Sail)
        {
            powerImage2.enabled = true;
            powerImage2.sprite  = sailSprite;
            sailPole2.SetActive(true);
        }
    }