void CheckElapsedTime <T>(CurrentRequestType crt, float timer, WWW www, bool completeFlag) { GameObject go = new GameObject("PubnubUnitTestCoroutine"); CoroutineClass cc = go.AddComponent <CoroutineClass> (); if (crt.Equals(CurrentRequestType.Subscribe)) { cc.isSubscribeComplete = completeFlag; cc.SubCompleteOrTimeoutEvent += CcCoroutineComplete <T>; } else if (crt.Equals(CurrentRequestType.NonSubscribe)) { cc.isNonSubscribeComplete = completeFlag; cc.NonsubCompleteOrTimeoutEvent += CcCoroutineComplete <T>; } else if (crt.Equals(CurrentRequestType.PresenceHeartbeat)) { cc.isPresenceHeartbeatComplete = completeFlag; cc.PresenceHeartbeatCompleteOrTimeoutEvent += CcCoroutineComplete <T>; } else if (crt.Equals(CurrentRequestType.Heartbeat)) { cc.isHearbeatComplete = completeFlag; cc.HeartbeatCompleteOrTimeoutEvent += CcCoroutineComplete <T>; } sCrt = crt; responseHandled = false; cc.CheckElapsedTime(crt, timer, www); UnityEngine.Debug.Log("waiting"); //Wait (); //Assert.True (responseHandled); }
void OnEnable() { if (cc == null) { cc = scCoroutine.Instance.Begin(GeneratingParticles()); } }
void CheckIfRequestIsRunning <T>(CurrentRequestType crt, bool completeFlag) { GameObject go = new GameObject("PubnubUnitTestCoroutine"); CoroutineClass cc = go.AddComponent <CoroutineClass> (); if (crt.Equals(CurrentRequestType.Subscribe)) { cc.isSubscribeComplete = completeFlag; } else if (crt.Equals(CurrentRequestType.NonSubscribe)) { cc.isNonSubscribeComplete = completeFlag; } else if (crt.Equals(CurrentRequestType.PresenceHeartbeat)) { cc.isPresenceHeartbeatComplete = completeFlag; } else if (crt.Equals(CurrentRequestType.Heartbeat)) { cc.isHearbeatComplete = completeFlag; } if (completeFlag) { Assert.False(cc.CheckIfRequestIsRunning(crt)); } else { Assert.True(cc.CheckIfRequestIsRunning(crt)); } }
/// <summary> /// This method is used to manage the cards that have been returned /// _listCheckImgID contains 2 cards. The card 1 and card 2. /// tmp1 and tmp2 to avoid blocking when you click on several card too quickly /// </summary> /// <param name="cs">Direct link to cardScript. Used to check IDs</param> public void AddIDToList(CardScript cs) { CardScript tmp1, tmp2; switch (_listCheckImgID.Count) { case 0: _listCheckImgID.Add(cs); break; case 1: _listCheckImgID.Add(cs); tmp1 = _listCheckImgID[0]; tmp2 = _listCheckImgID[1]; //If cards are not the same, rotate them face down. If same, translate them face shown if (!CheckSameImg()) { StartCoroutine(CoroutineClass.WaiterRotateBack(tmp1, tmp2)); } else { StartCoroutine(CoroutineClass.WaiterTranslate(tmp1, tmp2)); nbCardLeft--; } _listCheckImgID.Clear(); break; case 2: _listCheckImgID.Clear(); _listCheckImgID.Add(cs); break; } }
public void SetGetCoroutineParams <T>(string[] multiChannel, string url, CurrentRequestType crt, ResponseType respType, int timeout, bool resumeOnReconnect, bool isTimeout ) { List <ChannelEntity> channelEntities = Helpers.CreateChannelEntity <T>(multiChannel, true, false, null, null, null, null, null, null); RequestState <T> pubnubRequestState = BuildRequests.BuildRequestState <T> (channelEntities, respType, resumeOnReconnect, 0, isTimeout, 0, typeof(T)); CoroutineParams <T> cp = new CoroutineParams <T> (url, timeout, 0, crt, typeof(T), pubnubRequestState); GameObject go = new GameObject("PubnubUnitTestCoroutine"); CoroutineClass cc = go.AddComponent <CoroutineClass> (); cc.SetCoroutineParams <T>(crt, cp); CoroutineParams <T> cp2 = cc.GetCoroutineParams <T>(crt) as CoroutineParams <T>; Assert.True(cp.crt.Equals(cp2.crt)); Assert.True(cp.pause.Equals(cp2.pause)); Assert.True(cp.timeout.Equals(cp2.timeout)); Assert.True(cp.url.Equals(cp2.url)); }
/// <summary> /// Method used to rotate back card (when 2 returned cards aren't identical) /// And translate it to the board /// </summary> public void RotateBackCard() { //GetComponent<Collider>().enabled = false; StartCoroutine(CoroutineClass.Rotation(transform, new Vector3(0, 180, 0), StaticParameterClass.SpeedLevel + 0.1f)); StartCoroutine(CoroutineClass.Translation(transform, transform.position, source, 1.0f, CoroutineClass.MoveType.Time)); //GetComponent<Collider>().enabled = true; }
/// <summary> /// Update method. /// It will run once per frame. /// Each frame, we will check SCORE, TIME and if player has WON /// </summary> private void Update() { //Timer and score { if (!pauseTimer) { time += Time.deltaTime; } var min = Mathf.Floor(time / 60); var sec = time % 60; var micro = (time * 100) % 100; timeText.text = string.Format("{0:00} : {1:00} : {2:00}", min, sec, micro); scoreText.text = "Score : " + (nbFirstTryHit * 100).ToString(); } //Win condition if (nbCardLeft == 0) { //foreach (GameObject g in _listGOCard) // Destroy(g); StartCoroutine(CoroutineClass.WinGame(this)); pauseTimer = true; score = (nbFirstTryHit / time) * 1000; } }
void OnDisable() { CurrentGenerated = 0; if (cc != null) { cc.Stop(); cc = null; } }
public static Coroutine Wait(this MonoBehaviour mono, float time, System.Action action) { if (coroutine == null) { var go = new GameObject(); go.hideFlags = HideFlags.HideInHierarchy | HideFlags.DontSave; coroutine = go.AddComponent <CoroutineClass>(); //Object.DontDestroyOnLoad(go); } return(coroutine.StartCoroutine(itrWait(time, action))); }
void StopTimeouts(CurrentRequestType crt) { GameObject go = new GameObject("PubnubUnitTestCoroutine"); CoroutineClass cc = go.AddComponent <CoroutineClass> (); if (crt.Equals(CurrentRequestType.Subscribe)) { cc.runSubscribeTimer = true; } else if (crt.Equals(CurrentRequestType.NonSubscribe)) { cc.runNonSubscribeTimer = true; } else if (crt.Equals(CurrentRequestType.PresenceHeartbeat)) { cc.runPresenceHeartbeatTimer = true; } else if (crt.Equals(CurrentRequestType.Heartbeat)) { cc.runHeartbeatTimer = true; } cc.StopTimeouts(crt); if (crt.Equals(CurrentRequestType.Subscribe)) { Assert.True(!cc.runSubscribeTimer); Assert.True(cc.subscribeTimer.Equals(0)); } else if (crt.Equals(CurrentRequestType.NonSubscribe)) { Assert.True(!cc.runNonSubscribeTimer); Assert.True(cc.nonSubscribeTimer.Equals(0)); } else if (crt.Equals(CurrentRequestType.PresenceHeartbeat)) { Assert.True(!cc.runPresenceHeartbeatTimer); Assert.True(cc.presenceHeartbeatTimer.Equals(0)); Assert.True(!cc.runPresenceHeartbeatPauseTimer); Assert.True(cc.presenceHeartbeatPauseTimer.Equals(0)); } else if (crt.Equals(CurrentRequestType.Heartbeat)) { Assert.True(!cc.runHeartbeatTimer); Assert.True(cc.heartbeatTimer.Equals(0)); Assert.True(!cc.runPresenceHeartbeatPauseTimer); Assert.True(cc.heartbeatPauseTimer.Equals(0)); } }
/// <summary> /// Method used to translate card (face shown) to the board when they're the same /// </summary> public void TranslateBackCard() { StartCoroutine(CoroutineClass.Translation(transform, transform.position, source, 1.0f, CoroutineClass.MoveType.Time)); }
/// <summary> /// Method used to rotate card from a Coroutine /// And translate card closer than the player /// </summary> public void RotateCard() { StartCoroutine(CoroutineClass.Translation(transform, transform.position, transform.position - destination, 0.2f, CoroutineClass.MoveType.Time)); StartCoroutine(CoroutineClass.Rotation(transform, new Vector3(0, 180, 0), 0.5f)); }
/// <summary> /// On mouse down /// Play sound and start rotate card /// </summary> void OnMouseDown() { audioSource.Play(0); StartCoroutine(CoroutineClass.OnMouseDown(this, gameScript)); }
public scNetworkLoading LoadingForWhile(CoroutineClass cc) { Content.SetActiveSmart(true); ccs.Add(cc); return(this); }