Example #1
0
    // 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);
    }
Example #2
0
    void UpdateScoreText(int score)
    {
        textPlayerScore.text = "" + score;
        CarPlayerData carPlayerData = transform.gameObject.GetComponent <CarPlayerData>();

        carPlayerData.playerScore = score;
    }
Example #3
0
 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;
 }
Example #4
0
 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();
    }
Example #6
0
    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);
        }
    }
Example #7
0
    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);
 }