增加行数据结构
@ -25,6 +25,12 @@ namespace XMLTool
|
|||||||
|
|
||||||
public class ImageSelectMapAction : Action
|
public class ImageSelectMapAction : Action
|
||||||
{
|
{
|
||||||
|
public class Row
|
||||||
|
{
|
||||||
|
public string name = "";
|
||||||
|
public List<Item> items = new List<Item>();
|
||||||
|
|
||||||
|
}
|
||||||
public class Item
|
public class Item
|
||||||
{
|
{
|
||||||
public string pic;
|
public string pic;
|
||||||
@ -32,7 +38,7 @@ namespace XMLTool
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<string, string> args = new Dictionary<string, string>();
|
public Dictionary<string, string> args = new Dictionary<string, string>();
|
||||||
public List<Item> items = new List<Item>();
|
public List<Row> rows = new List<Row>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -286,7 +286,7 @@ public class ActionHelper
|
|||||||
case "ImageSelectMap":
|
case "ImageSelectMap":
|
||||||
{
|
{
|
||||||
var dictAction = (XMLTool.ImageSelectMapAction)act;
|
var dictAction = (XMLTool.ImageSelectMapAction)act;
|
||||||
return QFramework.ImageSelectMapAction.Allocate(dictAction.args,dictAction.items);
|
return QFramework.ImageSelectMapAction.Allocate(dictAction.args,dictAction.rows);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
Debug.LogError($"没有找到此Action的类型{act.Type}");
|
Debug.LogError($"没有找到此Action的类型{act.Type}");
|
||||||
|
|||||||
@ -21,14 +21,14 @@ namespace QFramework
|
|||||||
private static readonly SimpleObjectPool<ImageSelectMapAction> mPool =
|
private static readonly SimpleObjectPool<ImageSelectMapAction> mPool =
|
||||||
new SimpleObjectPool<ImageSelectMapAction>(() => new ImageSelectMapAction(), null, 10);
|
new SimpleObjectPool<ImageSelectMapAction>(() => new ImageSelectMapAction(), null, 10);
|
||||||
Dictionary<string, string> datas;
|
Dictionary<string, string> datas;
|
||||||
List<XMLTool.ImageSelectMapAction.Item> items;
|
List<XMLTool.ImageSelectMapAction.Row> rows;
|
||||||
public static ImageSelectMapAction Allocate(Dictionary<string, string> datas, List<XMLTool.ImageSelectMapAction.Item> items, System.Action OnFinished = null)
|
public static ImageSelectMapAction Allocate(Dictionary<string, string> datas, List<XMLTool.ImageSelectMapAction.Row> rows, System.Action OnFinished = null)
|
||||||
{
|
{
|
||||||
var retNode = mPool.Allocate();
|
var retNode = mPool.Allocate();
|
||||||
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
||||||
retNode.Deinited = false;
|
retNode.Deinited = false;
|
||||||
retNode.datas = datas;
|
retNode.datas = datas;
|
||||||
retNode.items = items;
|
retNode.rows = rows;
|
||||||
retNode.Reset();
|
retNode.Reset();
|
||||||
retNode.OnFinished = OnFinished;
|
retNode.OnFinished = OnFinished;
|
||||||
return retNode;
|
return retNode;
|
||||||
@ -70,13 +70,19 @@ namespace QFramework
|
|||||||
data.random = false;
|
data.random = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var item in items)
|
foreach (var rowItem in rows)
|
||||||
{
|
{
|
||||||
data.items.Add(new UIImageSelectMapData.OptionItem()
|
var row = new UIImageSelectMapData.Row();
|
||||||
|
row.name = rowItem.name;
|
||||||
|
data.rows.Add(row);
|
||||||
|
foreach (var item in rowItem.items)
|
||||||
{
|
{
|
||||||
pic = item.pic,
|
row.items.Add(new UIImageSelectMapData.OptionItem()
|
||||||
name = item.name
|
{
|
||||||
});
|
pic = item.pic,
|
||||||
|
name = item.name
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UIKit.OpenPanelAsync<UIImageSelectMap>(uiData: data).ToAction().StartGlobal(() =>
|
UIKit.OpenPanelAsync<UIImageSelectMap>(uiData: data).ToAction().StartGlobal(() =>
|
||||||
|
|||||||
9
Assets/Scripts/UI/UIImageSelectMap.Designer.cs
generated
@ -5,7 +5,7 @@ using QFramework;
|
|||||||
|
|
||||||
namespace QFramework.Example
|
namespace QFramework.Example
|
||||||
{
|
{
|
||||||
// Generate Id:b499f0f9-a71b-40ff-a499-a5e4defad39f
|
// Generate Id:ee191ed8-359d-4628-aa2b-d1711157540d
|
||||||
public partial class UIImageSelectMap
|
public partial class UIImageSelectMap
|
||||||
{
|
{
|
||||||
public const string Name = "UIImageSelectMap";
|
public const string Name = "UIImageSelectMap";
|
||||||
@ -13,20 +13,23 @@ namespace QFramework.Example
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
public RectTransform LeftContent;
|
public RectTransform LeftContent;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
|
public RectTransform RightContent;
|
||||||
|
[SerializeField]
|
||||||
public UnityEngine.UI.Image LeftItem;
|
public UnityEngine.UI.Image LeftItem;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
public UnityEngine.UI.Image RightItem;
|
public UnityEngine.UI.Image RightItem;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
public RectTransform RightContent;
|
public RectTransform RightRowItem;
|
||||||
|
|
||||||
private UIImageSelectMapData mPrivateData = null;
|
private UIImageSelectMapData mPrivateData = null;
|
||||||
|
|
||||||
protected override void ClearUIComponents()
|
protected override void ClearUIComponents()
|
||||||
{
|
{
|
||||||
LeftContent = null;
|
LeftContent = null;
|
||||||
|
RightContent = null;
|
||||||
LeftItem = null;
|
LeftItem = null;
|
||||||
RightItem = null;
|
RightItem = null;
|
||||||
RightContent = null;
|
RightRowItem = null;
|
||||||
|
|
||||||
mData = null;
|
mData = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using System;
|
using System;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace QFramework.Example
|
namespace QFramework.Example
|
||||||
{
|
{
|
||||||
@ -15,6 +16,11 @@ namespace QFramework.Example
|
|||||||
public string pic;
|
public string pic;
|
||||||
public string name;
|
public string name;
|
||||||
}
|
}
|
||||||
|
public class Row
|
||||||
|
{
|
||||||
|
public string name;
|
||||||
|
public List<OptionItem> items = new List<OptionItem>();
|
||||||
|
}
|
||||||
public string scoreName;
|
public string scoreName;
|
||||||
public float totalScore;
|
public float totalScore;
|
||||||
public float rightScore;
|
public float rightScore;
|
||||||
@ -23,7 +29,7 @@ namespace QFramework.Example
|
|||||||
public string wrongLabel;
|
public string wrongLabel;
|
||||||
public string finishedEvent;
|
public string finishedEvent;
|
||||||
public bool random = false;
|
public bool random = false;
|
||||||
public List<OptionItem> items = new List<OptionItem>();
|
public List<Row> rows = new List<Row>();
|
||||||
|
|
||||||
}
|
}
|
||||||
public partial class UIImageSelectMap : UIPanel
|
public partial class UIImageSelectMap : UIPanel
|
||||||
@ -57,31 +63,39 @@ namespace QFramework.Example
|
|||||||
RightContent.RemoveAllChildren();
|
RightContent.RemoveAllChildren();
|
||||||
itemDatas.Clear();
|
itemDatas.Clear();
|
||||||
leftAndRightMap.Clear();
|
leftAndRightMap.Clear();
|
||||||
foreach (var item in mData.items)
|
|
||||||
|
foreach (var row in mData.rows)
|
||||||
{
|
{
|
||||||
var leftObj = GameObject.Instantiate(LeftItem, LeftContent);
|
GameObject rowObj = GameObject.Instantiate(RightRowItem.gameObject, RightContent);
|
||||||
leftObj.name = item.pic;
|
rowObj.transform.Find("Type").GetComponent<TextMeshProUGUI>().text = row.name.Replace("\\n", "\n");
|
||||||
var path = Global.imagePath + item.pic;
|
Transform itemContent = rowObj.transform.Find("Items");
|
||||||
loader.Add2Load(path.ToNetImageResName(), (success, res) =>
|
foreach (var item in row.items)
|
||||||
{
|
{
|
||||||
if (success)
|
var rightObj = GameObject.Instantiate(RightItem, itemContent);
|
||||||
|
rightObj.name = item.pic;
|
||||||
|
rightObj.transform.Find("PicBg/Pic").GetComponent<Image>().color = new Color(1, 1, 1, 0);
|
||||||
|
rightObj.OnPointerEnterEvent(RightOnEnter);
|
||||||
|
rightObj.OnPointerExitEvent(RightOnExit);
|
||||||
|
rightObj.OnPointerClickEvent(RightOnClick);
|
||||||
|
|
||||||
|
var leftObj = GameObject.Instantiate(LeftItem, LeftContent);
|
||||||
|
leftObj.name = item.pic;
|
||||||
|
var path = Global.imagePath + item.pic;
|
||||||
|
loader.Add2Load(path.ToNetImageResName(), (success, res) =>
|
||||||
{
|
{
|
||||||
leftObj.GetComponent<Image>().sprite = Utility.GetSprite(res.Asset as Texture2D);
|
if (success)
|
||||||
}
|
{
|
||||||
});
|
leftObj.GetComponent<Image>().sprite = Utility.GetSprite(res.Asset as Texture2D);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
leftObj.OnBeginDragEvent(LeftOnBeginDrag);
|
leftObj.OnBeginDragEvent(LeftOnBeginDrag);
|
||||||
leftObj.OnDragEvent(LeftOnDrag);
|
leftObj.OnDragEvent(LeftOnDrag);
|
||||||
leftObj.OnEndDragEvent(LeftOnEndDrag);
|
leftObj.OnEndDragEvent(LeftOnEndDrag);
|
||||||
itemDatas.Add(leftObj.gameObject, item);
|
itemDatas.Add(leftObj.gameObject, item);
|
||||||
|
}
|
||||||
var rightObj = GameObject.Instantiate(RightItem, RightContent);
|
|
||||||
rightObj.name = item.pic;
|
|
||||||
rightObj.transform.Find("PicBg/Pic").GetComponent<Image>().color = new Color(1, 1, 1, 0);
|
|
||||||
rightObj.OnPointerEnterEvent(RightOnEnter);
|
|
||||||
rightObj.OnPointerExitEvent(RightOnExit);
|
|
||||||
rightObj.OnPointerClickEvent(RightOnClick);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mData.random)
|
if (mData.random)
|
||||||
{
|
{
|
||||||
Utility.ShuffleChildObjects(LeftContent);
|
Utility.ShuffleChildObjects(LeftContent);
|
||||||
@ -183,7 +197,7 @@ namespace QFramework.Example
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return leftAndRightMap.Count == mData.items.Count;
|
return leftAndRightMap.Count == itemDatas.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LeftOnDrag(PointerEventData data)
|
private void LeftOnDrag(PointerEventData data)
|
||||||
|
|||||||
@ -1718,13 +1718,20 @@ namespace XMLTool
|
|||||||
{
|
{
|
||||||
act.args.Add("random", random.Value);
|
act.args.Add("random", random.Value);
|
||||||
}
|
}
|
||||||
foreach (var itemData in action.Elements("Item"))
|
|
||||||
|
foreach (var rowData in action.Elements("Row"))
|
||||||
{
|
{
|
||||||
act.items.Add(new ImageSelectMapAction.Item()
|
var row = new ImageSelectMapAction.Row();
|
||||||
|
row.name = rowData.Attribute("name")?.Value;
|
||||||
|
act.rows.Add(row);
|
||||||
|
foreach (var itemData in rowData.Elements("Item"))
|
||||||
{
|
{
|
||||||
pic = itemData.Attribute("pic")?.Value,
|
row.items.Add(new ImageSelectMapAction.Item()
|
||||||
name = itemData.Attribute("name")?.Value
|
{
|
||||||
});
|
pic = itemData.Attribute("pic")?.Value,
|
||||||
|
name = itemData.Attribute("name")?.Value
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
newAction = act;
|
newAction = act;
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Data/Image/yushi/乌鸡种翡翠.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
Data/Image/yushi/俄料白玉.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Data/Image/yushi/冰种白翡.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
Data/Image/yushi/和田玉(烟紫玉).png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
Data/Image/yushi/墨玉(透光青).png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
Data/Image/yushi/墨翠.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Data/Image/yushi/天然红翡.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Data/Image/yushi/帝王绿.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
Data/Image/yushi/春带彩翡翠.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
Data/Image/yushi/查罗石(紫龙晶).png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
Data/Image/yushi/烧红翡翠.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Data/Image/yushi/碧玉.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
Data/Image/yushi/糖玉.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
Data/Image/yushi/糯种白翡.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
Data/Image/yushi/紫罗兰翡翠.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
Data/Image/yushi/红沁籽料.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Data/Image/yushi/红糖玉.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
Data/Image/yushi/羊脂白玉.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
Data/Image/yushi/翡翠(黄加绿).png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Data/Image/yushi/翡翠(黄加绿).png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
Data/Image/yushi/阳绿.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
Data/Image/yushi/青玉.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
Data/Image/yushi/黄翡.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
Data/Image/yushi/黑青玉.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
<Module>
|
<Module>
|
||||||
|
|
||||||
<Icon>1折射仪.png</Icon>
|
<Icon>1折射仪.png</Icon>
|
||||||
<Scene>ZheSheYiScene</Scene>
|
<Scene>ZheSheYiScene</Scene>
|
||||||
<Type>All</Type>
|
<Type>All</Type>
|
||||||
<Name>宝石分类</Name>
|
<Name>宝石分类</Name>
|
||||||
<OnlyCurScore>true</OnlyCurScore>
|
<OnlyCurScore>true</OnlyCurScore>
|
||||||
|
|
||||||
<!--状态机-->
|
<!--状态机-->
|
||||||
<FSM name="状态机1">
|
<FSM name="状态机1">
|
||||||
@ -23,39 +23,54 @@
|
|||||||
wrongLabel=""
|
wrongLabel=""
|
||||||
finishedEvent="全部完成"
|
finishedEvent="全部完成"
|
||||||
rightBg="baoshi/背景图.png">
|
rightBg="baoshi/背景图.png">
|
||||||
<Item name="碧玺(红)" pic="baoshi/碧玺(红).png"></Item>
|
|
||||||
<Item name="玻璃猫眼(白)" pic="baoshi/玻璃猫眼(白).png"></Item>
|
<Row name="红色\n(粉红)">
|
||||||
<Item name="查罗石" pic="baoshi/查罗石.png"></Item>
|
<Item name="碧玺(红)" pic="baoshi/碧玺(红).png"></Item>
|
||||||
<Item name="发晶(无色)" pic="baoshi/发晶(无色).png"></Item>
|
<Item name="合成红宝石" pic="baoshi/合成红宝石.png"></Item>
|
||||||
<Item name="方柱石" pic="baoshi/方柱石.png"></Item>
|
<Item name="红玛瑙" pic="baoshi/红玛瑙.png"></Item>
|
||||||
<Item name="橄榄石" pic="baoshi/橄榄石.png"></Item>
|
<Item name="菱锰矿" pic="baoshi/菱锰矿.png"></Item>
|
||||||
<Item name="合成红宝石" pic="baoshi/合成红宝石.png"></Item>
|
</Row>
|
||||||
<Item name="合成尖晶石" pic="baoshi/合成尖晶石.png"></Item>
|
<Row name="黄色\n(橙色)">
|
||||||
<Item name="红玛瑙" pic="baoshi/红玛瑙.png"></Item>
|
|
||||||
<Item name="菱锰矿" pic="baoshi/菱锰矿.png"></Item>
|
<Item name="合成立方氧化锆" pic="baoshi/合成立方氧化锆.png"></Item>
|
||||||
<Item name="合成立方氧化锆" pic="baoshi/合成立方氧化锆.png"></Item>
|
<Item name="磷灰石" pic="baoshi/磷灰石.png"></Item>
|
||||||
<Item name="磷灰石" pic="baoshi/磷灰石.png"></Item>
|
<Item name="石英岩玉" pic="baoshi/石英岩玉.png"></Item>
|
||||||
<Item name="石英岩玉" pic="baoshi/石英岩玉.png"></Item>
|
<Item name="月光石(黄)" pic="baoshi/月光石(黄).png"></Item>
|
||||||
<Item name="月光石(黄)" pic="baoshi/月光石(黄).png"></Item>
|
</Row>
|
||||||
<Item name="合成蓝宝石" pic="baoshi/合成蓝宝石.png"></Item>
|
<Row name="蓝色">
|
||||||
<Item name="托帕石" pic="baoshi/托帕石.png"></Item>
|
<Item name="合成尖晶石" pic="baoshi/合成尖晶石.png"></Item>
|
||||||
<Item name="玉髓(蓝)" pic="baoshi/玉髓(蓝).png"></Item>
|
<Item name="合成蓝宝石" pic="baoshi/合成蓝宝石.png"></Item>
|
||||||
<Item name="碧玺(绿)" pic="baoshi/碧玺(绿).png"></Item>
|
<Item name="托帕石" pic="baoshi/托帕石.png"></Item>
|
||||||
<Item name="合成祖母绿" pic="baoshi/合成祖母绿.png"></Item>
|
<Item name="玉髓(蓝)" pic="baoshi/玉髓(蓝).png"></Item>
|
||||||
<Item name="和田玉(碧玉)" pic="baoshi/和田玉(碧玉).png"></Item>
|
</Row>
|
||||||
<Item name="欧泊(白)" pic="baoshi/欧泊(白).png"></Item>
|
<Row name="绿色">
|
||||||
<Item name="月光石(白)" pic="baoshi/月光石(白).png"></Item>
|
<Item name="碧玺(绿)" pic="baoshi/碧玺(绿).png"></Item>
|
||||||
<Item name="合成蓝宝石" pic="baoshi/合成蓝宝石.png"></Item>
|
<Item name="橄榄石" pic="baoshi/橄榄石.png"></Item>
|
||||||
<Item name="紫晶" pic="baoshi/紫晶.png"></Item>
|
<Item name="合成祖母绿" pic="baoshi/合成祖母绿.png"></Item>
|
||||||
|
<Item name="和田玉(碧玉)" pic="baoshi/和田玉(碧玉).png"></Item>
|
||||||
|
|
||||||
|
</Row>
|
||||||
|
<Row name="无色\n(白)">
|
||||||
|
<Item name="玻璃猫眼(白)" pic="baoshi/玻璃猫眼(白).png"></Item>
|
||||||
|
<Item name="发晶(无色)" pic="baoshi/发晶(无色).png"></Item>
|
||||||
|
<Item name="欧泊(白)" pic="baoshi/欧泊(白).png"></Item>
|
||||||
|
<Item name="月光石(白)" pic="baoshi/月光石(白).png"></Item>
|
||||||
|
</Row>
|
||||||
|
<Row name="紫色">
|
||||||
|
<Item name="查罗石" pic="baoshi/查罗石.png"></Item>
|
||||||
|
<Item name="方柱石" pic="baoshi/方柱石.png"></Item>
|
||||||
|
<Item name="合成蓝宝石" pic="baoshi/合成蓝宝石.png"></Item>
|
||||||
|
<Item name="紫晶" pic="baoshi/紫晶.png"></Item>
|
||||||
|
</Row>
|
||||||
</Action>
|
</Action>
|
||||||
|
|
||||||
|
|
||||||
<Condition type="StrEvent" value="全部完成"></Condition>
|
<Condition type="StrEvent" value="全部完成"></Condition>
|
||||||
|
|
||||||
<Action type="TipWindow" value="恭喜你完成当前模块" btns="确定" audio=""></Action>
|
<Action type="TipWindow" value="恭喜你完成当前模块" btns="确定" audio=""></Action>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</Action>
|
</Action>
|
||||||
</Enter>
|
</Enter>
|
||||||
</State>
|
</State>
|
||||||
@ -67,7 +82,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</Module>
|
</Module>
|
||||||