コード例 #1
0
    public void KeyDown(int key)
    {
        if (keyContactData == null || iPlayerState == null || iGameState == null || playerState == null)
        {
            return;
        }
        if (iGameState.GameRunType != EnumGameRunType.Unsafa && iGameState.GameRunType != EnumGameRunType.Safe)
        {
            return;
        }
        KeyContactStruct[] keyContactStructs = keyContactData.GetKeyContactStruct(key, temp => temp.keyContactType == EnumKeyContactType.Prap, iPlayerState.KeyContactDataZone);
        if (keyContactStructs.Length == 0)
        {
            return;
        }
        KeyContactStruct keyContactStruct = keyContactStructs[0];
        PlayGoods        playGoods        = playerState.PlayerAllGoods.Where(temp => temp.ID == keyContactStruct.id).FirstOrDefault();

        if (playGoods == null)
        {
            return;
        }
        //暂时这么写
        if (playGoods.GoodsInfo.EnumGoodsType == EnumGoodsType.HFYJ)
        {
            iPlayerState.EatMedicine(playGoods.ID);
        }
    }
コード例 #2
0
 /// <summary>
 /// 设置焦点
 /// 已经在OnEnable处理过第一个焦点获取了,此时不需要重设
 /// </summary>
 public override void SetForcus()
 {
     focused = true;
     //如果当前没有选择焦点的选项则设置一个
     if (!focusUIListItem && uiDepostiList)
     {
         focusUIListItem = uiDepostiList.FirstShowItem();
     }
     if (focusUIListItem && uiDepostiList)
     {
         uiDepostiList.ShowItem(focusUIListItem);
         if (focusUIListItem.childImage)
         {
             focusUIListItem.childImage.enabled = true;
         }
         //设置选择了该物体
         PlayGoods playGoods = (PlayGoods)focusUIListItem.value;
         if (SelectGoodsIDAction != null)
         {
             SelectGoodsIDAction(playGoods.ID);
         }
     }
     else//否则就没有选择
     {
         if (SelectGoodsIDAction != null)
         {
             SelectGoodsIDAction(-1);
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// 监听角色状态更改(主要是装备)
 /// </summary>
 /// <param name="iPlayerState"></param>
 /// <param name="fieldName"></param>
 private void CallBackIPlayerStateState(IPlayerState iPlayerState, string fieldName)
 {
     if (!playerAnimator)
     {
         return;
     }
     //角色装备发生变化
     if (string.Equals(fieldName, GameState.Instance.GetFieldName <IPlayerState, bool>(temp => temp.EquipmentChanged)))
     {
         PlayerState playerState = DataCenter.Instance.GetEntity <PlayerState>();
         PlayGoods   playGoods   = playerState.PlayerAllGoods.Where(temp => temp.GoodsLocation == GoodsLocation.Wearing && temp.leftRightArms != null && temp.leftRightArms.Value == true).FirstOrDefault();
         if (playGoods != null)
         {
             EnumGoodsType enumGoodsType = playGoods.GoodsInfo.EnumGoodsType;
             //与1000相除求出剔除了具体类型后的上层一分类
             //然后与100求余计算出具体的武器分类
             //因为武器的分类是从10开始的因此减去10
             //动画的第一个分类留空为0表示空手,因此加1
             int num = (((int)enumGoodsType) / 1000) % 100 - 10 + 1;
             //如果是武器
             if (enumGoodsType > EnumGoodsType.Arms && enumGoodsType < EnumGoodsType.Arms + 100000)
             {
                 playerAnimator.SetFloat("WeaponType", num);
             }
             else //否则空手
             {
                 playerAnimator.SetFloat("WeaponType", 0);
             }
         }
         else
         {
             playerAnimator.SetFloat("WeaponType", 0);//0表示空手
         }
     }
 }
コード例 #4
0
 /// <summary>
 /// 选择了指定ID的道具
 /// </summary>
 /// <param name="goodsID"></param>
 public void SelectID(int goodsID)
 {
     ClearNowShow();
     if (playerState != null && goodsID >= 0)
     {
         PlayGoods playGoods = playerState.PlayerAllGoods.FirstOrDefault(temp => temp.ID == goodsID);
         if (playGoods != null)
         {
             if (Text_Title)
             {
                 Text_Title.text = playGoods.GoodsInfo.GoodsName;
             }
             if (ItemPrefab && goodsAbilityExplanList != null && ItemExplanValueList != null)
             {
                 List <GoodsAbility> goodsAbilityList = playGoods.GoodsInfo.goodsAbilities;
                 foreach (GoodsAbility goodsAbility in goodsAbilityList)
                 {
                     KeyValuePair <EnumGoodsAbility, string> KVP = goodsAbilityExplanList.FirstOrDefault(temp => temp.Key == goodsAbility.AbilibityKind);
                     if (string.IsNullOrEmpty(KVP.Value) || KVP.Key == EnumGoodsAbility.None)
                     {
                         continue;
                     }
                     GameObject createObj = GameObject.Instantiate(ItemPrefab);
                     createObj.transform.SetParent(AutoPanel);
                     createObj.GetComponent <Text>().text = KVP.Value + ":    " + goodsAbility.Value;
                     createObj.SetActive(true);
                     ItemExplanValueList.Add(createObj);
                 }
             }
         }
     }
 }
コード例 #5
0
    /// <summary>
    /// 移除物品的显示
    /// </summary>
    /// <param name="playGoods"></param>
    protected virtual void RemoveItemShow(PlayGoods playGoods)
    {
        UIListItem[] uiListItems    = ItemUIList.GetAllImtes();
        UIListItem   thisUIListItem = uiListItems.FirstOrDefault(temp =>
        {
            PlayGoods thisPlayGoods = temp.value as PlayGoods;
            if (thisPlayGoods != null && thisPlayGoods == playGoods)
            {
                return(true);
            }
            return(false);
        });

        if (thisUIListItem != null)
        {
            ItemUIList.RemoveItem(thisUIListItem);
            ItemUIList.UpdateUI();
            SelectGoods = ItemUIList.FirstShowItem();
            if (SelectGoods != null)
            {
                ItemUIList.ShowItem(SelectGoods);
                SelectGoods.childImage.enabled = true;
                SelectGoods.childImage.gameObject.SetActive(true);
            }
        }
    }
コード例 #6
0
    /// <summary>
    /// 重新设置格子的显示与数据
    /// </summary>
    private void ResetLatticeValueAndShow()
    {
        PlayGoods[] WearingPlayGoods = playerState.PlayerAllGoods.Where(temp => temp.GoodsLocation == GoodsLocation.Wearing).ToArray();
        //设置对应位置的装备
        foreach (UIFocusItemEquipmentLattice equipmentLattice in allLttices)
        {
            if (equipmentLattice == null)
            {
                continue;
            }
            PlayGoods[] firstCheck = WearingPlayGoods.Where(temp => (int)temp.GoodsInfo.EnumGoodsType > equipmentLattice.minType && (int)temp.GoodsInfo.EnumGoodsType < equipmentLattice.maxType).ToArray();
            if (firstCheck.Length > 0)
            {
                switch (equipmentLattice.handedType)
                {
                case UIFocusItemEquipmentLattice.EnumWeaponType.None:    //不是左右主手武器则直接显示
                    PlayGoods playGoods_None = firstCheck.First();
                    equipmentLattice.value = playGoods_None;
                    equipmentLattice.SetShowImage(playGoods_None.GetGoodsSprite);
                    break;

                case UIFocusItemEquipmentLattice.EnumWeaponType.LeftOneHanded:    //副手武器
                    PlayGoods[] leftOneHanded = firstCheck.Where(temp => temp.leftRightArms != null && temp.leftRightArms.Value == true).ToArray();
                    if (leftOneHanded.Length > 0)
                    {
                        PlayGoods playGoods_LeftOneHanded = leftOneHanded.First();
                        equipmentLattice.value = playGoods_LeftOneHanded;
                        equipmentLattice.SetShowImage(playGoods_LeftOneHanded.GetGoodsSprite);
                    }
                    else
                    {
                        equipmentLattice.value = null;
                        equipmentLattice.SetShowImage(null);
                    }
                    break;

                case UIFocusItemEquipmentLattice.EnumWeaponType.RightOneHanded:
                    PlayGoods[] rightOneHanded = firstCheck.Where(temp => temp.leftRightArms != null && temp.leftRightArms.Value == false).ToArray();
                    if (rightOneHanded.Length > 0)
                    {
                        PlayGoods playGoods_RightOneHanded = rightOneHanded.First();
                        equipmentLattice.value = playGoods_RightOneHanded;
                        equipmentLattice.SetShowImage(playGoods_RightOneHanded.GetGoodsSprite);
                    }
                    else
                    {
                        equipmentLattice.value = null;
                        equipmentLattice.SetShowImage(null);
                    }
                    break;
                }
            }
            else
            {
                equipmentLattice.value = null;
                equipmentLattice.SetShowImage(null);
            }
        }
    }
コード例 #7
0
    /// <summary>
    /// 点击条目后的动作
    /// </summary>
    private void ItemClickAction()
    {
        //卖出物品到商店
        if (SelectGoods == null)
        {
            return;
        }
        PlayGoods playGoods = SelectGoods.value as PlayGoods;

        if (playGoods == null)
        {
            return;
        }
        //计算物品的价格
        int sprice = GoodsSprice(playGoods.GoodsInfo);

        playerState.Sprice        += sprice / 2;
        iPlayerState.SpriteChanged = true;//设置金钱发生变化

        EnumGoodsType baseGoodsType = playGoods.GoodsInfo.EnumGoodsType;

        //如果是药品或道具等消耗品
        if (baseGoodsType > EnumGoodsType.Item && baseGoodsType < EnumGoodsType.SpecialItem)
        {
            //商人自身是否有该消耗品
            PlayGoods businessman_playGoods = businessman.BaseList.FirstOrDefault(temp => temp.GoodsInfo.EnumGoodsType == baseGoodsType);
            //商人回收道具是否有该消耗品
            if (businessman_playGoods == null)
            {
                businessman_playGoods = businessman.SellPropsList.FirstOrDefault(temp => temp.GoodsInfo.EnumGoodsType == baseGoodsType);
            }
            //如果还没有则添加到回收栏
            if (businessman_playGoods == null)
            {
                businessman_playGoods = new PlayGoods(playGoods.ID, playGoods.GoodsInfo, GoodsLocation.None);
                businessman.SellPropsList.Add(businessman_playGoods);
            }
            businessman_playGoods.Count++;
            playGoods.Count--;
            //如果当前数量为0则移除
            if (playGoods.Count <= 0)
            {
                playerState.PlayerAllGoods.Remove(playGoods);
            }
        }
        else
        {
            //移除玩家身上的道具
            playGoods.GoodsLocation = GoodsLocation.None;
            playerState.PlayerAllGoods.Remove(playGoods);
            //将道具转移到商人的回收栏
            businessman.SellPropsList.Add(playGoods);
            //显示列表减少
            RemoveItemShow(playGoods);
        }
    }
コード例 #8
0
    /// <summary>
    /// 移动子焦点(list中的数据,这里不用焦点)
    /// </summary>
    /// <param name="moveType"></param>
    public override void MoveChild(UIFocusPath.MoveType moveType)
    {
        if (focusUIListItem == null)
        {
            focusUIListItem = uiDepostiList.FirstShowItem();
        }
        UIListItem[] tempArrays = uiDepostiList.GetAllImtes();
        if (tempArrays.Length == 0)
        {
            return;
        }
        int index = 0;

        if (focusUIListItem)
        {
            index = tempArrays.ToList().IndexOf(focusUIListItem);
        }
        if (index < 0)
        {
            index = 0;
        }
        switch (moveType)
        {
        case UIFocusPath.MoveType.UP:    //-
            index--;
            break;

        case UIFocusPath.MoveType.DOWN:    //+
            index++;
            break;
        }
        index = Mathf.Clamp(index, 0, tempArrays.Length - 1);
        if (index < tempArrays.Length)
        {
            uiDepostiList.ShowItem(tempArrays[index]);
            if (focusUIListItem && focusUIListItem.childImage)
            {
                focusUIListItem.childImage.enabled = false;
            }
            focusUIListItem = tempArrays[index];
            if (focusUIListItem && focusUIListItem.childImage)
            {
                focusUIListItem.childImage.enabled = true;
            }
            //设置选择了该物体
            PlayGoods playGoods = (PlayGoods)focusUIListItem.value;
            if (SelectGoodsIDAction != null)
            {
                SelectGoodsIDAction(playGoods.ID);
            }
        }
    }
コード例 #9
0
 /// <summary>
 /// 格子的处理动作
 /// </summary>
 public void EquipmentLatticeAction()
 {
     if (nowLattice)
     {
         if (nowLattice.value != null && (nowLattice.value as PlayGoods) != null)
         {
             PlayGoods playGoods = nowLattice.value as PlayGoods;
             playGoods.leftRightArms          = null;
             playGoods.GoodsLocation          = GoodsLocation.Package;
             iPlayerStateRun.EquipmentChanged = true;
         }
     }
 }
コード例 #10
0
 /// <summary>
 /// 用于检测物理技能和普通攻击
 /// </summary>
 /// <param name="iAnimatorState"></param>
 /// <param name="fieldName"></param>
 private void IAnimatorStateChanged(IAnimatorState iAnimatorState, string fieldName)
 {
     if (string.Equals(fieldName, GameState.Instance.GetFieldName <IAnimatorState, EnumPhysicAnimatorType>(temp => temp.PhysicAnimatorType)))
     {
         if (iAnimatorState.PhysicAnimatorType == EnumPhysicAnimatorType.Skill)
         {
             PhysicSkillAudioStruct physicSkillAudioStruct = physicSkillAudios.FirstOrDefault(temp => temp.SkillType == iAnimatorState.PhysicAnimatorSkillType);
             if (physicSkillAudioStruct != null)
             {
                 audioSources[2].clip = physicSkillAudioStruct.Clip;
                 audioSources[2].Play();
             }
         }
         else if (iAnimatorState.PhysicAnimatorType == EnumPhysicAnimatorType.Normal)
         {
             PlayerState playerState = DataCenter.Instance.GetEntity <PlayerState>();
             PlayGoods   playGoods   = playerState.PlayerAllGoods.Where(temp => temp.GoodsLocation == GoodsLocation.Wearing && temp.leftRightArms != null && temp.leftRightArms.Value == false).FirstOrDefault();
             if (playGoods != null)
             {
                 EnumGoodsType enumGoodsType = playGoods.GoodsInfo.EnumGoodsType;
                 //与1000相除求出剔除了具体类型后的上层一分类
                 //然后与100求余计算出具体的武器分类
                 //因为武器的分类是从10开始的因此减去10
                 //动画的第一个分类留空为0表示空手,因此加1
                 int num = (((int)enumGoodsType) / 1000) % 100 - 10 + 1;
                 PhysicNormalAudioStruct physicNormalAudioStruct = physicNormalAudios.FirstOrDefault(temp => temp.WeaponNum == num);
                 if (physicNormalAudioStruct != null)
                 {
                     if (iAnimatorState.PhycisActionNowType == 0)
                     {
                         audioSources[2].clip = physicNormalAudioStruct.Clip1;
                     }
                     else if (iAnimatorState.PhycisActionNowType == 1)
                     {
                         audioSources[2].clip = physicNormalAudioStruct.Clip2;
                     }
                     else if (iAnimatorState.PhycisActionNowType == 2)
                     {
                         audioSources[2].clip = physicNormalAudioStruct.Clip3;
                     }
                     audioSources[2].Play();
                 }
             }
         }
     }
 }
コード例 #11
0
    /// <summary>
    /// 修改物品的显示(一般用于药品的数量变化)
    /// </summary>
    /// <param name="playGoods"></param>
    protected virtual void ChangeItemsShow(PlayGoods playGoods)
    {
        UIListItem[] uiListItems    = ItemUIList.GetAllImtes();
        UIListItem   thisUIListItem = uiListItems.FirstOrDefault(temp =>
        {
            PlayGoods thisPlayGoods = temp.value as PlayGoods;
            if (thisPlayGoods != null && thisPlayGoods == playGoods)
            {
                return(true);
            }
            return(false);
        });

        if (thisUIListItem != null)
        {
            thisUIListItem.childText.text = playGoods.GoodsInfo.GoodsName + "    X" + playGoods.Count;
        }
    }
コード例 #12
0
    /// <summary>
    /// 将当前选额的对象显示在面板上
    /// </summary>
    private void ShowThisGoods()
    {
        if (_selectGoods == null)
        {
            ExplanText.text = "";
            ActionText.text = "";
            return;
        }
        //显示装备说明
        PlayGoods playGoods = SelectGoods.value as PlayGoods;

        ExplanText.text = GoodsExplan(playGoods.GoodsInfo);
        //显示状态出售或购买价格
        int    sprice    = GoodsSprice(playGoods.GoodsInfo);
        string actionStr = ShowSpriceActionValue(sprice);

        ActionText.text = actionStr;
    }
コード例 #13
0
 /// <summary>
 /// 选择了该格子
 /// </summary>
 private void SelectNowLattice()
 {
     if (nowLattice != null)
     {
         //设置选择了物体
         PlayGoods playGoods = nowLattice.value as PlayGoods;
         if (SelectGoodsIDAction != null)
         {
             if (playGoods != null)
             {
                 SelectGoodsIDAction(playGoods.ID);
             }
             else
             {
                 SelectGoodsIDAction(-1);
             }
         }
     }
 }
コード例 #14
0
    /// <summary>
    /// 根据指定的类型和id设置图标
    /// </summary>
    public void InitShow()
    {
        switch (keyLatticeType)
        {
        case EnumKeyContactType.Skill:
            if (ThisSkillStructData == null)
            {
                break;
            }
            if (id > (int)EnumSkillType.MagicCombinedStart)    //组合技能
            {
                SetTargetImage(SkillCombineStaticTools.GetCombineSkillSprite(ThisSkillStructData, id));
            }
            else    //单一的技能
            {
                SkillBaseStruct skillBaseStruct = ThisSkillStructData.SearchSkillDatas(temp => temp.skillType == (EnumSkillType)id).FirstOrDefault();
                if (skillBaseStruct != null)
                {
                    SetTargetImage(skillBaseStruct.skillSprite);
                }
                else
                {
                    SetTargetImage(null);
                }
            }
            break;

        case EnumKeyContactType.Prap:
            if (ThisPlayerState == null)
            {
                break;
            }
            PlayGoods playGoods = ThisPlayerState.PlayerAllGoods.Where(temp => temp.ID == id).FirstOrDefault();
            SetTargetImage(playGoods.GetGoodsSprite);
            break;

        default:
            SetTargetImage(null);
            break;
        }
    }
コード例 #15
0
 /// <summary>
 /// 玩家状态发生变化
 /// </summary>
 /// <param name="iPlayerState"></param>
 /// <param name="name"></param>
 private void IPlayerStateChanged(IPlayerState iPlayerState, string name)
 {
     if (name == GameState.Instance.GetFieldName <IPlayerState, bool>(temp => temp.EquipmentChanged))//主要用于装备发生变化时修改集合
     {
         UIListItem[]      nowUIListItems  = uiDepostiList.GetAllImtes();
         List <UIListItem> mustDeleteItems = new List <UIListItem>();
         foreach (UIListItem item in nowUIListItems)
         {
             PlayGoods playGoods = item.value as PlayGoods;
             if (playGoods.GoodsLocation == GoodsLocation.Wearing)
             {
                 mustDeleteItems.Add(item);
             }
         }
         PlayGoods[]      packageGoods     = playerState.PlayerAllGoods.Where(temp => temp.GoodsLocation == GoodsLocation.Package).ToArray();
         List <PlayGoods> mustAddPlayGoods = new List <PlayGoods>();
         PlayGoods[]      lastPackageGoods = nowUIListItems.Select(temp => temp.value as PlayGoods).ToArray();
         foreach (PlayGoods item in packageGoods)
         {
             if (!lastPackageGoods.Contains(item))
             {
                 mustAddPlayGoods.Add(item);
             }
         }
         //删除需要删除的条目
         foreach (UIListItem item in mustDeleteItems)
         {
             uiDepostiList.RemoveItem(item);
         }
         //添加需要添加的条目
         foreach (PlayGoods item in mustAddPlayGoods)
         {
             UIListItem uiListItem = uiDepostiList.NewItem();
             uiListItem.childText.text = item.GoodsInfo.GoodsName;
             uiListItem.value          = item;
             uiDepostiList.ShowItem(uiListItem);
         }
         uiDepostiList.UpdateUI();
     }
 }
コード例 #16
0
    /// <summary>
    /// 集合中的条目被点击
    /// </summary>
    /// <param name="mouseType"></param>
    /// <param name="target"></param>
    private void UiDepostiList_ItemClickHandle(UIList.ItemClickMouseType mouseType, UIListItem target)
    {
        if (focusUIListItem != null && focusUIListItem.childImage != null)
        {
            focusUIListItem.childImage.enabled = false;
        }
        focusUIListItem = target;
        focusUIListItem.childImage.enabled = true;
        //设置选择了该物体
        PlayGoods playGoods = (PlayGoods)focusUIListItem.value;

        if (SelectGoodsIDAction != null)
        {
            SelectGoodsIDAction(playGoods.ID);
        }
        //处理功能
        switch (mouseType)
        {
        case UIList.ItemClickMouseType.Right:
            ItemAction();
            break;
        }
    }
コード例 #17
0
    private void Show()
    {
        if (skillStructData == null || playerState == null || keyImage == null)
        {
            return;
        }
        KeyContactStruct keyContactStruct = default(KeyContactStruct);

        //这里存在优化空间
        if (r1Press)
        {
            keyContactStruct = keyContactData.GetKeyContactStruct(InputType | (int)EnumInputType.RB, null, iPlayerState.KeyContactDataZone).FirstOrDefault();
        }
        else if (r2Press)
        {
            keyContactStruct = keyContactData.GetKeyContactStruct(InputType | (int)EnumInputType.RT, null, iPlayerState.KeyContactDataZone).FirstOrDefault();
        }
        else if (l1Press)
        {
            keyContactStruct = keyContactData.GetKeyContactStruct(InputType | (int)EnumInputType.LB, null, iPlayerState.KeyContactDataZone).FirstOrDefault();
        }
        else if (l2Press)
        {
            keyContactStruct = keyContactData.GetKeyContactStruct(InputType | (int)EnumInputType.LT, null, iPlayerState.KeyContactDataZone).FirstOrDefault();
        }
        else
        {
            keyContactStruct = keyContactData.GetKeyContactStruct(InputType, null, iPlayerState.KeyContactDataZone).FirstOrDefault();
        }

        switch (keyContactStruct.keyContactType)
        {
        case EnumKeyContactType.None:
            keyImage.sprite       = null;
            innerImage.fillAmount = 0;
            break;

        case EnumKeyContactType.Skill:
            int skillKey = keyContactStruct.id;
            if (skillKey > (int)EnumSkillType.MagicCombinedStart)
            {
                keyImage.sprite = SkillCombineStaticTools.GetCombineSkillSprite(skillStructData, skillKey);
            }
            else
            {
                keyImage.sprite = skillStructData.SearchSkillDatas(temp => (int)temp.skillType == skillKey).Select(temp => temp.skillSprite).FirstOrDefault();
            }
            //这里还需要判断是不是没有冷却的技能,比如魔法释放 普通攻击等
            if (skillKey != (int)EnumSkillType.MagicRelease && skillKey != (int)EnumSkillType.PhysicAttack)
            {
                innerImage.fillAmount = Mathf.Clamp(iSkillState.PublicCoolingTime / 1, 0, 1);
            }
            else
            {
                innerImage.fillAmount = 0;
            }
            break;

        case EnumKeyContactType.Prap:
            PlayGoods playGoods = playerState.PlayerAllGoods.Where(temp => (int)temp.GoodsInfo.EnumGoodsType == keyContactStruct.id).FirstOrDefault();
            if (playGoods != null)
            {
                keyImage.sprite = playGoods.GetGoodsSprite;
            }
            else
            {
                keyImage.sprite = null;
            }
            innerImage.fillAmount = 0;
            break;

        case EnumKeyContactType.Action:
            keyImage.sprite       = keyContactStruct.Sprite;
            innerImage.fillAmount = 0;
            break;
        }
        keyImage.enabled = keyImage.sprite != null;
        r1Press          = false;
        r2Press          = false;
        l1Press          = false;
        l2Press          = false;
    }
コード例 #18
0
 /// <summary>
 /// 检测任务(关于物品)
 /// 物品在外部进行填入(这里只处理检测和移除,物品的生成不做处理)
 /// </summary>
 /// <param name="goodsID">变动了的物品的类型id(EnumGoodsType枚举),内部会判断物品类型,不论是丢弃或者增加</param>
 bool CheckNowTaskGoods(int goodsID)
 {
     if (checkGoodsRunTimeDic == null)
     {
         return(false);
     }
     if (checkGoodsDicTempList == null)
     {
         checkGoodsDicTempList = new List <TaskMap.RunTimeTaskInfo>();
     }
     if (checkGoodsRunTimeDic.Count > 0)
     {
         checkGoodsDicTempList.Clear();
         foreach (KeyValuePair <int, TaskMap.RunTimeTaskInfo> checkGoodsRunTime in checkGoodsRunTimeDic)
         {
             TaskMap.RunTimeTaskInfo runTimeTaskInfo = checkGoodsRunTime.Value;
             if (!runTimeTaskInfo.TaskInfoStruct.NeedGetGoodsCount.ContainsKey((EnumGoodsType)goodsID))//如果该任务不需要判断该物品
             {
                 continue;
             }
             PlayGoods playerGoods = playerState.PlayerAllGoods.Where(temp => (int)temp.GoodsInfo.EnumGoodsType == goodsID).FirstOrDefault();
             if (playerGoods == null)
             {
                 continue;
             }
             runTimeTaskInfo.TaskInfoStruct.GameGetGoodsCount[(EnumGoodsType)goodsID] = playerGoods.Count;
             bool isOver = true;
             foreach (KeyValuePair <EnumGoodsType, int> item in runTimeTaskInfo.TaskInfoStruct.NeedGetGoodsCount)
             {
                 if (runTimeTaskInfo.TaskInfoStruct.GameGetGoodsCount[item.Key] < item.Value)
                 {
                     isOver = false;
                     break;
                 }
             }
             if (isOver)
             {
                 checkGoodsDicTempList.Add(checkGoodsRunTime.Value);
             }
         }
         if (checkGoodsDicTempList.Count > 0)
         {
             foreach (TaskMap.RunTimeTaskInfo runTimeTaskInfo in checkGoodsDicTempList)
             {
                 //如果检测出已完成则移除
                 checkGoodsRunTimeDic.Remove(runTimeTaskInfo.ID);
                 if (!HasCheckTaskID(runTimeTaskInfo.ID))//如果不存在检测项了则直接完成任务
                 {
                     OverTaskID = runTimeTaskInfo.ID;
                     //完成以后从物品栏中移除指定的物品
                     foreach (KeyValuePair <EnumGoodsType, int> item in runTimeTaskInfo.TaskInfoStruct.GameGetGoodsCount)
                     {
                         playerState.PlayerAllGoods
                         .Where(temp => temp.GoodsInfo.EnumGoodsType == item.Key).ToList()
                         .ForEach(temp => temp.Count -= item.Value);
                         playerState.PlayerAllGoods.RemoveAll(temp => temp.Count <= 0);
                     }
                     GoodsChanged = true;
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
 public override void ActionTrigger()
 {
     base.ActionTrigger();
     if (!treasureBoxState)
     {
         //触发宝箱
         treasureBoxState = true;
         if (animator != null)
         {
             animator.SetBool("TreasureBox", treasureBoxState);
         }
         //保存状态
         SaveDataAction(true);
         //发放道具
         Dictionary <EnumGoodsType, ActionInteractiveDataInfo.TreasureBoxStruct> dataDic = ActionInteractiveDataInfo.OtherValue as Dictionary <EnumGoodsType, ActionInteractiveDataInfo.TreasureBoxStruct>;
         if (dataDic != null)
         {
             //实例化数据并填入存档中
             GoodsMetaInfoMations goodsMetaInfoMations = DataCenter.Instance.GetMetaData <GoodsMetaInfoMations>();
             PlayerState          playerState          = DataCenter.Instance.GetEntity <PlayerState>();
             foreach (KeyValuePair <EnumGoodsType, ActionInteractiveDataInfo.TreasureBoxStruct> data in dataDic)
             {
                 EnumGoodsType   baseGoodsType  = data.Key;
                 EnumQualityType qualityTypeMin = data.Value.MinQualityType;
                 EnumQualityType qualityTypeMax = data.Value.MaxQualityType;
                 Goods           addGoods       = goodsMetaInfoMations[baseGoodsType].Clone(true);//获取需要添加物品的原始属性
                 //如果是道具或炼金物品则可以叠加,但是没有品质
                 if (baseGoodsType > EnumGoodsType.Item && baseGoodsType < EnumGoodsType.SpecialItem)
                 {
                     //尝试从玩家道具中获取id,如果没有则新建一个(这个id并没有什么卵用)
                     int addGoodsID = playerState.PlayerAllGoods.Where(temp => temp.GoodsInfo.EnumGoodsType == baseGoodsType).Select(temp => temp.ID).FirstOrDefault();
                     if (addGoodsID == 0)
                     {
                         addGoodsID = NowTimeToID.GetNowID(DataCenter.Instance.GetEntity <GameRunnedState>());
                         PlayGoods playGoods = new PlayGoods(addGoodsID, addGoods, GoodsLocation.Package);
                         playGoods.QualityType = EnumQualityType.White;
                         playGoods.Count       = data.Value.Count;
                         playerState.PlayerAllGoods.Add(playGoods);
                     }
                     else
                     {
                         PlayGoods playGoods = playerState.PlayerAllGoods.FirstOrDefault(temp => temp.ID == addGoodsID);
                         playGoods.Count += data.Value.Count;
                     }
                 }
                 //如果不是道具和炼金物品则不可以叠加,但是存在品质
                 else
                 {
                     int             addGoodsID  = NowTimeToID.GetNowID(DataCenter.Instance.GetEntity <GameRunnedState>());
                     EnumQualityType qualityType = (EnumQualityType)UnityEngine.Random.Range((int)qualityTypeMin, (int)qualityTypeMax + 1);
                     // 根据品质设置属性
                     if (qualityType != EnumQualityType.Red)//如果是唯一的则不用改变属性
                     {
                         //将所有属性随机
                         addGoods.goodsAbilities.ForEach(temp =>
                         {
                             float min  = temp.Value * 0.8f;
                             float max  = temp.Value * 1.2f;
                             temp.Value = (int)UnityEngine.Random.Range(min, max);
                         });
                         //取出用于分割固定属性以及随机属性的条目
                         GoodsAbility goodsAbility_nothing = addGoods.goodsAbilities.FirstOrDefault(temp => temp.AbilibityKind == EnumGoodsAbility.Nothing);
                         int          index = -1;
                         if (goodsAbility_nothing != null)
                         {
                             index = addGoods.goodsAbilities.IndexOf(goodsAbility_nothing);
                         }
                         //存在分割属性
                         if (index > -1 && index + 1 < addGoods.goodsAbilities.Count)
                         {
                             //取出分割项后的可变项
                             List <EnumGoodsAbility> randomAbilitys = Enumerable.Range(index + 1, addGoods.goodsAbilities.Count - index - 1).
                                                                      Select(temp => addGoods.goodsAbilities[temp]).Select(temp => temp.AbilibityKind).ToList();
                             int saveAbilityCount = (int)qualityType;//可保留的属性
                             while (randomAbilitys.Count > saveAbilityCount)
                             {
                                 int removeIndex = UnityEngine.Random.Range(0, randomAbilitys.Count);
                                 EnumGoodsAbility removeGoodsAbility = randomAbilitys[removeIndex];
                                 addGoods.goodsAbilities.RemoveAll(temp => temp.AbilibityKind == removeGoodsAbility);
                                 randomAbilitys.RemoveAt(removeIndex);
                             }
                         }
                     }
                     addGoods.goodsAbilities.RemoveAll(temp => temp.AbilibityKind == EnumGoodsAbility.Nothing);
                     PlayGoods playGoods = new PlayGoods(addGoodsID, addGoods, GoodsLocation.Package);
                     playGoods.QualityType = qualityType;
                     playGoods.Count       = 1;
                     playerState.PlayerAllGoods.Add(playGoods);
                 }
             }
         }
     }
 }
コード例 #20
0
    /// <summary>
    /// 点击条目后的动作
    /// </summary>
    private void ItemClickAction()
    {
        //购买物品到包裹
        if (SelectGoods == null)
        {
            return;
        }
        PlayGoods playGoods = SelectGoods.value as PlayGoods;

        if (playGoods == null)
        {
            return;
        }
        //判断商品的价格,如果可以购买则减去金钱
        int sprice = GoodsSprice(playGoods.GoodsInfo);

        if (playerState.Sprice < sprice)
        {
            return;
        }
        playerState.Sprice        -= sprice;
        iPlayerState.SpriteChanged = true;//设置金钱发生变化

        EnumGoodsType baseGoodsType = playGoods.GoodsInfo.EnumGoodsType;

        //如果是药品或道具等消耗品
        if (baseGoodsType > EnumGoodsType.Item && baseGoodsType < EnumGoodsType.SpecialItem)
        {
            //玩家自身是否存在消耗品
            PlayGoods player_playGoods = playerState.PlayerAllGoods.FirstOrDefault(temp => temp.GoodsInfo.EnumGoodsType == baseGoodsType);
            if (player_playGoods != null)//如果存在则直接加count
            {
                player_playGoods.Count++;
            }
            else//如果不存在则创建
            {
                PlayGoods newPlayGoods = new PlayGoods(playGoods.ID, playGoods.GoodsInfo, GoodsLocation.Package);
                newPlayGoods.Count       = 1;
                newPlayGoods.QualityType = playGoods.QualityType;
                playerState.PlayerAllGoods.Add(newPlayGoods);
            }
            //商店数量减少
            playGoods.Count--;
            if (playGoods.Count <= 0)//如果当前数量归0则移除
            {
                if (businessman.BaseList.Contains(playGoods))
                {
                    businessman.BaseList.Remove(playGoods);
                }
                else
                {
                    businessman.SellPropsList.Remove(playGoods);
                }
                //显示列表减少
                RemoveItemShow(playGoods);
            }
            else//如果没有归零则修改数量的显示
            {
                ChangeItemsShow(playGoods);
            }
        }
        else
        {
            //将道具转移到玩家身上
            playGoods.GoodsLocation = GoodsLocation.Package;
            playerState.PlayerAllGoods.Add(playGoods);
            //移除商人身上的道具
            if (businessman.BaseList.Contains(playGoods))
            {
                businessman.BaseList.Remove(playGoods);
            }
            else
            {
                businessman.SellPropsList.Remove(playGoods);
            }
            //显示列表减少
            RemoveItemShow(playGoods);
        }
    }
コード例 #21
0
    /// <summary>
    /// 更新商人的道具
    /// </summary>
    protected void UpdateBusinessman()
    {
        //获取当前商人
        businessman = businessmanStates.BusinessmanList.FirstOrDefault(temp => temp.BusinessmanID == iInteractiveState.ClickInteractiveNPCID && string.Equals(iGameState.SceneName, temp.BusinessmanScene));
        NPCDataInfo npcDataInfo = npcData.GetNPCDataInfo(iGameState.SceneName, iInteractiveState.ClickInteractiveNPCID);

        if (businessman == null && npcDataInfo != null)
        {
            businessman = new Businessman();
            businessman.BusinessManDataInfo = BusinessmanDataInfo.DeSerializeNow <BusinessmanDataInfo>(npcDataInfo.OtherValue);
            businessman.BusinessmanID       = iInteractiveState.ClickInteractiveNPCID;
            businessman.BusinessmanScene    = iGameState.SceneName;
            businessmanStates.BusinessmanList.Add(businessman);
        }
        if (businessman != null)
        {
            #region 刷新商品
            //如果商人的基础道具不足则刷新
            EnumGoodsType[] baseGoodsTypes = businessman.BusinessManDataInfo.GoodsDic.Select(temp => temp.Key).ToArray();//商人基础的物品
            foreach (EnumGoodsType baseGoodsType in baseGoodsTypes)
            {
                //如果不存在该物品则添加
                if (businessman.BaseList.FirstOrDefault(temp => temp.GoodsInfo.EnumGoodsType == baseGoodsType) == null)
                {
                    Goods addGoods = goodsMetaInfoMations[baseGoodsType].Clone(true);//获取需要添加物品的原始属性
                    BusinessmanDataInfo.GoodsDataInfoInner mustAddDataInfoInner = businessman.BusinessManDataInfo.GoodsDic[baseGoodsType];
                    EnumQualityType qualityTypeMin = mustAddDataInfoInner.MinQualityType;
                    EnumQualityType qualityTypeMax = mustAddDataInfoInner.MaxQualityType;
                    int             count          = mustAddDataInfoInner.Count;
                    //如果是道具或炼金物品则可以叠加,但是没有品质
                    if (baseGoodsType > EnumGoodsType.Item && baseGoodsType < EnumGoodsType.SpecialItem)
                    {
                        //尝试从玩家道具中获取id,如果没有则新建一个(这个id并没有什么卵用)
                        int addGoodsID = playerState.PlayerAllGoods.Where(temp => temp.GoodsInfo.EnumGoodsType == baseGoodsType).Select(temp => temp.ID).FirstOrDefault();
                        if (addGoodsID == 0)
                        {
                            addGoodsID = NowTimeToID.GetNowID(DataCenter.Instance.GetEntity <GameRunnedState>());
                        }
                        PlayGoods playGoods = new PlayGoods(addGoodsID, addGoods, GoodsLocation.None);
                        playGoods.QualityType = EnumQualityType.White;
                        playGoods.Count       = count;
                        businessman.BaseList.Add(playGoods);
                    }
                    //如果不是道具和炼金物品则不可以叠加,但是存在品质
                    else
                    {
                        int             addGoodsID  = NowTimeToID.GetNowID(DataCenter.Instance.GetEntity <GameRunnedState>());
                        EnumQualityType qualityType = (EnumQualityType)UnityEngine.Random.Range((int)qualityTypeMin, (int)qualityTypeMax + 1);
                        // 根据品质设置属性
                        if (qualityType != EnumQualityType.Red)//如果是唯一的则不用改变属性
                        {
                            float minRate = ((int)qualityType) * 0.2f + 0.8f;
                            float maxRate = minRate + 0.2f;
                            //将所有属性随机
                            addGoods.goodsAbilities.ForEach(temp =>
                            {
                                float min  = temp.Value * minRate;
                                float max  = temp.Value * maxRate;
                                temp.Value = (int)UnityEngine.Random.Range(min, max);
                            });
                            //取出用于分割固定属性以及随机属性的条目
                            GoodsAbility goodsAbility_nothing = addGoods.goodsAbilities.FirstOrDefault(temp => temp.AbilibityKind == EnumGoodsAbility.Nothing);
                            int          index = -1;
                            if (goodsAbility_nothing != null)
                            {
                                index = addGoods.goodsAbilities.IndexOf(goodsAbility_nothing);
                            }
                            //存在分割属性
                            if (index > -1 && index + 1 < addGoods.goodsAbilities.Count)
                            {
                                //取出分割项后的可变项
                                List <EnumGoodsAbility> randomAbilitys = Enumerable.Range(index + 1, addGoods.goodsAbilities.Count - index - 1).
                                                                         Select(temp => addGoods.goodsAbilities[temp]).Select(temp => temp.AbilibityKind).ToList();
                                int saveAbilityCount = (int)qualityType;//可保留的属性
                                while (randomAbilitys.Count > saveAbilityCount)
                                {
                                    int removeIndex = UnityEngine.Random.Range(0, randomAbilitys.Count);
                                    EnumGoodsAbility removeGoodsAbility = randomAbilitys[removeIndex];
                                    addGoods.goodsAbilities.RemoveAll(temp => temp.AbilibityKind == removeGoodsAbility);
                                    randomAbilitys.RemoveAt(removeIndex);
                                }
                            }
                        }
                        addGoods.goodsAbilities.RemoveAll(temp => temp.AbilibityKind == EnumGoodsAbility.Nothing);
                        //--------------------
                        PlayGoods playGoods = new PlayGoods(addGoodsID, addGoods, GoodsLocation.None);
                        playGoods.QualityType = qualityType;
                        playGoods.Count       = 1;
                        businessman.BaseList.Add(playGoods);
                    }
                }
            }
            #endregion
        }
    }
コード例 #22
0
    /// <summary>
    /// 创建物品并将物品保存到存档中
    /// </summary>
    /// <param name="playerState"></param>
    /// <param name="goodsMetaInfoMations"></param>
    /// <param name="baseGoodsType"></param>
    /// <param name="minQuality"></param>
    /// <param name="maxQuality"></param>
    /// <param name="count"></param>
    /// <returns></returns>
    public static PlayGoods CreatePlayGoodsAddToPlayData(PlayerState playerState, GoodsMetaInfoMations goodsMetaInfoMations, EnumGoodsType baseGoodsType, EnumQualityType minQuality, EnumQualityType maxQuality, int count)
    {
        PlayGoods playGoods = new PlayGoods();
        Goods     addGoods  = goodsMetaInfoMations[baseGoodsType].Clone(true);//获取需要添加物品的原始属性

        //如果是道具或炼金物品则可以叠加,但是没有品质
        if (baseGoodsType > EnumGoodsType.Item && baseGoodsType < EnumGoodsType.SpecialItem)
        {
            int addGoodsID = playerState.PlayerAllGoods.Where(temp => temp.GoodsInfo.EnumGoodsType == baseGoodsType).Select(temp => temp.ID).FirstOrDefault();
            if (addGoodsID == 0)
            {
                addGoodsID            = NowTimeToID.GetNowID(DataCenter.Instance.GetEntity <GameRunnedState>());
                playGoods             = new PlayGoods(addGoodsID, addGoods, GoodsLocation.Package);
                playGoods.Count       = count;
                playGoods.QualityType = EnumQualityType.White;
                playerState.PlayerAllGoods.Add(playGoods);
            }
            else
            {
                playGoods.Count += count;
            }
        }
        else
        {
            int             addGoodsID  = NowTimeToID.GetNowID(DataCenter.Instance.GetEntity <GameRunnedState>());
            EnumQualityType qualityType = (EnumQualityType)UnityEngine.Random.Range((int)minQuality, (int)maxQuality + 1);
            float           minRate     = ((int)qualityType) * 0.2f + 0.8f;
            float           maxRate     = minRate + 0.2f;
            // 根据品质设置属性
            if (qualityType != EnumQualityType.Red)//如果是唯一的则不用改变属性
            {
                //将所有属性随机(根据品质)
                addGoods.goodsAbilities.ForEach(temp =>
                {
                    float min  = temp.Value * minRate;
                    float max  = temp.Value * maxRate;
                    temp.Value = (int)UnityEngine.Random.Range(min, max);
                });
                //取出用于分割固定属性以及随机属性的条目
                GoodsAbility goodsAbility_nothing = addGoods.goodsAbilities.FirstOrDefault(temp => temp.AbilibityKind == EnumGoodsAbility.Nothing);
                int          index = -1;
                if (goodsAbility_nothing != null)
                {
                    index = addGoods.goodsAbilities.IndexOf(goodsAbility_nothing);
                }
                //存在分割属性
                if (index > -1 && index + 1 < addGoods.goodsAbilities.Count)
                {
                    //取出分割项后的可变项
                    List <EnumGoodsAbility> randomAbilitys = Enumerable.Range(index + 1, addGoods.goodsAbilities.Count - index - 1).
                                                             Select(temp => addGoods.goodsAbilities[temp]).Select(temp => temp.AbilibityKind).ToList();
                    int saveAbilityCount = (int)qualityType;//可保留的属性
                    while (randomAbilitys.Count > saveAbilityCount)
                    {
                        int removeIndex = UnityEngine.Random.Range(0, randomAbilitys.Count);
                        EnumGoodsAbility removeGoodsAbility = randomAbilitys[removeIndex];
                        addGoods.goodsAbilities.RemoveAll(temp => temp.AbilibityKind == removeGoodsAbility);
                        randomAbilitys.RemoveAt(removeIndex);
                    }
                }
                addGoods.goodsAbilities.RemoveAll(temp => temp.AbilibityKind == EnumGoodsAbility.Nothing);
                playGoods             = new PlayGoods(addGoodsID, addGoods, GoodsLocation.Package);
                playGoods.QualityType = qualityType;
                playGoods.Count       = 1;
                playerState.PlayerAllGoods.Add(playGoods);
            }
        }
        return(playGoods);
    }
コード例 #23
0
 /// <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("道具功能暂未实现");
         }
     }
 }
コード例 #24
0
    /// <summary>
    /// 当隐藏时处理
    /// </summary>
    private void OnDisable()
    {
        UIManager.Instance.KeyUpHandle -= Instance_KeyUpHandle;
        if (nowKeySettingLattice)
        {
            nowKeySettingLattice.LostForcus();
        }
        //保存状态
        UIFocus[] uiKeySettingLatticeArray = keySettingFocusPath.UIFocuesArray;
        foreach (UIFocus item in uiKeySettingLatticeArray)
        {
            if (!item)
            {
                continue;
            }
            UIFocusKeySettingLattice uiKeySettingLattice = item as UIFocusKeySettingLattice;
            int inputKey = uiKeySettingLattice.GetKeySettingInput();//输入的按键值
            if (uiKeySettingLattice)
            {
                //KeyContactStruct[] keyContactStructs = keyContactData.GetKeyContactStruct(inputKey);
                KeyContactStruct newTarget = new KeyContactStruct();
                newTarget.id             = uiKeySettingLattice.id;
                newTarget.keyContactType = uiKeySettingLattice.keyLatticeType;
                //if (keyContactStructs.Length > 0)
                //{
                //    newTarget = keyContactStructs[0];
                //}
                //else
                //{
                //设置对象的名字
                switch (newTarget.keyContactType)
                {
                case EnumKeyContactType.None:
                    newTarget.name = "None";
                    break;

                case EnumKeyContactType.Skill:
                    EnumSkillType[] skillTypes = SkillCombineStaticTools.GetCombineSkills(newTarget.id);
                    newTarget.name = SkillCombineStaticTools.GetCombineSkillsName(skillTypes);
                    //如果是火球术
                    if (newTarget.id == SkillCombineStaticTools.GetCombineSkillKey(new EnumSkillType[] { EnumSkillType.FS01, EnumSkillType.YSX01 }))
                    {
                        //给任务系统填入状态
                        INowTaskState iNowTaskState = GameState.Instance.GetEntity <INowTaskState>();
                        iNowTaskState.CheckNowTask(EnumCheckTaskType.Special, (int)TaskMap.Enums.EnumTaskSpecialCheck.SetFireSkillToLattice);
                    }
                    break;

                case EnumKeyContactType.Prap:
                    PlayGoods playGoods = playerState.PlayerAllGoods.FirstOrDefault(temp => temp.ID == newTarget.id);
                    newTarget.name = playGoods.GoodsInfo.GoodsName;
                    break;

                case EnumKeyContactType.Action:
                    newTarget.name = "暂无功能";
                    break;
                }
                //}
                keyContactData.SetKeyContactStruct(inputKey, newTarget);
            }
        }
    }