public void AddWeapon(IWeaponContainer weaponContainer) { if (weaponContainer.IsWeapon) { AddWeapon(weaponContainer.Name); } else { AddCartridges(weaponContainer.Name, weaponContainer.Count); } }
/// <summary> /// 获取其他玩家的信息 /// </summary> /// <param name="id"></param> private void GetShipData(ulong id) { //Debug.LogError("收到玩家信息"+id); ShipItemsProxy shipItemsProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShipItemsProxy) as ShipItemsProxy; // 飞船的 IShip ship = shipItemsProxy.GetCurrentWarShip(id); if (ship != null) { IWeaponContainer weaponContainer = ship.GetWeaponContainer(); if (weaponContainer != null) { IWeapon[] weapons = weaponContainer.GetWeapons(); //Debug.LogError("weapons==="+weapons.Length); if (weapons != null) { for (int i = 0; i < weapons.Length; i++) { IWeapon weapon = weapons[i]; m_Weapons[i].text = TableUtil.GetItemName((int)weapon.GetBaseConfig().Id); } } } IEquipmentContainer equipmentContainer = ship.GetEquipmentContainer(); if (equipmentContainer != null) { IEquipment[] equipments = ship.GetEquipmentContainer().GetEquipments(); for (int i = 0; i < equipments.Length; i++) { IEquipment equipment = equipments[i]; m_EquipMents[i].text = TableUtil.GetItemName((int)equipment.GetBaseConfig().Id); } } IReformer ireformer = ship.GetReformerContainer().GetReformer(); if (ireformer != null) { m_Converter.text = TableUtil.GetItemName((int)ireformer.GetBaseConfig().Id); } } else { Debug.LogError("船的信息为空"); } }
public int GetWeaponIndexByUID(ulong uid) { ShipProxy shipProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy; IShip currentShip = shipProxy.GetAppointWarShip(); IWeaponContainer container = currentShip.GetWeaponContainer(); if (container != null) { IWeapon[] weapons = container.GetWeapons(); if (weapons != null) { for (int iWeapon = 0; iWeapon < weapons.Length; iWeapon++) { if (weapons[iWeapon].GetUID() == uid) { return(weapons[iWeapon].GetPos()); } } } } return(0); }
/// <summary> /// 获取第一个可用武器的index /// </summary> /// <returns></returns> public int GetFirstAvailableWeaponIndex() { int firstAvailableWeaponIndex = -1; ShipProxy shipProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy; IShip currentShip = shipProxy.GetAppointWarShip(); IWeaponContainer container = currentShip.GetWeaponContainer(); if (container != null) { IWeapon[] weapons = container.GetWeapons(); if (weapons != null) { for (int iWeapon = 0; iWeapon < weapons.Length; iWeapon++) { if (weapons[iWeapon] != null) { firstAvailableWeaponIndex = firstAvailableWeaponIndex < 0 ? weapons[iWeapon].GetPos() : firstAvailableWeaponIndex; } } } } return(firstAvailableWeaponIndex); }
/// <summary> /// 重建技能列表 /// </summary> public void RebuildSkillList() { RefreshShipSkills(); ShipProxy shipProxy = GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy; IShip currentShip = shipProxy.GetAppointWarShip(); if (currentShip != null) { if (m_ShipIDToSkillList == null) { m_ShipIDToSkillList = new Dictionary <uint, List <PlayerSkillVO> >(); } // 缓存飞船自带技能 if (!m_ShipIDToSkillList.ContainsKey(currentShip.GetTID())) { ISkill[] shipSkills = currentShip.GetSkillContainer().GetSkills(); List <PlayerSkillVO> listToCache = new List <PlayerSkillVO>(); for (int iSkill = 0; iSkill < shipSkills.Length; iSkill++) { int skillID = (int)shipSkills[iSkill].GetTID(); PlayerSkillVO newSkill = PlayerSkillVO.CreateSkillVO(skillID); if (newSkill != null) { listToCache.Add(newSkill); if (!m_SkillIDToSkill.ContainsKey(skillID)) { m_SkillIDToSkill.Add(skillID, newSkill); } } } m_ShipIDToSkillList.Add(currentShip.GetTID(), listToCache); } // 缓存武器技能 IWeaponContainer container = currentShip.GetWeaponContainer(); if (container != null) { IWeapon[] weapons = container.GetWeapons(); if (weapons != null) { for (int iWeapon = 0; iWeapon < weapons.Length; iWeapon++) { if (weapons[iWeapon] != null) { int skillID = (int)weapons[iWeapon].GetBaseConfig().SkillId; PlayerSkillVO newSkill = PlayerSkillVO.CreateSkillVO(skillID); if (newSkill != null) { if (!m_SkillIDToSkill.ContainsKey(skillID)) { m_SkillIDToSkill.Add(skillID, newSkill); } if (!m_ShipIDToSkillList[currentShip.GetTID()].Contains(newSkill)) { m_ShipIDToSkillList[currentShip.GetTID()].Add(newSkill); } } } } } } } }