Exemple #1
0
    public ScoreData LoadScores()
    {
        ScoreData scoreData = new ScoreData();

        scoreData.Easy    = PlayerPrefs.GetInt("Score.Easy");
        scoreData.Normal  = PlayerPrefs.GetInt("Score.Normal");
        scoreData.Hard    = PlayerPrefs.GetInt("Score.Hard");
        scoreData.Endless = PlayerPrefs.GetInt("Score.Endless");

        if (scoreData.Easy == 0)
        {
            scoreData.Easy = 59999;
        }
        if (scoreData.Normal == 0)
        {
            scoreData.Normal = 59999;
        }
        if (scoreData.Hard == 0)
        {
            scoreData.Hard = 59999;
        }
        if (scoreData.Endless < 0)
        {
            scoreData.Endless = 0;
        }
        return(scoreData);
    }
Exemple #2
0
    public static ScoreData LoadData()
    {
        string path = Application.persistentDataPath + "/binaries.fun";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            ScoreData data = formatter.Deserialize(stream) as ScoreData;
            stream.Close();
            return(data);
        }
        else //on crée le binary avec les données de bases définies par le constructeur par défaut de ScoreData
        {
            Debug.LogError("Save file not found");
            ScoreData data = new ScoreData();

            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Create);
            formatter.Serialize(stream, data);
            stream.Close();

            return(data);
        }
    }
Exemple #3
0
        public void SaveHiScore(ScoreData data)
        {
            if (Application.platform == RuntimePlatform.WebGLPlayer)
            {
                return;
            }
            var existing = _savedScores.FirstOrDefault(x => x.LevelName == data.LevelName);

            if (existing != null)
            {
                _savedScores.Remove(existing);
            }
            _savedScores.Add(new SavedScore()
            {
                LevelName   = data.LevelName,
                ShiftsCount = data.LowestShapeShifts,
                Time        = data.BestTime
            });
            var list = new List <string>();

            foreach (var sa in _savedScores)
            {
                list.Add(JsonUtility.ToJson(sa));
            }

            File.WriteAllLines(_hiScoresPath, list.ToArray());
        }
Exemple #4
0
    public ScoreData ConvertToScoreData()
    {
        ScoreData newData = new ScoreData();

        newData.maxRescuable = maxRescuable;
        return(newData);
    }
Exemple #5
0
    private static void ReceiveFriendsScores(IResult result, ScoreArrayDelegate tmpScoreArrayDelegate)
    {
        if (result.Error == null)
        {
            ArrayList list = new ArrayList();
            Dictionary <string, object> resultDict = (Dictionary <string, object>)Facebook.MiniJSON.Json.Deserialize(result.RawResult);

            foreach (object entryObj in (List <object>)resultDict["data"])
            {
                Dictionary <string, object> entry = (Dictionary <string, object>)entryObj;
                Dictionary <string, object> user  = (Dictionary <string, object>)entry ["user"];

                ScoreData data = new ScoreData();
                data.score     = int.Parse(entry ["score"].ToString());
                data.user_id   = user ["id"].ToString();
                data.user_name = user ["name"].ToString();
                list.Add(data);
            }
            if (tmpScoreArrayDelegate != null)
            {
                tmpScoreArrayDelegate(list.ToArray(typeof(ScoreData)) as ScoreData[]);
            }
        }
        else
        {
            Debug.Log(result.Error);
            if (tmpScoreArrayDelegate != null)
            {
                tmpScoreArrayDelegate(null);
            }
        }
    }
 public void FollowScoreOf(IPlatformer2DUserControl control, HPScript hpScript)
 {
     CurrentScores.Add(new PlayerScoreTracker {CurrentScore = 0, Player = control.m_PlayerData});
     var data = new ScoreData() {HpScript = hpScript, Platformer2DUserControl = control};
     data.HpScript.Dead += HpScript_Dead;
     ScoreDatas.Add(data);
 }
        public void OnUpdateScoresInSummaryPanel(object scoreData)
        {
            ScoreData data = (ScoreData)scoreData;

            _summaryCurrentScoreText.text = data.CurrentScore.ToString();
            _summaryHighScoreText.text    = data.HighScore.ToString();
        }
 public SaveData()
 {
     Score     = Game.Score.OnSave() as ScoreData;
     Player    = Game.Player.OnSave() as PlayerGameData;
     Asteroids = Game.Asteroids.OnSave() as AsteroidsData;
     Bullets   = Game.Bullets.OnSave() as BulletsData;
 }
