/// /// ZWN-XHJ /// 20211019 /// using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; /*using static System.Net.Mime.MediaTypeNames;*/ public class humancost : MonoBehaviour { public human_area human_cur; //public FollowBoxManager followBoxManager; public Image show; public Sprite[] show_spr; private Color32 color_start = new Color32(255, 255, 255, 0), color_end = new Color32(255, 255, 255, 255); private Vector3 vec_start = new Vector3(-1920, 0, 0), vec_end = new Vector3(0, 0, 0); bool human_cost = false; bool cost_success = false; public GameObject show_green; public GameObject total, half; float alignArea = 0; public float AlignArea { get { return alignArea; } set { alignArea = value; } } /// /// 当符合条件后,判断为True /// public bool Cost_Success { get { return cost_success; } set { cost_success = value; } } int area_num = -1; public int Area_Num { get { return area_num; } set { area_num = value; } } int last_num = -2; private Transform tra_self; /// /// 当符合条件后,判断为True /// public bool Cost_Change { get { return cost_change; } set { cost_change = value; } } bool cost_change = false; // Use this for initialization void Start() { if (!human_cost) { if (human_cur.human_area_state_cur == human_area_state.totalbody) { total.SetActive(true); half.SetActive(false); } else if (human_cur.human_area_state_cur == human_area_state.halfbody) { total.SetActive(false); half.SetActive(true); } show_green.SetActive(false); if (tra_self == null) { tra_self = this.transform; } tra_self.localPosition = vec_start; area_num = -1; show_true(); cost_success = false; human_cost = false; } } /// /// 开始检测需调用 /// public void human_init() { // zwn_interface.single.zwn_init(); if (time_cost != 0) time_cost = 0; if (human_cur.human_area_state_cur == human_area_state.totalbody) { total.SetActive(true); half.SetActive(false); } else if (human_cur.human_area_state_cur == human_area_state.halfbody) { total.SetActive(false); half.SetActive(true); } show_green.SetActive(false); if (tra_self == null) { tra_self = this.transform; } tra_self.localPosition = vec_end; area_num = -1; last_num = -2; show_true(); cost_change = false; cost_success = false; human_cost = true; } /// /// 结束检测 /// public void human_end() { show_green.SetActive(false); if (tra_self == null) { tra_self = this.transform; } tra_self.localPosition = vec_start; area_num = -1; last_num = -2; show_true(); cost_change = false; cost_success = true; human_cost = false; } float time_cost = 0; //public Text text_id; // Update is called once per frame void Update() { if (Application.platform == RuntimePlatform.Android)// 使用Unity切换Platform无法模拟 { //text_id.text = "当前ID:" + zwn_interface_android.single.Cur_ID; } /* if (Cost_Change) { switch (Area_Num) { case -1: //没有人 break; case 0://对齐 break; case 1://请向右一点 break; case 2://请向左一点 break; case 3://请向后一点 break; case 4://请向前一点 break; } Cost_Change = false; }*/ if (human_cost && !cost_success) { //area_num = human_cur.human_area_true(); ////print("area_num " + area_num); //if (last_num != area_num) //{ // cost_change = true; // last_num = area_num; //} ////print("area_num" + area_num); //show_true(); //if (area_num == 0) if (FollowBoxManager.sigle.GetIsSuccee) { show_green.SetActive(true); time_cost += Time.deltaTime; if (time_cost >= 2) { human_end(); float x = (zwn_common_data.single.zwn_transform_pose[5].x - zwn_common_data.single.zwn_transform_pose[6].x); float y = (zwn_common_data.single.zwn_transform_pose[5].y - zwn_common_data.single.zwn_transform_pose[11].y); float area = Mathf.Abs(x * y); alignArea = area; } } else { show_green.SetActive(false); if (time_cost != 0) time_cost = 0; } } } void show_true() { if (area_num == -1) { if (show.color != color_start) show.color = color_start; } else { for (int i = 0; i < show_spr.Length; i++) { if (area_num == i) { show.sprite = show_spr[i]; show.SetNativeSize(); } } if (show.color != color_end) show.color = color_end; } } public void halfbody() { human_cur.human_area_state_cur = human_area_state.halfbody; human_init1(); } public void totalbody() { human_cur.human_area_state_cur = human_area_state.totalbody; human_init1(); } /// /// 开始检测需调用 /// public void human_init1() { if (time_cost != 0) time_cost = 0; if (human_cur.human_area_state_cur == human_area_state.totalbody) { total.SetActive(true); half.SetActive(false); } else if (human_cur.human_area_state_cur == human_area_state.halfbody) { total.SetActive(false); half.SetActive(true); } show_green.SetActive(false); if (tra_self == null) { tra_self = this.transform; } tra_self.localPosition = vec_end; area_num = -1; last_num = -2; show_true(); cost_change = false; cost_success = false; human_cost = true; } public void SetCostChange(bool bCostChange) { cost_change = bCostChange; } public void SetCostSuccess(bool bCostSuccess) { cost_success = bCostSuccess; } }