Language.json修改

This commit is contained in:
lq 2024-12-13 15:30:41 +08:00
parent 9aa45fe1d0
commit 4451817b92
3 changed files with 105 additions and 87 deletions

View File

@ -1624,6 +1624,41 @@
"Text": "网络延迟:{a1}ms",
"Note": "主界面"
},
{
"ID": "13003",
"Text": "对方正在讲话中",
"Note": "文本提示-对讲机"
},
{
"ID": "13004",
"Text": "取消",
"Note": "按钮名"
},
{
"ID": "13005",
"Text": "与服务器断开连接",
"Note": "断线提示"
},
{
"ID": "13006",
"Text": "自动重连 <b>第({a1}/3)次尝试……</b>",
"Note": "断线提示"
},
{
"ID": "13007",
"Text": "水枪方向",
"Note": "操控消火栓灭火时右摇杆上的文本"
},
{
"ID": "13008",
"Text": "执行中…",
"Note": "会读条的选项,进度条中的文字"
},
{
"ID": "13009",
"Text": "这里已经有人在处置了",
"Note": "Objects表配置为不支持多人操作的交互对象点击按钮后的提示。"
},
{
"ID": "14000",
"Text": "[{a1}]<color=#00FF00>报告:</color>120急救队伍已到场",

View File

@ -10281,6 +10281,10 @@ PrefabInstance:
propertyPath: panel
value:
objectReference: {fileID: 618256462}
- target: {fileID: 2102021661377337229, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2102021661377337229, guid: 86668fbe8407a8741bb903177bc93fdb, type: 3}
propertyPath: classCount
value:

View File

@ -13,8 +13,7 @@ using static UnityEditor.Progress;
public class EvacuationPanel : MonoBehaviour
{
public Dictionary<string, int> distributePeople = new Dictionary<string, int>();// 分配给各个场景的人数
public List<PersonnelItem> personnelItems;
public List<PersonnelItem> personnelItems;//左侧区域
public Transform personnelContent;
public Panel panel;
public GameObject personnelPrefabs;
@ -58,6 +57,8 @@ public class EvacuationPanel : MonoBehaviour
private HashSet<int> excludedAreas = new HashSet<int>(); // 被清空的区域 ID
public SelectScenePanel selectScene;
private HashSet<int> clearedAreas = new HashSet<int>();
// 保存分配结果的字典
public Dictionary<int, int> allocatedPeople = new Dictionary<int, int>();
// Start is called before the first frame update
void Start()
{
@ -65,14 +66,14 @@ public class EvacuationPanel : MonoBehaviour
nonZeroAreas= GetNonZeroNpcRatioAreas();
jc = JuesechoicePop.GetComponent<JueseChoicePop>();
//redistributeBtn.onClick.AddListener(ClearData);
redistributeBtn.onClick.AddListener(() =>
{
if (redistributeBtn.interactable)
{
Debug.Log("Redistribute button clicked!");
RedistributeLogic();
}
});
//redistributeBtn.onClick.AddListener(() =>
//{
// if (redistributeBtn.interactable)
// {
// Debug.Log("Redistribute button clicked!");
// RedistributeLogic();
// }
//});
CountsubmitBtn.onClick.AddListener(Submit);
submitBtn.onClick.AddListener(totalSubmit);
StuCountInputField.onEndEdit.AddListener(CheckInput);
@ -84,6 +85,13 @@ public class EvacuationPanel : MonoBehaviour
CheckInput(StuCountInputField.text);
IsRedistribution();
IsOpen(selectScene.difficultyId);
if(Input.GetKey(KeyCode.A))
{
foreach(var item in personnelItems)
{
Debug.Log(item.sceneId);
}
}
}
//上传数据
public void totalSubmit()
@ -126,12 +134,14 @@ public class EvacuationPanel : MonoBehaviour
}
}
private void Submit()
//文字框提交按钮
public void Submit()
{
// 获取输入的总人数
int count = int.Parse(StuCountInputField.text); // 总人数
StuCountInputField.text = "";
// 使用分配方法
foreach (var item in personnelItems)
{
personnelItemsDict[item.sceneId] = item; // 使用 sceneId 作为键
@ -139,10 +149,10 @@ public class EvacuationPanel : MonoBehaviour
// 将 nonZeroAreas 转换为场景 ID 数组
int[] sceneIds = nonZeroAreas.ToArray();
// 调用分配方法
var result = DistributePeopleWithBalance(sceneIds, personnelItemsDict, count);
// 保存并使用分配结果
allocatedPeople = result; // 你已经保存了分配结果在 allocatedPeople 字典中
// 更新 UI 显示
foreach (var kvp in result)
{
@ -153,6 +163,7 @@ public class EvacuationPanel : MonoBehaviour
}
}
}
public Dictionary<int, int> DistributePeopleWithBalance(int[] scenes, Dictionary<int, PersonnelItem> personnelItemsDict, int totalPeople)
{
// 1. 计算当前每个区域的总人数(初始人数 + 已分配人数)
@ -168,7 +179,6 @@ public class EvacuationPanel : MonoBehaviour
{
totalPeoplePerScene[scene] = 0;
}
// Debug 输出每个场景的初始人数
Debug.Log($"Scene {scene}: Initial People = {totalPeoplePerScene[scene]}");
}
@ -213,9 +223,13 @@ public class EvacuationPanel : MonoBehaviour
allocatedPeople[scene.Key] = scene.Value - initialPeople; // 分配人数 = 总人数 - 初始人数
}
// 保存分配结果
this.allocatedPeople = allocatedPeople;
return allocatedPeople;
}
//清除
//private void ClearData()
//{
@ -299,11 +313,13 @@ public class EvacuationPanel : MonoBehaviour
}
// 清空人员列表
personnelItems.Clear();
foreach (var sceneEntry in panel.sceneDataDictionary)
{
foreach (var sceneInfo in sceneEntry.Value)
{
LocationData area = js.GetAreaDateById(int.Parse(sceneInfo.sceneId));
// 如果NpcRatio不为"-1"表示该场景有效
if (area.NpcRatio != "-1")
{
@ -323,21 +339,38 @@ public class EvacuationPanel : MonoBehaviour
personnelItem.sceneText.text = sceneEntry.Key;
personnelItem.sceneId = area.ID;
personnelItem.Num = 1; // 设置初始值为 1
// 点击事件监听
button.onClick.AddListener(() =>
{
// 标记当前选择的区域
OnSceneItemClicked(item, Color.yellow, selectedScene);
// 如果被点击的区域已经有人员
if (personnelItem.Num > 0)
{
redistributeBtn.onClick.AddListener(() => {
// 清除选定区域的人员数据
RedistributeLogic(personnelItem.sceneId, personnelItem.Num);
});
}
// 清空现有场景下的所有人员UI
foreach (Transform child in sceneCount)
{
Destroy(child.gameObject);
}
// 执行后续的场景级别配置
LocationData locationData = js.GetAreaDateById(personnelItem.sceneId);
if (locationData.Level.ToString() != "0")
{
GameObject levelItem = GameObject.Instantiate<GameObject>(scenePrefab, sceneCount);
GameObject levelItem = GameObject.Instantiate(scenePrefab, sceneCount);
Button levelBtn = levelItem.transform.Find("chooseBtn2").GetComponent<Button>();
levelBtn.onClick.AddListener(() =>
{
JueseChoicePop jueseChoicePop= jueseChoicePanel.gameObject.GetComponent<JueseChoicePop>();
JueseChoicePop jueseChoicePop = jueseChoicePanel.GetComponent<JueseChoicePop>();
jueseChoicePop.SetClass(personnelItem.sceneId);
jueseChoicePanel.gameObject.SetActive(true);
});
@ -345,7 +378,7 @@ public class EvacuationPanel : MonoBehaviour
classItem.classname.text = locationData.Level.ToString();
}
});
//Debug.Log("New PersonnelItem created. SceneId: " + personnelItem.sceneId + ", Num: " + personnelItem.Num);
personnelItems.Add(personnelItem);
}
}
@ -356,7 +389,6 @@ public class EvacuationPanel : MonoBehaviour
}
}
}
// 判断重新分配按钮是否可以点击
public void IsRedistribution()
{
@ -426,25 +458,18 @@ public class EvacuationPanel : MonoBehaviour
}
//重新分配
public void RedistributeLogic()
public void RedistributeLogic(int excludedSceneId, int excludedNum)
{
// 计算需要重新分配的 NPC 总数
int totalRedistributePeople = 0;
int totalRedistributePeople = excludedNum;
foreach (var kvp in personnelItemsDict)
{
PersonnelItem item = kvp.Value;
// 如果 gameObject 是激活的,表示需要清空 NPC
if (item.personnelImage.gameObject.activeSelf)
{
totalRedistributePeople += item.Num; // 累加需要重新分配的 NPC 数量
item.Num = 0; // 清空该区域的 NPC 数量
item.SetInfo(""); // 更新 UI 显示
item.personnelImage.gameObject.SetActive(false); // 隐藏图标
excludedAreas.Add(kvp.Key); // 记录清空的区域 ID
Debug.Log($"Cleared NPCs from Scene ID: {kvp.Key}");
}
}
// 清除当前选中区域的人员数据
PersonnelItem excludedItem = personnelItemsDict[excludedSceneId];
excludedItem.Num = 0;
excludedItem.SetInfo(""); // 更新 UI 显示
excludedItem.personnelImage.gameObject.SetActive(false); // 隐藏图标
excludedAreas.Add(excludedSceneId); // 记录清空的区域 ID
Debug.Log($"Cleared NPCs from Scene ID: {excludedSceneId}");
// 准备有效分配区域列表(排除被清空的区域)
List<int> validAreas = new List<int>();
@ -455,7 +480,6 @@ public class EvacuationPanel : MonoBehaviour
validAreas.Add(kvp.Key);
}
}
// 如果没有有效区域,则提示
if (validAreas.Count == 0)
{
@ -474,10 +498,11 @@ public class EvacuationPanel : MonoBehaviour
{
if (personnelItemsDict.ContainsKey(kvp.Key))
{
personnelItemsDict[kvp.Key].Num += kvp.Value; // 更新人数
personnelItemsDict[kvp.Key].SetInfo(personnelItemsDict[kvp.Key].Num.ToString()); // 更新 UI 显示
personnelItemsDict[kvp.Key].personnelImage.gameObject.SetActive(true); // 确保图标显示
personnelItemsDict[kvp.Key].personnelNum.gameObject.SetActive(true); // 确保图标显示
PersonnelItem redistributedItem = personnelItemsDict[kvp.Key];
redistributedItem.Num += kvp.Value; // 更新人数
redistributedItem.SetInfo(redistributedItem.Num.ToString()); // 更新 UI 显示
redistributedItem.personnelImage.gameObject.SetActive(true); // 确保图标显示
redistributedItem.personnelNum.gameObject.SetActive(true); // 确保图标显示
Debug.Log($"Assigned {kvp.Value} NPCs to Scene ID: {kvp.Key}");
}
}
@ -520,50 +545,4 @@ public class EvacuationPanel : MonoBehaviour
classCount.gameObject.SetActive(false);
}
}
//// 1. 把所选区域的NPC分配到其它区域
//public void RedistributeNpc(int selectedAreaId)
//{
// // 获取所有非已清空的区域ID
// var availableAreas = GetNonZeroNpcRatioAreas().Where(areaId => areaId != selectedAreaId && !clearedAreas.Contains(areaId)).ToList();
// // 从选中的区域获取NPC
// int npcToRedistribute = distributePeople[selectedAreaId.ToString()];
// if (npcToRedistribute == 0) return;
// // 移除该区域的NPC
// distributePeople[selectedAreaId.ToString()] = 0;
// //personnelItemsDict[selectedAreaId].UpdateNpcCount(0); // 假设你有一个更新UI的方法
// // 将这些NPC分配到其它区域
// DistributeNpcToOtherAreas(npcToRedistribute, availableAreas);
//}
//// 2. 记录被清空NPC分布的区域ID下次重新分配时这些区域不参与分配
//private void DistributeNpcToOtherAreas(int npcToRedistribute, List<int> availableAreas)
//{
// if (availableAreas.Count == 0) return;
// // 简单的均分方式,你可以根据自己的需要修改分配策略
// int npcPerArea = npcToRedistribute / availableAreas.Count;
// foreach (var areaId in availableAreas)
// {
// distributePeople[areaId.ToString()] += npcPerArea;
// //personnelItemsDict[areaId].UpdateNpcCount(distributePeople[areaId]);
// }
// // 如果有剩余的NPC可以将其分配到其他区域
// int remainder = npcToRedistribute % availableAreas.Count;
// for (int i = 0; i < remainder; i++)
// {
// distributePeople[availableAreas[i]] += 1;
// //personnelItemsDict[availableAreas[i]].UpdateNpcCount(distributePeople[availableAreas[i]]);
// }
//}
//// 重新分配前,清空区域时调用此方法,记录清空区域
//public void MarkAreaAsCleared(int areaId)
//{
// clearedAreas.Add(areaId);
//}
}