Esempio n. 1
0
 public void SetStats(AgentStats stats)
 {
     _stats = stats;
     if (OnAgentUpgrade != null)
     {
         OnAgentUpgrade(stats);
     }
 }
Esempio n. 2
0
        public static void ReportScore(AgentStats player)
        {
            var score = GetScore(player);

            _instance.resentDeathWasFamous = Famous(player, score);
            Debug.Log("Got score: " + score + " (famous=" + _instance.resentDeathWasFamous + ")");
            SceneManager.LoadScene("death", LoadSceneMode.Single);
        }
Esempio n. 3
0
        static float GetScore(AgentStats stats)
        {
            float score = 0;

            score += stats.health + stats.xp;
            score += stats.kills * _instance.killScoreFactor;
            score += stats.maxLevel * _instance.levelScoreFactor;
            return(score);
        }
Esempio n. 4
0
        static bool Famous(AgentStats player, float score)
        {
            //TODO: This should use some proper serialization that allows saving player avatar too
            //Should save: Name, Icon, Score, Day, MaxLevel

            for (int i = 0; i < _instance.famePositions; i++)
            {
                if (score > PlayerPrefs.GetFloat(_instance.playerScores + i, 0f))
                {
                    for (int j = _instance.famePositions - 1; j > i; j--)
                    {
                        PlayerPrefs.SetFloat(_instance.playerScores + j, PlayerPrefs.GetFloat(_instance.playerScores + (j - 1), 0f));
                        PlayerPrefs.SetString(_instance.playerName + j, PlayerPrefs.GetString(_instance.playerName + (j - 1), ""));
                    }

                    PlayerPrefs.SetFloat(_instance.playerScores + i, score);
                    PlayerPrefs.SetString(_instance.playerName + i, player.name);

                    return(true);
                }
            }

            return(false);
        }