Exemple #9
0
    /**
     * @pre Game has ended
     * @post Add current game's score data to the 'savedGames.gd' file
     * @param int score of the winner, string name of player who won
     * @return None.
     */
    private void WriteScoreToFile(int score, string playerName)
    {
        ScoreData       scoreData = new ScoreData();
        BinaryFormatter bf        = new BinaryFormatter();

        if (File.Exists(Application.persistentDataPath + "/savedGames.gd"))
        {
            FileStream readFile = File.Open(Application.persistentDataPath + "/savedGames.gd", FileMode.Open);
            scoreData = (ScoreData)bf.Deserialize(readFile);
            readFile.Close();
        }
        ScoreEntry currentScoreEntry = new ScoreEntry();

        currentScoreEntry.score = score;
        currentScoreEntry.name  = playerName;
        scoreData.AddScoreByNumShips(Team1.numberOfShips, currentScoreEntry);
        FileStream writeFile = File.Create(Application.persistentDataPath + "/savedGames.gd");

        bf.Serialize(writeFile, scoreData);
        writeFile.Close();

        foreach (ScoreEntry a in scoreData.GetScoresByNumShips(1))
        {
            Debug.Log("1 Ship: " + a.name + ": " + a.score);
        }
    }
Exemple #10
0
    private void upload(GameData data)
    {
        ScoreData score = new ScoreData(data);

        Firebase.Instance.UpdateData <GameData>(string.Format("Game/splash/BestScores/{0}", data.id), data, () =>
                                                { Debug.Log(string.Format("User {0} uploaded.", data.id)); });
    }
    public static ScoreData LoadPlayer(List <float> score)
    {
        string path = Application.persistentDataPath + filename;

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            ScoreData data = formatter.Deserialize(stream) as ScoreData;
            stream.Close();

            if (data == null)
            {
                Debug.LogError("Nothing saved");
                return(null);
            }
            return(data);
        }
        else
        {
            Debug.LogError("NO SAVE FOUND" + path);
            SavePlayer(score);
            LoadPlayer(score);
            return(null);
        }
    }
 public HighScoreInformation(ScoreData gameData)
 {
     score = gameData.score;
     level = gameData.levelReached;
     rows  = gameData.rowsDeleted;
     time  = (gameData.time.Minutes * 100) + gameData.time.Seconds;
 }
    //loads for cloud profiles
    public void LoadCloudProfile(SaveData newLoadData)
    {
        Debug.Log("LoadSaveDataCloud");
        currentScoreData = newLoadData.scoreData;

        for (int i = 0; i < buildings.childCount; i++)
        {
            RatBuildings ratBuilding = buildings.GetChild(i).GetComponent <RatBuildings>();
            if (ratBuilding != null)
            {
                int index = newLoadData.buildingsPurchased.FindIndex(x => x.buildingName == ratBuilding.buildingName);
                ratBuilding.LoadSaveData(newLoadData.buildingsPurchased[index]);
            }
        }
        gameData.total_cheese = newLoadData.currentCheese;
        gameData.username     = newLoadData.username;

        for (int i = buyableUpgrades.childCount - 1; i >= 0; i--)
        {
            Upgrade upgradeInstance = buyableUpgrades.GetChild(i).GetComponent <Upgrade>();

            if (upgradeInstance != null)
            {
                int index = newLoadData.upgradesPurchased.FindIndex(x => x == upgradeInstance.upgradeName);


                if (index != -1)
                {
                    upgradeInstance.PurchaseWithoutCost();
                }
            }
        }
    }
Exemple #14
0
    void SaveNewScore(int level, float score)
    {
        ScoreData sd = new ScoreData();

        sd.facebookID = Data.Instance.userData.facebookID;
        sd.playerName = Data.Instance.userData.username;
        sd.score      = score;
        levelsScore[level].scoreData.Add(sd);

        if (!levelsScore[level].parseInfoLoaded)
        {
            Debug.Log("Todavia no llego data de parse para este nivel...");
            return;
        }

        Debug.Log("___________SaveNewScore" + level);

        ParseObject gameScore = new ParseObject("Level_" + level.ToString());

        //gameScore.Increment("score", hiscore);
        gameScore["playerName"] = Data.Instance.userData.username;
        gameScore["facebookID"] = Data.Instance.userData.facebookID;
        gameScore["score"]      = score;
        //gameScore["objectId"] = ParseUser.CurrentUser.Username;
        gameScore.SaveAsync();
    }
    private void updateTimeCounter()
    {
        float  time    = this.timeManager.getStopwatchTime();
        string timeStr = ScoreData.formatScoreTimestamp(time);

        this.timeCounterTextUI.text = timeStr;
    }
