コード例 #1
0
    // Start is called before the first frame update
    void Start()
    {
        if (Score.score > 0)
        {
            int carrots_get = Convert.ToInt16(Math.Round(Score.score / 1000));
            Carrot_Text.text = carrots_get.ToString();

            //update the json file
            GetInput.Player_Info player_info = Title.getPlayerInfo();
            int newCarrotsNum = carrots_get + player_info.carrots;
            player_info.carrots = newCarrotsNum;
            Title.savePlayerInfo(player_info);

            //update the database
            string query = "update runoob.player_info set carrots = " + newCarrotsNum.ToString() + " where email = \'" + Title.UserEmail + "\';";
            mysqlConnector.Query(query);
        }

        else
        {
            Carrot_Text.text = "0";
        }

        // add carrot to user json
    }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        Score_Text.text = Score.score.ToString();


        //update the json file
        GetInput.Player_Info player_info = Title.getPlayerInfo();
        float newScore = Math.Max(Score.score, player_info.Score);

        player_info.Score = newScore;
        Title.savePlayerInfo(player_info);

        //update the database
        string query = @"update runoob.player_info set score = " + newScore.ToString() + " where email = \'" + Title.UserEmail + "\';";

        mysqlConnector.Query(query);
    }
コード例 #3
0
    public void savePlayerInfoWithListString(List<string> result)
    {
        GetInput.Player_Info player_Info = new GetInput.Player_Info()
        {
            Age = Convert.ToInt16(result[0]),
            City = result[1],
            Country = result[2],
            Email = result[3],
            FamilyName = result[4],
            FirstName = result[5],
            Institution = result[6],
            Level = Convert.ToInt16(result[7]),
            Score = float.Parse(result[8]),
            Sex = result[9],
            password = result[10],
            carrots = Convert.ToInt16(result[11])
        };

        savePlayerInfo(player_Info);
    }
コード例 #4
0
 public static void savePlayerInfo(GetInput.Player_Info player_info)
 {
     string playerJson = JsonConvert.SerializeObject(player_info, Formatting.Indented);
     File.WriteAllText(path, playerJson);
 }
コード例 #5
0
 public static GetInput.Player_Info getPlayerInfo()
 {
     string playerJson = File.ReadAllText(path);
     GetInput.Player_Info player_info = JsonConvert.DeserializeObject<GetInput.Player_Info>(playerJson);
     return player_info;
 }
コード例 #6
0
 public static int carrot_number = 5; // initially set to 5, should be get from user json
 // Start is called before the first frame update
 void Start()
 {
     GetInput.Player_Info player_info = Title.getPlayerInfo();
     carrot_number = player_info.carrots;
     DisplayCarrot();
 }