mp fundementals and turn timer
This commit is contained in:
+18
-8
@@ -1,12 +1,15 @@
|
||||
using System.Collections;
|
||||
using Mirror;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class Puck : MonoBehaviour
|
||||
public class Puck : NetworkBehaviour
|
||||
{
|
||||
[HideInInspector]public Rigidbody2D rb;
|
||||
[SyncVar]
|
||||
public bool isSelected;
|
||||
public LineRenderer lineRenderer;
|
||||
[SyncVar]
|
||||
public Team team;
|
||||
public GameObject redTeamMarker;
|
||||
public GameObject blueTeamMarker;
|
||||
@@ -38,7 +41,7 @@ public class Puck : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
GameManager.OnSelectedPuckChanged += OnSelectedPuckChanged;
|
||||
GameEvents.OnSelectedPuckChanged += OnSelectedPuckChanged;
|
||||
GameManager.OnTeamChanged += OnTeamChanged;
|
||||
|
||||
GameManager.instance.RegisterPuck(this);
|
||||
@@ -46,7 +49,7 @@ public class Puck : MonoBehaviour
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
GameManager.OnSelectedPuckChanged -= OnSelectedPuckChanged;
|
||||
GameEvents.OnSelectedPuckChanged -= OnSelectedPuckChanged;
|
||||
GameManager.OnTeamChanged -= OnTeamChanged;
|
||||
|
||||
GameManager.instance.DisposePuck(this);
|
||||
@@ -56,9 +59,9 @@ public class Puck : MonoBehaviour
|
||||
{
|
||||
if (isSelected && lineRenderer != null)
|
||||
{
|
||||
Vector3 worldEnd = Camera.main.ScreenToWorldPoint(new Vector3(GameManager.instance.curPosition.x, GameManager.instance.curPosition.y, Camera.main.nearClipPlane));
|
||||
Vector3 worldEnd = Camera.main.ScreenToWorldPoint(new Vector3(NetPlayer.curPosition.x, NetPlayer.curPosition.y, Camera.main.nearClipPlane));
|
||||
|
||||
lineEnd = transform.InverseTransformPoint(worldEnd);
|
||||
lineEnd = transform.InverseTransformPoint(worldEnd);
|
||||
float clamp = GameManager.instance.puckDragClampMax;
|
||||
lineEnd = Vector2.ClampMagnitude(lineEnd, clamp);
|
||||
|
||||
@@ -69,7 +72,7 @@ public class Puck : MonoBehaviour
|
||||
}
|
||||
|
||||
selectedMarker.gameObject.SetActive(GetMarkerVisibility());
|
||||
if(GameManager.SelectedTeam == team){
|
||||
if(GameManager.instance.SelectedTeam == team){
|
||||
selectedMarker.Rotate(new Vector3(0,0,1), markerRotateSpeed * Time.deltaTime);
|
||||
bounceSinA += Time.deltaTime * markerBounceSpeed;
|
||||
float bounce = Mathf.Sin(bounceSinA) * markerBounceIntensity;
|
||||
@@ -78,9 +81,11 @@ public class Puck : MonoBehaviour
|
||||
}
|
||||
|
||||
bool GetMarkerVisibility(){
|
||||
if(GameManager.isMoving){return false;}
|
||||
if(GameManager.instance.m_isMoving){return false;}
|
||||
if(NetPlayer.localPlayer == null){return false;}
|
||||
if(NetPlayer.localPlayer.myTeam != team){return false;}
|
||||
|
||||
if(GameManager.SelectedTeam == team){
|
||||
if(GameManager.instance.SelectedTeam == team){
|
||||
if(GameManager.NoPuckSelected){
|
||||
return true;
|
||||
}else{
|
||||
@@ -95,6 +100,11 @@ public class Puck : MonoBehaviour
|
||||
{
|
||||
isSelected = puck == this;
|
||||
lineRenderer.enabled = isSelected;
|
||||
|
||||
if(NetPlayer.localPlayer == null){return;}
|
||||
if(team != NetPlayer.localPlayer.myTeam){
|
||||
lineRenderer.widthMultiplier = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void OnTeamChanged(Team team){
|
||||
|
||||
Reference in New Issue
Block a user