This commit is contained in:
lq 2024-12-27 23:42:49 +08:00
commit 1441e13a50
4 changed files with 327 additions and 9 deletions

View File

@ -759,6 +759,7 @@ public class test : MonoBehaviour
MoveRequest taskUpdateRequest = ProtoBufffer.DeSerialize<MoveRequest>(bytes);
Debug.Log(taskUpdateRequest);
break;
//对象触发操作

View File

@ -217,7 +217,7 @@ RectTransform:
m_Children:
- {fileID: 2059853628}
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@ -999,10 +999,11 @@ MonoBehaviour:
m_GameObject: {fileID: 1416567123}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b2ff411b5e682c439d271893fe57cf2, type: 3}
m_Script: {fileID: 11500000, guid: c4ed3303e02a8594c8bac0747d38a1b9, type: 3}
m_Name:
m_EditorClassIdentifier:
jSONReader: {fileID: 2009348684}
isYou: 1
--- !u!1 &1509783291
GameObject:
m_ObjectHideFlags: 0
@ -1177,6 +1178,203 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1617184227}
m_CullTransparentMesh: 1
--- !u!1001 &1750337032
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 919949400, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_Enabled
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_Pivot.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_Pivot.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMax.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMin.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157411, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1986279549173157415, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_Name
value: Command_End
objectReference: {fileID: 0}
- target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5824380172705816005, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6164110187781327644, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8544101838369953969, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchoredPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8618474577547420637, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 807d6c3842cc1714caf2b4497e4daed7, type: 3}
--- !u!1 &1946593407
GameObject:
m_ObjectHideFlags: 0
@ -1379,7 +1577,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &3077635299975306478
PrefabInstance:
@ -1412,6 +1610,14 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1407198451437384586, guid: 940be89243a038b4090a77556e45a06d, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1407198451437384586, guid: 940be89243a038b4090a77556e45a06d, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 1407198451904434455, guid: 940be89243a038b4090a77556e45a06d, type: 3}
propertyPath: m_SizeDelta.x
value: 0
@ -1452,6 +1658,14 @@ PrefabInstance:
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3032695104264456879, guid: 940be89243a038b4090a77556e45a06d, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3032695104264456879, guid: 940be89243a038b4090a77556e45a06d, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3032695104320383594, guid: 940be89243a038b4090a77556e45a06d, type: 3}
propertyPath: m_AnchorMax.y
value: 0
@ -1484,6 +1698,14 @@ PrefabInstance:
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3032695105467395617, guid: 940be89243a038b4090a77556e45a06d, type: 3}
propertyPath: m_SizeDelta.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3032695105467395617, guid: 940be89243a038b4090a77556e45a06d, type: 3}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3077635299444999927, guid: 940be89243a038b4090a77556e45a06d, type: 3}
propertyPath: m_Pivot.x
value: 0
@ -1572,6 +1794,10 @@ PrefabInstance:
propertyPath: m_Name
value: FreePanel_End
objectReference: {fileID: 0}
- target: {fileID: 3077635299444999931, guid: 940be89243a038b4090a77556e45a06d, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4030979446590429124, guid: 940be89243a038b4090a77556e45a06d, type: 3}
propertyPath: m_AnchorMax.y
value: 0

View File

@ -38,6 +38,7 @@ public class JSONReader : MonoBehaviour
public Dictionary<int, NPCData> OpcNameDictionary=new Dictionary<int, NPCData>();
public Dictionary<string, List<Select>> ZZFindTaskID = new Dictionary<string, List<Select>>();
void Awake()
{
// 解析 NPC 和 Location 数据
@ -236,7 +237,6 @@ public class JSONReader : MonoBehaviour
{
OpcNameDictionary[npc.ID]= npc;
}
return OpcNameDictionary;
}
//找到玩家接取的任务ID对应的

View File

