AvatarData.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public class AvatarData
  5. {
  6. public int id;
  7. public Vector3 bloodBarPos;
  8. public Vector3 skillNamePos;
  9. public Vector3 hurtPos;
  10. public Vector3 crazyPos;
  11. public Vector3 buffIconPos;
  12. public Vector3 buffTextPos;
  13. public Vector3 rot = Vector3.zero;
  14. public Vector3 offset = Vector3.zero;
  15. public string prefab;
  16. public float scale;
  17. public string bodyTexture;
  18. public string headTexture;
  19. public string leftWeapon;
  20. public string rightWeapon;
  21. public int[] initEffects;
  22. public string leftWeaponNode;
  23. public string rightWeaponNode;
  24. public string weaponTexture;
  25. public float modelSize;
  26. public float shadowScale;
  27. public bool valid = false;
  28. private bool mbDisposed = false;
  29. private string mIdleSound;
  30. private string mRunSound;
  31. private string mDieSound;
  32. private string mHitSound;
  33. public string IdleSound
  34. {
  35. get { return mIdleSound; }
  36. }
  37. public string RunSound
  38. {
  39. get { return mRunSound; }
  40. }
  41. public string DieSound
  42. {
  43. get { return mDieSound; }
  44. }
  45. public string HitSound
  46. {
  47. get { return mHitSound; }
  48. }
  49. public AvatarData(int id)
  50. {
  51. Dictionary<string, string> dic = ConfigMgr.Instance.getLine(id,Config.AvatarCfgName);
  52. if(dic==null)
  53. {
  54. DebugHelper.Log("没有找到相应的avatar配置: {0}", id);
  55. return;
  56. }
  57. this.id = id;
  58. float tempX = 0,tempY = 0;
  59. float.TryParse(dic["BloodBarX"], out tempX);
  60. float.TryParse(dic["BloodBarY"], out tempY);
  61. bloodBarPos = new Vector3(tempX, tempY, 0);
  62. float.TryParse(dic["SkillnamePosX"], out tempX);
  63. float.TryParse(dic["SkillnamePosY"], out tempY);
  64. skillNamePos = new Vector3(tempX, tempY, 0);
  65. float.TryParse(dic["DamagePosX"], out tempX);
  66. float.TryParse(dic["DamagePosY"], out tempY);
  67. hurtPos = new Vector3(tempX, tempY, 0);
  68. float.TryParse(dic["CrazyPosX"], out tempX);
  69. float.TryParse(dic["CrazyPosY"], out tempY);
  70. crazyPos = new Vector3(tempX, tempY, 0);
  71. if(dic.ContainsKey("BuffIconPosX"))
  72. float.TryParse(dic["BuffIconPosX"], out tempX);
  73. if(dic.ContainsKey("BuffIconPosY"))
  74. float.TryParse(dic["BuffIconPosY"], out tempY);
  75. buffIconPos = new Vector3(tempX, tempY, 0);
  76. if (dic.ContainsKey("BuffTextPosX"))
  77. float.TryParse(dic["BuffTextPosX"], out tempX);
  78. if (dic.ContainsKey("BuffTextPosY"))
  79. float.TryParse(dic["BuffTextPosY"], out tempY);
  80. buffTextPos = new Vector3(tempX, tempY, 0);
  81. prefab = dic["AvatarPrefab"];
  82. float.TryParse(dic["AvatarScale"], out scale);
  83. if(scale == 0)
  84. {
  85. scale = 1.0f;
  86. }
  87. if (dic.ContainsKey("AvatarSize"))
  88. {
  89. float.TryParse(dic["AvatarSize"], out modelSize);
  90. }
  91. else
  92. {
  93. modelSize = 0.5f;
  94. }
  95. if (dic.ContainsKey("ShadowScale"))
  96. {
  97. float.TryParse(dic["ShadowScale"], out shadowScale);
  98. }
  99. else
  100. {
  101. shadowScale = 1.0f;
  102. }
  103. if(dic.ContainsKey("Rot"))
  104. {
  105. rot = StringUtil.convertVector3(dic["Rot"]);
  106. }
  107. if(dic.ContainsKey("Offset"))
  108. {
  109. offset = StringUtil.convertVector3(dic["Offset"]);
  110. }
  111. if(dic.ContainsKey("IdleSound"))
  112. {
  113. mIdleSound = dic["IdleSound"].Trim();
  114. }
  115. if(dic.ContainsKey("RunSound"))
  116. {
  117. mRunSound = dic["RunSound"].Trim();
  118. }
  119. if(dic.ContainsKey("DieSound"))
  120. {
  121. mDieSound = dic["DieSound"].Trim();
  122. }
  123. if(dic.ContainsKey("HitSound"))
  124. {
  125. mHitSound = dic["HitSound"].Trim();
  126. }
  127. valid = true;
  128. }
  129. public void Dispose()
  130. {
  131. if (mbDisposed)
  132. return;
  133. initEffects = null;
  134. bodyTexture = null;
  135. headTexture = null;
  136. leftWeapon = null;
  137. rightWeapon = null;
  138. mbDisposed = true;
  139. }
  140. }