Exemplo n.º 1
0
        private void HandleLayOffs()
        {
            Player        finalPlayer          = CurrentPlayer == CurrentGame.PlayerOne ? CurrentGame.PlayerTwo : CurrentGame.PlayerOne;
            PlayerResults currentPlayerResults = _playerResults.First(i => i.Player == CurrentPlayer);

            finalPlayer.RequestLayOffs(this, currentPlayerResults.Melds);
        }
Exemplo n.º 2
0
        public bool AddChallengeResult(int playerId, ChallengeResult challengeResult)
        {
            if (DateTime.Now > CurrentSeason.EndDate)
            {
                Globals.Logger.Debug(
                    $"{challengeResult.ToLongString()} was not added because the season is over. Now: {DateTime.Now}, EndDate: {CurrentSeason.EndDate}");
                return(false);
            }


            Challenge foundChallenge = CurrentSeason.Challenges.FirstOrDefault
                                       (
                c => c.TrackName == challengeResult.TrackLocationAndVariant &&
                c.CarName == challengeResult.CarName
                                       );

            if (foundChallenge == null)
            {
                Globals.Logger.Debug(
                    $"{challengeResult.ToLongString()} was not added because the challenge wasn't found in the current season {CurrentSeason}.");
                return(false);
            }

            PlayerResult foundPlayerResult = PlayerResults.FirstOrDefault(p => p.ChallengeId == foundChallenge.Id && p.PlayerId == playerId);

            if (foundPlayerResult == null)
            {
                PlayerResults.Add(new PlayerResult
                {
                    PlayerId    = playerId,
                    ChallengeId = foundChallenge.Id,
                    FastestLap  = challengeResult.LastValidLapTime
                });

                Globals.Logger.Debug(
                    $"PlayerId: {playerId}, {challengeResult.ToLongString()} was added to DataView.PlayerResults.");
            }
            else
            {
                if (challengeResult.LastValidLapTime < foundPlayerResult.FastestLap)
                {
                    foundPlayerResult.FastestLap = challengeResult.LastValidLapTime;

                    Globals.Logger.Debug(
                        $"PlayerId: {playerId}, {challengeResult.ToLongString()}. DataView foundPlayerResult was successfully updated.");
                }
                else
                {
                    Globals.Logger.Debug(
                        $"PlayerId: {playerId}, {challengeResult.ToLongString()} was not added because it's not a best time. Fastest lap: {foundPlayerResult.FastestLap}, last lap: {challengeResult.LastValidLapTime}.");
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 3
0
    private void GoToResults()
    {
        AudioManager.StopAll();
        onLevelClosed?.Invoke();

        // Share results
        m_playerStats.ScoreTotal += m_playerStats.ScoreLast;
        m_playerResults           = new PlayerResults(m_playerStats);
        onShareResults?.Invoke(m_playerResults);
        m_playerStats.ScoreLast = 0;
    }
Exemplo n.º 4
0
    private void Awake()
    {
        Time.timeScale = 1;
        allParametrs   = JsonUtility.FromJson <AllParametrs>(PlayerPrefs.GetString("allParametrs"));

        playerMove    = parentHeroes.GetComponent <PlayerMove>();
        playerResults = parentHeroes.GetComponent <PlayerResults>();

        GameObject hero = Instantiate(heroes[allParametrs.NamesAllHeroes.IndexOf(allParametrs.selectedHero)], parentHeroes.transform);

        PlayerEffects heroEffects = hero.GetComponent <PlayerEffects>();

        playerMove.groundCheck            = heroEffects.groundCheck;
        playerMove.particleBam            = heroEffects.particleBam;
        playerResults.spriteBones         = heroEffects.spriteBones;
        parentHeroes.transform.localScale = hero.GetComponent <PlayerState>().scale;
    }
Exemplo n.º 5
0
 async Task ExecuteLoadResultsCommand()
 {
     IsRefreshing = true;
     try
     {
         PlayerResults.Clear();
         await LoadPlayerResults();
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
     }
     finally
     {
         IsRefreshing = false;
     }
 }
Exemplo n.º 6
0
        public void RemovePlayerByName(string playerName)
        {
            var playerToRemove = Players.FirstOrDefault(p => p.Name.Equals(playerName, StringComparison.Ordinal));

            if (playerToRemove == null)
            {
                return;
            }

            Players.Remove(playerToRemove);

            foreach (var playerResult in PlayerResults.Where(p => p.PlayerId == playerToRemove.Id).ToList())
            {
                PlayerResults.Remove(playerResult);
            }

            foreach (var handicap in Handicaps.Where(p => p.PlayerId == playerToRemove.Id).ToList())
            {
                Handicaps.Remove(handicap);
            }

            PlayerRemoved?.Invoke();
        }
Exemplo n.º 7
0
 public MatchScoreGroup(Entities.Match match, PlayerResults score)
 {
     Match = match;
     Score = score;
 }
Exemplo n.º 8
0
    private void Update()
    {
        switch (myTextgameObject.tag)
        {
        case "Torso":
            ourComponent.text = PlayerResults.getBodyScore().ToString();
            break;

        case "Feet":
            ourComponent.text = PlayerResults.getLegsScore().ToString();
            break;

        case "Hands":
            ourComponent.text = PlayerResults.getHandsScore().ToString();
            break;

        case "Abs":
            ourComponent.text = PlayerResults.getAbsScore().ToString();
            break;

        case "Back":
            ourComponent.text = PlayerResults.getBackScore().ToString();
            break;

        case "Chest":
            ourComponent.text = PlayerResults.getChestScore().ToString();
            break;

        case "Biceps":
            ourComponent.text = PlayerResults.getBicepsScore().ToString();
            break;

        case "Triceps":
            ourComponent.text = PlayerResults.getTricepsScore().ToString();
            break;

        case "Forehand":
            ourComponent.text = PlayerResults.getForearmsScore().ToString();
            break;

        case "Shoulders":
            ourComponent.text = PlayerResults.getShoulderScore().ToString();
            break;

        case "Buttocks":
            ourComponent.text = PlayerResults.getButtocksScore().ToString();
            break;

        case "Thighs":
            ourComponent.text = PlayerResults.getThighsScore().ToString();
            break;

        case "Calfs":
            ourComponent.text = PlayerResults.getCalfScore().ToString();
            break;

        default:
            ourComponent.text = PlayerResults.getOverall().ToString();
            break;
        }
    }
Exemplo n.º 9
0
 private void UpdateResults(PlayerResults playerResults)
 {
     m_playerResults = playerResults;
     StartCoroutine(DisplayLastRoundStats());
 }
Exemplo n.º 10
0
 void Awake()
 {
     playerResults = gameObject.AddComponent <PlayerResults> ();
 }