BattleWeapon.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /// <summary>
  5. /// 战斗武器
  6. /// </summary>
  7. public class BattleWeapon : MonoBehaviour
  8. {
  9. /// <summary>
  10. /// 武器列表
  11. /// </summary>
  12. public List<GameObject> m_Weapons = new List<GameObject>();
  13. /// <summary>
  14. /// 武器特效列表
  15. /// </summary>
  16. public List<GameObject> m_WeaponEffects = new List<GameObject>();
  17. /// <summary>
  18. /// 设置武器
  19. /// </summary>
  20. /// <param name="id">武器ID</param>
  21. public void SetWeapon(int id)
  22. {
  23. int index = 0;
  24. if (3000002 == id)
  25. {
  26. index = 1;
  27. }
  28. if (index >= 0 && index < m_Weapons.Count)
  29. {
  30. for (int i = 0; i < m_Weapons.Count; i++)
  31. {
  32. if (i == index)
  33. {
  34. m_Weapons[i].SetActive(true);
  35. }
  36. else
  37. {
  38. m_Weapons[i].SetActive(false);
  39. }
  40. }
  41. }
  42. }
  43. /// <summary>
  44. /// 设置武器特效
  45. /// </summary>
  46. /// <param name="id">武器ID</param>
  47. public void SetWeaponEffect(int id)
  48. {
  49. // 关闭所有特效
  50. for (int i = 0; i < m_WeaponEffects.Count; i++)
  51. {
  52. m_WeaponEffects[i].SetActive(false);
  53. }
  54. if (id <= 0)
  55. {
  56. return;
  57. }
  58. int index = 0;
  59. // 火弓用火独有的
  60. if (3000002 == id)
  61. {
  62. index = 1;
  63. }
  64. if (index >= 0 && index < m_WeaponEffects.Count)
  65. {
  66. for (int i = 0; i < m_WeaponEffects.Count; i++)
  67. {
  68. if (i == index)
  69. {
  70. m_WeaponEffects[i].SetActive(true);
  71. }
  72. else
  73. {
  74. m_WeaponEffects[i].SetActive(false);
  75. }
  76. }
  77. }
  78. }
  79. //// Use this for initialization
  80. //void Start()
  81. //{
  82. //}
  83. //// Update is called once per frame
  84. //void Update()
  85. //{
  86. //}
  87. }