public void OnHouseEnter(int houseRef) { if (mOnWaitMainCharEnterHouse != null && houseRefWait == houseRef) { var action = mOnWaitMainCharEnterHouse; mOnWaitMainCharEnterHouse = null; action(houseRef); } }
public bool WaitEnterHouse(ScriptGame scriptGame, ScriptGui.MainCharAction data, OnMainCharEnterHouse callBack) { if (IsMainChar_Wait_To_Interaction()) { return(false); } GameObject prefab = Resources.Load <GameObject>("OBJ/CheckPoint"); if (prefab == null) { return(false); } List <GameObject> checkPointList = new List <GameObject>(); { // Add CheckPoint var triggerNode = AutoTileMap_Editor.Instance.TriggerNode; string hash = "House_" + data.IdHouse; for (int i = 0; i < triggerNode.childCount; i++) { var c = triggerNode.GetChild(i); Debug.Log(c.name); if (c.name.IndexOf(hash) >= 0) { var obj = GameObject.Instantiate(prefab); obj.transform.parent = c; obj.transform.localRotation = Quaternion.identity; obj.transform.localPosition = new Vector3(0, 0, 0); checkPointList.Add(obj); } } } if (checkPointList.Count == 0) { return(false); } houseRefWait = data.IdHouse; mOnWaitMainCharEnterHouse = ( int houseRef) => { while (checkPointList.Count > 0) { var o = checkPointList[0]; checkPointList.RemoveAt(0); o.transform.parent = null; GameObject.Destroy(o); } callBack(houseRef); }; return(true); }