Trail growth

This commit is contained in:
Sewmina
2022-06-30 03:18:02 +05:30
parent 253710d137
commit f18f2562eb
14 changed files with 7159 additions and 7158 deletions

View File

@@ -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);
}