private IEnumerator IEPlayAnimation(string sn, AnimType animType, NoParamCallback callback = null) { SSMotion an = m_Dict[sn].GetComponentInChildren <SSMotion>(); if (an != null && animType != AnimType.NO_ANIM) { yield return(null); NoParamCallback play = null; float time = 0; switch (animType) { case AnimType.SHOW: play = an.PlayShow; time = an.TimeShow(); break; case AnimType.SHOW_BACK: play = an.PlayShowBack; time = an.TimeShowBack(); break; case AnimType.HIDE: play = an.PlayHide; time = an.TimeHide(); break; case AnimType.HIDE_BACK: play = an.PlayHideBack; time = an.TimeHideBack(); break; } if (play != null) { play(); } yield return(StartCoroutine(Pause(time))); if (callback != null) { callback(); } } else { if (animType == AnimType.NO_ANIM) { an.transform.localPosition = Vector3.zero; } if (callback != null) { callback(); } } }
/// <summary> /// Hides the sub back. /// </summary> private void HideSubBack(NoParamCallback callback = null) { if (m_StackSub.Count > 0) { string top = m_StackSub.Peek(); if (!string.IsNullOrEmpty(top)) { CloseScene(top, false, ForceType.FORCE_NO_DESTROY, AnimType.HIDE_BACK, callback); } } }
/// <summary> /// Shows the loading indicator /// </summary> /// <param name="alpha">Alpha of shield.</param> /// <param name="timeOut">Time out.</param> /// <param name="callBack">Call back.</param> public void ShowLoading(float alpha = 0.5f, float timeOut = 0, NoParamCallback callBack = null) { if (m_Loading == null) { return; } ShieldTopOn(alpha); m_Loading.SetActive(true); m_LoadingCount++; if (timeOut > 0) { StartCoroutine("IEHideLoading", new CallbackData(timeOut, callBack)); } }
private void LoadScene(string sn, NoParamCallback onLoaded) { if (m_Dict.ContainsKey(sn)) { ActiveScene(sn); onLoaded(); } else { SSApplication.LoadLevelAdditive(sn, m_IsLoadAsync, (GameObject root) => { GameObject scene = root; m_Dict.Add(sn, scene); scene.transform.parent = m_Scenes.transform; OnSceneLoad(scene); onLoaded(); }); } }
private void ClosePopUp(bool imme, NoParamCallback callback = null) { string curSn = m_StackPopUp.Pop (); string preSn = string.Empty; if (m_StackPopUp.Count >= 1) { preSn = m_StackPopUp.Peek(); } else { if (m_CurrentStackScreen != null && m_CurrentStackScreen.Count >= 1) { preSn = m_CurrentStackScreen.Peek(); } } CmClose (curSn, imme, () => { // Shield Off ShieldOff(); // Show & BGM change ShowAndBgmChangeClose(preSn); // Callback if (callback != null) { callback(); } }); }
/// <summary> /// Clears all game objects which were not called by 'DontDestroyOnLoad' /// </summary> protected void Clear(NoParamCallback callback = null) { SSApplication.LoadLevel("SSEmpty", false, false, (GameObject root) => { if (callback != null) { callback(); } }); }
public CallbackData(float timeOut, NoParamCallback callBack) { TimeOut = timeOut; Callback = callBack; }
protected IEnumerator IEPlayAnimation(string sn, AnimType animType, NoParamCallback callback = null) { SSMotion an = m_DictAllScene[sn].GetComponentInChildren<SSMotion>(); if (an != null && animType != AnimType.NO_ANIM) { an.Reset(animType); yield return null; NoParamCallback play = null; float time = 0; switch (animType) { case AnimType.SHOW: play = an.PlayShow; time = an.TimeShow (); break; case AnimType.SHOW_BACK: play = an.PlayShowBack; time = an.TimeShowBack (); break; case AnimType.HIDE: play = an.PlayHide; time = an.TimeHide (); break; case AnimType.HIDE_BACK: play = an.PlayHideBack; time = an.TimeHideBack (); break; } if (play != null) { play (); } yield return StartCoroutine (Pause (time)); yield return new WaitForEndOfFrame(); OnAnimationFinish(sn); if (callback != null) callback (); } else { if (animType == AnimType.NO_ANIM && an != null) { MoveAnimTransformPosition(an, 0); } if (callback != null) callback (); } }
public virtual void Close (bool immediate = false, NoParamCallback callback = null) { StartCoroutine( IEClose (immediate, callback) ); }
/// <summary> /// Shows the loading indicator /// </summary> /// <param name="alpha">Alpha of shield.</param> /// <param name="timeOut">Time out.</param> /// <param name="callBack">Call back.</param> public void ShowLoading(float alpha = 0.5f, float timeOut = 0, NoParamCallback callBack = null, float delay = 0.5f) { if (m_LoadingTop == null) return; ShieldTopOn (alpha); m_LoadingTop.SetActive (true); m_LoadingCount++; if (timeOut > 0) { StartCoroutine ("IEHideLoading", new CallbackData(timeOut, callBack)); } }
private void LoadScene(string sn, NoParamCallback onLoaded) { if (m_Dict.ContainsKey(sn)) { ActiveScene (sn); onLoaded (); } else { SSApplication.LoadLevelAdditive (sn, m_IsLoadAsync, (GameObject root) => { GameObject scene = root; m_Dict.Add(sn, scene); scene.transform.parent = m_Scenes.transform; OnSceneLoad (scene); onLoaded (); }); } }
private IEnumerator IEPlayAnimation(string sn, AnimType animType, NoParamCallback callback = null) { SSMotion an = m_Dict[sn].GetComponentInChildren<SSMotion>(); if (an != null && animType != AnimType.NO_ANIM) { yield return null; NoParamCallback play = null; float time = 0; switch (animType) { case AnimType.SHOW: play = an.PlayShow; time = an.TimeShow (); break; case AnimType.SHOW_BACK: play = an.PlayShowBack; time = an.TimeShowBack (); break; case AnimType.HIDE: play = an.PlayHide; time = an.TimeHide (); break; case AnimType.HIDE_BACK: play = an.PlayHideBack; time = an.TimeHideBack (); break; } if (play != null) { play (); } yield return StartCoroutine (Pause (time)); if (callback != null) callback (); } else { if (animType == AnimType.NO_ANIM) { an.transform.localPosition = Vector3.zero; } if (callback != null) callback (); } }
private void CmClose(string sceneName, bool imme, NoParamCallback onAnimEnded = null, bool forceDontDestroy = false) { string sn = sceneName; AnimType animType = (imme) ? AnimType.NO_ANIM : AnimType.HIDE; GameObject sc = GetRoot (sn); SSController ct = GetController (sn); if (ct != null) { // Show Empty shield ShowEmptyShield (); // Hide ct.OnFocus (false); ct.OnHide (); StartCoroutine(IEPlayAnimation(sn, animType, () => { // Deactive DeactiveAScene(sn); // Destroy or Cache if (!forceDontDestroy) { DestroyOrCache(sc, ct); } // Hide empty shield HideEmptyShield(); // Next Step if (onAnimEnded != null) onAnimEnded(); // No Busy m_IsBusy = false; })); } }
private void CloseScene(string sn, bool immediate, ForceType force = ForceType.NO_FORCE, AnimType animType = AnimType.HIDE, NoParamCallback callback = null) { // Event SSController ct = m_Dict[sn].GetComponentInChildren<SSController>(); if (ct != null) { ct.OnHide(); } // Play Animation if (!immediate) { StartCoroutine( IEPlayAnimation (sn, animType, () => { // Deactive or Destroy DeactiveOrDestroy(sn, force); if (callback != null) callback(); })); } else { // Deactive or Destroy DeactiveOrDestroy(sn, force); if (callback != null) callback(); } }
private void LoadOrActive(string sceneName, NoParamCallback onLoaded, SSCallBackDelegate onActive = null, SSCallBackDelegate onDeactive = null) { string sn = sceneName; if (m_DictAllScene.ContainsKey(sn)) { // Callback SetActiveDeactiveCallback (sn, onActive, onDeactive); // Active ActiveAScene (sn); // Event onLoaded (); } else { SSApplication.LoadLevel (sn, m_IsLoadAsync, m_IsAllAdditive || !m_NotAdditiveSceneList.Contains(sn), (GameObject root) => { GameObject scene = root; // Bring to very far BringAnimationToVeryFar(scene); // Add to dictionary m_DictAllScene.Add(sn, scene); // Set parent scene.transform.parent = m_Scenes.transform; // Callback SetActiveDeactiveCallback (sn, onActive, onDeactive); // Active ActiveAScene (sn); // Event OnSceneLoad (scene); onLoaded (); }); } }
private void CloseAny(bool imme = false, NoParamCallback callback = null) { if (m_StackPopUp.Count >= 1) { ClosePopUp (imme, callback); } else { if (m_CurrentStackScreen.Count > 1) { CloseScreen (imme, callback); } else { if (m_CurrentStackScreen.Count == 1) { // Do Nothing } m_IsBusy = false; } } }
private IEnumerator IEClose (bool immediate = false, NoParamCallback callback = null) { if (m_CanClose) { m_CanClose = false; CloseAny(immediate, callback); } else { yield return StartCoroutine(IEWaitForNotBusy()); CloseAny(immediate, callback); } }
/// <summary> /// Executed when the 'game process' (game.dat in fullscreen mode, qres.dat in windowed) has exited. /// </summary> private void GameProcessExited() { if (cmbP1Name.InvokeRequired) { ms.ParseStatistics(ProgramConstants.gamepath, defaultGame); StatisticsManager.Instance.AddMatchAndSaveDatabase(ms); NoParamCallback d = new NoParamCallback(GameProcessExited); this.BeginInvoke(d, null); return; } Logger.Log("The game process has exited; displaying game lobby."); DomainController.Instance().ReloadSettings(); ProgramConstants.IsInGame = false; CnCNetData.DoGameStopped(); if (gameLobbyPersistentCheckBox != "none") { int chkId = CheckBoxes.FindIndex(c => c.Name == gameLobbyPersistentCheckBox); if (chkId > -1) { if (!CheckBoxes[chkId].Checked) { btnLeaveGame.PerformClick(); return; } } } if (isHost) { string returnMessage = "NOTICE " + ChannelName + " " + CTCPChar1 + CTCPChar2 + "RETURN" + CTCPChar2; CnCNetData.ConnectionBridge.SendMessage(returnMessage); Seed = new Random().Next(10000, 99999); GenericGameOptionChanged(null, EventArgs.Empty); if (Players.Count < playerLimit) { UnlockGame(true); } timer.Stop(); timer.Tick -= UpdateGameListing; timer.Dispose(); timer = new Timer(); timer.Interval = 5000; timer.Tick += UpdateGameListing; timer.Start(); UpdateGameListing(null, EventArgs.Empty); } else { if (hasHostLeft) btnLeaveGame.PerformClick(); string returnMessage = "NOTICE " + ChannelName + " " + CTCPChar1 + CTCPChar2 + "RETURN" + CTCPChar2; CnCNetData.ConnectionBridge.SendMessage(returnMessage); if (isHostInGame) { DisplayHostInGameBox(); } } }
private void DisplayHostInGameBox() { if (this.InvokeRequired) { NoParamCallback d = new NoParamCallback(DisplayHostInGameBox); this.BeginInvoke(d, null); return; } AddNotice("The game host is still playing the game you previously started. " + "You can either wait for the host to return or leave the game room " + "by clicking Leave Game."); }
private void CloseScreen(bool imme, NoParamCallback callback = null) { string curSn = m_CurrentStackScreen.Pop (); string preSn = string.Empty; // Check if has prev scene if (m_CurrentStackScreen.Count > 0) { preSn = m_CurrentStackScreen.Peek (); } // Thread 1 (current scene animation) CmClose (curSn, imme, () => { if (callback != null) { callback(); } }); // Thread 2 (previous scene animation) if (!string.IsNullOrEmpty (preSn)) { // Active ActiveAScene (preSn); // Animation AnimType animType = (imme) ? AnimType.NO_ANIM : AnimType.SHOW_BACK; StartCoroutine (IEPlayAnimation (preSn, animType, () => { // Show & BGM change ShowAndBgmChangeClose (preSn); })); } else { // Do nothing or application quit } }
private void CmOpen(string sceneName, int ip, float ic, object data, bool imme, string curBgm, NoParamCallback onAnimEnded = null, NoParamCallback onLoaded = null, SSCallBackDelegate onActive = null, SSCallBackDelegate onDeactive = null) { string sn = sceneName; // Show Empty shield ShowEmptyShield (); LoadOrActive (sn, () => { if (onLoaded != null) { onLoaded(); } // Set camera and position SetCameras(sn, ic); SetCanvases(sn, ic); SetPosition(sn, ip); // On Set SSController ct = GetController(sn); if (ct != null) { ct.OnSet(data); } // Animation AnimType animType = (imme) ? AnimType.NO_ANIM : AnimType.SHOW; StartCoroutine (IEPlayAnimation (sn, animType, () => { // Show & BGM change ShowAndBgmChangeOpen (sn, curBgm); // Hide empty shield HideEmptyShield(); // Call back if (onAnimEnded != null) onAnimEnded(); // No busy m_IsBusy = false; })); }, onActive, onDeactive); }
private void CloseScene(string sn, bool immediate, ForceType force = ForceType.NO_FORCE, AnimType animType = AnimType.HIDE, NoParamCallback callback = null) { // Event SSController ct = m_Dict[sn].GetComponentInChildren <SSController>(); if (ct != null) { ct.OnHide(); } // Play Animation if (!immediate) { StartCoroutine(IEPlayAnimation(sn, animType, () => { // Deactive or Destroy DeactiveOrDestroy(sn, force); if (callback != null) { callback(); } })); } else { // Deactive or Destroy DeactiveOrDestroy(sn, force); if (callback != null) { callback(); } } }
/// <summary> /// Hides the sub back. /// </summary> private void HideSubBack(NoParamCallback callback = null) { if (m_StackSub.Count > 0) { string top = m_StackSub.Peek (); if (!string.IsNullOrEmpty (top)) { CloseScene (top, false, ForceType.FORCE_NO_DESTROY, AnimType.HIDE_BACK, callback); } } }