public void StepInit() { if (happyCheck == null) { happyCheck = transform.parent.GetComponentInChildren <HappyCheck>(); } happyCheck.resetNumbersValue(); ufaMap = new List2DInt(happyCheck.mineDatas.XSize, happyCheck.mineDatas.YSize, -1); watchList.list = ufaMap; ufaIndexes = new int[happyCheck.unFlipAreaList.Count]; numberCount = happyCheck.numberList.Count; int index = 0; foreach (var ufa in happyCheck.unFlipAreaList) { ufaIndexes[index] = happyCheck.map[ufa.pos]; ufaMap[ufa.pos] = 0; index++; } stack = new List <int>(); happyMap = new int[happyCheck.unFlipAreaList.Count]; checkResults = new List <List <int> >(); isHappy = false; GameObject[] resultGbs = new GameObject[transform.childCount]; sortIndex = 0; for (int i = 0; i < transform.childCount; i++) { resultGbs[i] = transform.GetChild(i).gameObject; } foreach (var resultGb in resultGbs) { Destroy(resultGb); } }
// Use this for initialization void Awake() { happyCheck = GameObject.Find("Algorithm").GetComponentInChildren <HappyCheck>(); happyCheckStep = GameObject.Find("Algorithm").GetComponentInChildren <HappyCheckStep>(); GameObject debugWithMap = new GameObject("Map"); debugWithMap.transform.parent = transform; watchList = debugWithMap.AddComponent(typeof(WatchList2DInScene)) as WatchList2DInScene; happyCheckStep.clickAction += changeMineDataForHappy; }
/// <summary> /// OnGUI is called for rendering and handling GUI events. /// This function can be called multiple times per frame (one call per event). /// </summary> public void OnSceneGUI() { HappyCheck happyCheck = target as HappyCheck; Handles.color = Color.white; if (mainData == null) { mainData = GameObject.Find("MainData").GetComponent <MainData>(); } if (happyCheck.map == null) { return; } if (now == null) { SmartList <HCArea>[] hack = { happyCheck.unFlipAreaList, happyCheck.numberList }; for (int i = 0; i < 2; i++) { foreach (HCArea ufa in hack[i]) { Handles.color = ufa.value >= 0 ? Color.yellow : Color.red; if (Handles.Button(mainData.AreaPosWorld(ufa.pos.x, ufa.pos.y), Quaternion.identity, 0.5f, 0.5f, Handles.CylinderHandleCap)) { now = ufa; } Handles.Label(mainData.AreaPosWorld(ufa.pos.x, ufa.pos.y), ufa.value.ToString()); } } } else { foreach (HCArea neighbor in now.neighbours) { Handles.color = neighbor.value >= 0 ? Color.yellow : Color.red; Handles.Label(mainData.AreaPosWorld(neighbor.pos.x, neighbor.pos.y), neighbor.value.ToString()); if (Handles.Button(mainData.AreaPosWorld(neighbor.pos.x, neighbor.pos.y), Quaternion.identity, 0.5f, 0.5f, Handles.CylinderHandleCap)) { now = neighbor; } } Handles.color = now.value >= 0 ? Color.yellow : Color.red; if (Handles.Button(mainData.AreaPosWorld(now.pos.x, now.pos.y), Quaternion.identity, 0.5f, 0.5f, Handles.CylinderHandleCap)) { now = null; } } }