Exemple #16
0
    public void SaveScore()
    {
        var scoreData = new ScoreData()
        {
            name  = "test1",
            round = 0,
            score = Mathf.RoundToInt(m_CurrentScore.Value)
        };

        m_ScoresData.Add(scoreData);
        m_ScoresData = m_ScoresData.OrderByDescending(d => d.score).ToList();

        for (int i = 0; i < m_KeepedScoreCount; i++)
        {
            var key = m_KeyPrefix + i;

            var json = JsonUtility.ToJson(m_ScoresData[i]);

            //Debug.Log($"Saving: {json}");

            PlayerPrefs.SetString(key, json);
        }

        PlayerPrefs.Save();
        UpdateText();
    }
Exemple #17
0
    /// <summary>
    /// A method that will clear the playerScoreDataList as well as the Google Firebase database.
    /// </summary>
    /// <returns></returns>
    private IEnumerator ClearListCoroutine()
    {
        isClearListCoroutineRunning = true;

        // Clear the playerScoreDataList and the scoreListText.
        playerScoreDataList.Clear();
        scoreListText.text = "";

        // Make new ScoreData object
        ScoreData newScoreData = new ScoreData();

        newScoreData.playerScoreDataList = playerScoreDataList;

        // Convert list to JSON
        string json = JsonUtility.ToJson(newScoreData);

        if (debugComponent)
        {
            Debug.Log("json: " + Environment.NewLine + json);
        }

        // Upload JSON to Database
        if (_database != null)
        {
            var sendData = _database.GetReference(path: SCORELISTKEY).SetRawJsonValueAsync(json);
            yield return(new WaitUntil(() => sendData.IsCompleted));
        }
        else
        {
            Debug.LogError("Firebase database instance not found. Please initialize the database in order to upload data.");
        }

        isClearListCoroutineRunning = false;
    }
Exemple #18
0
    public void SaveScore()
    {
        string name;

        if (input.text == "" || input.text == null)
        {
            name = "Mr. Placeholder";
        }
        else
        {
            name = input.text;
        }

        //create score
        ScoreData score = new ScoreData(FindObjectOfType <Score>().getCurrentScore(), name);

        //Increase score list size
        int size = PlayerPrefs.GetInt(PrefKeySize);

        PlayerPrefs.SetInt(PrefKeySize, size + 1);

        //Add score to list
        PlayerPrefs.SetString(PrefKeyPrefix + size.ToString(), score.ToString());

        manager.loadLevel("menu");
    }
        public async Task <ScoreData> GetLowestScoreDrinkData(DateTime start, DateTime end)
        {
            var scoreActivities = await _activitiesRepository.Get(x =>
                                                                  x.Created > start && x.Created < end && x.Action == PerformedAction.AddedReview && x.Score != null);

            var lowestScoreDrinkData = new ScoreData();

            if (scoreActivities.Count == 0)
            {
                lowestScoreDrinkData.DrinkName    = "none";
                lowestScoreDrinkData.AverageScore = 0;
            }
            else
            {
                var data = scoreActivities
                           .GroupBy(x => x.DrinkId)
                           .Select(x => new {
                    drinkId      = x.Key,
                    averageScore = x.Select(y => y.Score).Average(),
                    drinkName    = x.Select(x => x.DrinkName).First()
                })
                           .OrderBy(x => x.averageScore)
                           .First();

                lowestScoreDrinkData.DrinkName    = data.drinkName;
                lowestScoreDrinkData.AverageScore = data.averageScore;
            }
            return(lowestScoreDrinkData);
        }
