baowen 15 小时之前
父节点
当前提交
9ab11eab22

文件差异内容过多而无法显示
+ 1189 - 175
assets/editor/prefab/SuperFindPanel.prefab


+ 1 - 1
assets/editor/script/MapItem.ts

@@ -15,7 +15,7 @@ export class MapItem extends Component {
 
     init(key: number,isSelect:boolean = false)
     {
-        let mapPath = allMapList[key]
+        let mapPath = allMapList[key].path
         this.selectedSprite.node.active = isSelect
         this._isSelected = isSelect
         this._key = key

+ 64 - 7
assets/editor/script/SelectMapPanel.ts

@@ -1,6 +1,6 @@
-import { _decorator, Button, Component, EditBox, instantiate, Node, ScrollView, UITransform, Vec2, Vec3 } from 'cc';
+import { _decorator, Button, Component, EditBox, instantiate, Label, Node, ScrollView, UITransform, Vec2, Vec3 } from 'cc';
 import { LayerMgr } from '../../script/Manager/LayerMgr';
-import { allMapList, getAllMapKeys, MapData, SuperFind, UserMap } from '../../script/Manager/LocalDataMgr';
+import { allMapList, getAllMapKeys, getOneTypeImgKeyList, imgTypeList, MapData, MapItemData, SuperFind, UserMap } from '../../script/Manager/LocalDataMgr';
 import { MapItem } from './MapItem';
 const { ccclass, property } = _decorator;
 
@@ -18,22 +18,28 @@ export class SelectMapPanel extends Component {
     editBox:EditBox = null;
     @property(Button)
     btnTurn:Button = null;
-
+    @property(Button)
+    btnAll:Button = null;
+    @property(Node)
+    btnsMoreContent:Node = null;
+    @property(Node)
+    selectTypeBtns:Node = null
     _mapData:MapData = null
-    _allMapList:{ [key: number]: string };
+    _allMapList:{ [key: number]: MapItemData };
     _items: Node[] = [];
     _hasCreatedItems:boolean = false;
     protected start(): void {
         this.btnClose.node.on(Node.EventType.TOUCH_END,this.onBtnCloseClick,this)
         this.btnTurn.node.on(Node.EventType.TOUCH_END,this.scrollToItem,this)
+        this.btnAll.node.on(Node.EventType.TOUCH_END,this.onBtnAllClick,this)
     }
 
-    init() {
+    init(mapList:number[] = null) {
         if(this._hasCreatedItems) return;
         this._hasCreatedItems = true;
         this._allMapList = allMapList
         this._mapData = UserMap.getMapData()
-        let allMapKeys = getAllMapKeys()
+        let allMapKeys = mapList? mapList : getAllMapKeys()
         let count = allMapKeys.length;
         for (let i = 0; i < count; i++) {
             this.createItem(allMapKeys[i]);
@@ -56,8 +62,9 @@ export class SelectMapPanel extends Component {
 
     judgeSelect(key)
     {
-        let selMaps = this._mapData.selectedMaps
+        let selMaps = UserMap.getMapData().selectedMaps
         let index = selMaps.indexOf(key)
+        console.log("key",key,"存在",index !== -1)
         return index !== -1
     }
 
@@ -116,6 +123,56 @@ export class SelectMapPanel extends Component {
         // 滚动到该偏移量
         this.scrollView.scrollToOffset(new Vec2(0, offset), 0.5);
     }
+
+    reset(type:string)
+    {
+        this.clearItems()
+        let mapList = getOneTypeImgKeyList(type)
+        this.init(mapList)
+    }
+
+    clearItems()
+    {
+        this._items.forEach((item)=>{
+            item.destroy()
+        })
+        this._items = []
+        this._hasCreatedItems = false
+    }
+
+    onBtnAllClick()
+    {
+        this.selectTypeBtns.active = true
+        this.appearMoreBtns()
+    }
+
+    typeBtns:Node[] = []
+    appearMoreBtns()
+    {
+        if(this.typeBtns.length > 0) 
+        {
+            this.selectTypeBtns.active = true
+            return
+        }
+        let count = imgTypeList.length
+        for(let i = 0; i < count; i++){
+            let itemNode = instantiate(this.btnAll.node);
+            itemNode.parent = this.btnsMoreContent;
+            itemNode.setPosition(0,0,0)
+            itemNode.getComponentInChildren(Label).string = imgTypeList[i]
+            this.typeBtns.push(itemNode)
+        }
+        this.typeBtns.forEach((item)=>{
+            item.on(Node.EventType.TOUCH_END,this.onBtnTypeClick,this)
+        })
+    }
+
+    onBtnTypeClick(event: Event) {
+        let item = event.target as unknown as Node
+        let type = item.getComponentInChildren(Label).string
+        this.reset(type)
+        this.selectTypeBtns.active = false
+    }
 }
 
 

+ 65 - 18
assets/script/Manager/LocalDataMgr.ts

@@ -343,7 +343,7 @@ export class UserMapData {
 
     constructor() {
         let defaultData: MapData = {
-            types: ["全部","爆量"],
+            types: imgTypeList,
             selectedMaps: []
         }
         this._mapData = sys.localStorage.getItem("mapData") ? Object.assign(defaultData, JSON.parse(sys.localStorage.getItem("mapData"))) : defaultData
@@ -365,7 +365,7 @@ export class UserMapData {
         for(let key of selectMapKeys)
         {
             let map = allMapList[key]
-            this._selectMaps.push(map)
+            this._selectMaps.push(map.path)
         }
         this._selectMaps = this._selectMaps.length > 0?this._selectMaps:[defaultMap]
         return this._selectMaps
@@ -389,7 +389,7 @@ export class UserMapData {
     clearData()
     {
         let defaultData: MapData = {
-            types: ["全部","爆量"],
+            types: imgTypeList,
             selectedMaps: []
         }
         this._mapData = defaultData
@@ -404,6 +404,18 @@ export class UserMapData {
         }
         this.saveMapData()
     }
+    addSelectMap2(keys:number[])
+    {
+        for(let key of keys)
+        {
+            let index = this._mapData.selectedMaps.indexOf(key)
+            if(index == -1)
+            {
+                this._mapData.selectedMaps.push(key)
+            }
+        }
+        this.saveMapData()
+    }
 
     removeSelectMap(key:number)
     {
@@ -529,7 +541,7 @@ export class UserSuperFindData {
         this._superFindData.currentBgKey = lastKey
         this.setTitle()
         this._superFindData.levelDesc = `疯狂最强找茬-找小熊-第${lastKey}关`
-        this._superFindData.imgPath = allMapList[lastKey]
+        this._superFindData.imgPath = allMapList[lastKey].path
         this.saveSuperFindData()
     }
 
@@ -539,7 +551,7 @@ export class UserSuperFindData {
         this._superFindData.currentBgKey = nextKey
         this.setTitle()
         this._superFindData.levelDesc = `疯狂最强找茬-找小熊-第${nextKey}关`
-        this._superFindData.imgPath = allMapList[nextKey]
+        this._superFindData.imgPath = allMapList[nextKey].path
         this.saveSuperFindData()
     }
 
@@ -623,19 +635,27 @@ export const allSkinList: { [key: number]: string } = {
 
 export const defaultSkin = "prefab/spine/spine01"
 
-export const allMapList: { [key: number]: string } = {
-    // 背景图片资源
-    1: "image/bg1",
-    2: "image/bg2",
-    3: "image/bg3",
-    4: "image/bg4",
-    5: "image/bg5",
-    6: "image/bg6",
-    7: "image/bg7",
-    8: "image/bg8",
-    9: "image/bg9",
-    10: "image/bg10",
-    11: "image/bg11",
+export interface MapItemData {
+    path: string;
+    type: string;
+}
+
+export const imgTypeList = ["爆量","默认","美女"]
+
+export const allMapList: { [key: number]: MapItemData } = {
+
+    // 背景图片资源,附带分类
+    1: { path: "image/bg1", type: "爆量" },
+    2: { path: "image/bg2", type: "爆量" },
+    3: { path: "image/bg3", type: "爆量" },
+    4: { path: "image/bg4", type: "爆量" },
+    5: { path: "image/bg5", type: "爆量" },
+    6: { path: "image/bg6", type: "美女" },
+    7: { path: "image/bg7", type: "美女" },
+    8: { path: "image/bg8", type: "默认" },
+    9: { path: "image/bg9", type: "默认" },
+    10: { path: "image/bg10", type: "默认" },
+    11: { path: "image/bg11", type: "默认" },
     // 12: "image/bg12",
     // 13: "image/bg13",
     // 14: "image/bg14",
@@ -657,6 +677,33 @@ export const allMapList: { [key: number]: string } = {
     // 30: "image/bg30",
 };
 
+export function getOneTypeImgList(type:string)
+{
+    let list = []
+    for(let key in allMapList)
+    {
+        if(allMapList[key].type == type)
+        {
+            list.push(allMapList[key])
+        }
+    }
+    return list
+}
+
+export function getOneTypeImgKeyList(type:string)
+{
+    let list = []
+    for(let key in allMapList)
+    {
+        if(allMapList[key].type == type)
+        {
+            list.push(key)
+        }
+    }
+    return list
+}
+
+
 /**
  * 获取 所有皮肤 中所有的键
  * @returns 包含所有键的数字数组

部分文件因为文件数量过多而无法显示