Beispiel #1
0
 /// <summary>
 /// 当显示时初始化按键数据
 /// </summary>
 private void OnEnable()
 {
     playerState     = DataCenter.Instance.GetEntity <PlayerState>();
     keyContactData  = DataCenter.Instance.GetEntity <KeyContactData>();
     skillStructData = DataCenter.Instance.GetMetaData <SkillStructData>();
     selectTargetPanel.gameObject.SetActive(false);
     UIManager.Instance.KeyUpHandle += Instance_KeyUpHandle;
     enumKeySettingType              = EnumKeySettingType.Lattice;
     if (keySettingFocusPath)
     {
         nowKeySettingLattice = keySettingFocusPath.GetFirstFocus() as UIFocusKeySettingLattice;
         if (nowKeySettingLattice)
         {
             nowKeySettingLattice.SetForcus();
         }
         //初始化显示
         UIFocus[] uiKeySettingLatticeArray = keySettingFocusPath.NewUIFocusArray;// 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);
                 if (keyContactStructs.Length > 0)
                 {
                     uiKeySettingLattice.keyLatticeType = keyContactStructs[0].keyContactType;
                     uiKeySettingLattice.id             = keyContactStructs[0].id;
                 }
                 else
                 {
                     uiKeySettingLattice.keyLatticeType = EnumKeyContactType.None;
                     uiKeySettingLattice.id             = 0;
                 }
                 //初始化显示
                 uiKeySettingLattice.InitShow();
             }
         }
     }
 }
Beispiel #2
0
    /// <summary>
    /// 按键设置框被点击
    /// </summary>
    /// <param name="e"></param>
    private void KeySettingLatticeClick(BaseEventData e)
    {
        PointerEventData pe = e as PointerEventData;

        if (pe.pointerCurrentRaycast.gameObject != null)
        {
            UIFocusKeySettingLattice currentKeySettingLattice = UITools.FindTargetPopup <UIFocusKeySettingLattice>(pe.pointerCurrentRaycast.gameObject.transform);
            if (currentKeySettingLattice)
            {
                if (nowKeySettingLattice)
                {
                    nowKeySettingLattice.LostForcus();
                }
                nowKeySettingLattice = currentKeySettingLattice;
                nowKeySettingLattice.SetForcus();
                //显示集合
                ShowUIList();
            }
        }
    }
Beispiel #3
0
    /// <summary>
    /// 接收输入
    /// </summary>
    /// <param name="keyType"></param>
    /// <param name="rockValue"></param>
    private void Instance_KeyUpHandle(UIManager.KeyType keyType, Vector2 rockValue)
    {
        if (!nowKeySettingLattice && keySettingFocusPath)
        {
            nowKeySettingLattice = keySettingFocusPath.GetFirstFocus() as UIFocusKeySettingLattice;
        }
        switch (enumKeySettingType)
        {
        case EnumKeySettingType.Lattice:    //此时可以移动和确认
            Action <UIFocusPath.MoveType> MoveNExtEndAction = (moveType) =>
            {
                if (keySettingFocusPath)
                {
                    //UIFocusKeySettingLattice currentKeySettingLattice = keySettingFocusPath.GetNextFocus(nowKeySettingLattice, moveType) as UIFocusKeySettingLattice;
                    //UIFocusKeySettingLattice currentKeySettingLattice = keySettingFocusPath.GetNextFocus(nowKeySettingLattice, moveType, UIFocusPath.EnumFocusCheckModel.Vertical) as UIFocusKeySettingLattice;
                    UIFocusKeySettingLattice currentKeySettingLattice = keySettingFocusPath.GetNewNextFocus(nowKeySettingLattice, moveType) as UIFocusKeySettingLattice;
                    if (currentKeySettingLattice != null && !object.Equals(currentKeySettingLattice, nowKeySettingLattice))
                    {
                        nowKeySettingLattice.LostForcus();
                        nowKeySettingLattice = currentKeySettingLattice;
                        nowKeySettingLattice.SetForcus();
                    }
                }
            };
            switch (keyType)
            {
            case UIManager.KeyType.A:        //进入选择
                //显示集合
                ShowUIList();
                break;

            case UIManager.KeyType.LEFT:
                MoveNExtEndAction(UIFocusPath.MoveType.LEFT);
                break;

            case UIManager.KeyType.RIGHT:
                MoveNExtEndAction(UIFocusPath.MoveType.RIGHT);
                break;

            case UIManager.KeyType.UP:
                MoveNExtEndAction(UIFocusPath.MoveType.UP);
                break;

            case UIManager.KeyType.DOWN:
                MoveNExtEndAction(UIFocusPath.MoveType.DOWN);
                break;
            }
            break;

        case EnumKeySettingType.Select:    //此时可以选择技能
            Action <int> MoveListSelect = (addOffset) =>
            {
                UIListItem[] tempArrays = uiKeySettingList.GetAllImtes();
                int          index      = 0;
                if (nowKeySettingListItem)
                {
                    index = tempArrays.ToList().IndexOf(nowKeySettingListItem);
                }
                if (index < 0)
                {
                    index = 0;
                }
                index += addOffset;
                index  = Mathf.Clamp(index, 0, tempArrays.Length - 1);
                if (index < tempArrays.Length && tempArrays.Length > 0)
                {
                    uiKeySettingList.ShowItem(tempArrays[index]);
                    if (nowKeySettingListItem && nowKeySettingListItem.childImage)
                    {
                        nowKeySettingListItem.childImage.enabled = false;
                    }
                    nowKeySettingListItem = tempArrays[index];
                    if (nowKeySettingListItem && nowKeySettingListItem.childImage)
                    {
                        nowKeySettingListItem.childImage.enabled = true;
                    }
                }
            };
            switch (keyType)
            {
            case UIManager.KeyType.A:        //确认选择
                SelectAction();
                break;

            case UIManager.KeyType.UP:
                MoveListSelect(-1);
                break;

            case UIManager.KeyType.DOWN:
                MoveListSelect(1);
                break;
            }
            break;
        }
    }
Beispiel #4
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);
            }
        }
    }