Пример #1
0
	void OnCollisionEnter(Collision col)
	{
		if (col.gameObject.tag == "Ball")
		{
			ballInfo = col.gameObject.GetComponent<DodgeBallBehaviour>();
			if (netInfo.teamNumber != ballInfo.b_ThrownByTeam && ballInfo.b_ThrownByTeam != 0 && killable) {
				Cmd_TakeDamage (gameObject);
			}
		}
	}
Пример #2
0
    private void SpawnBall1Player()
    {
        // Pick a random spot on the far side of the battle room to spawn a new ball
        Vector3            spawnPos        = new Vector3(Random.Range(-2.5f, 2.5f), Random.Range(-2.5f, 2.5f), Random.Range(-2.5f, 2.5f));
        GameObject         newAsteroid     = Instantiate(asteroid, spawnPos, Quaternion.identity) as GameObject;
        DodgeBallBehaviour newBallBehavior = newAsteroid.GetComponent <DodgeBallBehaviour>();
        GameObject         psystem         = Instantiate(partSystem, newAsteroid.transform.position, Quaternion.identity) as GameObject;

        newBallBehavior.initForce = initForce;
        newBallBehavior.psystem   = psystem.GetComponent <ParticleSystem>();
        newAsteroid.GetComponent <Rigidbody>().AddForce(initForce * (p1pos.transform.position + new Vector3(0f, 0.25f, 0f) - spawnPos).normalized);
    }
Пример #3
0
    // Update is called once per frame
    void Update ()
	{



//DEBUG//
//Debug.DrawRay (head.transform.position, head.transform.forward, Color.green, rayDistance);

		//Is the player looking at a ball?
		if (Physics.SphereCast (c_Head.transform.position, rayRadius, c_Head.transform.forward, out hit, rayDistance)) {
			if (!isLocalPlayer) {
				return;
			}
			if (hit.collider.GetComponent<DodgeBallBehaviour> () != null) {
//				print ("Ball!");
				//Pick up the ball
				if (CrossPlatformInputManager.GetButton ("Fire1") && !holdingBall && !playerInfo.c_Dead) {
					if (!hit.collider.GetComponent<DodgeBallBehaviour> ().b_PickedUp) {
					currentBall = hit.collider.gameObject;
					Cmd_GetPickedUp (currentBall , gameObject);
					holdingBall = true;
//					Cmd_toggleFake (fakeBall);

					}

				}
			}
		}
//--THROW BALL--//
		if (Input.GetButton ("Fire2")) {
			if (!isLocalPlayer) {
				return;
			}
			if (!holdingBall) {
				anim.SetBool ("isThrowing", false);
				return;
			}
			if (!throwing && holdingBall) {
				throwing = true;
				anim.SetBool ("isThrowing", true);
			} 
			holdingBall = false;
			StartCoroutine(StartThrow(0.5F));
			Cmd_Shoot (currentBall, tossForce);
//			brb.AddForce(head.transform.forward * tossForce);
			currentBall = null;
			ballScript = null;

		}
		if (Input.GetButtonUp ("Fire2") && throwing) {
			throwing = false;
			anim.SetBool ("isThrowing", false);
		}

	}
Пример #4
0
	void Cmd_GetPickedUp(GameObject bs, GameObject go){
		ballScript = bs.GetComponent<DodgeBallBehaviour> ();
		ballScript.Rpc_GetPickedUp (go);
	}
Пример #5
0
	public void Cmd_Shoot(GameObject bs, float force){
		ballScript = bs.GetComponent<DodgeBallBehaviour> ();
		ballScript.Rpc_Shoot (force);
	}