/// ----------------------------------------------------------------------------------------------- /// <summary> /// ��ɫ��װ������Ӧ��֪ͨ�����ͻ��� /// </summary> /// ----------------------------------------------------------------------------------------------- public void SetPlayerWeapon(int nWeaponID) { if (nWeaponID < 0) { return; } TankWeaponDefinition def = GameSettings.s_Instance.GetWeaponbyID(nWeaponID); if (def != null) { if (m_EquipWeapon != null) { m_EquipWeapon.transform.parent = null; m_EquipWeapon.SetActive(false); GameObject.Destroy(m_EquipWeapon, 2f); } UnityEngine.Object obj = AssetManager.Get().GetResources(def.perfab); GameObject weapon = GameObject.Instantiate(obj) as GameObject; weapon.transform.parent = m_WeaponHP.transform; weapon.transform.localPosition = Vector3.zero; weapon.transform.localRotation = Quaternion.identity; weapon.transform.localScale = Vector3.one; m_WeaponProtol = def; m_EquipWeapon = weapon; // װ������ m_curBullets = m_WeaponProtol.m_nBullets; } }
/// ------------------------------------------------------------------------------------------------------------------------------ /// <summary> /// 刷新武器 /// </summary> /// ------------------------------------------------------------------------------------------------------------------------------ void SpawnWeapon() { for (int i = 0; i < weaponPoints.Count; i++) { if (!weaponPoints[i].IsDirty()) { continue; } TankWeaponDefinition def = GameSettings.s_Instance.GetWeaponbyID(0); if (def == null) { continue; } UnityEngine.Object obj = AssetManager.Get().GetResources(def.perfab); GameObject weapon = GameObject.Instantiate(obj) as GameObject; weapon.transform.parent = weaponPoints[i].gameObject.transform; weaponPoints[i].m_PerviewObj = weapon; weapon.transform.localPosition = Vector3.zero; weapon.transform.localRotation = Quaternion.identity; weapon.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); weaponlist.Add(weapon); } }
/// <summary> /// 初始各个刷新点和武器刷新点 /// </summary> private void LazyLoadSpawnPoints() { if (spawnPoints != null && spawnPoints.Count > 0) { return; } SpawnPoint[] foundSpawnPoints = GetComponentsInChildren <SpawnPoint>(); spawnPoints.AddRange(foundSpawnPoints); if (weaponPoints != null && weaponPoints.Count > 0) { return; } WeaponSpawnPoint[] foundPoints = GetComponentsInChildren <WeaponSpawnPoint>(); weaponPoints.AddRange(foundPoints); for (int i = 0; i < weaponPoints.Count; i++) { TankWeaponDefinition def = GameSettings.s_Instance.GetWeaponbyID(0); if (def == null) { continue; } UnityEngine.Object obj = AssetManager.Get().GetResources(def.perfab); GameObject weapon = GameObject.Instantiate(obj) as GameObject; weapon.transform.parent = weaponPoints[i].gameObject.transform; weaponPoints[i].m_PerviewObj = weapon; weapon.transform.localPosition = Vector3.zero; weapon.transform.localRotation = Quaternion.identity; weapon.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); weaponlist.Add(weapon); } }
/// ----------------------------------------------------------------------------------------------- /// <summary> /// 角色安装武器,应该通知其他客户端 /// </summary> /// ----------------------------------------------------------------------------------------------- public void SetPlayerWeapon(int nWeaponID) { if (nWeaponID < 0) { return; } TankWeaponDefinition def = GameSettings.s_Instance.GetWeaponbyID(nWeaponID); if (def != null) { m_Weapon = def; } }