Esempio n. 1
0
 public void StartCreate(int owner)
 {
     if (PhotonNetwork.isMasterClient)
     {
         ownerID = owner;
         CoroutineUtility.GetInstance()
         .Do()
         .Then(() => CreateCatBall(dir[0], 0))
         .Then(() => CreateCatBall(dir[1], 1))
         .Then(() => CreateCatBall(dir[2], 2))
         .Wait(waitTime)
         .Then(() => CreateCatBall(dir[3], 0))
         .Then(() => CreateCatBall(dir[4], 1))
         .Then(() => CreateCatBall(dir[5], 2))
         .Wait(waitTime)
         .Then(() => CreateCatBall(dir[6], 0))
         .Then(() => CreateCatBall(dir[7], 1))
         .Then(() => CreateCatBall(dir[8], 2))
         .Wait(waitTime)
         .Then(() => CreateCatBall(dir[9], 0))
         .Then(() => CreateCatBall(dir[10], 1))
         .Then(() => CreateCatBall(dir[11], 2))
         .Then(() => Destroy(gameObject))
         .Go();
     }
     else
     {
         Destroy(gameObject);
     }
 }
Esempio n. 2
0
 private void Start()
 {
     CoroutineUtility.GetInstance()
     .Do()
     .UIMove(gameObject, Vector2.zero, 0.2f)
     .Go();
 }
Esempio n. 3
0
        IEnumerator CoroutineWithInternalErrorHandling()
        {
            startMessage = "STARTED";
            yield return(new WaitForSecondsRealtime(1));

            //we can yield it with catch or wait on it and check errors
            //we will use an empty catch to completely swallow the error
            yield return(new CFunc(ThrowExceptionCoroutine()).Catch(e => { }));

            endMessage = "FINISHED";

            yield return(new WaitForSecondsRealtime(1));

            //Here we will use our own wait and check the error manually. then we don't need a catch block.
            //The reason it does not buble the error is because we don't yield the ICFunc
            startMessage = "STARTED ANOTHER";

            ICFunc coroFunc2 = CoroutineUtility.Start(ThrowExceptionCoroutine());

            while (!coroFunc2.IsDone)
            {
                yield return(null);
            }
            if (coroFunc2.Error != null)
            {
                Debug.Log("We should have already seen an error log, but here is another..");
            }

            endMessage = "FINISHED ANOTHER";
        }
    public void GameOver()
    {
        Debug.Log("GameOverrrrrrrrrrrr");
        MainGameManager.getInstance().isGameOver = true;
        List <PlayerController> list             = PhotonManager.getInstance().playerList;

        CoroutineUtility.GetInstance()
        .Do()
        .Wait(1.2f)
        .Then(() => MainGameManager.getInstance().gameOverUI.SetActive(true))
        .Wait(3.5f)
        .Then(() => MainGameManager.getInstance().map.DisableBGM())
        .Then(() => ScoreManager.getInstance().scoreObj.SetActive(true))
        .Go();
        foreach (PlayerController p in list)
        {
            if (!p.isDied)
            {
                MainGameManager.getInstance().changeCameraFocusPanel.SetActive(false);
                CoroutineUtility.GetInstance()
                .Do()
                .Wait(1.5f)
                .Then(() => p.canMove = false)
                .Go();

                p.playerRig.velocity = Vector2.zero;
                ScoreManager.getInstance().SetRank(0, p);
            }
        }
        //MainGameManager.getInstance().GameOver();
    }
Esempio n. 5
0
 public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
 {
     if (scene.name == "Room")
     {
         CoroutineUtility.GetInstance().Do().Wait(0.5f).Then(Initial).Go();
     }
 }
Esempio n. 6
0
 public static void FrameDelayCall(this MonoBehaviour component, Callback function,
                                   int frames = 1)
 {
     component.StartCoroutine(
         CoroutineUtility.RunThenCallback(
             CoroutineUtility.WaitForFrames(frames), function));
 }
Esempio n. 7
0
 public static void TimeDelayCall(this MonoBehaviour component, Callback function,
                                  float seconds = 1)
 {
     component.StartCoroutine(
         CoroutineUtility.RunThenCallback(
             CoroutineUtility.WaitForSeconds(seconds), function));
 }