Exemple #20
0
    public void loginButtonClick()
    {
        BinaryFormatter bf         = new BinaryFormatter();
        PlayerInfo      playerData = new PlayerInfo();
        ScoreData       scoreData  = new ScoreData();
        GiftData        giftData   = new GiftData();

        if (userNameInput.text != null && userEmailInput.text != null)
        {
            playerData.userEmail = userEmailInput.text;
            playerData.userName  = userNameInput.text;



            bf.Serialize(playerInfoFile, playerData);
            bf.Serialize(scoreDataFile, scoreData);
            bf.Serialize(giftDataFile, giftData);


            playerInfoFile.Close();
            scoreDataFile.Close();
            giftDataFile.Close();

            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
        }
        else
        {
            Debug.Log("Either one is null");
        }
    }
Exemple #21
0
    private void LoadData(int _level)
    {
        ParseQuery <ParseObject> query;

        if (Data.Instance.levels.levels[_level].totalLaps > 0)
        {
            query = ParseObject.GetQuery("Level_" + _level.ToString())
                    .OrderBy("score")
                    .Limit(10);
        }
        else
        {
            query = ParseObject.GetQuery("Level_" + _level.ToString())
                    .OrderByDescending("score")
                    .Limit(10);
        }

        query.FindAsync().ContinueWith(t =>
        {
            IEnumerable <ParseObject> results = t.Result;
            int a = 1;
            foreach (var result in results)
            {
                ScoreData sd = new ScoreData();

                sd.playerName = result["playerName"].ToString();
                sd.facebookID = result["facebookID"].ToString();
                sd.score      = float.Parse(result["score"].ToString());
                scoresData.Add(sd);
                a++;
            }
        });
    }
Exemple #22
0
    /// <summary>
    /// 終了イベント。スコアの保存とリザルト画面に遷移
    /// </summary>
    void FinishEvent()
    {
        var scoreData = new ScoreData(_score, _maxCombo);

        SystemManager.Instance.ScoreData = scoreData;
        UnityEngine.SceneManagement.SceneManager.LoadScene("ResultScene");
    }
Exemple #23
0
 void AddNewRefreshedData(ScoreData scoreData, float score)
 {
     print("AddNewRefreshedData score: " + score);
     scoreData.score      = score;
     scoreData.playerName = Data.Instance.userData.username;
     scoreData.facebookID = Data.Instance.userData.facebookID;
 }
Exemple #24
0
    public void CheckScore(List <CardBase> checkCardList, ScoreData scoreData)
    {
        sc.CheckCards(checkCardList, scoreData);
        int score = sc.GetScore(scoreData);

        UIManager.Instance.SetDatas(isUserTurn, score);

        if (rule.CanGo(score, scoreData))
        {
            if (targetUserData.utilizeCards.Count == 0)
            {
                UIManager.Instance.gostopUI.stopUI.OnStop();
            }
            else
            {
                UIManager.Instance.gostopUI.AccomplishedCondition();
            }
        }
        else
        {
            if (user.utilizeCards.Count == 0 && ai.userData.utilizeCards.Count == 0)
            {
                UIManager.Instance.gostopUI.stopUI.OnStop(false, true);
            }
            else
            {
                SetTurn();
            }
        }
    }
Exemple #25
0
    public void Start()
    {
        if (File.Exists(Application.persistentDataPath + "/scoreData.dat"))
        {
            FileStream scoreDataFile = File.Open(Application.persistentDataPath + "/scoreData.dat", FileMode.Open);

            scoreData = (ScoreData)bf.Deserialize(scoreDataFile);
            scoreDataFile.Close();

            Debug.Log(scoreData.coinScore);
            Debug.Log(scoreData.currentCoinScore);

            foreach (Button defButton in buttons)
            {
                string buttonTagString = defButton.tag;
                int    buttonTagInt;
                int.TryParse(buttonTagString, out buttonTagInt);

                if (scoreData.currentCoinScore < buttonTagInt)
                {
                    Image giftPanel = GameObject.FindGameObjectWithTag(defButton.tag).GetComponent <Image>();
                    giftPanel.color = Color.white;
                }
                else
                {
                    Image giftPanel = GameObject.FindGameObjectWithTag(defButton.tag).GetComponent <Image>();
                    giftPanel.color = Color.green;
                }
            }
        }
    }
