public void StopVideo(System.Action onStopped = null, bool withFade = false)
        {
            _isStopping = true;

            if (withFade)
            {
                _image.DOComplete();
                _image.DOFade(0f, 0.5f).OnComplete(() =>
                {
                    if (_vp.isPlaying)
                    {
                        _vp.Stop();
                    }

                    _image.SetAlpha(0f);
                    onStopped.SafeInvoke();
                    _isStopping = false;
                });
            }
            else
            {
                if (_vp.isPlaying)
                {
                    _vp.Stop();
                }

                _image.SetAlpha(0f);
                onStopped.SafeInvoke();
                _isStopping = false;
            }
        }
Exemple #2
0
    public void OrderedUndo(HistoryActionContainer actionContainer)
    {
        //Find where it is on the list.
        int index     = undoList.IndexOf(actionContainer);
        int lastIndex = undoList.Count - 1;
        List <HistoryActionContainer> cacheList = new List <HistoryActionContainer>(undoList);

        for (int i = lastIndex; i > index - 1; i--)
        {
            Undo(cacheList[i]);
        }

        OnHistoryChanged.SafeInvoke();
    }
Exemple #3
0
    public void DoRotate(Vector3 direction, bool tIsEnd)
    {
        if ((mInputDirection == direction ||
             (tIsEnd && (mInputDirection == Vector3.left || mInputDirection == Vector3.right))) &&
            mIsGround && !mIsSlide)
        {
            if (mRotateDirection == -1)
            {
                this.transform.Rotate(Vector3.up * -90, Space.Self);
            }
            else if (mRotateDirection == 1)
            {
                this.transform.Rotate(Vector3.up * 90, Space.Self);
            }
            mCallOnRotate.SafeInvoke(mRotateDirection);
            mRotateDirection = 0;
            mInputDirection  = Vector2.zero;
            mIsRotateDelay   = true;
            Invoke("Rotateable", 0.3f);
        }
        else//게임오버 처리
        {
            GameOver();
        }

        mIsDirectionInputChecking = false;
    }
Exemple #4
0
    public void PresentCoin(int coinNum, Vector3 origin, int startCoinNum, System.Action callback)
    {
        float popingDuration = 0.5f;
        float earnDuration   = 0.75f;
        int   showCoinNum    = Mathf.RoundToInt(coinNum * 0.1f);

        showCoinNum = Mathf.Min(15, showCoinNum);
        var maxDelayFrame = 0;

        for (int i = 0; i < showCoinNum; i++)
        {
            maxDelayFrame = 2 * i;
            StartCoroutine(KKUtilities.DelayFrame(maxDelayFrame, () => StartCoroutine(EarnCoinAnimation(origin, popingDuration, earnDuration))));
        }

        float delay    = popingDuration + earnDuration - 0.25f;
        float duration = 0.08f * showCoinNum;

        StartCoroutine(KKUtilities.Delay(delay, () =>
        {
            CountUpText(startCoinNum, startCoinNum + coinNum, duration);
        }, false));

        this.DelayFrame(maxDelayFrame, () =>
        {
            this.Delay(popingDuration + earnDuration, () => callback.SafeInvoke());
        });
    }
Exemple #5
0
 public static void DoTimes(this int times, System.Action <int> action)
 {
     for (int i = 0; i < times; i++)
     {
         action.SafeInvoke(i);
     }
 }
Exemple #6
0
        private void UpdateChannels(TLVector <TLChatBase> channels, System.Action callback)
        {
            const int firstSliceCount = 3;
            var       secondSlice     = new List <TLChatBase>();

            for (var i = 0; i < channels.Count; i++)
            {
                if (i < firstSliceCount)
                {
                    //users[i].IsAdmin = false;
                    Items.Add(channels[i]);
                }
                else
                {
                    secondSlice.Add(channels[i]);
                }
            }

            Execute.BeginOnUIThread(() =>
            {
                foreach (var user in secondSlice)
                {
                    //user.IsAdmin = false;
                    Items.Add(user);
                }
                callback.SafeInvoke();
            });
        }
Exemple #7
0
    IEnumerator ScrollAnimation(System.Action callback = null)
    {
        backPanel.SetActive(true);
        textContainer.gameObject.SetActive(true);
        var startDelayTime = 0.5f;

        textContainer.anchoredPosition = Vector2.down * 750.0f;

        yield return(new WaitForSeconds(startDelayTime));

        currentSpeed = scrollSpeed;
        while (true)
        {
            yield return(null);

            textContainer.anchoredPosition += Vector2.up * currentSpeed;

            if (textContainer.anchoredPosition.y > textContainer.sizeDelta.y - 500.0f)
            {
                break;
            }
        }

        backPanel.SetActive(false);
        textContainer.gameObject.SetActive(false);
        pageObj.SetActive(false);

        callback.SafeInvoke();
    }
