DogProperty.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. public class DogProperty
  12. {
  13. // Start is called before the first frame update
  14. public string id = "121212121";
  15. public string name = "小泥鳅";
  16. public int gender = 1;
  17. public string breed = "shibaInu"; // 狗的默认模型
  18. public string skin = "black"; // 狗的默认贴图
  19. public DateTime brithday = new(2023, 1, 1, 12, 0, 0);
  20. public int satiety = 15;
  21. public int happiness = 50;
  22. public int stamina = 29;
  23. public int thirsty = 8;
  24. public int healthy = 7;
  25. public int clean = 21;
  26. public int curiosity = 50;
  27. public int iq = 50;
  28. public int runSpeed = 50;
  29. public int JumpHeight = 50;
  30. public int liveliness = 50;
  31. public int agility = 50;
  32. public int obesity = 75;
  33. public int intimate = 50;
  34. public int friendly = 50;
  35. public int Obedience = 50;
  36. public int friendlyToHost = 50;
  37. public int friendlyToStranger = 50;
  38. public int friendlyToOtherSSDog = 50;
  39. public int friendlyToOtherDSDog = 50;
  40. public int frisbeeSkill = 50;
  41. public int ballSkill = 50;
  42. public int AIName = 50;
  43. public int AISit = 50;
  44. public int AILieDown = 50;
  45. public int AIRotate = 50;
  46. }
  47. public class DogBreed
  48. {
  49. public string breed { get; set; }
  50. public Dictionary<string, string> name { get; set; }
  51. public Dictionary<string, string> description { get; set; }
  52. public DateTime createDate { get; set; }
  53. public DateTime lastDpdate { get; set; }
  54. public int cost { get; set; }
  55. public string prefab { get; set; }
  56. public string[] skin { get; set; }
  57. }
  58. public class DogBreedController
  59. {
  60. // 读取狗的数据并放入EnviromentSetting.dogBreeds
  61. public static void LoadDogBreed()
  62. {
  63. string filePath = EnviromentSetting.dogDBFilePath;
  64. string json = File.ReadAllText(filePath);
  65. Dictionary<string, object> dogDB = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
  66. string json2 = dogDB["dogDB"].ToString();
  67. EnviromentSetting.dogBreeds = JsonConvert.DeserializeObject<DogBreed[]>(json2);
  68. }
  69. }