Example #1
0
    public void gameSet()
    {
        updatePlayers(ref player1, ref player2);
        col1.GetComponent<CountUp>().displayValue(player1.totalOne);
        col2.GetComponent<CountUp>().displayValue(player1.totalTwo);
        col3.GetComponent<CountUp>().displayValue(player1.totalThree);
        col4.GetComponent<CountUp>().displayValue(player1.totalFour);

        row1.GetComponent<CountUp>().displayValue(player2.totalOne);
        row2.GetComponent<CountUp>().displayValue(player2.totalTwo);
        row3.GetComponent<CountUp>().displayValue(player2.totalThree);
        row4.GetComponent<CountUp>().displayValue(player2.totalFour);
        if (player1.grandTotal > player2.grandTotal)
            Winner.GetComponent<CountUp>().displayValue("Player 1 Wins");
        else if (player1.grandTotal == player2.grandTotal)
            Winner.GetComponent<CountUp>().displayValue("Tie!");
        else
            Winner.GetComponent<CountUp>().displayValue("Player 2 Wins!");

    }
Example #2
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (rs == 21)
        {
            TextMesh t = (TextMesh)Winner.GetComponent(typeof(TextMesh)); t.text = "Winner    Right";
        }
        else if (ls == 21)
        {
            TextMesh t = (TextMesh)Winner.GetComponent(typeof(TextMesh)); t.text = "Winner    Left";
        }
        else
        {
            if (col.gameObject.name == "RacketLeft")
            {
                float y = hitFactor(transform.position,
                                    col.transform.position, col.collider.bounds.size.y);


                ls++;
                TextMesh t = (TextMesh)LeftScore.GetComponent(typeof(TextMesh));
                t.text = "Left Score : " + ls.ToString();
                Vector2 dir = new Vector2(1, y).normalized; GetComponent <Rigidbody2D>().velocity = dir * speed;
            }
            if (col.gameObject.name == "RacketRight")
            {
                float y = hitFactor(transform.position,
                                    col.transform.position, col.collider.bounds.size.y);


                rs++;
                TextMesh t = (TextMesh)RightScore.GetComponent(typeof(TextMesh));
                t.text = "Right Score : " + rs.ToString();
                Vector2 dir = new Vector2(-1, y).normalized;
                GetComponent <Rigidbody2D>().velocity = dir * speed;
            }
        }
    }
Example #3
0
    private IEnumerator DisplayWinnerScreen()
    {
        yield return(null);

        MenuMan.gameEnd = true;

        string     strWinnerName = string.Empty;
        GameObject Winner;
        GameObject Loser;
        Vector3    prevVelocity;
        Vector3    prevAngularVelocity;

        SoundMan.cutMusic();
        SoundMan.playbwahbwahBWAH();

        if (mintPlayer1Score > mintPlayer2Score)
        {
            // Player 1 won
            strWinnerName = mstrPlayer1CharName;
            Winner        = Player1;
            Loser         = Player2;
        }
        else
        {
            // Player 2 won
            strWinnerName = mstrPlayer2CharName;
            Winner        = Player2;
            Loser         = Player1;
        }

        //Save these for l8r
        prevVelocity        = Loser.GetComponent <Rigidbody>().velocity;
        prevAngularVelocity = Loser.GetComponent <Rigidbody>().angularVelocity;

        Loser.GetComponent <Rigidbody>().velocity        = new Vector3(0, 0, 0);
        Loser.GetComponent <Rigidbody>().angularVelocity = new Vector3(0, 0, 0);

        Camera.main.GetComponent <CombatCam>().lookAt(new Vector3(Loser.transform.position.x + Random.Range(-10, 10), Loser.transform.position.y + Random.Range(0, 10), Loser.transform.position.z + Random.Range(-10, 10)));
        Camera.main.GetComponent <CombatCam>().setTarget(Loser);

        yield return(new WaitForSeconds(0.3f));

        Camera.main.GetComponent <CombatCam>().lookAt(new Vector3(Loser.transform.position.x + Random.Range(-10, 10), Loser.transform.position.y + Random.Range(0, 10), Loser.transform.position.z + Random.Range(-10, 10)));

        yield return(new WaitForSeconds(0.3f));

        Camera.main.GetComponent <CombatCam>().lookAt(new Vector3(Loser.transform.position.x + Random.Range(-10, 10), Loser.transform.position.y + Random.Range(0, 10), Loser.transform.position.z + Random.Range(-10, 10)));

        //Explode into distance
        Loser.GetComponent <Rigidbody>().velocity        = new Vector3(prevVelocity.x * 3, (prevVelocity.y + 1) * 50, prevVelocity.z * 3);
        Loser.GetComponent <Rigidbody>().angularVelocity = prevAngularVelocity * 2;

        yield return(new WaitForSeconds(2));

        Camera.main.GetComponent <CombatCam>().setTarget(Winner);

        SoundMan.playResultsMusic();

        Player1.GetComponent <Rigidbody>().velocity        = new Vector3(0, 0, 0);
        Player2.GetComponent <Rigidbody>().velocity        = new Vector3(0, 0, 0);
        Player1.GetComponent <Rigidbody>().angularVelocity = new Vector3(0, 0, 0);
        Player2.GetComponent <Rigidbody>().angularVelocity = new Vector3(0, 0, 0);

        Player1.transform.position = new Vector3(-2, 0.5f, 0);
        Player2.transform.position = new Vector3(2, 0.5f, 0);

        Camera.main.GetComponent <CombatCam>().resetCamera();

        Camera.main.GetComponent <CombatCam>().lookAt(new Vector3(0, 3, 0));

        SoundMan.playCharacterName(strWinnerName);
        yield return(new WaitForSeconds(1));

        SoundMan.playWins();

        yield return(new WaitForSeconds(3));

        // TODO Enable winner screen
        Player1.GetComponent <PlayerControls>().CurrentAction = PlayerControls.ActionType.Dead;
        Player2.GetComponent <PlayerControls>().CurrentAction = PlayerControls.ActionType.Dead;

        // Yeet the loser
        Loser.transform.position = new Vector3(50, 50, 50);

        Camera.main.transform.position = new Vector3(100, 100, 90);
        Camera.main.transform.LookAt(new Vector3(100, 100, 100));
        Winner.transform.position = new Vector3(100, 100, 100);
        Winner.GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0);
        Winner.GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0);
        Winner.GetComponent <PlayerControls>().DisableGravity();
        AnimationController.StartAnimation(strWinnerName, 1);

        EndGameOptionsController.gameObject.SetActive(true);
        EndGameOptionsController.EnableOptionsPanel(Player1Image.sprite, Player2Image.sprite);
        //QuitToTitle();
        //ReturnToCharacterSelect();
        //PlayAgain();

        yield return(null);
    }