@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class ZZZPlayer : MonoBehaviour
@ -7,10 +8,13 @@ public class ZZZPlayer : MonoBehaviour
public static ZZZPlayer CSZS;
public JSONReader jSONReader;
public Dictionary<int, string> CSB1 = new Dictionary<int, string>(); //Key是判断是不是一组string是ID tanchuang1用的
public bool isYou=true;
public void Start()
{
SetPlayerID("11007");
// SetPlayerID("11007");
FindPlayerTaskID(10810, "tanchuang1");
////遍历字典
//foreach (KeyValuePair<string, List<string>> kvp in PlayerID)
//{
@ -73,7 +77,7 @@ public class ZZZPlayer : MonoBehaviour
}
}
/// <summary>
/// 解析以 "|" 分隔的字符串并返回一个 List
/// 判断那些角色可以接取任务
/// </summary>
/// <param name="input">输入的字符串</param>
/// <returns>解析后的 List如果输入为空则返回空列表</returns>
@ -90,13 +94,69 @@ public class ZZZPlayer : MonoBehaviour
}
/// <summary>
/// 判断数字是否存在于字符串中
/// 判断玩家是否接取这个任务或者(返回是bool)
/// </summary>
/// <param name="data">原始字符串</param>
/// <param name="number">要检查的数字</param>
/// <param number="number">要检查的数字</param>
/// <param Type="Type">弹窗名</param>
/// <returns>是否存在</returns>
public void FindPlayerTaskID(int number,string Type)
{
foreach (var item in jSONReader.ZZSelectsDictionary)
{
Select data = item.Value;
if (data.AppliedUI == "tanchuang1")
{
var a = GetNumberBeforeComma(data.Group);
Debug.Log("bbbb");
//先用Grop分组
if (!CSB1.ContainsKey(a))
{
CSB1.Add(a, data.ID);// 更新值
}
}
}
TwoFind(number);
}
public void TwoFind(int number)
{
//再一次来判断
if (isYou)
{
Debug.Log("进来了脸脸了了了了了了脸脸了脸脸了了了脸脸了了");
Debug.Log(CSB1.Count);
foreach (KeyValuePair<int, string> kvp in CSB1)
{
Debug.Log("进不来了");
int key = kvp.Key;
string value = kvp.Value;
// 将字符串拆分为 List<string>
List<string> values = new List<string>(value.Split(','));
// 对值列表进行对比
for (int i = 0; i < values.Count; i++)
{
Debug.Log("进不来了11111");
for (int j = i + 1; j < values.Count; j++)
{
Debug.Log("进不来了22222");
isYou = IsNumberInData(values[j], number);
if (isYou)
{
break;
}
}
if (isYou)
{
break;
}
}
}
}
}
public bool IsNumberInData(string data, int number)
{
// 按 # 分割 OR 条件组
string[] orGroups = data.Split('#');
@ -124,5 +184,36 @@ public class ZZZPlayer : MonoBehaviour
}
return false; // 如果所有条件都不匹配,返回 false
}
/// <summary>
/// 解析并提取逗号(,)前的数字(判断分组)
/// </summary>
/// <param name="data">输入字符串</param>
/// <returns>返回一个包含数字的列表</returns>
/// <summary>
/// 获取逗号(,或,)前的数字
/// </summary>
/// <param name="data">输入的字符串(例如 "12315"</param>
/// <returns>逗号前的数字,如果解析失败返回 -1</returns>
public int GetNumberBeforeComma(string data)
{
Debug.Log("aaaa");
if (string.IsNullOrEmpty(data))
{
Debug.LogWarning("输入为空或 null");
return -1;
}
// 按逗号分割(支持中文 "" 和英文 ","
string[] parts = data.Split(new char[] { '', ',' });
// 检查分割结果并尝试解析
if (parts.Length > 0 && int.TryParse(parts[0], out int number))
{
return number; // 返回解析成功的数字
}
Debug.LogWarning($"无法解析逗号前的数字:{data}");
return -1; // 解析失败返回 -1
}
}