DogProperty.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using Newtonsoft.Json;
  6. using System.IO;
  7. /* 本文件包含对于狗的基础类
  8. * DogProperty 用于描述具体某一只狗的属性配置
  9. * DogBreed 用于描述某一种狗的数据
  10. */
  11. [System.Serializable]
  12. public class DogProperty
  13. {
  14. // Start is called before the first frame update
  15. public string d_id = "121212121";
  16. public string owner_id = string.Empty;
  17. public string dog_name = "小泥鳅";
  18. public int sex = 1;
  19. public string breed = "shibaInu"; // 狗的默认模型
  20. public string skin = "black"; // 狗的默认贴图
  21. public DateTime brithday = new(2023, 1, 1, 12, 0, 0);
  22. public int satiety = 15;
  23. public int happiness = 50;
  24. public int stamina = 29;
  25. public int thirsty = 8;
  26. public int healthy = 7;
  27. public int clean = 21;
  28. public int curiosity = 50;
  29. public int iq = 50;
  30. public int runSpeed = 50;
  31. public int JumpHeight = 50;
  32. public int liveliness = 50;
  33. public int agility = 50;
  34. public int obesity = 75;
  35. public int intimate = 50;
  36. public int friendly = 50;
  37. public int Obedience = 50;
  38. public int friendlyToHost = 50;
  39. public int friendlyToStranger = 50;
  40. public int friendlyToOtherSSDog = 50;
  41. public int friendlyToOtherDSDog = 50;
  42. public int frisbeeSkill = 50;
  43. public int ballSkill = 50;
  44. public int commandName = 50;
  45. public int commandSit = 50;
  46. public int commandLieDown = 50;
  47. public int commandRotate = 50;
  48. }
  49. public class DogBreed
  50. {
  51. public string breed { get; set; }
  52. public Dictionary<string, string> name { get; set; }
  53. public Dictionary<string, string> description { get; set; }
  54. public DateTime createDate { get; set; }
  55. public DateTime lastDpdate { get; set; }
  56. public int cost { get; set; }
  57. public string prefab { get; set; }
  58. public string[] skin { get; set; }
  59. }
  60. public class DogBreedController
  61. {
  62. // 读取狗的数据并放入EnviromentSetting.dogBreeds
  63. public static void LoadDogBreed()
  64. {
  65. string filePath = EnviromentSetting.dogDBFilePath;
  66. string json = File.ReadAllText(filePath);
  67. Dictionary<string, object> dogDB = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
  68. string json2 = dogDB["dogDB"].ToString();
  69. EnviromentSetting.dogBreeds = JsonConvert.DeserializeObject<DogBreed[]>(json2);
  70. }
  71. }