/// <summary> /// 判断是否是双手武器 /// </summary> /// <param name="enumGoodsType"></param> /// <returns></returns> public static bool IsTwoHandedWeapon(EnumGoodsType enumGoodsType) { return(GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.TwoHandedSword) || //双手剑 GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.Arch) || //弓 GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.CrossBow) || //弩 GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.LongRod)); //长杖 }
/// <summary> /// 设置显示的数组 /// </summary> /// <param name="datas"></param> private void SetEnableArray(EquipmentTypeToObj[] datas) { EnumGoodsType[] goodsTypeArray = playerState.PlayerAllGoods.Where(temp => temp.GoodsLocation == GoodsLocation.Wearing).Select(temp => temp.GoodsInfo.EnumGoodsType).ToArray(); foreach (EquipmentTypeToObj data in datas) { if (data.SelfObj) { if (goodsTypeArray.Contains(data.GoodsType) || goodsTypeArray.Count(temp => GoodsStaticTools.IsChildGoodsNode(temp, data.GoodsType, false)) > 0) { data.SelfObj.SetActive(true); } else { data.SelfObj.SetActive(false); } } } }
/// <summary> /// 判断是否是副手武器 /// </summary> /// <param name="enumGoodsType"></param> /// <returns></returns> public static bool IsLeftOneHandedWeapon(EnumGoodsType enumGoodsType) { return(GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.Shield) || //盾牌 GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.CrystalBall)); //水晶球 }
/// <summary> /// 判断是否是主手武器 /// </summary> /// <param name="enumGoodsType"></param> /// <returns></returns> public static bool IsRightOneHandedWeapon(EnumGoodsType enumGoodsType) { return(GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.SingleHanedSword) || //单手剑 GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.Dagger) || //匕首 GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.ShortRod)); //短杖 }
/// <summary> /// 开始道具的功能 /// 如果是装备则替换,如果是药水则恢复 /// </summary> private void ItemAction() { if (focusUIListItem) { //物品对象 PlayGoods playGoods = (PlayGoods)focusUIListItem.value; EnumGoodsType enumGoodsType = playGoods.GoodsInfo.EnumGoodsType; int goodsTypeInt = (int)enumGoodsType; if (GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.Equipment))//如果是装备类型则替换装备 { //如果是副手武器 if (GoodsStaticTools.IsLeftOneHandedWeapon(enumGoodsType)) { //需要判断当前是否佩戴了双手武器以及副手武器(左手武器),如果佩戴了则需要卸载双手武器 PlayGoods[] twoHandedWeapons = playerState.PlayerAllGoods.Where( temp => temp.GoodsLocation == GoodsLocation.Wearing && (GoodsStaticTools.IsTwoHandedWeapon(temp.GoodsInfo.EnumGoodsType) || (temp.leftRightArms != null && temp.leftRightArms.Value == false))).ToArray(); foreach (PlayGoods _playGoods in twoHandedWeapons) { _playGoods.leftRightArms = null; _playGoods.GoodsLocation = GoodsLocation.Package; } playGoods.leftRightArms = false; } //如果是双手武器 else if (GoodsStaticTools.IsTwoHandedWeapon(enumGoodsType)) { //需要判断当前是否佩戴了副手武器以及主手武器(右手武器),如果佩戴了则需要卸载副手武器 PlayGoods[] oneHandedWeapons = playerState.PlayerAllGoods.Where( temp => temp.GoodsLocation == GoodsLocation.Wearing && (GoodsStaticTools.IsLeftOneHandedWeapon(temp.GoodsInfo.EnumGoodsType) || (temp.leftRightArms != null && temp.leftRightArms.Value == true))).ToArray(); foreach (PlayGoods _playGoods in oneHandedWeapons) { _playGoods.leftRightArms = null; _playGoods.GoodsLocation = GoodsLocation.Package; } playGoods.leftRightArms = true; } //如果是饰品 else if (GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.Ornaments)) { EnumGoodsType?ornamentsType = GoodsStaticTools.GetParentGoodsType(playGoods.GoodsInfo.EnumGoodsType); //从基础的饰品类型向上跳到饰品的分类类型(项链 戒指 护身符 勋章) if (ornamentsType != null && GoodsStaticTools.IsChildGoodsNode(ornamentsType.Value, EnumGoodsType.Ornaments)) { PlayGoods[] ornaments = playerState.PlayerAllGoods.Where( temp => temp.GoodsLocation == GoodsLocation.Wearing && GoodsStaticTools.IsChildGoodsNode(temp.GoodsInfo.EnumGoodsType, ornamentsType.Value)).ToArray(); foreach (PlayGoods _playGoods in ornaments) { _playGoods.GoodsLocation = GoodsLocation.Package; } } } //如果是武器(这里是单手武器,双手武器以及副手在上面已经判断过了 ) else if (GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.Arms)) { //需要卸载所有的右手装备 PlayGoods[] rightHandedWeapons = playerState.PlayerAllGoods.Where( temp => temp.GoodsLocation == GoodsLocation.Wearing && temp.leftRightArms != null && temp.leftRightArms.Value == true).ToArray(); foreach (PlayGoods _playGoods in rightHandedWeapons) { _playGoods.leftRightArms = null; _playGoods.GoodsLocation = GoodsLocation.Package; } playGoods.leftRightArms = true; } //如果是其他装备(防具等) else { EnumGoodsType?armorType = GoodsStaticTools.GetParentGoodsType(playGoods.GoodsInfo.EnumGoodsType, 2); //从基础的防具类型向上跳到防具的大类(头盔大类 盔甲类 鞋子类) if (armorType != null && GoodsStaticTools.IsChildGoodsNode(armorType.Value, EnumGoodsType.Equipment)) { PlayGoods[] ammors = playerState.PlayerAllGoods.Where( temp => temp.GoodsLocation == GoodsLocation.Wearing && GoodsStaticTools.IsChildGoodsNode(temp.GoodsInfo.EnumGoodsType, armorType.Value)).ToArray(); foreach (PlayGoods _playGoods in ammors) { _playGoods.GoodsLocation = GoodsLocation.Package; } } } playGoods.GoodsLocation = GoodsLocation.Wearing; iPlayerStateRun.EquipmentChanged = true; } else if (GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.Elixir))//如果是炼金药剂类则直接服用 { iPlayerStateRun.EatMedicine(playGoods.ID); } else if (GoodsStaticTools.IsChildGoodsNode(enumGoodsType, EnumGoodsType.Item)) //如果是道具 { if (enumGoodsType == EnumGoodsType.MagicScroll) //此处的魔法卷轴有一个任务的特殊检测 { INowTaskState iNowTaskState = GameState.Instance.GetEntity <INowTaskState>(); iNowTaskState.CheckNowTask(EnumCheckTaskType.Special, (int)TaskMap.Enums.EnumTaskSpecialCheck.SummonsScrollMagic); } Debug.Log("道具功能暂未实现"); } } }