private void RPC_ShovePlayer(int player, Vector3 Direction) { // Debug.Log("RpcShovePlayer Called"); Shove shove = PhotonView.Find(player).GetComponent <Shove>(); shove.LaunchPlayer(MaxShoveForce, Direction); BallHandling bh = PhotonView.Find(player).GetComponent <BallHandling>(); bh.DropBall(); }
public void RPC_UpdateBH(string Code) { PlayerColor[] Players = FindObjectsOfType <PlayerColor>(); foreach (PlayerColor pc in Players) { if (pc.GetCode() == Code) { BH = pc.GetComponent <BallHandling>(); break; } } }
private void SetPlayer(GameObject spawningObject) { Debug.Log("setting up player"); PlayerColor PC = spawningObject.GetComponent <PlayerColor>(); PC.LocalPlayer = LocalPlayer; PC.SetUpPlayer1(this); HBS = spawningObject.GetComponent <hoverBoardScript>(); BH = spawningObject.GetComponent <BallHandling>(); BS = spawningObject.GetComponent <BallSteal>(); Debug.Log("finished setting up player"); }
public void RPC_ResetBall() { print("Ball Reset"); if (BH != null) { BH.ReturnHand().DetachChildren(); } Held = false; BH = null; Hand = null; transform.parent = null; Debug.Log("unParetning Ball shoot. old parent: " + transform.parent); transform.SetParent(null); }
private void RPC_CollidePlayer(GameObject player, Vector3 Direction) { Shove shove = player.GetComponent <Shove>(); if (shove.ShieldStrength / (ShieldStrength + 0.1f) < 0.8f && ShieldStrength > 0.4f) { BallHandling bh = player.GetComponent <BallHandling>(); bh.DropBall(); shove.LaunchPlayer(MaxShoveForce, Direction); } else { shove.LaunchPlayer(MaxShoveForce * 0.5f, Direction); LaunchPlayer(MaxShoveForce * 0.5f, Direction); } }
void Update() { if (IsServer) { if (!HasStarted) { m_pregameTime += Time.deltaTime; if (m_pregameTime > 30.0 * 1000.0) { HasStarted = true; } } } if (m_ballhandling == null) { m_ballhandling = GameObject.FindGameObjectWithTag("Ball")?.GetComponent <BallHandling>(); } }
public void RPC_SetSteal(bool Passing, int Target, float Force, Vector3 HandPos, int WhoThrew) { Thrown = true; ResetBall(); passedTarget = PhotonView.Find(Target).gameObject; transform.parent = null; Handle.parent = null; isInPassing = true; RB.velocity = Vector3.zero; RB.angularVelocity = Vector3.zero; float distance = (transform.position - PhotonView.Find(Target).gameObject.transform.position).magnitude; transform.LookAt(PhotonView.Find(Target).gameObject.transform); RB.AddForce(transform.up * Force, ForceMode.Impulse); Held = false; WhoTossedTheBall = PhotonView.Find(WhoThrew).gameObject; Hand = null; BH = null; }
public override void NetworkStart() { if (IsClient) { NetworkEvents.Singleton.RegisterEvent(NetworkEvent.GAME_START, this, OnStartGame); } if (IsServer) { ball = Instantiate(m_ballPrefab, new Vector3(1, 3, 1), Quaternion.identity); ball.GetComponent <NetworkedObject>().Spawn(); m_ballhandling = ball.GetComponent <BallHandling>(); ball.SetActive(false); ball.name = "Ball"; } if (IsServer) { //StartCoroutine(DEBUG_SERVER_UPDATE()); } }
public void RPC_Shoot(Vector3 power, string tag, Vector3 HandPos, int WhoThrew) { RB.mass = 5; transform.SetParent(null); Thrown = true; CanBeCaughtTimer = 0.15f; RB.useGravity = false; RB.isKinematic = false; RB.detectCollisions = true; RB.velocity = Vector3.zero; RB.angularVelocity = Vector3.zero; transform.position = HandPos; RB.AddForce(power, ForceMode.Impulse); teamTag = tag; gameObject.layer = 10; Held = false; WhoTossedTheBall = PhotonView.Find(WhoThrew).gameObject; Hand = null; BH = null; HardCol.isTrigger = false; }
private void RPC_SetPlayerBH(int Code) { GameObject pc = PhotonView.Find(Code).gameObject; Debug.Log("PC: " + pc.name); BH = pc.GetComponent <BallHandling>(); if (BH.canHold) { BH.ball = this; Hand = BH.ReturnHand(); transform.SetParent(Hand); Debug.Log("the parent is: " + transform.parent); transform.localPosition = Vector3.zero; BH.canHold = false; BH.canHoldTimer = 1; Held = true; RB.useGravity = false; RB.isKinematic = true; RB.detectCollisions = false; HardCol.isTrigger = true; } }
public void RPC_SetPass(bool Passing, int Target, float Force, Vector3 HandPos, int WhoThrew) { transform.SetParent(null); Thrown = true; CanBeCaughtTimer = 0.15f; passedTarget = PhotonView.Find(Target).gameObject; isInPassing = true; RB.useGravity = false; RB.isKinematic = false; RB.detectCollisions = true; transform.position = HandPos; Held = false; WhoTossedTheBall = PhotonView.Find(WhoThrew).gameObject; Hand = null; BH = null; HardCol.isTrigger = false; RB.velocity = Vector3.zero; RB.angularVelocity = Vector3.zero; transform.LookAt(PhotonView.Find(Target).gameObject.transform); RB.AddForce(Force * transform.forward, ForceMode.Impulse); teamTag = tag; gameObject.layer = 10; }
private void CatchThief() { gameObject.layer = 2; HardCol.isTrigger = true; Held = true; // Set who has the the ball BH = thiefTransform.GetComponent <BallHandling>(); SetBallHandling(BH.gameObject); if (BH.canHold) { Hand = BH.ReturnHand(); UpdateHandTransform(BH.gameObject); BH.SetBall(gameObject); } else { BH = null; } stolenInProgress = false; thiefTransform = null; }
// Use this for initialization void Start() { PC = GetComponent <PlayerColor>(); PV = GetComponent <PhotonView>(); player = gameObject; teamNum = player.GetComponent <PlayerColor>().TeamNum; bH = transform.GetComponent <BallHandling>(); if (ballTransform == null) { if (GameObject.FindGameObjectWithTag("Ball") != null) { ballTransform = GameObject.FindGameObjectWithTag("Ball").transform; if (ballTransform != null) { ballScript = ballTransform.GetComponent <Ball>(); } } } }
// Update is called once per frame void Update() { if (teamNum == 0) { teamNum = player.GetComponent <PlayerColor>().TeamNum; } else { if (ballTransform == null) { if (GameObject.FindGameObjectWithTag("Ball") != null) { ballTransform = GameObject.FindGameObjectWithTag("Ball").transform; } if (ballTransform != null) { if (ballScript == null) { ballScript = ballTransform.GetComponent <Ball>(); } } } if (ballScript == null) { if (FindObjectOfType <Ball>()) { ballScript = FindObjectOfType <Ball>(); } if (ballScript != null) { if (ballTransform == null) { ballTransform = ballScript.transform; } } } if (PC.LocalPlayer == PC.ParentPlayer) { if (ballTransform != null) { if (ballScript.Hand && target == null) { if (ballScript.BH != null) { //Debug.Log("BH"); if (ballScript.BH.gameObject != null) { // Debug.Log("BH.gameObject"); if (ballScript.BH.gameObject.GetComponent <PlayerColor>() != null) { // Debug.Log("BH.gameObject.GET<PlayerColor>"); if (ballScript.BH.gameObject.GetComponent <PlayerColor>().TeamNum != teamNum) { // Debug.Log("BH.gameObject.GET<PlayerColor>(). teamNum"); target = ballScript.BH.gameObject; } } } } } if (ballScript.Hand == false) { target = null; } // Debug.Log("TeamNum: " + teamNum); if (bH.ball == null) { //Debug.Log("Can steal"); if (target != null) { // Debug.Log("Target has been selected"); directionFromPlayer = target.transform.position - transform.position; distanceToTarget = directionFromPlayer.magnitude; angle = Vector3.Angle(directionFromPlayer, transform.forward); if (distanceToTarget < maxDistance && angle < stealMaxAngle) { //Debug.Log("In range and in view"); //steal if (Input.GetMouseButtonDown(0) && !isPaused) { // ballScript.DropBall(); BallHandling BH = target.GetComponent <BallHandling>(); Debug.Log("BH.tag: " + target.tag); BH.Pass(player.gameObject, ballTransform.gameObject, playerHandTransform.position, target); PV.RPC("RPC_DisableBallOfTarget", RpcTarget.AllBuffered, target.GetPhotonView().ViewID); } } } } } } } }
public void RPC_DisableBallOfTarget(int viewId) { BallHandling BH = PhotonView.Find(viewId).GetComponent <BallHandling>(); BH.ball = null; }
public void RpcSetPlayerHolding(GameObject bhObject) { BallHandling bh = bhObject.GetComponent <BallHandling>(); PlayerHolding = bh; }
private void RPC_UpdateHandTransform(int HandParent) { BallHandling bh = PhotonView.Find(HandParent).gameObject.GetComponent <BallHandling>(); Hand = bh.ReturnHand(); }
private void RPC_SetBallHandling(int bhObject) { BH = PhotonView.Find(bhObject).gameObject.GetComponent <BallHandling>(); }