コード例 #1
0
        public JsonResult OnGet(string boat)
        {
            var boat1 = JsonConvert.DeserializeObject <BoatsTidy>(boat.ToString());

            try
            {
                return(new JsonResult(RaceHelpers.PlaceOf(boat1, ManageRaceModel.Race)));
            }
            catch
            {
                return(new JsonResult(0));
            }
        }
コード例 #2
0
 public JsonResult OnGet()
 {
     return(new JsonResult(RaceHelpers.NoOfLaps(ManageRaceModel.Race)));
 }
コード例 #3
0
        /* This is called every time a ship passes the start line, r is the reference to the ship that has passed. */
        public override void OnShipTriggerStartLine(ShipRefs r)
        {
            /* If this lap has been validated or the ship hasn't done any laps yet, then we want to do some stuff. */
            if (r.LapValidated || r.CurrentLap == 0)
            {
                // invalidate the lap again
                r.LapValidated = false;

                /* If the ship has finished a lap and is not on the last lap then we want to store and display some information. */
                if (r.CurrentLap > 0 && r.CurrentLap <= Race.MaxLaps)
                {
                    if (r.IsPlayer)
                    {
                        /* Update best time */
                        if ((r.CurrentLapTime < r.BestLapTime || !r.HasBestLapTime) && !r.LoadedBestLapTime)
                        {
                            r.BestLapTime    = r.CurrentLapTime;
                            r.HasBestLapTime = true;
                        }

                        /* Perfect lap notification */
                        if (r.IsPerfectLap)
                        {
                            // this triggers an onscreen message to appear. You can provide a color or you can write it using richtext in the string.
                            BallisticEvents.Ui.CallOnTriggerMessage("PERFECT LAP", r, ScriptableHud.BnGAccent);

                            // this plays a voice, you can feed this any sound you want (if you load your own you can also use that).
                            AudioHelpers.PlayVoice(AudioHelpers.Voice_PerfectLap);
                        }

                        /* Interface sounds */
                        if (r.CurrentLap == Race.MaxLaps - 1)
                        {
                            BallisticEvents.Ui.CallOnTriggerMessage("FINAL LAP", r, ScriptableHud.BnGAccent);
                            AudioHelpers.PlayVoice(AudioHelpers.Voice_FinalLap);
                        }
                        AudioHelpers.PlayOneShot(AudioHelpers.UI_Checkpoint, AudioHelpers.E_AUDIOCHANNEL.INTERFACE, 1.0f, 1.0f);
                    }

                    // set values for current lap
                    r.LapTimes[r.CurrentLap - 1]    = r.CurrentLapTime;
                    r.PerfectLaps[r.CurrentLap - 1] = r.IsPerfectLap;
                }

                /* Tasks for when the ship has completed the race */
                if (r.CurrentLap >= Race.MaxLaps && !r.FinishedEvent && !r.Eliminated)
                {
                    r.FinishedEvent = true;

                    // calling this does some needed config to mark the ship as having finished
                    RaceHelpers.FinishRace(r);

                    // if this is a player ship then set the ship as an AI ship and then save the time
                    if (r.IsPlayer)
                    {
                        // destroy the ship camera and replace it with the finished camera
                        Object.Destroy(r.ShipCamera.GetComponent <ShipCamera>());
                        ShipFCam finishCam = r.ShipCamera.gameObject.AddComponent <ShipFCam>();
                        finishCam.r = r;

                        r.IsAi = true;
                        SaveTime(r);
                    }
                }

                /* Reset timers and states */
                // this resets the current laps time to zero
                r.CurrentLapTime = 0.0f;
                r.IsPerfectLap   = true;
                ++r.CurrentLap;
                r.PassedValidationGate = false;

                // this clears the hit weapon pads so ships can use them again
                r.ClearHitPads();
                BallisticEvents.Race.CallOnShipLapUpdate(r);

                // this calculates the time between this ship and another (depending on the ships position)
                if (r.IsPlayer)
                {
                    CalculateAndDisplayRelativeTime(r);
                }

                // give the ship a turbo
                PickupRegistry.GivePickupToShip(r, PickupRegistry.FindPickupByName("turbo"));
            }
        }