示例#1
0
    void OnBlockPatternClick(int index)
    {
        if (PEBuildingMan.Self == null)
        {
            return;
        }

        if (!mWndCtrl.mBlockPatternList[index].IsActive)
        {
            //lz-2016.10.31 Insufficient skill to use this item.
            new PeTipMsg(PELocalization.GetString(8000854), PeTipMsg.EMsgLevel.Warning, PeTipMsg.EMsgType.Misc);
            return;
        }


        int i = 0;

        foreach (var kvp in BSPattern.s_tblPatterns)
        {
            if (i == index)
            {
                if (mWndCtrl.BlockMatSelectIndex == -1)
                {
                    // Voxel Mat is selected ?  Swicth it to block mat !
                    if (mWndCtrl.TextureListSelectIndex != -1)
                    {
                        int itemId = mWndCtrl.mVoxelMatList[mWndCtrl.TextureListSelectIndex].ItemId;
                        PEBuildingMan.Self.Manipulator.MaterialType = (byte)PEBuildingMan.GetBlockMaterialType(itemId);
                        int find_index = mWndCtrl.mBlockMatList.FindIndex(item0 => item0.ItemId == itemId);
                        if (find_index != -1)
                        {
                            mWndCtrl.BlockMatSelectIndex = find_index;
                        }
                        else
                        {
                            mWndCtrl.BlockMatSelectIndex = 0;
                        }

                        mWndCtrl.DisselectVoxel();
                    }
                    else
                    {
                        PEBuildingMan.Self.Manipulator.MaterialType = (byte)PEBuildingMan.GetBlockMaterialType(mWndCtrl.mBlockMatList[0].ItemId);
                        mWndCtrl.BlockMatSelectIndex = 0;
                    }
                }
                ItemAsset.ItemProto item = ItemAsset.ItemProto.GetItemData(mWndCtrl.mBlockMatList[mWndCtrl.BlockMatSelectIndex].ItemId);
                if (!GameUI.Instance.mSkillWndCtrl._SkillMgr.CheckBuildBlockLevel(item.level))
                {
                    PEBuildingMan.Self.Manipulator.MaterialType = 2;
                }
                PEBuildingMan.Self.Pattern = kvp.Value;

                ChangeBrushToBox();
                break;
            }
            i++;
        }
    }
示例#2
0
    void OnBlockMatClick(int index)
    {
        if (PEBuildingMan.Self == null)
        {
            return;
        }

        if (!mWndCtrl.mBlockMatList[index].IsActive)
        {
            //lz-2016.10.31 Insufficient skill to use this item.
            new PeTipMsg(PELocalization.GetString(8000854), PeTipMsg.EMsgLevel.Warning, PeTipMsg.EMsgType.Misc);
            return;
        }

        mWndCtrl.DisselectVoxel();

        PEBuildingMan.Self.Manipulator.MaterialType = (byte)PEBuildingMan.GetBlockMaterialType(mWndCtrl.mBlockMatList[index].ItemId);

        //lw:2017.4.6 Crash修复
        if (GameUI.Instance.mSkillWndCtrl != null && GameUI.Instance.mSkillWndCtrl._SkillMgr != null &&
            !GameUI.Instance.mSkillWndCtrl._SkillMgr.CheckBuildShape(mWndCtrl.BlockPatternSelectIndex))
        {
            PEBuildingMan.Self.Pattern = BSPattern.DefaultB1;
        }
        else
        {
            if (mWndCtrl.BlockPatternSelectIndex == -1)
            {
                PEBuildingMan.Self.Pattern = BSPattern.DefaultB1;
            }
            else
            {
                PEBuildingMan.Self.Pattern = BSPattern.s_tblPatterns[mWndCtrl.mBlockPatternList[mWndCtrl.BlockPatternSelectIndex].ItemId];
            }
        }

        ChangeBrushToBox();
    }
