// Use this for initialization void Start() { if (!isLocalPlayer) { return; } // Possible way to get the playerScoreScript for the rest of the code GameObject carPlayerObject = this.gameObject; playerScoreScript = carPlayerObject.GetComponent <CarPlayerData>(); GameObject mapObject = GameObject.Find("GameMap"); GameObject lapStuffObject = mapObject.transform.Find("LapStuff").gameObject; GameObject lapTextNumberPositionObject = lapStuffObject.transform.Find("LapsDrivenNumberTextPosition").gameObject; GameObject lapTextNumberObject = new GameObject("LapsDrivenNumberText"); lapTextNumberObject.transform.parent = lapStuffObject.transform; lapTextNumberObject.transform.position = lapTextNumberPositionObject.transform.position; lapTextNumberObject.transform.rotation = lapTextNumberPositionObject.transform.rotation; lapTextNumberObject.AddComponent <MeshRenderer>(); lapTextNumberObject.AddComponent <TextMesh>(); lapTextNumber = lapTextNumberObject.GetComponent <TextMesh>(); lapTextNumber.fontSize = 40; lapTextNumber.text = "" + 0; Instantiate(lapTextNumberObject); }
void UpdateScoreText(int score) { textPlayerScore.text = "" + score; CarPlayerData carPlayerData = transform.gameObject.GetComponent <CarPlayerData>(); carPlayerData.playerScore = score; }
public void Init(CarPlayerData Data) { this.CurrentCarType = Data.CurrentCarType; this.HP = Data.HP; this.CurrentHP = this.HP; this.Speed = Data.Speed; this.SpeedSides = Data.SpeedSides; this.CurveControl = Data.CurveControl; }
public void Init(PlayerConfig Data, int IndexStruct) { this.CarData = Data.ListPlayerData.Find(element => (int)element.CurrentCarType == IndexStruct); this.PowerChargeBySec = Data.PowerChargeBySec; this.PowerChargeMax = Data.PowerChargeMax; this.BegPowerCharge = Data.BegPowerCharge; this.UltimeEnable = false; this.ExploEnable = false; this._curveControl = this.CarData.CurveControl[0]; ApplyUpgrade(Data, (CarType)IndexStruct); this.CarData.CurrentHP = this.CarData.HP; }
private void ShowEndingMenu(CarPlayerData data) { endingMenu.SetActive(true); Debug.Log("Game ended. Player won = " + data.gameWon); endingMenuScoreText.text = "" + data.playerScore; endingMenuWinLossText.text = data.gameWon ? "won!" : "lost!"; audioSource.volume = 0.75f; audioSource.clip = data.gameWon ? endingVictoryMusic : endingLoserMusic; audioSource.Play(); }
void RpcDestroyOnDeath(GameObject objectToDestroy) { Destroy(objectToDestroy); if (isLocalPlayer) { GameObject startAndEndScreenManager = GameObject.Find("StartAndEndScreenManager"); var startAndEndScreenManagerScript = startAndEndScreenManager.GetComponent <StartAndEndScreenManagerScript>(); GameObject playerCarObject = transform.gameObject; CarPlayerData carPlayerData = playerCarObject.GetComponent <CarPlayerData>(); GetComponent <LapManager>().RemoveLapsDrivenNumberText(); startAndEndScreenManagerScript.EndGame(carPlayerData); } }
void OnTriggerEnter(Collider other) { GameObject carPlayerObject = null; try { GameObject collidersObject = other.gameObject.transform.parent.gameObject; carPlayerObject = collidersObject.transform.parent.gameObject; } catch { return; } if (carPlayerObject != null && carPlayerObject.tag == "Player") { Debug.Log("Pickup collected!"); CarPlayerData playerScoreScript = carPlayerObject.GetComponent <CarPlayerData>(); playerScoreScript.OnPickupPickedUp(scoreAddition); NetworkServer.Destroy(gameObject); } }
public void EndGame(CarPlayerData data) { DisconnectGame(); ShowEndingMenu(data); }