Exemple #1
0
    IEnumerator StartTimer()
    {
        while (_levelInProgress && _timeLeft > 0)
        {
            yield return(new WaitForSeconds(1));

            _timeLeft -= 1;
            OnTimeChanged?.Invoke(_timeLeft);


            if (_nextWarningIndex < TimeLeftWhenWarningPlays.Count)
            {
                if (_nextWarningIndex > 0 && _timeLeft > TimeLeftWhenWarningPlays[_nextWarningIndex - 1])
                {
                    _nextWarningIndex--;
                }

                if (_timeLeft == TimeLeftWhenWarningPlays[_nextWarningIndex])
                {
                    OnWarning?.Invoke(_timeLeft);
                    _nextWarningIndex++;
                }
            }

            if (_timeLeft == 0)
            {
                WhenTimeRunsOut();
            }
        }
    }
Exemple #2
0
 /*
  * It's button func on WarningButton
  */
 public void OnWarningBackClicked()
 {
     audioM.Click();
     OnWarning?.Invoke(this, new WarningArgs {
         action = WindowAction.Close
     });
 }
Exemple #3
0
 /*
  * It's button func on WarningButton
  */
 public void OnWarningConfirmClicked()
 {
     audioM.Click();
     // SEND WARNING TO US
     Debug.LogWarning("Warning on the question!");
     OnWarning?.Invoke(this, new WarningArgs {
         action = WindowAction.Confirm
     });
 }
Exemple #4
0
        internal static void Log(string msg, LogType type = LogType.Info)
        {
            switch (type)
            {
            case LogType.Info:
                OnInfo?.Invoke(msg);
                break;

            case LogType.Warning:
                OnWarning?.Invoke(msg);
                break;

            case LogType.Error:
                OnError?.Invoke(msg);
                break;
            }
        }
Exemple #5
0
        private void OnEngineHttpMessageEnd([In][MarshalAs(UnmanagedType.LPStr)] string requestHeaders, uint requestHeadersLength, [In] IntPtr requestBody, uint requestBodyLength, [In][MarshalAs(UnmanagedType.LPStr)] string responseHeaders, uint responseHeadersLength, [In] IntPtr responseBody, uint responseBodyLength, ref bool shouldBlock, NativeCustomResponseStreamWriter customBlockResponseStreamWriter)
        {
            byte[] requestBodyManaged  = null;
            byte[] responseBodyManaged = null;

            if (requestBody != IntPtr.Zero)
            {
                requestBodyManaged = new byte[requestBodyLength];
                Marshal.Copy(requestBody, requestBodyManaged, 0, requestBodyManaged.Length);
            }

            if (responseBody != IntPtr.Zero)
            {
                responseBodyManaged = new byte[requestBodyLength];
                Marshal.Copy(responseBody, responseBodyManaged, 0, responseBodyManaged.Length);
            }

            ResponseWriter thisWriter = (byte[] responseData) =>
            {
                var myNativeWriter = customBlockResponseStreamWriter;
                if (myNativeWriter == null)
                {
                    OnWarning?.Invoke("Native response writers exhausted.");
                }

                myNativeWriter?.Invoke(responseData, (uint)responseData.Length);

                GC.KeepAlive(myNativeWriter);
            };

            var shouldBlockManaged = false;

            HttpMessageEndCallback?.Invoke(requestHeaders, requestBodyManaged, responseHeaders, responseBodyManaged, out shouldBlockManaged, thisWriter);

            shouldBlock = shouldBlockManaged;
        }
Exemple #6
0
        private void OnEngineHttpMessageBegin([In][MarshalAs(UnmanagedType.LPStr)] string requestHeaders, uint requestHeadersLength, [In] IntPtr requestBody, uint requestBodyLength, [In][MarshalAs(UnmanagedType.LPStr)] string responseHeaders, uint responseHeadersLength, [In] IntPtr responseBody, uint responseBodyLength, ref uint nextAction, NativeCustomResponseStreamWriter customBlockResponseStreamWriter)
        {
            byte[] requestBodyManaged  = null;
            byte[] responseBodyManaged = null;

            if (requestBody != IntPtr.Zero)
            {
                requestBodyManaged = new byte[requestBodyLength];
                Marshal.Copy(requestBody, requestBodyManaged, 0, requestBodyManaged.Length);
            }

            if (responseBody != IntPtr.Zero)
            {
                responseBodyManaged = new byte[requestBodyLength];
                Marshal.Copy(responseBody, responseBodyManaged, 0, responseBodyManaged.Length);
            }

            ResponseWriter thisWriter = (byte[] responseData) =>
            {
                var myNativeWriter = customBlockResponseStreamWriter;
                if (myNativeWriter == null)
                {
                    OnWarning?.Invoke("Native response writers exhausted.");
                }

                myNativeWriter?.Invoke(responseData, (uint)responseData.Length);

                GC.KeepAlive(myNativeWriter);
            };

            var managedNextAction = ProxyNextAction.AllowAndIgnoreContentAndResponse;

            HttpMessageBeginCallback?.Invoke(requestHeaders, requestBodyManaged, responseHeaders, responseBodyManaged, out managedNextAction, thisWriter);

            nextAction = (uint)managedNextAction;
        }
Exemple #7
0
 private void OnEngineWarning(string message, uint messageLength)
 {
     OnWarning?.Invoke(message);
 }