コード例 #1
0
        void Start()
        {
            instance       = this;
            sentResult     = false;
            timeText.text  = "X";
            speedText.text = "X";
            errorText.text = "";
            sentResult     = false;
            Time.timeScale = 1f;

            Track  track  = StartScreen.tracks [StartScreen.trackNumber];
            string script = StartScreen.script;

            isTrial = StartScreen.isTrial;
            timer   = 0;

            if (isTrial)
            {
                // generate car object
                stats = new RaceStats();
                TrialRacer racer = new TrialRacer(script, track, stats);
                racers = new Racer[] { racer };
            }
            else
            {
                int    noRacers     = StartScreen.noRacers;
                string secondscript = StartScreen.secondscript;
                racers = new Racer[noRacers * 2];
                for (int x = 0; x < noRacers * 2; x++)
                {
                    racers [x] = new Racer(x, x % 2 == 0 ? script : secondscript, track);
                }
            }
        }
コード例 #2
0
    public static bool IsOpponentInFront(RaceStats opponentCar, RaceStats thisCar)
    {
        bool opponentIsInFrontOnDifferentLap    = opponentCar.Laps > thisCar.Laps;
        bool opponentHasHigherCheckpointTarget  = opponentCar.TargetCheckpoint > thisCar.TargetCheckpoint;
        bool opponentIsCloserToCheckpointTarget = opponentCar.DistanceToTargetCheckpoint < thisCar.DistanceToTargetCheckpoint;

        bool opponentIsOnTheSameLap             = opponentCar.Laps == thisCar.Laps;
        bool opponentHasTheSameCheckpointTarget = opponentCar.Laps == thisCar.Laps;

        if (opponentIsInFrontOnDifferentLap)
        {
            return(true);
        }

        if (opponentIsOnTheSameLap)
        {
            if (opponentHasHigherCheckpointTarget)
            {
                return(true);
            }

            if (opponentHasTheSameCheckpointTarget)
            {
                if (opponentIsCloserToCheckpointTarget)
                {
                    return(true);
                }
            }
        }

        return(false);
    }
コード例 #3
0
ファイル: Goal.cs プロジェクト: elephantatwork/KabrioKiller
    public override void EnterAction(RaceStats _stats)
    {
        base.EnterAction (_stats);

        if(_stats.lastWaypoint == this){
            RaceManager.instance.CompletedLap(_stats.racerID);
            _stats.lastWaypoint = null;
        }
    }
コード例 #4
0
    private void UpdateRaceStats()
    {
        var raceStats = new RaceStats(
            _currentLap,
            _targetCheckpointNumber,
            _checkpointNodes.Count,
            _distanceToTargetCheckpoint);

        Lap = _currentLap;
        CheckpointTarget     = _targetCheckpointNumber;
        DistanceToCheckpoint = _distanceToTargetCheckpoint;

        RaceStats = raceStats;
    }
コード例 #5
0
ファイル: AppController.cs プロジェクト: AnnaDodge/RaceTiming
        public RaceStats GetRaceStats()
        {
            var raceStats = new RaceStats
            {
                NumberEntrants             = GetRunners().Count(),
                NumberMaleEntrants         = GetRunners().Count(r => r.Gender == GenderEnum.Male),
                NumberFemaleEntrants       = GetRunners().Count(r => r.Gender == GenderEnum.Female),
                NumberFinishers            = GetFinishers().Count(),
                NumberMaleFinishers        = GetFinishers().Count(f => f.Gender == GenderEnum.Male),
                NumberFemaleFinishers      = GetFinishers().Count(f => f.Gender == GenderEnum.Female),
                NumberAffiliatedEntrants   = GetRunners().Count(r => !string.IsNullOrEmpty(r.Club.Trim())),
                NumberUnaffiliatedEntrants = GetRunners().Count(r => string.IsNullOrEmpty(r.Club.Trim())),
            };

            return(raceStats);
        }
コード例 #6
0
    public virtual void EnterAction(RaceStats _stats)
    {
        if(_stats != null){

            if(_stats.currentWaypoint == this){
                _stats.lastWaypoint = _stats.currentWaypoint;
                _stats.currentWaypoint = nextWaypoint;

                _stats.waypointScore ++;

                RaceManager.instance.RecalculateRankings();

            }
        }else{
            Debug.LogWarning("No RaceStats!");
        }
    }
