IEnumerator nextRoomCoroutine(CollisionBehaviour cb) { SMovableObject mainRole = MainGameData.MainRole; mainRole.enabled = false; mainRole.SetKinematic(true); unregisterEvent(); mCurRoom.OnExitRoom(); //try get next room DRoom nextRoom = mCurRoom.GetJointRoom(cb); if (nextRoom == null) { //TODO: Be Random After GameObject go = Instantiate(Rooms[0]) as GameObject; nextRoom = go.GetComponent <DRoom>(); nextRoom.Init(); CollisionBehaviour nextCb = nextRoom.AlignmentOtherRoom(cb, mCurRoom.CenterPos); mCurRoom.JointRoom(cb, nextRoom); nextRoom.JointRoom(nextCb, mCurRoom); } StartCoroutine(mainRoleCutScene(nextRoom.CenterPos)); yield return(StartCoroutine(SCameraMgr.Instance.moveToPos(nextRoom.CenterPos))); while (mRoleCurSceneEnable == true) { yield return(null); } mCurRoom = nextRoom; registerEvent(); mCurRoom.OnEnterRoom(); mainRole.SetKinematic(false); mainRole.enabled = true; }
public override void Init() { base.Init(); //init room GameObject go = Instantiate(StartRoom) as GameObject; mCurRoom = go.GetComponent <DRoom>(); mCurRoom.CenterPos = Vector3.zero; mCurRoom.Init(); registerEvent(); mRoomList.Add(go); }