Exemple #26
0
        private string GetRankEmoji(ScoreData score)
        {
            switch (score.Rank)
            {
            case "F":
                return("<:whenlifegetsatyou:495914397659824128>");

            case "D":
                return("<:D_:495911981694451723>");

            case "C":
                return("<:C_:495911972810915840>");

            case "B":
                return("<:B_:495911965739319316>");

            case "A":
                return("<:A_:495911960710348820>");

            case "S":
                return("<:S_:495911953584357377>");

            case "X":
                return("<:X_:495911948207259648>");

            case "SH":
                return("<:SH:495911942360137732>");

            case "XH":
                return("<:XH:495911930238599169>");

            default:
                return("<:whenlifegetsatyou:495914397659824128>");
            }
        }
    public void Save()
    {
        var playerAndValueSorted = playerAndValue.ToList();

        playerAndValueSorted.Sort((pair1, pair2) => pair1.Value.CompareTo(pair2.Value));
        if (playerAndValueSorted.Count > 10)
        {
            playerAndValueSorted.Remove(playerAndValueSorted.Last());
        }

        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/score.dat");
        ScoreData       data = new ScoreData();

        data.scores = new int[playerAndValueSorted.Count];
        data.nicks  = new string[playerAndValueSorted.Count];

        for (int i = 0; i < playerAndValueSorted.Count; i++)
        {
            data.nicks[i]  = playerAndValueSorted[i].Key;
            data.scores[i] = playerAndValueSorted[i].Value;
        }

        bf.Serialize(file, data);
        file.Close();

        ShowScores();
    }
	void Awake ()
	{

		if (instance == null)
		{
			instance = this;
			DontDestroyOnLoad(gameObject);
		}
		else
		{
			Destroy(gameObject);
			return;
		}

		scoresList = new List<ScoreData>();
		for (int i = 0; i < MAX_SCORES; ++i)
		{
			int points = PlayerPrefs.GetInt(POINTS_KEY + i, -1);
			if (points >= 0)
			{
				string name = PlayerPrefs.GetString(PLAYER_KEY + i, "");
				ScoreData sd = new ScoreData(name, points, i);
				scoresList.Add(sd);
				Debug.LogFormat("<color=green> INFO: player {0} with score {1}</color>", name, points);
			}
		}
		SortScoresList();
	}
Exemple #29
0
    public int GetCalculatedScore()
    {
        ScoreData sd    = null;
        ScoreData other = null;

        if (GameManager.Instance.isUserTurn)
        {
            sd    = GameManager.Instance.user.scoreData;
            other = GameManager.Instance.ai.userData.scoreData;
        }
        else
        {
            other = GameManager.Instance.user.scoreData;
            sd    = GameManager.Instance.ai.userData.scoreData;
        }

        int score = GetScore(sd);

        score  = CalculateByGoCount(score, GameManager.Instance.targetUserData.scoreData.goCount);
        score  = CalculateByNagariCount(score);
        score *= GetMagnification(sd, other);
        score *= jum;

        return(score);
    }
Exemple #30
0
    /// <summary>
    /// Deserialize from json.
    /// MemberData型のリストがjsonに入っていると仮定して
    /// </summary>
    /// <returns>The from json.</returns>
    /// <param name="sStrJson">S string json.</param>
    public static List <ScoreData> DeserializeFromJson(string sStrJson)
    {
        var ret = new List <ScoreData>();

        IList jsonList = (IList)Json.Deserialize(sStrJson);

        foreach (IDictionary jsonOne in jsonList)
        {
            //新レコード解析開始
            var tmp = new ScoreData();

            //該当するキー名が jsonOne に存在するか調べ、存在したら取得して変数に格納する。
            if (jsonOne.Contains("Score"))
            {
                tmp.Score = (long)jsonOne["Score"];
            }

            if (jsonOne.Contains("Day"))
            {
                tmp.Day = (string)jsonOne["Day"];
            }

            //現レコード解析終了
            ret.Add(tmp);
        }

        return(ret);
    }
Exemple #31
0
 private void InitializeGame()
 {
     CreatePhoneOwnerPaddle();
     CreateOpponentPaddle();
     CreateBall();
     ScoreData.ResetCurentGameScore();
 }
 public void FromRawData(ScoreData data)
 {
     StoredData = data;
     //this.date = null;
     this.value = data.Value;
     this.rank = rank;
     this.userID = data.Player;
 }
