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(); AlongWindCheck.alongWindCheck += CheckHeadquaterPosition; } void OnDestroy() { AlongWindCheck.alongWindCheck -= CheckHeadquaterPosition; } /// /// 检查指挥部是否设置在上风向或侧风向 /// /// /// /// 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; } }