/// <summary> /// 获取当前武器武器准星对象 /// </summary> /// <returns></returns> public WeaponAndCrossSight GetCurrentWeaponAndCrossSight() { SpacecraftEntity mainPlayer = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID()); if (mainPlayer == null) { return(null); } WeaponAndCrossSight result = null; if (UsingReformer()) { //转化炉武器 IReformer reformer = GetReformer(); if (reformer != null && mainPlayer.HaveWeaponAndCrossSight(reformer.GetUID())) { result = mainPlayer.GetWeaponAndCrossSight(reformer.GetUID()); } } else { //普通武器 IWeapon weapon = GetCurrentWeapon(); if (weapon != null && mainPlayer.HaveWeaponAndCrossSight(weapon.GetUID())) { result = mainPlayer.GetWeaponAndCrossSight(weapon.GetUID()); } } return(result); }
/// <summary> /// 转化炉切换 /// </summary> /// <param name="entityEvent"></param> private void ReformerWeapons(IComponentEvent entityEvent) { if (m_IPerceptronTarget.GetCurrentState().IsHasSubState(EnumSubState.Peerless)) { //转化炉模式 if (!m_SkillProxy.UsingReformer()) { return; } IReformer reformer = m_SkillProxy.GetReformer(); if (reformer == null) { return; } ulong uid = reformer.GetUID(); if (!m_IPerceptronTarget.HaveWeaponAndCrossSight(uid)) { WeaponAndCrossSight weaponAndCross = WeaponAndCrossSightFactory.CreatTWeapon(uid, reformer.GetConfig().Id, reformer.GetBaseConfig().SkillId, (WeaponAndCrossSight.WeaponAndCrossSightTypes)reformer.GetConfig().Reticle); //Debug.LogError(string.Format("创建准星 uid = {0}, tid = {1} , type = {2}, null? {3}", uid, weapon.GetConfig().Id, weapon.GetConfig().Reticle , (weaponAndCross== null))); if (weaponAndCross == null) { return; } m_IPerceptronTarget.AddWeaponAndCrossSight(uid, weaponAndCross); } } else { //非转化炉模式 m_IPerceptronTarget.DeleReformerWeaponAndCrossSight(); } }
/// <summary> /// 查找可以比较的数据 /// </summary> /// <param name="data">当前数据</param> /// <param name="compareableDatas">可参与比较的数据列表</param> protected override void FindCompareableData(object data, List <object> compareableDatas) { base.FindCompareableData(data, compareableDatas); if (data == null) { return; } if (!(data is ItemBase)) { return; } ItemBase item = data as ItemBase; if (item.MainType != Category.Blueprint && item.MainType != Category.Warship && item.MainType != Category.Weapon && item.MainType != Category.Reformer && item.MainType != Category.Equipment) { return; } //当前角色的包 ItemContainer container = GetPackage().GetHeroItem(); if (container == null || container.Items == null || container.Items.Count == 0) { return; } //当前出战的飞船 ItemWarShipVO ship = null; foreach (ItemBase heroItem in container.Items.Values) { if (heroItem is ItemWarShipVO) { ship = heroItem as ItemWarShipVO; break; } } //当前是飞船 if (item.MainType == Category.Warship) { if (item != ship) { compareableDatas.Add(ship); } } //当前是飞船的蓝图 else if (item.MainType == Category.Blueprint && (item as ItemDrawingVO).DrawingType == BlueprintL1.Warship) { compareableDatas.Add(ship); } else { IShip iship = (GameFacade.Instance.RetrieveProxy(ProxyName.ShipProxy) as ShipProxy).GetAppointWarShip(); Category mainType = item.MainType; Enum secondaryType = null; if (item is ItemDrawingVO) { ItemDrawingVO blueprint = item as ItemDrawingVO; switch (blueprint.DrawingType) { case BlueprintL1.Weapon: mainType = Category.Weapon; break; case BlueprintL1.Reformer: mainType = Category.Reformer; break; case BlueprintL1.Equipment: FoundryProxy foundryProxy = GameFacade.Instance.RetrieveProxy(ProxyName.FoundryProxy) as FoundryProxy; Item product = foundryProxy.GetItemByProduceKey((int)blueprint.TID); mainType = Category.Equipment; secondaryType = (Enum)ItemTypeUtil.GetItemType(product.Type).EnumList[2]; break; } } else if (item is ItemEquipmentVO) { ItemEquipmentVO equip = item as ItemEquipmentVO; mainType = equip.MainType; secondaryType = equip.EquipmentType; } //武器 if (mainType == Category.Weapon) { ItemBase[] list = new ItemBase[iship.GetWeaponContainer().GetCurrentSizeMax()]; foreach (IWeapon weapon in iship.GetWeaponContainer().GetWeapons()) { list[weapon.GetPos()] = GetPackage().GetItem <ItemWeaponVO>(weapon.GetUID()); } compareableDatas.AddRange(list); } //转化炉 else if (mainType == Category.Reformer) { IReformer reformer = iship.GetReformerContainer().GetReformer(); if (reformer != null) { compareableDatas.Add(GetPackage().GetItem <ItemReformerVO>(reformer.GetUID())); } else { compareableDatas.Add(null); } } //装备 else if (mainType == Category.Equipment) { foreach (IEquipment equip in iship.GetEquipmentContainer().GetEquipments()) { ItemEquipmentVO equipVO = GetPackage().GetItem <ItemEquipmentVO>(equip.GetUID()); Enum type = equipVO.EquipmentType; if (Enum.Equals(type, secondaryType)) { compareableDatas.Add(equipVO); } } } } }