Example #1
0
    IEnumerator ShowHiScores()
    {
        int   _startRank = _rank < 11 ? 1 : _rank - 4;
        float pos        = trPanel.rect.min.y;
        float ScrHght    = trPanel.rect.height;
        int   ScrWdth    = Screen.width;
        float ScoreHght  = ScrHght / 11;

        yield return(new WaitForSecondsRealtime(2));

        for (int n = 9; n >= 0; n--)
        {
            int           r         = n + _startRank;
            GameObject    goHiScore = (GameObject)GameObject.Instantiate(HiScorePrefab, trPanel);
            RectTransform tr        = goHiScore.GetComponent <RectTransform>();
            tr.anchorMin        = new Vector3(0.5f, 0);
            tr.anchorMax        = new Vector3(0.5f, 0);
            tr.anchoredPosition = Vector2.zero;
            tr.localPosition    = new Vector3(pos, pos, 0);
            tr.localScale       = Vector3.one;
            tr.sizeDelta        = new Vector2(0, ScoreHght);
            tr.Find("txtRank").GetComponent <Text>().text = r.ToString();
            if (r <= L.Count)
            {
                tr.Find("txtName").GetComponent <Text>().text = L[r - 1].Name;
                tr.Find("txtTime").GetComponent <Text>().text = GenFunc.HMS(L[r - 1].SegTime * Road.Instance.Segments.Count);
            }
            if (r != _rank)
            {
                tr.Find("ipName").gameObject.SetActive(false);
            }
            else
            {
                _myTransform = tr;
                InputField ip = tr.Find("ipName").GetComponent <InputField>();
                ip.onEndEdit.AddListener(delegate { NameOnEndEdit(ip.text); });
                StartCoroutine(ShowBling(_trTrophy, tr.localPosition));
            }
            pos += ScoreHght;
            yield return(new WaitForSecondsRealtime(0.3f));
        }
        yield break;
    }
Example #2
0
    public void Update()
    {
        if (Paused)
        {
            return;
        }
        if (!Started)
        {
            return;
        }
        if (txtTimer == null)
        {
            txtTimer = GameObject.Find("txtTimer").GetComponent <Text>();
        }
        foreach (Racer r in Racers)
        {
            r.GetProgrss();
        }
        float TotalTime = Time.time - StartTime;

        txtTimer.text = GenFunc.HMS(TotalTime);
    }
Example #3
0
 void ShowBestLap()
 {
     _bestLap = Race.Current.LapStats.OrderBy(ls => ls.time).First();
     transform.Find("txtBestLapTime").GetComponent <Text>().text = GenFunc.HMS(_bestLap.time);
 }
Example #4
0
    private void OnSegmentEnter()
    {
        if (Progrss < 20 && PrevProgrss > RoadSegCount - 20)
        {
            Lap++;
            if (!isMachine)
            {
                float LapTime = Time.time - LapStartTime;
                _Race.LapStats.Add(new LapStat {
                    stFr = LapStartFrame, finFr = Recrdng.Current.FrameCount - 1, time = LapTime
                });
                if (Game.current.BestLap == null || LapTime < Game.current.BestLap)
                {
                    int LapScore = RoadSegCount / 50;
                    Race.Current.LapRecBonus += LapScore;
                    StringBuilder s = new StringBuilder("New Lap Record\n$");
                    s.Append(LapScore.ToString());
                    Main.Instance.PopupMsg(s.ToString(), Color.green);
                    Game.current.BestLap = LapTime;
                    SaveLoadModel.SaveSavedGames();
                }
                if (Main.Instance.Ghost)
                {
                    GhostController gc = (GhostController)DrivingPlayManager.Current.GhostCarManager.VehicleController;
                    gc.Frame = 0;
                }
                LapStartTime  = Time.time;
                LapStartFrame = Recrdng.Current.FrameCount;
            }
        }
        TotProgrss = Progrss + (Lap - 1) * RoadSegCount;

        //keeping the AI cars close to the player
        if (isMachine)
        {
            foreach (Racer pr in PlayerOpposition)
            {
                if (_hogBonusTime == 0 && pr.TotProgrss > TotProgrss + 20 || pr.TotProgrss < TotProgrss - 301)
                //Player is too far ahead or really far behind
                {
                    JumpTo(pr);
                }
                if (pr.TotProgrss < TotProgrss - 10)
                //AICar is a bit ahead of the player slow down
                {
                    _vehicleController.motorForce = _defaultMotorForce * 0.4f;
                }
                else
                {
                    _vehicleController.motorForce = _defaultMotorForce;
                }
            }
        }
        else
        {
            if (txtLap == null)
            {
                txtLap = GameObject.Find("txtLap").GetComponent <Text>();
            }
            float LapTime = Time.time - LapStartTime;
            if (LapTime > 10)
            {
                txtLap.text = GenFunc.HMS(LapTime);
            }
            if (Lap == Race.Current.Laps + 1)
            {
                Race.Current.Finish();
            }
            if (TotProgrss > RoadSegCount * Race.Current.Laps - 100 && ChFlag == false)
            {
                Transform trStart = GameObject.Find("StartingLine").transform;
                foreach (ParticleSystem ps in trStart.GetComponentsInChildren <ParticleSystem>())
                {
                    ps.Play();
                }
                Race.Current.ShowChequeredFlag(true);
                CamSelector.Instance.SelectCam("Simple");
                ChFlag = true;
            }
        }
    }