ItemData.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Codice.Client.Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Reflection;
  6. namespace GFGGame
  7. {
  8. public class ItemData
  9. {
  10. public int id;
  11. public int num;
  12. public bool isOnceBonus;
  13. public Dictionary<int, int> AttributesDic = new Dictionary<int, int>();
  14. delegate object MemberGetDelegate(ItemCfg p);
  15. public void Reset()
  16. {
  17. id = 0;
  18. num = 0;
  19. isOnceBonus = false;
  20. AttributesDic.Clear();
  21. }
  22. public int MainScore
  23. {
  24. get
  25. {
  26. var cfg = ItemCfgArray.Instance.GetCfg(id);
  27. return GetScore(cfg.mainScore>0? cfg.mainScore:1);
  28. }
  29. }
  30. public int GetScore(int scoreType)
  31. {
  32. int valueBase = 0;
  33. var cfg = ItemCfgArray.Instance.GetCfg(id);
  34. switch(scoreType)
  35. {
  36. case (int)ConstItemAttributeType.FENG:
  37. valueBase = cfg.score1;
  38. break;
  39. case (int)ConstItemAttributeType.HUA:
  40. valueBase = cfg.score2;
  41. break;
  42. case (int)ConstItemAttributeType.XUE:
  43. valueBase = cfg.score3;
  44. break;
  45. case (int)ConstItemAttributeType.YUE:
  46. valueBase = cfg.score4;
  47. break;
  48. }
  49. AttributesDic.TryGetValue(CalculateUtil.GetItemScoreKey(scoreType, (int)ConstItemAttributeActionType.ADD_VALUE), out var valueAdd);
  50. AttributesDic.TryGetValue(CalculateUtil.GetItemScoreKey(scoreType, (int)ConstItemAttributeActionType.ADD_PERCENT), out var percentAdd);
  51. return CalculateUtil.GetItemAttribute(valueBase, percentAdd, valueAdd);
  52. }
  53. }
  54. }