|
|
|
using AX.MessageSystem;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using System;
|
|
|
|
using AX.NetworkSystem;
|
|
|
|
using UnityEngine.AI;
|
|
|
|
|
|
|
|
public enum AroundState
|
|
|
|
{
|
|
|
|
Normal,
|
|
|
|
SmokeNear,
|
|
|
|
FireNear
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 被困人员/伤员血量控制脚本基类,不适用于消防员
|
|
|
|
/// </summary>
|
|
|
|
public class BaseHaemalController : MonoBehaviour
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// 最近操作的消防员Id或者消防员本身Id,用于事件记录,以便事件触发时可以查到操作用户
|
|
|
|
/// </summary>
|
|
|
|
public long LastFireManId;
|
|
|
|
/// <summary>
|
|
|
|
/// 对该角色实施过的技能
|
|
|
|
/// </summary>
|
|
|
|
public List<KeyValuePair<GameObject, FireManSkills>> skillList = new List<KeyValuePair<GameObject, FireManSkills>>();
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 是否被实施过急救
|
|
|
|
/// </summary>
|
|
|
|
public bool beFristAid = false;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 当前血量
|
|
|
|
/// </summary>
|
|
|
|
private float haemal;
|
|
|
|
|
|
|
|
public float Haemal
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return haemal;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
haemal = value;
|
|
|
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement)
|
|
|
|
{//灾情库模式下不同步
|
|
|
|
if (CurrentUserInfo.mySelf.Id==CurrentUserInfo.room.Owner.UserInfo.Id)
|
|
|
|
{
|
|
|
|
if (GameSettings.othersSettings.isStartDrill)
|
|
|
|
{
|
|
|
|
HaemalSyncData arg = new HaemalSyncData();
|
|
|
|
arg.gameObjID = GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
arg.SendUserID = CurrentUserInfo.mySelf.Id;
|
|
|
|
if (GetComponent<TrappedMoveFree>())
|
|
|
|
{
|
|
|
|
if (GetComponent<TrappedMoveFree>().movestate != MoveState.FALLDOWN)
|
|
|
|
{
|
|
|
|
if (Haemal <= 50)
|
|
|
|
{
|
|
|
|
arg.FallDown = true;
|
|
|
|
AdjustRotationWhileEndPathfindData ajarg = new AdjustRotationWhileEndPathfindData
|
|
|
|
{
|
|
|
|
SenderId = CurrentUserInfo.mySelf.Id,
|
|
|
|
GameObjId = arg.gameObjID,
|
|
|
|
Hitpoint = transform.position,
|
|
|
|
EndRotation = new Vector3(transform.rotation.eulerAngles.x,
|
|
|
|
transform.rotation.eulerAngles.y, transform.rotation.eulerAngles.z)
|
|
|
|
};
|
|
|
|
NetworkManager.Default.SendAsync("ABJUST_ROTATION_SYNC", ajarg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
arg.Haemal = Haemal;
|
|
|
|
NetworkManager.Default.SendAsync("HAEMAL_BLOOD_SYNC", arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public float Speed=0.2f;
|
|
|
|
/// <summary>
|
|
|
|
/// 最大血量
|
|
|
|
/// </summary>
|
|
|
|
public float MaxHaemal;
|
|
|
|
/// <summary>
|
|
|
|
/// 演练是否开始
|
|
|
|
/// </summary>
|
|
|
|
public bool DrillBegin;
|
|
|
|
|
|
|
|
public AroundState aroundState;
|
|
|
|
/// <summary>
|
|
|
|
/// 附近危险集合
|
|
|
|
/// </summary>
|
|
|
|
public List<GameObject> DangerousList = new List<GameObject>();
|
|
|
|
public Transform P_Disasters;
|
|
|
|
public SceneType scenetype;
|
|
|
|
/// <summary>
|
|
|
|
/// 是否佩戴面具
|
|
|
|
/// </summary>
|
|
|
|
public bool HasMashk = false;
|
|
|
|
/// <summary>
|
|
|
|
/// 遇到危险最大距离
|
|
|
|
/// </summary>
|
|
|
|
public float MetDangerousDistance;
|
|
|
|
//public bool IsInDangerousThisSecond;
|
|
|
|
|
|
|
|
//用来判断扣血
|
|
|
|
private float timer = 1f;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 判断该角色是否还活着
|
|
|
|
/// </summary>
|
|
|
|
public bool IsStillAlive = true;
|
|
|
|
|
|
|
|
//是否被移动状态
|
|
|
|
public bool IsMoving = false;
|
|
|
|
|
|
|
|
public bool BeFristAid
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return beFristAid;
|
|
|
|
}
|
|
|
|
|
|
|
|
set
|
|
|
|
{
|
|
|
|
beFristAid = value;
|
|
|
|
WounderFristAidSyncData arg = new WounderFristAidSyncData();
|
|
|
|
arg.SendUserID = CurrentUserInfo.mySelf.Id;
|
|
|
|
arg.gameObjID = GetComponent<BaseGameObjInfo>().gameObjID;
|
|
|
|
arg.IsBeFristAid = value;
|
|
|
|
NetworkManager.Default.SendAsync("WOUNDER_FRISEAID_SYNC", arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//public virtual void OnDestroy()
|
|
|
|
//{
|
|
|
|
// MessageDispatcher.AddListener("FRISTAID_MAN_COMMAND", FristAid);
|
|
|
|
// //接收消防员技能,用来事件触发记录的
|
|
|
|
//}
|
|
|
|
|
|
|
|
//public virtual void OnEnable()
|
|
|
|
//{
|
|
|
|
|
|
|
|
// MessageDispatcher.AddListener("FRISTAID_MAN_COMMAND", FristAid);
|
|
|
|
// //接收消防员技能
|
|
|
|
//}
|
|
|
|
|
|
|
|
//public virtual void OnDisable()
|
|
|
|
//{
|
|
|
|
|
|
|
|
// MessageDispatcher.AddListener("FRISTAID_MAN_COMMAND", FristAid);
|
|
|
|
// //接收消防员技能
|
|
|
|
//}
|
|
|
|
|
|
|
|
//private void FristAid(IMessage obj)
|
|
|
|
//{
|
|
|
|
// BeFristAid = true;
|
|
|
|
// // CancelInvoke("BucklebloodMeetDangerous");
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void Start()
|
|
|
|
{
|
|
|
|
DrillBegin = GameSettings.othersSettings.isStartDrill;
|
|
|
|
P_Disasters = GameObject.Find("P_AllParent").transform.Find("P_Disasters");
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 扣血方法,子类实现扣血方法
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
public virtual void BucklebloodMeetDangerous()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
public void Update()
|
|
|
|
{
|
|
|
|
DrillBegin = GameSettings.othersSettings.isStartDrill;
|
|
|
|
if (DrillBegin)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (CurrentUserInfo.room!=null&&CurrentUserInfo.mySelf.Id==CurrentUserInfo.room.Owner.UserInfo.Id)
|
|
|
|
{
|
|
|
|
if (IsStillAlive)
|
|
|
|
{
|
|
|
|
if (IsMoving)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
timer -= Time.deltaTime;
|
|
|
|
if (timer < 0)
|
|
|
|
{
|
|
|
|
GetDangerousList();
|
|
|
|
AroundStateSet();
|
|
|
|
BucklebloodMeetDangerous();
|
|
|
|
timer = 1f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 死亡处理
|
|
|
|
/// </summary>
|
|
|
|
public virtual void DeadDispose()
|
|
|
|
{
|
|
|
|
//加入事件触发列表
|
|
|
|
//EventReportController.Instance.EventReportList.Add();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取周围的危险列表,现只考虑火
|
|
|
|
/// </summary>
|
|
|
|
public void GetDangerousList()
|
|
|
|
{
|
|
|
|
DangerousList.Clear();
|
|
|
|
CloneGameObjInfo[] allDisaster = P_Disasters.GetComponentsInChildren<CloneGameObjInfo>();
|
|
|
|
for (int i = 0; i < allDisaster.Length; i++)
|
|
|
|
{
|
|
|
|
if (/*allDisaster[i].gameObjType == CloneObjType.dangerousGoods ||*/
|
|
|
|
allDisaster[i].gameObjType == CloneObjType.fireNormal ||
|
|
|
|
allDisaster[i].gameObjType == CloneObjType.fireBreakThrough ||
|
|
|
|
allDisaster[i].gameObjType == CloneObjType.LiquidLevel||
|
|
|
|
allDisaster[i].gameObjType == CloneObjType.SpreadedFire/* ||
|
|
|
|
allDisaster[i].gameObjType == CloneObjType.smokeNormal ||
|
|
|
|
allDisaster[i].gameObjType == CloneObjType.smokeIndoor1 ||
|
|
|
|
allDisaster[i].gameObjType == CloneObjType.smokeIndoor2*/
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if ((allDisaster[i].gameObjType == CloneObjType.fireNormal) ||
|
|
|
|
allDisaster[i].gameObjType == CloneObjType.fireBreakThrough ||
|
|
|
|
allDisaster[i].gameObjType == CloneObjType.LiquidLevel||
|
|
|
|
allDisaster[i].gameObjType == CloneObjType.SpreadedFire)
|
|
|
|
{//普通火判断下是否是熄灭状态
|
|
|
|
MetDangerousDistance = 15;
|
|
|
|
}
|
|
|
|
//if (allDisaster[i].gameObjType == CloneObjType.smokeNormal ||
|
|
|
|
//allDisaster[i].gameObjType == CloneObjType.smokeIndoor1 ||
|
|
|
|
//allDisaster[i].gameObjType == CloneObjType.smokeIndoor2)
|
|
|
|
//{
|
|
|
|
// MetDangerousDistance = 0;
|
|
|
|
//}
|
|
|
|
if (scenetype != SceneType.化工建筑)
|
|
|
|
{
|
|
|
|
//现检测高度范围为低于1.2(地面下0.2),高于2米(头上1米)
|
|
|
|
if (transform.position.y - allDisaster[i].transform.position.y < 1.2
|
|
|
|
|| allDisaster[i].transform.position.y - transform.position.y < 2)
|
|
|
|
{
|
|
|
|
//检测范围以内的
|
|
|
|
if (Vector3.Distance(transform.position, allDisaster[i].transform.position) <= MetDangerousDistance)
|
|
|
|
{
|
|
|
|
if ((allDisaster[i].gameObjType == CloneObjType.fireNormal
|
|
|
|
&& allDisaster[i].GetComponent<NavMeshObstacle>().enabled == true))
|
|
|
|
{
|
|
|
|
|
|
|
|
DangerousList.Add(allDisaster[i].gameObject);
|
|
|
|
}
|
|
|
|
else if(allDisaster[i].gameObjType != CloneObjType.fireNormal)
|
|
|
|
{
|
|
|
|
DangerousList.Add(allDisaster[i].gameObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//化工暂时不限高
|
|
|
|
if (transform.position.y - allDisaster[i].transform.position.y < 1.2)
|
|
|
|
{
|
|
|
|
//检测范围以内的
|
|
|
|
if (Vector3.Distance(transform.position, allDisaster[i].transform.position) <= MetDangerousDistance)
|
|
|
|
{
|
|
|
|
if ((allDisaster[i].gameObjType == CloneObjType.fireNormal
|
|
|
|
&& allDisaster[i].GetComponent<NavMeshObstacle>().enabled == true))
|
|
|
|
{
|
|
|
|
|
|
|
|
DangerousList.Add(allDisaster[i].gameObject);
|
|
|
|
}
|
|
|
|
else if (allDisaster[i].gameObjType != CloneObjType.fireNormal)
|
|
|
|
{
|
|
|
|
DangerousList.Add(allDisaster[i].gameObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool InDangerous()
|
|
|
|
{
|
|
|
|
if (DangerousList.Count > 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else { return false; }
|
|
|
|
}
|
|
|
|
public void AroundStateSet()
|
|
|
|
{
|
|
|
|
if (DangerousList.Count <= 0)
|
|
|
|
{
|
|
|
|
aroundState = AroundState.Normal;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < DangerousList.Count; i++)
|
|
|
|
{
|
|
|
|
if (DangerousList[i].GetComponent<CloneGameObjInfo>().gameObjType == CloneObjType.fireNormal ||
|
|
|
|
DangerousList[i].GetComponent<CloneGameObjInfo>().gameObjType == CloneObjType.fireBreakThrough ||
|
|
|
|
DangerousList[i].GetComponent<CloneGameObjInfo>().gameObjType == CloneObjType.LiquidLevel)
|
|
|
|
{
|
|
|
|
aroundState = AroundState.FireNear;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//ToDo:
|
|
|
|
//以后加上烟的粒子碰撞回调判断是否在烟里
|
|
|
|
//aroundState = AroundState.Normal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|