public void ArrangeGrid() { System.Random rnd = new System.Random(); List <iRacer> GridOrder = Racers.OrderBy(item => rnd.Next()).ToList <iRacer>(); goStartingLine = GameObject.Find("StartingLine"); Transform SL = goStartingLine.transform; goChequeredFlag = SL.Find("ChequeredFlag").gameObject; goChequeredFlag.SetActive(false); int Pos = 0; foreach (iRacer r in GridOrder) { int row = Pos % 3; int col = Pos / 3; Pos++; r.SetPos(SL.position + SL.rotation * (Vector3.left * (-4 + 4 * row) + Vector3.back * 6 * col + Vector3.up * 0.5f)); r.SetRot(SL.rotation); r.goRacer.GetComponent <Rigidbody>().velocity = Vector3.zero; } Road.Instance.RemoveRuts(); if (Main.Instance.Ghost && PlayerManager.Type != "Replayer") { DrivingPlayManager.Current.GhostCarManager.VehicleController.Init(); } LapStats = new List <LapStat>(); PlayerRacer = DrivingPlayManager.Current.PlayerCarManager.Racer; }
/// <summary> /// Сама проверка окончания /// </summary> /// <param name="obj"></param> private void CheckDo(object obj) { if (Racers.Count(x => x.IsFinished) == Racers.Count) { _timer.Dispose(); IsAllFinished = true; OnFinishHandler?.Invoke(); //Отсортируем по времени и выведем таблицу var list = Racers.OrderBy(x => x.ElapsedTime).ToList(); for (var i = 0; i < list.Count; i++) { list[i].Place = i + 1; FinishedRacers.Add(list[i]); } } }