Exemple #33
0
    public void UpdateScore(ScoreData newScore)
    {
        // Cache the previous score
        PreviousScore = CurrentScoreData != null ? CurrentScoreData.Score : 0;

        // Update the current score
        CurrentScoreData = newScore;
    }
 public TIRDetail()
 {
     ScoreData1 = new ScoreData();
     ScoreData2 = new ScoreData();
     ScoreData3 = new ScoreData();
     ScoreData4 = new ScoreData();
     ScoreData5 = new ScoreData();
 }
 public Score(ScoreboardService rest, string player, long value)
 {
     _rest = rest;
     StoredData = new ScoreData();
     StoredData.Player = player;
     StoredData.Value = value;
     StoredData.Platform = Application.platform.ToString().ToUpper();
     StoredData.GameSessionGUID = Guid.NewGuid().ToString().ToUpper();
 }
Exemple #36
0
    /// <summary>
    /// Returns score data for 8 players. Each score has a random value between 0 and 2000.
    /// </summary>
    /// <returns></returns>
    public static Dictionary<PlayerData, ScoreData> GetPlayerScores(int amount = 8)
    {
        var data = new Dictionary<PlayerData, ScoreData>();
        for (int i = 0; i < amount; i++)
        {
            var player = new PlayerData();
            player.ID = i.ToString();
            player.Name = "Player " + i;

            var score = (uint)Random.Range(0, 2000);
            var scoreData = new ScoreData(score, (uint)Random.Range(0, 4), new AnswerData(Random.Range(0, 1000).ToString()));
            scoreData.AnswerGiven.Likes = Random.Range(0, 5);
            data.Add(player, scoreData);
        }
        return data;
    }
        public async Task<bool> IsDeviceReliable(string correlationId, double temperature)
        {
            try
            {
                using (var client = new HttpClient())
                {
                    ScoreData scoreData = new ScoreData()
                    {
                        FeatureVector = new Dictionary<string, string>()
                    {
                        {"temperature", temperature.ToString()},
                    },
                        GlobalParameters = new Dictionary<string, string>() { }

                    };

                    ScoreRequest scoreRequest = new ScoreRequest()
                    {
                        Id = correlationId,
                        Instance = scoreData
                    };

                    string apiKey = CloudConfigurationManager.GetSetting("AzureMLApiKey");
                    string endpoint = CloudConfigurationManager.GetSetting("AzureMLEndpoint");
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);

                    client.BaseAddress = new Uri(endpoint);
                    HttpResponseMessage response = await client.PostAsJsonAsync("", scoreRequest);
                    response.EnsureSuccessStatusCode();
                    if (response.IsSuccessStatusCode)
                    {
                        string result = await response.Content.ReadAsStringAsync();
                        
                        var array = JArray.Parse(result);

                        return array.Last.Value<int>() == 0;
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("There was an error with AzureML: {0}", ex);
            }

            return _defaultReliability == FailAction.Reliable;
        }
Exemple #38
0
	public void Save()
	{
		BinaryFormatter bf = new BinaryFormatter();
		FileStream file = File.Create(Application.persistentDataPath + "/scoreInfo.dat");

		// put data in container
		ScoreData data = new ScoreData();
		data.win = win;
		data.lose = lose;
		data.tie = tie;

		// put in file
		Debug.Log ("PRE SERIALIZE");
		bf.Serialize(file, data);
		Debug.Log ("POST SERIALIZE");
		file.Close();

		Debug.Log ("ScoreControl.SAVE(): " + win + "/" + lose + "/" + tie );
	}
Exemple #39
0
    /// <summary>
    /// Read scores
    /// </summary>
    /// <param name="filename">XML format file name</param>
    public void ScoresReader(string filename)
    {
        this.fileName = filename;
        this.VerifyFileExist(filename);

        XmlReaderSettings settings = new XmlReaderSettings();
        settings.IgnoreComments = true;
        settings.IgnoreWhitespace = true;
        settings.ValidationType = ValidationType.None;
        XmlReader reader = XmlTextReader.Create(filename, settings);
        while (reader.Read())
        {
            ScoreData score = null;
            switch (reader.NodeType)
            {
                case XmlNodeType.Element:
                    string tagName = reader.LocalName;
                    if (tagName.Equals(ScoreTag.UserTag))
                    {
                        score = new ScoreData(reader[ScoreTag.ID],
                                              reader[ScoreTag.UserName],
                                              reader[ScoreTag.Score],
                                              reader[ScoreTag.GameTime],
                                              reader[ScoreTag.Coppers],
                                              reader[ScoreTag.Silvers],
                                              reader[ScoreTag.Golds],
                                              reader[ScoreTag.Rank],
                                              reader[ScoreTag.PlayDate],
                                              reader[ScoreTag.Scene]);
                        this.scoreList.Add(score);
                    }
                    break;
                default:
                    break;
            }
        }
        reader.Close();
    }
Exemple #40
0
    public static void createScoreData()
    {
        List<ScoreData> list = new List<ScoreData>();

        for (int n = 0; n < 30; n++)
        {
            if (n == 0)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.optimalpath_moves = 5;
                data.unlock_triplets = false;
                data.star1 =0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.level_status = true;
                data.star2_status = false;
                
                list.Add(data);
            }
            if (n == 1)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.optimalpath_moves = 2;
                data.unlock_triplets = false;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.level_status = false;
                data.star2_status = false;

                list.Add(data);
            }
            if (n == 2)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.unlock_triplets = false;
                data.optimalpath_moves = 1;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 3)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.unlock_triplets = false;
                data.optimalpath_moves = 8;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 4)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.unlock_triplets = false;
                data.optimalpath_moves = 6;
                data.highScore = 0;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.star2_status = true;

                list.Add(data);
            }

            if (n == 5)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.unlock_triplets = false;
                data.optimalpath_moves = 5;
                
                data.highScore = 0;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.star2_status = false;

                list.Add(data);
            }

            if (n == 6)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.unlock_triplets = false;
                data.highScore = 0;
                data.optimalpath_moves = 1;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.star2_status =false;

                list.Add(data);
            }
            if (n == 7)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.unlock_triplets = false;
                data.highScore = 0;
                data.optimalpath_moves = 1;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 8)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.unlock_triplets = false;
                data.highScore = 0;
                data.optimalpath_moves = 2;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 9)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.unlock_triplets = false;
                data.optimalpath_moves = 2;
                data.highScore = 0;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.star2_status = false;


                list.Add(data);
            }



            if (n == 10)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.unlock_triplets = false;
                data.optimalpath_moves = 0;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }

            if (n == 11)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.unlock_triplets = false;
                data.level_status = false;
                data.optimalpath_moves = 2;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = false;

                list.Add(data);
            }
            if (n == 12)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.unlock_triplets = false;
                data.level_status = false;
                data.optimalpath_moves = 6;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 13)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.unlock_triplets = false;
                data.level_status = false;
                data.optimalpath_moves = 2;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 14)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.unlock_triplets = false;
                data.level_status = false;
                data.optimalpath_moves = 2;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 15)
            {
                ScoreData data = new ScoreData();
                data.levelNumber = (n + 1);
                data.unlock_triplets = false;
                data.level_status = false;
                data.optimalpath_moves = 4;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 16)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 2;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }


            if (n == 17)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 6;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = false;

                list.Add(data);
            }

            ///START CHANGES!
            if (n == 18)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 5;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
				data.star2_status = true;

                list.Add(data);
            }
            if (n == 19)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 3;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 20)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 8;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 21)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 0;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 22)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 6;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 23)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 13;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 24)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 8;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
				data.star2_status = true;

                list.Add(data);
            }
            if (n == 25)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 8;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = false;

                list.Add(data);
            }
            if (n == 26)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 16;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 27)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 7;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 28)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 5;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = true;

                list.Add(data);
            }
            if (n == 29)
            {
                ScoreData data = new ScoreData();
                data.unlock_triplets = false;
                data.levelNumber = (n + 1);
                data.level_status = false;
                data.optimalpath_moves = 5;
                data.star1 = 0;
                data.star2 = 0;
                data.star3 = 0;
                data.highScore = 0;
                data.star2_status = false;

                list.Add(data);
            }



            _scoreContainer.LevelScores = list;

            Save();
        }
    }
