private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { RespawnComponent rc = other.GetComponent <RespawnComponent>(); if (!rc) { return; } if (rc.checkpointNum == checkpointNum - 1) { rc.checkpointCount++; rc.checkpointNum = checkpointNum; rc.respawnPoint = transform; } else if (rc.checkpointNum == checkpointNum) { rc.checkpointNum = checkpointNum; rc.respawnPoint = transform; } } }
public SceneManager() : base() { RC = new RespawnComponent(this); this.AddComponent(RC); GetAllLevels(); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { PlayerScore ps = other.GetComponent <PlayerScore>(); RespawnComponent rc = other.GetComponent <RespawnComponent>(); if (!ps) { return; } if (rc.checkpointCount >= raceCheckpoints) { if (ps.laps < raceLaps - 1) { ps.laps++; rc.checkpointCount = 0; rc.checkpointNum = 0; return; } ps.score += rewardScore; rewardScore--; RandomAllRacePlayerScore rarPS = other.GetComponent <RandomAllRacePlayerScore>(); if (rarPS) { rarPS.UpdatePlayerScore(); } Instantiate(ps.finishParticles, other.gameObject.transform.position, other.gameObject.transform.rotation); Destroy(other.gameObject); playersLeft--; } } }