Exemple #1
0
    private int CalculatePlayerPositionInRace(Opponent player)
    {
        if (CurrentRace == null)
        {
            return(0);
        }

        int output           = 1;
        int playerCheckpoint = player.CheckpointsPassed;
        int beforeYou        = Opponents.Count(tuple => {
            if (tuple == player)
            {
                return(false);
            }
            return(tuple.CheckpointsPassed > playerCheckpoint);
        });

        output += beforeYou;
        var samePosAsYou = Opponents.Where(tuple => tuple.CheckpointsPassed == playerCheckpoint && tuple != player);

        output +=
            samePosAsYou.Count(
                tuple =>
                (CurrentRace.Checkpoints[playerCheckpoint].Subtract(tuple.Client.position)).Length() <
                (CurrentRace.Checkpoints[playerCheckpoint].Subtract(player.Client.position)).Length());
        return(output);
    }