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.
83 lines
2.5 KiB
83 lines
2.5 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class FireAlongWindCheck : MonoBehaviour { |
|
WeatherSettingManager weatherMgr; |
|
void Awake() |
|
{ |
|
weatherMgr = GameObject.Find("Canvas").transform.Find("WeatherSettingPanel").GetComponent<WeatherSettingManager>(); |
|
AlongWindCheck.alongWindCheck += CheckHeadquaterPosition; |
|
} |
|
void OnDestroy() |
|
{ |
|
AlongWindCheck.alongWindCheck -= CheckHeadquaterPosition; |
|
} |
|
/// <summary> |
|
/// 检查指挥部是否设置在上风向或侧风向 |
|
/// </summary> |
|
/// <param name="arg1"></param> |
|
/// <param name="arg2"></param> |
|
/// <returns></returns> |
|
private IntData CheckHeadquaterPosition(Vector3 pos, IntData data) |
|
{ |
|
Vector3 myPos = transform.position; |
|
float dx = Mathf.Abs(myPos.x - pos.x); |
|
float dz = Mathf.Abs(myPos.z - pos.z); |
|
switch (weatherMgr.TianQiSettingData.fengxiang) |
|
{ |
|
case FengXiang.北风: |
|
if (dx < 10 && myPos.z < pos.z) |
|
data.value++; |
|
break; |
|
case FengXiang.东北风: |
|
if (pos.x > myPos.x && pos.z > myPos.z) |
|
data.value++; |
|
break; |
|
case FengXiang.东风: |
|
if (dz < 10 && myPos.x < pos.x) |
|
data.value++; |
|
break; |
|
case FengXiang.东南风: |
|
if (myPos.x < pos.x && myPos.z > pos.z) |
|
data.value++; |
|
break; |
|
case FengXiang.南风: |
|
if (dx < 10 && myPos.z > pos.z) |
|
data.value++; |
|
break; |
|
case FengXiang.西南风: |
|
if (myPos.x > pos.x && myPos.z > pos.z) |
|
data.value++; |
|
break; |
|
case FengXiang.西风: |
|
if (dz < 10 && myPos.x > pos.x) |
|
data.value++; |
|
break; |
|
case FengXiang.西北风: |
|
if (myPos.z < pos.z && myPos.x > pos.x) |
|
data.value++; |
|
break; |
|
default: |
|
break; |
|
} |
|
if (weatherMgr.TianQiSettingData.fengli==FengLi.无风) |
|
{ |
|
data.value = 0; |
|
} |
|
return data; |
|
} |
|
} |
|
public class IntData |
|
{ |
|
public int value; |
|
public IntData(int initValue) |
|
{ |
|
value = initValue; |
|
} |
|
public void Clear() |
|
{ |
|
value = 0; |
|
} |
|
|
|
} |