Exemple #41
0
 public GameScore(ScoreData scoreData)
 {
     
 }
 private void LoadScores()
 {
     if (File.Exists(Application.persistentDataPath + "/scores.dat"))
     {
         FileStream scoresFile = File.Open(Application.persistentDataPath + "/scores.dat", FileMode.Open);
         scoreData = serializer.Deserialize(scoresFile) as ScoreData;
         scoresFile.Close();
     }
     else
     {
         scoreData = new ScoreData();
     }
 }
Exemple #43
0
	public void ResetDataList () {
		scores = new List<ScoreData> ();
		for (int index = 0; index < 10; ++index) {
			currentData = new ScoreData();
			scores.Add(currentData);
		}
	}
Exemple #44
0
	public void OnClick_RestartLeaderBoard()
	{
		Debug.Log("Restart LeaderBoard");
		PlayerPrefs.DeleteAll ();
		currentData = new ScoreData ();
		ResetDataList ();
		ShowScores ();
	}
Exemple #45
0
	public ScoreData (ScoreData data){
		name = data.name;
		score = data.score;
	}
Exemple #46
0
    /// <summary>
    /// Write score to file
    /// </summary>
    /// <param name="scoreData">A full score data.</param>
    /// <param name="filename">Which XML format file you want to write.</param>
    public void ScoresWrite(ScoreData scoreData, string filename)
    {
        XmlDocument document = new XmlDocument();

        this.VerifyFileExist(GameDefinition.ScoresFilePath);
        document.Load(filename);
        XmlNode node = document.SelectSingleNode(ScoreTag.ScoresTag);

        XmlElement newUser = document.CreateElement(ScoreTag.UserTag);
        newUser.SetAttribute(ScoreTag.ID, scoreData.ID);
        newUser.SetAttribute(ScoreTag.UserName, scoreData.UserName);
        newUser.SetAttribute(ScoreTag.Score, scoreData.Score);
        newUser.SetAttribute(ScoreTag.GameTime, scoreData.GameTime);
        newUser.SetAttribute(ScoreTag.Coppers, scoreData.Coppers);
        newUser.SetAttribute(ScoreTag.Silvers, scoreData.Silvers);
        newUser.SetAttribute(ScoreTag.Golds, scoreData.Golds);
        newUser.SetAttribute(ScoreTag.Rank, scoreData.Rank);
        newUser.SetAttribute(ScoreTag.PlayDate, scoreData.PlayDate);
        newUser.SetAttribute(ScoreTag.Scene, scoreData.Scene);
        node.AppendChild(newUser);
        document.Save(filename);
        this.scoreList.Add(scoreData);
    }
    /// <summary>
    /// スコアを保存する
    /// </summary>
    private static void SaveScore( ScoreData[] i_scoreList )
    {
        for( int i = 0; i < i_scoreList.Length; ++i )
        {
            var scoreData   = i_scoreList[ i ];
            PlayerPrefs.SetString( GetNameSaveKey( i ), scoreData.Name );
            PlayerPrefs.SetInt( GetScoreSaveKey( i ), scoreData.Score);
        }

        PlayerPrefs.Save();
    }
 /// <summary>
 /// Post User Score
 /// </summary>
 /// <param name="score">Score data</param>
 /// <param name="callback">Callback method with Exception and ScoreData args</param>
 public void PostScore(ScoreData score, Action<Exception, ScoreData> callback)
 {
     Post<ScoreData>("/v1/scoreboard/score", score, callback);
 }
