Trail growth
This commit is contained in:
@@ -10,6 +10,9 @@ public class SpaceshipController : NetworkBehaviour
|
||||
public string pname;
|
||||
[SyncVar(hook=nameof(OnScoresChanged))]
|
||||
public int Scores;
|
||||
[SyncVar(hook=nameof(OnTrailTimeChanged))]
|
||||
public float trailTime;
|
||||
public float trailIncrementRate = 0.5f;
|
||||
[SyncVar]
|
||||
public bool dead;
|
||||
public Text pnameTxt;
|
||||
@@ -42,6 +45,10 @@ public class SpaceshipController : NetworkBehaviour
|
||||
Debug.Log($"Add scores { newScores - oldScores}, (total: {newScores})");
|
||||
}
|
||||
|
||||
void OnTrailTimeChanged(float oldValue, float newValue){
|
||||
trailMgr.trail.time = newValue;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (isLocalPlayer)
|
||||
@@ -71,6 +78,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
int lastClientUpdateTime = 0;
|
||||
void FixedUpdate()
|
||||
{
|
||||
pnameTxt.rectTransform.rotation = Quaternion.Euler(Vector3.zero);
|
||||
if(dead){return;}
|
||||
|
||||
if (isLocalPlayer)
|
||||
@@ -330,14 +338,18 @@ public class SpaceshipController : NetworkBehaviour
|
||||
Debug.Log($"{pname} killed {deadPlayer.pname}");
|
||||
|
||||
Scores+= 10; //TODO: Need to change Scores on kills?
|
||||
trailTime = trailMgr.trail.time+ trailIncrementRate;
|
||||
trailMgr.trail.time = trailTime;
|
||||
}
|
||||
}
|
||||
|
||||
public void Die(string killer){
|
||||
Debug.Log("You got killed by " + killer);
|
||||
Debug.Log($"Sending death signal to {pname} by {killer}");
|
||||
|
||||
//Handle Respawning
|
||||
dead=true;
|
||||
trailTime = 1;
|
||||
trailMgr.trail.time = trailTime;
|
||||
RpcDie(killer);
|
||||
FindObjectOfType<MinigameManager>().SetRespawn(gameObject);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user