コード例 #1
0
    private void UpdateText(List <LevelScore> scores)
    {
        ImageYellowStraw.SetActive(true);
        TextLeaderboardNames.GetComponent <Text>().text  = "";
        TextLeaderboardScores.GetComponent <Text>().text = "";

        foreach (LevelScore tmp in scores)
        {
            if (tmp == null || tmp.DeviceId == null)
            {
                TextLeaderboardNames.GetComponent <Text>().text  += "---\n";
                TextLeaderboardScores.GetComponent <Text>().text += "---\n";
            }
            else
            {
                string name = tmp.Name;
                //in case we changed the name in settings and want this to apply without another useless server call
                if (tmp.DeviceId == WebConnector.GetDeviceId())
                {
                    name = Game.Me.UserName;
                }
                TextLeaderboardNames.GetComponent <Text>().text  += tmp.Place + ". " + name + "\n";
                TextLeaderboardScores.GetComponent <Text>().text += "" + tmp.Interventions + " INTERV, " + tmp.Time.ToString("##.##") + " s\n";
            }
        }

        string tmp2 = TextLeaderboardNames.GetComponent <Text>().text;

        TextLeaderboardNames.GetComponent <Text>().text = tmp2.Substring(0, tmp2.Length - 1);
        tmp2 = TextLeaderboardScores.GetComponent <Text>().text;
        TextLeaderboardScores.GetComponent <Text>().text = tmp2.Substring(0, tmp2.Length - 1);
    }
コード例 #2
0
    public void Prepare(Mission mission, Dictionary <ScoreType, Result> actualResults)
    {
        Mission = mission;
        //you can only repeat specified missions (i have no time to do backend search for last random mission)
        ButtonRepeat.SetActive(mission.MissionType == MissionType.Specified);
        //GetComponent<ButtonsInCloud>().ButtonTopText = mission.MissionType == MissionType.Random?"Quick Mission":"Next mission";
        ActualResults = actualResults;
        TextLeaderboardNames.GetComponent <Text>().text  = "";
        TextLeaderboardScores.GetComponent <Text>().text = "";

        YourScore = new LevelScore();
        YourScore.AddInfo(Game.Me.UserName, (int)actualResults[ScoreType.Interventions].Value, WebConnector.GetDeviceId(), actualResults[ScoreType.Time].Value, -1);
        LevelScore yourPrevious = mission.YourBest;

        TextYourScore.GetComponent <Text>().text = YourScore.Interventions + " interv, " + (YourScore.Time.ToString("##.##")) + " seconds";

        int   interventionDelta = yourPrevious.Interventions - YourScore.Interventions;
        float timeDelta         = yourPrevious.Time - YourScore.Time;

        if (yourPrevious.Interventions == 0 || YourScore.Interventions < yourPrevious.Interventions || (YourScore.Interventions == yourPrevious.Interventions && YourScore.Time < yourPrevious.Time))
        {
            TextYourScore.GetComponent <Text>().text += "\n (YOUR RECORD";
            if (yourPrevious.Interventions == 0)
            {
                TextYourScore.GetComponent <Text>().text += ", first try";
            }
            else
            {
                if (interventionDelta > 0)
                {
                    TextYourScore.GetComponent <Text>().text += " by " + interventionDelta + " interv";
                }
                else
                {
                    TextYourScore.GetComponent <Text>().text += " by " + timeDelta.ToString("##.##") + " seconds";
                }
            }
            TextYourScore.GetComponent <Text>().text += ")";
        }
        else
        {
            TextYourScore.GetComponent <Text>().text += "\n WORSE THAN YOUR RECORD BY ";
            if (interventionDelta < 0)
            {
                TextYourScore.GetComponent <Text>().text += -interventionDelta + " interv";
            }
            else
            {
                TextYourScore.GetComponent <Text>().text += (-timeDelta).ToString("##.##") + " seconds";
            }
        }

        TextLeaderboardNames.GetComponent <Text>().text  = "Loading";
        TextLeaderboardScores.GetComponent <Text>().text = "scores";
        ImageYellowStraw.SetActive(false);
        UpdateText(Mission.BestScores);
    }