Exemple #49
0
		public ScoreActivityEventArgs(ScoreData sData)
		{
			this.ScoreData = sData;
		}
Exemple #50
0
	public float UpdateScore(string scoreType, string playerGuid, float value, ScoreSetType setType = ScoreSetType.delta) 
	{
		// Returns the new assigned value

		// Create the dictionary key if it doesn't exist
		if(!this.scoreList.ContainsKey(scoreType))
			this.scoreList[scoreType] = new Dictionary<string, float>();

		float newValue = -1;
		if(setType == ScoreSetType.delta)
		{
			float beforeValue = 0;
			this.scoreList[scoreType].TryGetValue(playerGuid, out beforeValue);

			newValue = beforeValue + value;
		}
		else//(setType == ScoreSetType.absolute)
		{
			newValue = value;
		}

		this.scoreList[scoreType][playerGuid] = newValue;

		// Fire the event
		//Debug.Log("Firing Score Updated Event");
		ScoreData scoreData = new ScoreData();
		scoreData.scoreType = scoreType;
		scoreData.guid = playerGuid;
		scoreData.value = newValue;
		this.OnScoreUpdated(this, new ScoreActivityEventArgs(scoreData));

		// Tell the others the score
		if(Network.isServer)
			networkView.RPC("RPCUpdateScore", RPCMode.OthersBuffered, scoreType, playerGuid, newValue);

		return newValue;
	}