Esempio n. 8
0
        // Iterate phrases
        private static void IteratePhrases(TTSService service, TTSPreloadData preloadData, TTSPreloadIterateDelegate onIterate, Action <float> onProgress, Action <string> onComplete)
        {
            // No service
            if (service == null)
            {
                onComplete?.Invoke("\nNo TTSService found in current scene");
                return;
            }
            // No preload data
            if (preloadData == null)
            {
                onComplete?.Invoke("\nTTS Preload Data Not Found");
                return;
            }
            // Ignore if running
            if (Application.isPlaying)
            {
                onComplete?.Invoke("Cannot preload while running");
                return;
            }

            // Unload previous coroutine performer
            if (_performer != null)
            {
                MonoBehaviour.DestroyImmediate(_performer.gameObject);
                _performer = null;
            }

            // Run new coroutine
            _performer = CoroutineUtility.StartCoroutine(PerformIteratePhrases(service, preloadData, onIterate, onProgress, onComplete));
        }
 void Start()
 {
     for (int i = 0; i < 10; i++)
     {
         CoroutineUtility.Start(ParentCoroutine("id=" + i));
     }
 }
Esempio n. 10
0
        public IEnumerator CreatePolygon(List <FieldConnectPoint> points, float width, float uvY1, float uvY2)
        {
            var candidates = new WeightedValue[] { new WeightedValue {
                                                       value = width, weight = 1
                                                   } };

            yield return(CoroutineUtility.CoroutineCycle(CreatePolygon(points, candidates, uvY1, uvY2)));
        }
Esempio n. 11
0
 public IEnumerator FadeOut()
 {
     panel.SetActive(true);
     yield return(CoroutineUtility.RunThenCallback(
                      LerpAlpha((Color newColor) => this.color = newColor,
                                tint.a, 0.0f, duration, false, tint),
                      Hide));
 }
Esempio n. 12
0
 public void GameOverFunction()
 {
     this.gameObject.SetActive(true);
     SetGameOverText();
     StartCoroutine(CoroutineUtility.RunThenCallback(
                        winDisplayPanel.FadeIn(),
                        () => this.TimeDelayCall(
                            StartCountdown, delayBeforeResetCountdown)));
 }
Esempio n. 13
0
    public void PlayCrashEffect(Vector2 contactPoint)
    {
        GameObject effectObj = Instantiate(crashEffect, contactPoint, Quaternion.identity);

        CoroutineUtility.GetInstance()
        .Do()
        .Wait(0.5f)
        .Then(() => Destroy(effectObj))
        .Go();
    }
Esempio n. 14
0
 public void ChangeMap(int targetIndex)
 {
     isSlidingMap = true;
     CoroutineUtility.GetInstance()
     .Do()
     .DoEnumerator(Slide(MapContainer.gameObject, targetIndex))
     .Then(() => MoveMapPos(MapContainer.gameObject, nowMapIndex))
     .Then(() => isSlidingMap = false)
     .Go();
 }
Esempio n. 15
0
        protected IEnumerator _Hide(float waitTime)
        {
            if (isVisible == false)
            {
                yield break;
            }

            yield return(StartCoroutine(CoroutineUtility.WaitRealtime(waitTime)));

            DoHide();
        }
Esempio n. 16
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Esempio n. 17
0
 public void ReStartWholeGame()
 {
     AIList     = null;
     playerList = null;
     CoroutineUtility.GetInstance().Do()
     .Then(() => SceneManager.sceneLoaded -= OnSceneFinishedLoading)
     .Then(() => Destroy(this))
     .Then(() => SceneManager.LoadScene("FirstScene"))
     .Go();
     //Destroy(gameObject);
 }
Esempio n. 18
0
        public void Send <T>(IUploadWebRequest <T> request, Action <T> onResult = null) where T : WebResult, new()
        {
            var unityWebRequest = CreateUnityWebRequest(request);

            CoroutineUtility.Start(SendRequest(unityWebRequest, () =>
            {
                var result = new T();
                result.SetUnityWebRequest(unityWebRequest);
                onResult?.Invoke(result);
            }));
        }
