Beispiel #1
0
    void Start()
    {
        playerControllerScript = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
        opponentScript         = GameObject.FindGameObjectWithTag("Enemy").GetComponent <OpponentBehavior>();
        gMScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameManager>();

        rb       = gameObject.GetComponent <Rigidbody>();
        meshRend = gameObject.GetComponent <MeshRenderer>();
    }
Beispiel #2
0
    void OnCollisionEnter(Collision col)
    {
        if (col.gameObject.tag == "Player")
        {
            if (ballState == BallFSM.PickupReady)
            {
                if (!playerControllerScript.isHolding && !GameManager.isDodgeballGameWon)
                {
                    //print("bingo");
                    gameObject.transform.parent = col.gameObject.transform;
                    //playerControllerScript = col.gameObject.GetComponent<PlayerController>();
                    playerControllerScript.isHolding     = true;
                    playerControllerScript.projectileObj = this.gameObject;
                    playerControllerScript.ballTrans     = this.transform;
                    ballState = BallFSM.Held;
                }
            }
            else if (ballState == BallFSM.Thrown)
            {
                playerControllerScript.playerHealth -= 1;
                //Opponent Score + 1
                gMScript.opponentScore += 1;
            }
        }

        if (col.gameObject.tag == "Enemy")
        {
            if (ballState == BallFSM.PickupReady)
            {
                if (!opponentScript.isHoldingBall)
                {
                    //print("bingo");
                    gameObject.transform.parent     = col.gameObject.transform;
                    gameObject.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
                    opponentScript = col.gameObject.GetComponent <OpponentBehavior>();
                    opponentScript.isHoldingBall = true;
                    opponentScript.projectileObj = this.gameObject;
                    ballState = BallFSM.HeldOpponent;
                }
            }
            else if (ballState == BallFSM.Thrown)
            {
                opponentScript.OpponentHealth -= 1;
                //Player Score + 1
                gMScript.playerScore += 1;
            }
        }
    }