Exemple #8
0
 private void Recieve()
 {
     while (true)
     {
         try
         {
             IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, 0);
             byte[]     data     = _udp.Receive(ref remoteEP);
             string     text     = System.Text.Encoding.UTF8.GetString(data);
             OnDataRacieved.SafeInvoke(text);
         }
         catch (SocketException)
         {
             //Debug.Log(e.Message);
         }
     }
 }
Exemple #9
0
        private void OnDropdownValueChanged(int val)
        {
            if (_withoutChangeCallback)
            {
                _withoutChangeCallback = false;
                return;
            }

            onValueChanged.SafeInvoke(val);
        }
Exemple #10
0
 private void GameOver()
 {
     if (IsImmotal)
     {
         return;
     }
     SetMoveStart(false);
     Anim.Get().SetTrigger("AnimTrigGameOver");
     mCallOnGameOver.SafeInvoke();
 }
Exemple #11
0
        private void OnToggleValueChanged(bool isOn)
        {
            if (_withoutChangeValueCallback)
            {
                _withoutChangeValueCallback = false;
                return;
            }

            onValueChanged.SafeInvoke(isOn);
        }
Exemple #12
0
 /// @param callback
 ///     The function to call when the Global Director is ready
 ///
 public static void CallWhenReady(System.Action callback)
 {
     if (HasInstance() && GetInstance().IsReady())
     {
         callback.SafeInvoke();
     }
     else
     {
         OnReady += callback;
     }
 }
Exemple #13
0
        public bool TrySkipVideo(int frame = -1)
        {
            if (_isStopping || !_vp.isPlaying)
            {
                return(false);
            }

            _image.DOComplete();
            _image.SetAlpha(1f);
            _vp.Pause();

            if (frame < 0)
            {
                frame = (int)_vp.frameCount;
            }

            _vp.frame = frame;
            _onEndOfFrame.SafeInvoke();
            return(true);
        }
Exemple #14
0
        //private void OnEndInputFieldEdit(string text)
        //{
        //    if (float.TryParse(text, out float res))
        //    {
        //        _slider.value = res;
        //    }
        //}

        private void OnChangeSliderValue(float val)
        {
            _valueText.text = val.ToString("F2");

            if (_withoutCallback)
            {
                _withoutCallback = false;
                return;
            }

            onValueChanged.SafeInvoke(val);
        }
Exemple #15
0
    IEnumerator MoveWindow(RectTransform holder, float moveToY, System.Action onCompleteAction = null)
    {
        var targetPosition = holder.anchoredPosition;

        targetPosition.y = moveToY;
        while (holder.anchoredPosition != targetPosition)
        {
            yield return(null);

            holder.anchoredPosition = Vector2.MoveTowards(holder.anchoredPosition, targetPosition, Time.unscaledDeltaTime * MoveSpeed);
        }
        onCompleteAction.SafeInvoke();
    }
        public static void DrawSelector <T>(string title, Color elementColor, T[] variants, System.Converter <T, string> converter, System.Action <T> selectionCallback, params GUILayoutOption[] options)
        {
            var values = new[] { title }.Concat(variants.ConvertAll(converter));
            var color = GUI.backgroundColor;

            GUI.backgroundColor = elementColor;
            var newIndex = EditorGUILayout.Popup(0, values, options);

            if (newIndex > 0)
            {
                selectionCallback.SafeInvoke(variants[newIndex - 1]);
            }
            GUI.backgroundColor = color;
        }
Exemple #17
0
    public static void CreateOrAddComponentToPrefab <T>(DBEntry dbEntry, string key, System.Action <T> onAdding) where T : Component
    {
        var originalPrefab = dbEntry.Load <GameObject>(key);

#if UNITY_2018_3_OR_NEWER
        var path      = AssetDatabase.GetAssetPath(originalPrefab);
        var prefabGO  = PrefabUtility.LoadPrefabContents(path);
        var component = prefabGO.GetComponent <T>();
        if (component == null)
        {
            component = prefabGO.AddComponent <T>();
        }
        onAdding.SafeInvoke(component);
        PrefabUtility.SaveAsPrefabAsset(prefabGO, path);
#else
        var component = originalPrefab.GetComponent <ComponentType>();
        if (component == null)
        {
            component = originalPrefab.AddComponent <ComponentType>();
        }
        onAdding.SafeInvoke(component);
#endif
        EditorUtility.SetDirty(originalPrefab);
    }
