/// <summary> /// Replaces the model subfunction /// </summary> /// <param name='_prefabName'> /// _prefab name. /// </param> /// <param name='_originalModel'> /// _original model. /// </param> private void ReplaceModel(string _prefabName, GameObject _originalModel, ResourceMgr.ResourceDelegate dele = null) { if (Globals.Instance.MResourceManager == null) { return; } Globals.Instance.MResourceManager.Load(_prefabName, delegate(Object obj, string error) { if (obj == null) { Debug.LogError("obj == null ReplaceModel " + error); return; } GameObject t_warship = (GameObject)Instantiate(obj); try{ RelAnimControl t_src = _originalModel.GetComponent <RelAnimControl>(); RelAnimControl t_dst = t_warship.AddComponent <RelAnimControl>(); t_src.CopyTo(t_dst); t_dst.transform.parent = _originalModel.transform.parent; t_dst.transform.localPosition = _originalModel.transform.localPosition; Destroy(_originalModel); if (dele != null) { dele(t_warship, error); } }catch (System.Exception ex) { Debug.LogError("ReplaceModel error: " + ex.Message); } }); }
void Start() { float tEndMoveTime = 0; // remove the main camera of its child GameObject t_tmpCamera = transform.Find("Tmp Camera").gameObject; if (t_tmpCamera != null) { mStoreMainCamera = GameObject.FindWithTag("MainCamera"); if (mStoreMainCamera == null) { mStoreMainCamera = Globals.Instance.MSceneManager.mMainCamera.gameObject; } mStoreMainCamera.transform.parent = t_tmpCamera.transform.parent; mStoreMainCamera.transform.localPosition = t_tmpCamera.transform.localPosition; mStoreMainCamera.transform.rotation = t_tmpCamera.transform.rotation; RelAnimControl t_src = t_tmpCamera.GetComponent <RelAnimControl>(); RelAnimControl t_dst = mStoreMainCamera.AddComponent <RelAnimControl>(); t_src.CopyTo(t_dst); DestroyObject(t_tmpCamera); m_currCameraAnimControl = t_dst; m_currCameraAnimControl.SetPlayAnimDoneDelegate(delegate(){ if (m_playOverDelegate != null) { try{ m_playOverDelegate(this); }catch (System.Exception e) { Debug.LogError(e.GetType().Name + " " + e.Message); } } // destroy own Destroy(this); // SceneFadeInOut.Instance.FadeInScene(5); }); tEndMoveTime = m_currCameraAnimControl.GetPlayLength(); if (tEndMoveTime > 0) { StartCoroutine(EndCutsceneMove(tEndMoveTime)); } } // replace the model int t_num = Mathf.Min(m_replaceDst.Length, m_replaceSrc.Length); for (int i = 0; i < t_num; i++) { if (m_replaceDst[i].ToLower() == "actor") { ReplaceActor(m_replaceSrc[i]); } else if (m_replaceDst[i].ToLower() == "boss") { ReplaceBoss(m_replaceSrc[i]); } } // get the cutscene background position if (smTopCutscene == null && Globals.Instance.MGUIManager != null) { smTopCutscene = Globals.Instance.MGUIManager.MGUICamera.transform.Find("CutsceneTop").gameObject; smBottomCutscene = Globals.Instance.MGUIManager.MGUICamera.transform.Find("CutsceneBottom").gameObject; PackedSprite ps = smTopCutscene.GetComponent <PackedSprite>(); smTopCutscenePos[0] = new Vector3(0, Screen.height / 2, smTopCutscene.transform.localPosition.z); smBottomCutscenePos[0] = new Vector3(0, -Screen.height / 2, smTopCutscene.transform.localPosition.z); smTopCutscenePos[1] = smTopCutscenePos[0] + new Vector3(0, CUT_SCENE_MOVE_HEIGHT, 0); smBottomCutscenePos[1] = smBottomCutscenePos[0] + new Vector3(0, -CUT_SCENE_MOVE_HEIGHT, 0); } if (tEndMoveTime > 0) { // setup the animation of cutscene background smTopCutscene.transform.localPosition = smTopCutscenePos[1]; smBottomCutscene.transform.localPosition = smBottomCutscenePos[1]; iTween.MoveTo(smTopCutscene, iTween.Hash("position", smTopCutscenePos[0], "time", CUT_SCENE_MOVE_LENGTH, "isLocal", true)); iTween.MoveTo(smBottomCutscene, iTween.Hash("position", smBottomCutscenePos[0], "time", CUT_SCENE_MOVE_LENGTH, "isLocal", true)); } // set the uiCamera cull mask to default/LargeObject in order to // hide the all interface and show the cutscene background // defualt layer is cutscene background // LargeObject layer is fadeInOut backgroud Globals.Instance.MGUIManager.MGUICamera.cullingMask = (1 << 0) | (1 << 11); // disable the UIManager for POINTER_PTR evente; }