示例#3
0
    void OnMenuQuickBarClick(UIBuildWndItem item)
    {
        if (item.mTargetItemType != UIBuildWndItem.ItemType.mNull &&
            item.mTargetItemType != UIBuildWndItem.ItemType.mMenu &&
            !item.IsActive)
        {
            //lz-2016.10.31 Insufficient skill to use this item.
            new PeTipMsg(PELocalization.GetString(8000854), PeTipMsg.EMsgLevel.Warning, PeTipMsg.EMsgType.Misc);
            return;
        }


        switch (item.mTargetItemType)
        {
        case UIBuildWndItem.ItemType.mVoxelType:
        {
            if (PEBuildingMan.Self != null)
            {
                if (!GameUI.Instance.mSkillWndCtrl._SkillMgr.CheckUnlockBuildBlockVoxel())
                {
                    return;
                }
                PEBuildingMan.Self.Manipulator.MaterialType = (byte)item.ItemId;
                PEBuildingMan.Self.Pattern = BSPattern.DefaultV1;

                mWndCtrl.DisselectBlock();
                // Refresh the selected voxel mat for control window
                int itemID = BSVoxelMatMap.GetItemID(item.ItemId);
                for (int i = 0; i < mWndCtrl.mVoxelMatList.Count; i++)
                {
                    if (mWndCtrl.mVoxelMatList[i].ItemId == itemID)
                    {
                        mWndCtrl.TextureListSelectIndex = i;

                        OnVoxelMatItemClick(i);

                        mWndCtrl.TypeSelectIndex = item.mTargetIndex;
                        break;
                    }
                }

                ChangeBrushToBox();
            }
        } break;

        case UIBuildWndItem.ItemType.mBlockMat:
        {
            if (PEBuildingMan.Self != null)
            {
                PEBuildingMan.Self.Manipulator.MaterialType = (byte)PEBuildingMan.GetBlockMaterialType(item.ItemId);

                if (PEBuildingMan.Self.Pattern == null || PEBuildingMan.Self.Pattern.type == EBSVoxelType.Voxel)
                {
                    if (mWndCtrl.BlockPatternSelectIndex == -1)
                    {
                        PEBuildingMan.Self.Pattern = BSPattern.DefaultB1;
                    }
                    else
                    {
                        if (mWndCtrl.mBlockPatternList.Count > mWndCtrl.BlockPatternSelectIndex && mWndCtrl.TextureListSelectIndex > -1)
                        {
                            PEBuildingMan.Self.Pattern = BSPattern.s_tblPatterns[mWndCtrl.mBlockPatternList[mWndCtrl.BlockPatternSelectIndex].ItemId];
                        }
                    }
                }

                mWndCtrl.DisselectVoxel();

                // Refresh the selected block mat for control window
                for (int i = 0; i < mWndCtrl.mBlockMatList.Count; i++)
                {
                    if (mWndCtrl.mBlockMatList[i].ItemId == item.ItemId)
                    {
                        mWndCtrl.BlockMatSelectIndex = i;
                        OnBlockMatClick(i);
                        break;
                    }
                }

                ChangeBrushToBox();
            }
        } break;

        case UIBuildWndItem.ItemType.mBlockPattern:
        {
            if (PEBuildingMan.Self != null)
            {
                if (PEBuildingMan.Self.Pattern == null)
                {
                    OnBlockMatClick(0);
                }
                else if (PEBuildingMan.Self.Pattern.type == EBSVoxelType.Voxel)
                {
                    if (mWndCtrl.mVoxelMatList.Count > mWndCtrl.TextureListSelectIndex && mWndCtrl.TextureListSelectIndex > -1)
                    {
                        PEBuildingMan.Self.Manipulator.MaterialType = (byte)PEBuildingMan.GetBlockMaterialType(mWndCtrl.mVoxelMatList[mWndCtrl.TextureListSelectIndex].ItemId);
                    }
                }

                mWndCtrl.DisselectVoxel();

                int i = 0;
                foreach (var kvp in BSPattern.s_tblPatterns)
                {
                    if (i == item.mTargetIndex)
                    {
                        if (mWndCtrl.TextureListSelectIndex != -1)
                        {
                            int itemId = mWndCtrl.mVoxelMatList[mWndCtrl.TextureListSelectIndex].ItemId;
                            PEBuildingMan.Self.Manipulator.MaterialType = (byte)PEBuildingMan.GetBlockMaterialType(itemId);
                            int find_index = mWndCtrl.mBlockMatList.FindIndex(item0 => item0.ItemId == itemId);
                            if (find_index != -1)
                            {
                                mWndCtrl.BlockMatSelectIndex = find_index;
                            }
                            else
                            {
                                mWndCtrl.BlockMatSelectIndex = 0;
                            }
                        }
                        else if (mWndCtrl.BlockMatSelectIndex == -1)
                        {
                            PEBuildingMan.Self.Manipulator.MaterialType = (byte)PEBuildingMan.GetBlockMaterialType(mWndCtrl.mBlockMatList[0].ItemId);
                            mWndCtrl.BlockMatSelectIndex = 0;
                        }

                        PEBuildingMan.Self.Pattern = kvp.Value;

                        break;
                    }
                    i++;
                }

                if (item.mTargetIndex != -1)
                {
                    mWndCtrl.BlockPatternSelectIndex = item.mTargetIndex;
                }

                ChangeBrushToBox();
            }
        } break;

        default:
            break;
        }
    }