123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- /// <summary>
- /// 战斗武器
- /// </summary>
- public class BattleWeapon : MonoBehaviour
- {
- /// <summary>
- /// 武器列表
- /// </summary>
- public List<GameObject> m_Weapons = new List<GameObject>();
- /// <summary>
- /// 武器特效列表
- /// </summary>
- public List<GameObject> m_WeaponEffects = new List<GameObject>();
- /// <summary>
- /// 设置武器
- /// </summary>
- /// <param name="id">武器ID</param>
- public void SetWeapon(int id)
- {
- int index = 0;
- if (3000002 == id)
- {
- index = 1;
- }
- if (index >= 0 && index < m_Weapons.Count)
- {
- for (int i = 0; i < m_Weapons.Count; i++)
- {
- if (i == index)
- {
- m_Weapons[i].SetActive(true);
- }
- else
- {
- m_Weapons[i].SetActive(false);
- }
- }
- }
- }
- /// <summary>
- /// 设置武器特效
- /// </summary>
- /// <param name="id">武器ID</param>
- public void SetWeaponEffect(int id)
- {
- // 关闭所有特效
- for (int i = 0; i < m_WeaponEffects.Count; i++)
- {
- m_WeaponEffects[i].SetActive(false);
- }
- if (id <= 0)
- {
- return;
- }
- int index = 0;
- // 火弓用火独有的
- if (3000002 == id)
- {
- index = 1;
- }
- if (index >= 0 && index < m_WeaponEffects.Count)
- {
- for (int i = 0; i < m_WeaponEffects.Count; i++)
- {
- if (i == index)
- {
- m_WeaponEffects[i].SetActive(true);
- }
- else
- {
- m_WeaponEffects[i].SetActive(false);
- }
- }
- }
- }
- //// Use this for initialization
- //void Start()
- //{
- //}
- //// Update is called once per frame
- //void Update()
- //{
- //}
- }
|