コード例 #7
0
        public void ShouldBeBehindOpponentWhenOpponentHasPassedCheckerPriorToFirstLapAndDriverHasNot()
        {
            var opponentDriver = new RaceStats(
                ZERO_LAPS_ELAPSED_PASSED_CHECKER_FLAG,
                TARGET_CHECKPOINT_TWO,
                TOTAL_CHECKPOINTS,
                NEAR_TARGET_CHECKPOINT);

            var testDriver = new RaceStats(
                ZERO_LAPS_ELAPSED,
                TARGET_CHECKPOINT_TWO,
                TOTAL_CHECKPOINTS,
                NEAR_TARGET_CHECKPOINT);

            bool shouldBeTrue = RaceHelperFuntions.IsOpponentInFront(opponentDriver, testDriver);

            Assert.IsTrue(shouldBeTrue);
        }
コード例 #8
0
        public void ShouldBeInfrontOfOpponentOnFirstLap()
        {
            var opponentDriver = new RaceStats(
                ZERO_LAPS_ELAPSED,
                TARGET_CHECKPOINT_TWO,
                TOTAL_CHECKPOINTS,
                NEAR_TARGET_CHECKPOINT);

            var testDriver = new RaceStats(
                ZERO_LAPS_ELAPSED,
                TARGET_CHECKPOINT_TREE,
                TOTAL_CHECKPOINTS,
                NEAR_TARGET_CHECKPOINT);

            bool shouldBeFalse = RaceHelperFuntions.IsOpponentInFront(opponentDriver, testDriver);

            Assert.IsFalse(shouldBeFalse);
        }
コード例 #9
0
        public void ShouldInCorrectOrder()
        {
            var inFirstPositionDriver = new RaceStats(
                ZERO_LAPS_ELAPSED_PASSED_CHECKER_FLAG,
                TARGET_CHECKPOINT_TREE,
                TOTAL_CHECKPOINTS,
                FIRST_POSITION_DISTANCE_TO_CHECKPOINT);

            var inSecondPositionDriver = new RaceStats(
                ZERO_LAPS_ELAPSED_PASSED_CHECKER_FLAG,
                TARGET_CHECKPOINT_TWO,
                TOTAL_CHECKPOINTS,
                SECOND_POSITION_DISTANCE_TO_CHECKPOINT);

            var inThirdPositionDriver = new RaceStats(
                ZERO_LAPS_ELAPSED_PASSED_CHECKER_FLAG,
                TARGET_CHECKPOINT_TWO,
                TOTAL_CHECKPOINTS,
                THIRD_POSITION_DISTANCE_TO_CHECKPOINT);



            bool firstShouldBeInFrontOfSecond = RaceHelperFuntions.IsOpponentInFront(inFirstPositionDriver, inSecondPositionDriver);
            bool firstShouldBeInFrontOfThird  = RaceHelperFuntions.IsOpponentInFront(inFirstPositionDriver, inThirdPositionDriver);

            bool secondShouldBeInFrontOfThrid = RaceHelperFuntions.IsOpponentInFront(inSecondPositionDriver, inThirdPositionDriver);

            bool thirdShouldBeBehindFirst  = RaceHelperFuntions.IsOpponentInFront(inFirstPositionDriver, inThirdPositionDriver);
            bool thirdShouldBeBehindSecond = RaceHelperFuntions.IsOpponentInFront(inSecondPositionDriver, inThirdPositionDriver);

            Assert.IsTrue(firstShouldBeInFrontOfSecond);
            Assert.IsTrue(firstShouldBeInFrontOfThird);
            Assert.IsTrue(secondShouldBeInFrontOfThrid);

            Assert.IsTrue(thirdShouldBeBehindFirst);
            Assert.IsTrue(thirdShouldBeBehindSecond);
        }
コード例 #10
0
 public TrialRacer(string script, Track track, RaceStats stats) : base(-1, script, track)
 {
     this.stats = stats;
 }
コード例 #11
0
        public IHttpActionResult GetRaceStatus(int id)
        {
            RaceStats vehicle = _leaderboardService.GetRaceStats(id);

            return(OkOrNotFound(vehicle));
        }