Exemple #18
0
    public void ShowRewardVideo(string key, System.Action onSuccess, System.Action onFailuer)
    {
#if IMPORT_HYPERCOMMON
        AudioManager.Instance.SetMute(true);
        AdManager.Instance.ShowRewardBasedVideoWithKey(key, (_) =>
        {
            AudioManager.Instance.SetMute(false);
            onSuccess.SafeInvoke();
        }, (_) =>
        {
            AudioManager.Instance.SetMute(false);
            onFailuer.SafeInvoke();
        });
#endif
    }
        private void Awake()
        {
            if (instance != null)
            {
                Debug.LogWarning("Can't have two VideoThumbnail instances running at the same time!\nInitial instance is now obsolete.");
            }

            if (ThumbnailVideoPlayer == null)
            {
                ThumbnailVideoPlayer = GetComponent <VideoPlayer>();
            }

            ThumbnailVideoPlayer.prepareCompleted += delegate { onVideoPlayerPrepared.SafeInvoke(); };

            instance = this;
        }
    /// <summary>
    /// 先頭に点を追加する
    /// </summary>
    /// <param name="point">点</param>
    /// <param name="isRefresh">Viewを更新するか</param>
    /// <param name="callEvent">点を追加したイベントを呼ぶか</param>
    public void AddFirstPoint(Vector3 point, bool isRefresh = true, bool callEvent = true)
    {
        //イベントを呼ぶよりも先に点の追加を行いたいので一時変数を使う
        Vector3 temp = FirstPoint;

        positionList.Insert(0, point);

        if (callEvent && PointCount > 0)
        {
            OnAddFirstPoint.SafeInvoke(temp, point);
        }

        if (isRefresh)
        {
            Refresh();
        }
    }
    //Slide to target Section
    private IEnumerator GoToRoutine(RectTransform target)
    {
        Canvas.ForceUpdateCanvases();
        Vector2 localScrollRectPosition    = (Vector2)MyScrollRect.transform.InverseTransformPoint(Content.position);
        Vector2 localNewScrollRectPosition = (Vector2)MyScrollRect.transform.InverseTransformPoint(target.position);
        Vector2 targetPosition             = localScrollRectPosition - localNewScrollRectPosition;

        MyScrollRect.enabled = false;
        while ((Vector2)Content.localPosition != targetPosition)
        {
            OnValueChanged.SafeInvoke();
            Content.localPosition = Vector2.Lerp(Content.localPosition, targetPosition, m_slideSpeed);
            if (Vector2.Distance(Content.localPosition, targetPosition) < 5)
            {
                Content.localPosition = targetPosition;
                break;
            }
            yield return(null);
        }
        MyScrollRect.enabled = true;
    }
Exemple #22
0
    private void Update()
    {
        m_PointPosition.y = transform.position.y;
        bool isIdle = m_NavAgent.velocity.AlmostEquals(Vector3.zero);

        if (isIdle != IsIdle)
        {
            UpdateMovement(isIdle);
            UpdateSpeech();
        }

        Quaternion targetRotation = isIdle == true ? m_PointRotation : Quaternion.LookRotation(m_PointPosition - transform.position, Vector3.up);

        transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * m_RotationSpeed);

        if (m_StateUpdated == true)
        {
            StateUpdated.SafeInvoke();
            m_StateUpdated = false;
        }

        UpdateAlpha();
    }
        public static void EditPhoto(System.Action <byte[]> callback)
        {
            var photoChooserTask = new PhotoChooserTask {
                ShowCamera = true, PixelHeight = 800, PixelWidth = 800
            };

            photoChooserTask.Completed += (o, e) =>
            {
                if (e.TaskResult == TaskResult.OK)
                {
                    byte[] bytes;
                    var    sourceStream = e.ChosenPhoto;
                    using (var memoryStream = new MemoryStream())
                    {
                        sourceStream.CopyTo(memoryStream);
                        bytes = memoryStream.ToArray();
                    }

                    callback.SafeInvoke(bytes);
                }
            };
            photoChooserTask.Show();
        }
        private IEnumerator _PlayVideo(bool withFade, System.Action onStartOfFrame)
        {
            _vp.Prepare();

            while (!_vp.isPrepared)
            {
                yield return(null);
            }

            _vp.Play();
            _image.texture = _vp.texture;
            _selfRectTR.SetSize(_vp.texture.width, _vp.texture.height);
            onStartOfFrame.SafeInvoke();

            if (withFade)
            {
                _image.DOComplete();
                _image.DOFade(1f, 0.5f);
            }
            else
            {
                _image.SetAlpha(1);
            }
        }
Exemple #25
0
 protected virtual void OnDataRecieved(T packet)
 {
     onDataRecieved.SafeInvoke(packet);
 }
Exemple #26
0
 protected virtual void OnLatestDataRecieved(T recievedData)
 {
     onLatestDataRecieved.SafeInvoke(recievedData);
 }
Exemple #27
0
 private void OnClickDebugButton()
 {
     onClick.SafeInvoke();
 }
 public void ClearCache()
 {
     _clearCacheAction.SafeInvoke();
     Close();
 }
Exemple #29
0
        /// @param callback
        ///		the action to perform once the frame ended
        ///
        private static IEnumerator WaitForEndOfFrame(System.Action callback)
        {
            yield return(null);

            callback.SafeInvoke();
        }
Exemple #30
0
        /// @param time
        ///		the time to wait for in seconds
        /// @param callback
        ///		the action to perform once the time is up
        ///
        private static IEnumerator WaitForSeconds(float time, System.Action callback)
        {
            yield return(new WaitForSeconds(time));

            callback.SafeInvoke();
        }