Esempio n. 19
0
        // While active, perform any sent callbacks
        private void WatchMainThreadCallbacks()
        {
            // Ifnore if already performing
            if (_performer != null)
            {
                return;
            }

            // Check callbacks every frame (editor or runtime)
            _performer = CoroutineUtility.StartCoroutine(PerformMainThreadCallbacks());
        }
Esempio n. 20
0
 public static CoroutineUtility GetInstance()
 {
     if (Instance == null)
     {
         Instance = new GameObject("CoroutineUtility").AddComponent <CoroutineUtility>();
         return(Instance);
     }
     else
     {
         return(Instance);
     }
 }
Esempio n. 21
0
        public void Run()
        {
            var current = 0.0f;
            var target  = startSpeed;

            void WindUp(float t)
            {
                CurrentSpeed = Mathf.Lerp(current, target, t);
            }

            StartCoroutine(CoroutineUtility.InvokeOverTimeNormalized(WindUp, windUpDuration));
        }
Esempio n. 22
0
        public IEnumerator CreatePolygon(List <FieldConnectPoint> points, WeightedValue[] widthCandidates, float uvY1, float uvY2, float disconnectionProb = 0, float decalSize = 1)
        {
            if (meshFilter != null)
            {
                lastInterruptionTime = System.DateTime.Now;
                this.widthCandidates = widthCandidates;
                Prepare(points);
                yield return(CoroutineUtility.CoroutineCycle(CreateMeshParameter(points, uvY1, uvY2, decalSize)));

                meshFilter.sharedMesh = CreateMesh();
            }
        }
Esempio n. 23
0
        public void Stop()
        {
            var current = m_CurrentSpeed;
            var target  = 0.0f;

            void WindDown(float t)
            {
                CurrentSpeed = Mathf.Lerp(current, target, t);
            }

            StartCoroutine(CoroutineUtility.InvokeOverTimeNormalized(WindDown, windDownDuration));
        }
Esempio n. 24
0
 public void ImReady()
 {
     MainGameManager.getInstance().PlayerLoadingFinishCount++;
     if (MainGameManager.getInstance().PlayerLoadingFinishCount >= PhotonManager.getInstance().playerList.Count)
     {
         CoroutineUtility.GetInstance()
         .Do()
         .Wait(1.5f)
         .Then(() => gameObject.GetPhotonView().RPC("StartGame", PhotonTargets.All))
         .Go();
         Debug.Log("EveryBodyFinishLoading");
     }
 }
Esempio n. 25
0
    public void PlayAudio(string audioName, float afterTime)
    {
        if (audios == null)
        {
            InitialDictionary();
        }
        SoundEffect se = Instantiate(AudioHandler).GetComponent <SoundEffect>();

        CoroutineUtility.GetInstance()
        .Do()
        .Wait(afterTime)
        .Then(() => se.Play(audios[audioName]))
        .Go();
    }
Esempio n. 26
0
        static void SendRequest(UnityWebRequest request, Action <UnityWebRequest> callback)
        {
            if (s_Cache.ContainsKey(request.url))
            {
                callback.Invoke(s_Cache[request.url]);
                return;
            }

            CoroutineUtility.Start(SendRequestCoroutine(request, (result) =>
            {
                s_Cache.Add(result.url, result);
                callback.Invoke(result);
            }));
        }
