You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
239 lines
7.3 KiB
239 lines
7.3 KiB
4 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using System.Net;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 表示游戏设置。
|
||
|
/// </summary>
|
||
|
public static class GameSettings
|
||
|
{
|
||
|
public static OthersSettings othersSettings = new OthersSettings();
|
||
|
|
||
|
/// <summary>
|
||
|
/// 表示登录服务器的设置。
|
||
|
/// </summary>
|
||
|
public static readonly LoginSetting LoginSetting = new LoginSetting();
|
||
|
|
||
|
public static DisasterSetting disasterSetting = new DisasterSetting();
|
||
|
}
|
||
|
|
||
|
public class OthersSettings
|
||
|
{
|
||
|
public SceneType SceneType = SceneType.None;
|
||
|
public string mapname;
|
||
|
|
||
|
public Mode mode = Mode.None;
|
||
|
|
||
|
public bool startRecord = false;//先默认初始化为true,没做新建节点时好测试记录回放
|
||
|
|
||
|
public bool isStartDrill = false;//是否开始演练
|
||
|
|
||
|
//车辆信息:Value表示某类型车的车辆数量
|
||
|
public List<KeyValuePair<FireCarEngine, int>> CarList = new List<KeyValuePair<FireCarEngine, int>>();
|
||
|
/// <summary>
|
||
|
/// 播放状态
|
||
|
/// </summary>
|
||
|
public PlayState playState = PlayState.None;
|
||
|
|
||
|
//true:表示是选择灾情库创建房间;或查看、编辑灾情
|
||
|
public bool isSelectedDisaster;
|
||
|
//要加载的灾情库数据
|
||
|
public DisasterLibraryFile disaster;
|
||
|
|
||
|
//总指挥移交需要
|
||
|
public List<Organization> orgs = new List<Organization>();
|
||
|
|
||
|
public int personNum = 0;
|
||
|
public int nowperson = 0;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 中队派遣的消防员
|
||
|
/// </summary>
|
||
|
public Dictionary<string, int> DisplayName_Num_Dic = new Dictionary<string, int>();
|
||
|
/// <summary>
|
||
|
/// 力量调派的数据
|
||
|
/// </summary>
|
||
|
public Dictionary<string, int> FireEngines_Dic = new Dictionary<string, int>();
|
||
|
/// <summary>
|
||
|
/// 中队是否到达
|
||
|
/// </summary>
|
||
|
public Dictionary<string, bool> DisPlay_Arrive_Dic = new Dictionary<string, bool>();
|
||
|
/// <summary>
|
||
|
/// 所有调派的车辆,key为中队名,List<KeyValuePair<FireCarEngine,bool>>是该中队的车辆,键值对的value为false表示该车还没有分派人数
|
||
|
/// </summary>
|
||
|
public Dictionary<string, List<KeyValuePair<FireCarEngine, bool>>> DisCarList_Dic = new Dictionary<string, List<KeyValuePair<FireCarEngine, bool>>>();
|
||
|
///// <summary>
|
||
|
///// 车辆是否到达,false为没有到达
|
||
|
///// </summary>
|
||
|
//public List<KeyValuePair<FireCarEngine, bool>> CarArriveList = new List<KeyValuePair<FireCarEngine, bool>>();
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 添加车辆
|
||
|
/// </summary>
|
||
|
/// <param name="engine">添加的车型</param>
|
||
|
/// <param name="num">添加数量</param>
|
||
|
public void AddFireCar(FireCarEngine engine, int num)
|
||
|
{
|
||
|
for (int i = 0; i < CarList.Count; i++)
|
||
|
{
|
||
|
var pair = CarList[i];
|
||
|
if (pair.Key == engine)
|
||
|
{
|
||
|
int preNum = pair.Value;
|
||
|
KeyValuePair<FireCarEngine, int> currPair = new KeyValuePair<FireCarEngine, int>(engine, preNum + num);
|
||
|
CarList.Remove(pair); //删除旧数据
|
||
|
CarList.Add(currPair); //添加新数据
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
//如果之前CarList中没有保存此种车型数据,就添加新数据
|
||
|
KeyValuePair<FireCarEngine, int> newPair = new KeyValuePair<FireCarEngine, int>(engine, num);
|
||
|
CarList.Add(newPair);
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 移除车辆
|
||
|
/// </summary>
|
||
|
/// <param name="engine">移除的车型</param>
|
||
|
/// <param name="num">移除数量</param>
|
||
|
public void RemoveFireCar(FireCarEngine engine, int num)
|
||
|
{
|
||
|
for (int i = 0; i < CarList.Count; i++)
|
||
|
{
|
||
|
var pair = CarList[i];
|
||
|
if (pair.Key == engine)
|
||
|
{
|
||
|
int preNum = pair.Value;
|
||
|
if (preNum - num <= 0)
|
||
|
{
|
||
|
CarList.Remove(pair);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
KeyValuePair<FireCarEngine, int> currPair = new KeyValuePair<FireCarEngine, int>(engine, preNum - num);
|
||
|
CarList.Remove(pair); //删除旧数据
|
||
|
CarList.Add(currPair); //添加新数据
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
Debug.Log("没有找到要删除的车型");
|
||
|
}
|
||
|
public void ResertGameSettig()
|
||
|
{
|
||
|
//mode = Mode.None;
|
||
|
|
||
|
//startRecord = false;//先默认初始化为true,没做新建节点时好测试记录回放
|
||
|
|
||
|
isStartDrill = false;//是否开始演练
|
||
|
|
||
|
//车辆信息:Value表示某类型车的车辆数量
|
||
|
CarList = new List<KeyValuePair<FireCarEngine, int>>();
|
||
|
/// <summary>
|
||
|
/// 播放状态
|
||
|
/// </summary>
|
||
|
playState = PlayState.None;
|
||
|
|
||
|
//要加载的灾情库数据
|
||
|
disaster = null;
|
||
|
|
||
|
//总指挥移交需要
|
||
|
orgs = new List<Organization>();
|
||
|
isSelectedDisaster = false;
|
||
|
personNum = 0;
|
||
|
nowperson = 0;
|
||
|
DisplayName_Num_Dic = new Dictionary<string, int>();
|
||
|
DisPlay_Arrive_Dic = new Dictionary<string, bool>();
|
||
|
DisCarList_Dic = new Dictionary<string, List<KeyValuePair<FireCarEngine, bool>>>();
|
||
|
FireEngines_Dic = new Dictionary<string, int>();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
public enum Mode
|
||
|
{
|
||
|
None,
|
||
|
manoeuvre,//演习模式
|
||
|
Practice,//练习模式
|
||
|
DisasterManagement,//灾情管理模式
|
||
|
Replay//回放模式
|
||
|
}
|
||
|
|
||
|
public enum PlayState
|
||
|
{
|
||
|
None,
|
||
|
Playing, //播放过程中
|
||
|
Pause, //暂停过程中
|
||
|
Over //播放结束
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 表示登录服务器的设置。
|
||
|
/// </summary>
|
||
|
public class LoginSetting
|
||
|
{
|
||
|
private List<KeyValuePair<string, short>> list = new List<KeyValuePair<string, short>>();
|
||
|
|
||
|
/// <summary>
|
||
|
/// 随机获取一个登录服务器地址。
|
||
|
/// </summary>
|
||
|
public bool GetLoginAddress(out string ip, out short port)
|
||
|
{
|
||
|
var index = Random.Range(0, list.Count);
|
||
|
ip = list[index].Key;
|
||
|
port = list[index].Value;
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 随机获取一个登录服务器地址。
|
||
|
/// </summary>
|
||
|
public IPEndPoint GetLoginAddress()
|
||
|
{
|
||
|
string ip;
|
||
|
short port;
|
||
|
GetLoginAddress(out ip, out port);
|
||
|
return new IPEndPoint(IPAddress.Parse(ip), port);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 设置登录服务器地址。
|
||
|
/// </summary>
|
||
|
/// <param name="ip"></param>
|
||
|
/// <param name="port"></param>
|
||
|
public void SetLoginAddress(string ip, short port)
|
||
|
{
|
||
|
list.Add(new KeyValuePair<string, short>(ip, port));
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 表示指定的地址是否包含在登录服务器设置中,即该地址是否是登录服务器地址。
|
||
|
/// </summary>
|
||
|
public bool Contains(IPEndPoint endpoint)
|
||
|
{
|
||
|
return Contains(endpoint.Address.ToString(), (short)endpoint.Port);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 表示指定的地址是否包含在登录服务器设置中,即该地址是否是登录服务器地址。
|
||
|
/// </summary>
|
||
|
public bool Contains(string ip, short port)
|
||
|
{
|
||
|
return list.Exists((pair) => ip == pair.Key && port == pair.Value);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public class DisasterSetting
|
||
|
{
|
||
|
public MapType mapType;
|
||
|
|
||
|
//当前收到的报警信息
|
||
|
public PoliceCallData policeCallData;
|
||
|
|
||
|
public bool isEdit;//false表示查看,true表示编辑
|
||
|
|
||
|
public bool isCteateDisaster;//true,表示是创建灾情;false表示是编辑,查看灾情
|
||
|
}
|