任务接口和相关函数

This commit is contained in:
huyulong 2024-12-05 20:21:15 +08:00
parent feda86e6c3
commit 47787b8bfd
8 changed files with 316 additions and 40 deletions

View File

@ -1,22 +0,0 @@
[
{
"ID": "11001",
"Text": "测试任务1",
"Note": "测试任务"
},
{
"ID": "11002",
"Text": "测试任务2",
"Note": "测试任务"
},
{
"ID": "11003",
"Text": "测试任务3",
"Note": "测试任务"
},
{
"ID": "11004",
"Text": "测试任务4",
"Note": "测试任务"
}
]

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: d5e54aa3c34f90f48ac60f40191f2532
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@ -7,6 +7,16 @@ using DG.Tweening;
public class TaskPanel : Base
{
public List<int> taskId = new List<int>();
public Transform contentTrans;
public GameObject taskPrefab;
public JSONReader JSONReader;
public Dictionary<int, Language> taskDic = new Dictionary<int, Language>();
public Button closeBtn;
private bool isOpen = false;
@ -16,8 +26,21 @@ public class TaskPanel : Base
{
closeBtn.onClick.AddListener(CloseBtn);
InitTask();
}
public void InitTask()
{
for(int i = 0; i < taskId.Count;i++)
{
GameObject go = GameObject.Instantiate(taskPrefab, contentTrans);
go.transform.name = "Task_" + i;
}
}
public void CloseBtn()
{
if (isOpen)//关闭任务面板
@ -34,6 +57,10 @@ public class TaskPanel : Base
}
}
// Update is called once per frame
void Update()
{

View File

@ -1,4 +1,24 @@
[
{
"ID": "2001",
"Text": "厨房起火",
"Note": "事故位置"
},
{
"ID": "2002",
"Text": "学生宿舍起火",
"Note": "事故位置-测试"
},
{
"ID": "2003",
"Text": "测试位置1",
"Note": "事故位置-测试"
},
{
"ID": "2004",
"Text": "测试位置2",
"Note": "事故位置-测试"
},
{
"ID": "6001",
"Text": "小学生",
@ -79,11 +99,31 @@
"Text": "武侯实验小学",
"Note": "场景名"
},
{
"ID": "40002",
"Text": "协和医院",
"Note": "场景名"
},
{
"ID": "40003",
"Text": "2号线地铁工地",
"Note": "场景名"
},
{
"ID": "9000",
"Text": "学校",
"Note": "场景分类"
},
{
"ID": "9001",
"Text": "医院",
"Note": "场景分类"
},
{
"ID": "9002",
"Text": "建筑工地",
"Note": "场景分类"
},
{
"ID": "10001",
"Text": "1",
@ -739,25 +779,210 @@
"Text": "131",
"Note": "选项文本"
},
{
"ID": "10199",
"Text": "让学生赶紧去操场集合",
"Note": "选项文本"
},
{
"ID": "10200",
"Text": "“跟在我后面”",
"Note": "选项文本"
},
{
"ID": "11001",
"Text": "测试任务1",
"Note": "测试任务"
"Text": "扑灭明火(非困难难度)-总指挥",
"Note": "任务"
},
{
"ID": "11002",
"Text": "测试任务2",
"Note": "测试任务"
"Text": "扑灭明火(困难难度)-总指挥",
"Note": "任务"
},
{
"ID": "11003",
"Text": "测试任务3",
"Note": "测试任务"
"Text": "疏散学生(非困难难度)-总指挥",
"Note": "任务"
},
{
"ID": "11004",
"Text": "测试任务4",
"Note": "测试任务"
"Text": "疏散学生(困难难度)-总指挥",
"Note": "任务"
},
{
"ID": "11005",
"Text": "处理上报人员受伤-总指挥",
"Note": "任务"
},
{
"ID": "11006",
"Text": "处理上报请求增援-总指挥",
"Note": "任务"
},
{
"ID": "11007",
"Text": "穿戴防护服-抢险救援",
"Note": "任务"
},
{
"ID": "11008",
"Text": "扑灭明火-抢险救援",
"Note": "任务"
},
{
"ID": "11009",
"Text": "扑灭明火(不用穿防护服)-抢险救援",
"Note": "任务"
},
{
"ID": "11010",
"Text": "消火栓操作增援-抢险救援-同组增援",
"Note": "任务"
},
{
"ID": "11011",
"Text": "救助受伤人员-医疗救护",
"Note": "任务"
},
{
"ID": "11012",
"Text": "紧急救助昏迷人员-医疗救护",
"Note": "任务"
},
{
"ID": "11013",
"Text": "拨打120报警-医疗救护",
"Note": "任务"
},
{
"ID": "11014",
"Text": "转移无法移动的学生-医疗救护",
"Note": "任务"
},
{
"ID": "11015",
"Text": "疏散任务-非困难",
"Note": "任务"
},
{
"ID": "11045",
"Text": "清点人数-非困难",
"Note": "任务"
},
{
"ID": "11075",
"Text": "清点教室人数-困难",
"Note": "任务"
},
{
"ID": "11105",
"Text": "疏散任务-困难",
"Note": "任务"
},
{
"ID": "11135",
"Text": "断电、切断燃气供应-后勤组",
"Note": "任务"
},
{
"ID": "11136",
"Text": "运送灭火器给起火点区域的抢险救援组",
"Note": "任务"
},
{
"ID": "11137",
"Text": "后勤组转移可燃物",
"Note": "任务"
},
{
"ID": "11138",
"Text": "运送灭火器给起火点区域的抢险救援组",
"Note": "任务"
},
{
"ID": "11139",
"Text": "转移可燃物-后勤组",
"Note": "任务"
},
{
"ID": "11140",
"Text": "布置警戒线",
"Note": "任务"
},
{
"ID": "11141",
"Text": "拨打119报警-后勤组",
"Note": "任务"
},
{
"ID": "11142",
"Text": "将滞留在楼上的学生带下楼-搜寻组",
"Note": "任务"
},
{
"ID": "11143",
"Text": "转移疏散通道上的障碍物-后勤组",
"Note": "任务"
},
{
"ID": "11144",
"Text": "切断燃气-逻辑判定任务-玩家不可见",
"Note": "任务"
},
{
"ID": "11145",
"Text": "疏散组触发选项用-玩家不可见-非1楼",
"Note": "任务"
},
{
"ID": "11146",
"Text": "疏散组触发选项用-玩家不可见-1楼",
"Note": "任务"
},
{
"ID": "11147",
"Text": "困难触发清点教室人数用-玩家不可见",
"Note": "任务"
},
{
"ID": "11148",
"Text": "困难选择疏散楼梯2楼-总指挥触发选项用-玩家不可见",
"Note": "任务"
},
{
"ID": "11152",
"Text": "困难总指挥触发广播让疏散用-玩家不可见",
"Note": "任务"
},
{
"ID": "11153",
"Text": "医疗救护组转移惊颤学生",
"Note": "任务"
},
{
"ID": "11154",
"Text": "医疗救护组转移负伤学生",
"Note": "任务"
},
{
"ID": "11155",
"Text": "医疗救护组-转移角色",
"Note": "任务"
},
{
"ID": "11156",
"Text": "医疗救护组-急救角色",
"Note": "任务"
},
{
"ID": "11158",
"Text": "医疗救护组-包扎-行动能力受限",
"Note": "任务"
},
{
"ID": "11159",
"Text": "打开学校大门迎接消防队伍",
"Note": "任务"
},
{
"ID": "20000",

View File

@ -6804,7 +6804,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 896229b2da4cc204aae01b62e5129e22, type: 3}
m_Name:
m_EditorClassIdentifier:
button: {fileID: 670223750}
retbutton: {fileID: 0}
ClosureObj: {fileID: 0}
contentTrans: {fileID: 1889829591}
taskPrefab: {fileID: 3645880154619645306, guid: 1a0185fc1549da647943a21145debe29, type: 3}
JSONReader: {fileID: 1526740604}
closeBtn: {fileID: 0}
--- !u!1001 &825899810
PrefabInstance:
m_ObjectHideFlags: 0
@ -17903,6 +17908,7 @@ GameObject:
- component: {fileID: 1526740602}
- component: {fileID: 1526740601}
- component: {fileID: 1526740603}
- component: {fileID: 1526740604}
m_Layer: 0
m_Name: GameObject (1)
m_TagString: Untagged
@ -17954,6 +17960,26 @@ MonoBehaviour:
serverIP: ws://124.221.149.22
serverPort: 38445
type:
--- !u!114 &1526740604
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1526740600}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 13fa0701c49727a4c84282a40243e52d, type: 3}
m_Name:
m_EditorClassIdentifier:
npcJsonFile: {fileID: 4900000, guid: a854e20393334f04a8fc75e06404fe4f, type: 3}
locationJsonFile: {fileID: 4900000, guid: 4d6cd655327e27c4b88c2033169c8fed, type: 3}
eventJsonFile: {fileID: 4900000, guid: 2ef075e4830019a42b84d8d05d13d81c, type: 3}
matialJsonFile: {fileID: 4900000, guid: d98cb351d1a87dc4887a37106b9745d4, type: 3}
sceneJsonFile: {fileID: 4900000, guid: 06c09fd1c8b0a0a45951a1065189d922, type: 3}
incidentSiteJosnFile: {fileID: 4900000, guid: 1efa4372b10d4294199638c49173ff4c, type: 3}
NPCJosnFile: {fileID: 4900000, guid: 41009f009f0718647a782c7e1aec97dd, type: 3}
LanguageJsonFile: {fileID: 4900000, guid: 62a41129c4663ee41a06274114d28feb, type: 3}
--- !u!1001 &1542437476
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -4,6 +4,8 @@ using UnityEngine.UI;
public class JSONReader : MonoBehaviour
{
// 让 Unity 编辑器能够分别拖入两个不同的 JSON 文件
public TextAsset npcJsonFile; // 用来加载 NPC 数据
public TextAsset locationJsonFile; // 用来加载 Location 数据
@ -193,6 +195,32 @@ public class JSONReader : MonoBehaviour
return null; // 如果没有找到符合条件的语言数据,返回 null
}
//获取任务
public Language GetTaskByID(int id,Dictionary<int,Language> dic)
{
Language info = null;
if (LanguageDictionary.TryGetValue(id, out info))
{
// 判断 Note 是否等于 "预定演练"
if (info.Note == "任务")
{
Debug.Log($"Found Language: ID = {info.ID}, Text = {info.Text}, Note = {info.Note}");
dic.Add(id, info);
return info; // 返回符合条件的 Language 数据
}
else
{
Debug.Log($"Language with ID {id} found, but Note is not '预定演练'.");
}
}
else
{
Debug.Log($"No Language found with ID: {id}");
}
return null; // 如果没有找到符合条件的语言数据,返回 null
}
public SceneData GetSceneById(int id)
{
SceneData info = null;

View File

@ -447,7 +447,7 @@ public class SelectScenePanel : MonoBehaviour
// ¼ì²é³¡¾°Ñ¡Ôñ
foreach (Toggle toggle in scenetoggleList)
{
Debug.Log("++++++++++++++++++++++++=" + scenetoggleList.Count());
//Debug.Log("++++++++++++++++++++++++=" + scenetoggleList.Count());
if (toggle.isOn)
{
anyToggleSelected = true;