Esempio n. 27
0
    public void Initial(int index, int id, bool isAI, string nickName)
    {
        int wait = 1;

        if (SceneManager.GetActiveScene().name == "Tutorial")
        {
            wait = 0;
        }
        CoroutineUtility.GetInstance()
        .Do()
        .Wait(wait)
        .Then(() => SpawnAnimation.SetActive(true))
        .Wait(0.3f)
        .Then(() => playerSprite.SetActive(true))
        .Wait(1f)
        .Then(() => SpawnAnimation.SetActive(false))
        .Go();
        this.isAI = isAI;
        if (PhotonManager.getInstance().playerList == null)
        {
            PhotonManager.getInstance().playerList = new List <PlayerController>();
        }
        PhotonManager.getInstance().playerList.Add(this);
        ID                  = id;
        this.index          = index;
        this.NickName       = nickName;
        PlayerNameText.text = nickName;
        if (isOwner())
        {
            OnSceneLoaded();
            MainGameManager.getInstance().player = this;
            if (SceneManager.GetActiveScene().name == "Tutorial")
            {
                TutorialManager.GetInstance().player = this;
            }
            //MainUIManager.instance.UpdateHealthBar(hp);
            SaveData playerData = EntireGameManager.getInstance().playerData;
            SetCharacterSprite(playerData.nowEquipment.animal, playerData.nowEquipment.cup, playerData.nowEquipment.liquid);
            gameObject.GetPhotonView().RPC("SetCharacterSprite", PhotonTargets.All, playerData.nowEquipment.animal, playerData.nowEquipment.cup, playerData.nowEquipment.liquid);
            GameObject inputer = PhotonNetwork.Instantiate("FakeInputer", Vector3.zero, Quaternion.identity, 0);
            fakeInputer          = inputer.GetComponent <FakeInputer>();
            fakeInputer.playerID = id;
            inputer.GetPhotonView().RPC("SetID", PhotonTargets.MasterClient, id);
            gameObject.GetPhotonView().RPC("SetSkill", PhotonTargets.All, playerData.nowEquipment.animal);
        }
        else if (isAI && PhotonNetwork.isMasterClient)
        {
            OnSceneLoaded();
        }
    }
Esempio n. 28
0
    public static void OneShotFadeTransition(float totalDuration,
                                             float blackScreenPauseDuration = 0.0f)
    {
        float            fadeDuration      = totalDuration * 0.5f;
        ScreenTransition screenTransition  = new ScreenTransition(fadeDuration);
        IEnumerator      coroutineSequence = CoroutineUtility.RunSequentially(
            screenTransition.FadeOut(),
            CoroutineUtility.WaitForRealtimeSeconds(blackScreenPauseDuration),
            screenTransition.FadeIn()
            );

        TransitionUtility.instance.StartCoroutine(
            CoroutineUtility.RunThenCallback(
                coroutineSequence,
                () => Destroy(screenTransition.panel.panel)));
    }
Esempio n. 29
0
    void checkInput()
    {
        //float x = joystick.Horizontal;
        //float y = joystick.Vertical;

        //target.x += x;
        //target.y += y;

        //forceFoward = new Vector2(x, y);
        if (MainGameManager.getInstance().isGameOver)
        {
            return;
        }
        if (isAI)
        {
            if (AITime > 1)
            {
                float x = UnityEngine.Random.Range(-6, 7);
                float y = UnityEngine.Random.Range(-6, 7);
                forceFoward = new Vector2(x, y);
                if (isAIFocusEnemy && UnityEngine.Random.Range(0, 2) >= 1)
                {
                    forceFoward = AIFocusEnemy.transform.position - transform.position;
                }
                CoroutineUtility.GetInstance().Do().Wait(0.6f).Then(() => forceFoward = Vector2.zero).Go();
                if (mp >= 100)
                {
                    gameObject.GetPhotonView().RPC("UseSkill", PhotonTargets.All);
                }
                AITime = 0;
            }
        }
        if (canMove)
        {
            playerRig.AddForce(forceFoward * (0.1f * (maxVelcocity + speedBuff)), ForceMode2D.Impulse);
            if (Vector2.Distance(Vector2.zero, playerRig.velocity) > maxVelcocity + speedBuff)
            {
                playerRig.velocity = playerRig.velocity.normalized * (maxVelcocity + speedBuff);
            }
        }


        //photonView.RPC("PlayerMove", PhotonTargets.MasterClient, forceFoward);
        //playerRig.AddForce(forceFoward * 1.5f, ForceMode2D.Impulse);
        //if (Vector2.Distance(Vector2.zero, playerRig.velocity) > maxVelcocity)
        //    playerRig.velocity = playerRig.velocity.normalized * maxVelcocity;
    }
Esempio n. 30
0
        protected IEnumerator _Show(float waitTime)
        {
            if (isVisible)
            {
                yield break;
            }

            // Show default page before wait is completed, otherwise it'd pop in after time.
            if (defaultPage != null)
            {
                defaultPage.Show();
            }

            yield return(StartCoroutine(CoroutineUtility.WaitRealtime(waitTime)));

            DoShow();
        }