public static HockeyPuck GetInstance() { if (_instance == null) { _instance = FindObjectOfType <HockeyPuck>(); } return(_instance); }
private void OnTriggerEnter(Collider other) { HockeyPuck puck = other.GetComponent <HockeyPuck>(); if (puck != null) { Director.instance.uiManager.DoScore(!isPlayerTeam); puckTimer = 1.5f; } }
private void OnTouchingPuck(HockeyPuck puck) { interactingPuck = puck; cachedPuckInteractionTime = puckInteractionTime; puck.OnPlayerInteract(this); myRigidbody.velocity = Vector3.zero; myRigidbody.detectCollisions = false; // if (isPlayerTeam) // { // Director.instance.playerTeamManager.SetControllingPlayer(this); // } }
private void Update() { if (puckTimer >= 0f) { puckTimer -= Time.unscaledDeltaTime; if (puckTimer <= 0f) { HockeyPuck.GetInstance().transform.position = Vector3.zero; HockeyPuck.GetInstance().myRigidbody.velocity = Vector3.zero; Director.instance.playerTeamManager.ResetPlayerPosition(); Director.instance.enemyTeamManager.ResetPlayerPosition(); } } }
public HockeyPlayer GetNearestPlayerToPuck() { int returnIndex = 0; float distance = -1f; for (int i = 0; i < myPlayers.Count; i++) { float d = Vector3.Distance(HockeyPuck.GetInstance().transform.position, myPlayers[i].transform.position); if (distance == -1 || distance > d) { returnIndex = i; distance = d; } } return(myPlayers[returnIndex]); }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.layer == HockeyPuck.GetPuckLayer() && cachedPuckInteractionTime <= 0f) { HockeyPuck puck = collision.gameObject.GetComponent <HockeyPuck>(); if (puck.currentControllingPlayer == null) { if (isPlayerTeam) { Director.instance.cameraManager.DoScreenShake(); } OnTouchingPuck(collision.gameObject.GetComponent <HockeyPuck>()); } else { //teamates if (puck.currentControllingPlayer.isPlayerTeam == isPlayerTeam) { if (isPlayerTeam) { Director.instance.cameraManager.DoScreenShake(); } OnTouchingPuck(collision.gameObject.GetComponent <HockeyPuck>()); } else { //win battle if (BattleForPuck(puck.currentControllingPlayer)) { Director.instance.cameraManager.DoScreenShake(); DoShrinkSequence(); puck.currentControllingPlayer.PushBack(); OnTouchingPuck(collision.gameObject.GetComponent <HockeyPuck>()); } else //lose battle { Director.instance.cameraManager.DoScreenShake(); puck.currentControllingPlayer.DoShrinkSequence(); PushBack(); } } } } }
public void OnLosingPuck() { cachedPuckInteractionTime = puckInteractionTime; interactingPuck = null; }
public void MoveToPuck() { MoveToPosition(HockeyPuck.GetInstance().transform.position); }