Exemple #1
0
 void RunPlayerAnimation()
 {
     if (data.PlayerCoinCount > 0 && Elements["instruction2"].Visible && !animationsRun["player"])
     {
         if (data.IsDecider)
         {
             Co.WaitForSeconds(0.5f, () => {
                 AnimElementUI coin = CreateAnimation();
                 coin.SpriteName    = "coin";
                 coin.Text          = "+" + data.PlayerCoinCount.ToString();
                 coin.Size          = new Vector2(100, 100);
                 coin.TextPadding   = new Vector2(-10, 0);
                 coin.Animate(new UIAnimator.Expand(1.5f, () => {
                     Co.WaitForSeconds(1f, () => {
                         coin.Animate(new UIAnimator.Shrink(1.5f, () => {
                             coin.Destroy();
                         }));
                     });
                 }));
             });
         }
         else
         {
             RunCoinAnimation(data.PlayerCoinCount.ToString(), data.PlayerAvatarColor);
         }
         animationsRun["player"] = true;
     }
 }
 public void DelayedFadeIn(float delay = 0.75f, float fadeTime = 0.5f)
 {
     Alpha = 0f;
     Co.WaitForSeconds(delay, () => {
         Animate(new UIAnimator.FadeIn(fadeTime));
     });
 }
Exemple #3
0
        protected override void OnInputEnabled()
        {
            // Introduce the coin
            AnimElementUI coin = CreateAnimation();

            coin.SpriteName    = "coin";
            coin.Text          = "+" + data.CoinCount.ToString();
            coin.Size          = new Vector2(50, 50);
            coin.LocalPosition = new Vector3(-50, 25, 0);
            coin.Animate(new UIAnimator.Expand(0.5f));

            Co.WaitForSeconds(1f, () => {
                // Introduce the avatar
                Vector3 avatarPosition = new Vector3(50, 25f, 0);
                AnimElementUI avatar   = CreateAnimation();
                avatar.AvatarName      = data.PlayerAvatarColor;
                avatar.Size            = new Vector2(75, 75);
                avatar.LocalPosition   = avatarPosition;
                avatar.Animate(new UIAnimator.Expand(0.5f));

                Co.WaitForSeconds(0.5f, () => {
                    coin.Animate(new UIAnimator.Shrink(0.5f));

                    Co.WaitForSeconds(0.5f, () => {
                        avatar.Animate(new UIAnimator.Spin(0.5f, () => {
                            avatar.Animate(new UIAnimator.Shrink(0.5f));
                        }));
                    });
                });
            });
        }
Exemple #4
0
        public Co Convert <Co>() where Co : DaoCollection <C, T>, IHasDataTable, new()
        {
            Co val = As <Co>();

            val.Parent = this.Parent;
            return(val);
        }
Exemple #5
0
 public void Show(string message, Color color)
 {
     text.text = message;
     panel.SetActive(true);
     panel.GetComponent <Image>().color = color;
     Co.WaitForSeconds(3, Hide);
 }
Exemple #6
0
 public void Reset(bool is_reverse)
 {
     _is_reverse = is_reverse;
     Co.End(_execute);
     _execute = null;
     _EvaluateValue(is_reverse ? _duration : 0.0f);
 }
Exemple #7
0
    // TODO: add static functions for waitforseconds, waitforcondition, etc.

    public static Co Start(float duration, System.Action <float> action, System.Action onEnd = null, Func <bool> condition = null)
    {
        Co co = new Co();

        co.Begin(duration, action, onEnd, condition);
        return(co);
    }
Exemple #8
0
        void RunPotAnimation()
        {
            if (Elements["instruction4"].Visible && !animationsRun["pot"])
            {
                Co.WaitForSeconds(0.5f, () => {
                    int potStartCount = data.PotCount;
                    int potEndCount   = (int)(potStartCount * 1.5f);

                    AnimElementUI pot = CreateAnimation();
                    pot.SpriteName    = "coin_stack";
                    pot.Text          = potStartCount.ToString();
                    pot.Size          = new Vector2(100, 100);
                    pot.TextPadding   = new Vector2(-60, 0);
                    pot.Animate(new UIAnimator.Expand(1.5f));

                    Co.WaitForSeconds(4f, () => {
                        Co.StartCoroutine(2.5f, (float p) => {
                            pot.Text = Mathf.Ceil(Mathf.Lerp(potStartCount, potEndCount, p)).ToString();
                        });
                        Co.WaitForSeconds(0.5f, () => {
                            pot.Animate(new UIAnimator.Shrink(2f));
                        });
                    });
                });

                animationsRun["pot"] = true;
            }
        }
Exemple #9
0
 void Translate()
 {
     // if (translateCo != null && translateCo.gameObject.activeSelf)
     // translateCo.Stop (false);
     Co.Start(TranslateTime, UpdateTranslation, EndMove);
     // translateCo = Co.Start (TranslateTime, UpdateTranslation, EndMove);
 }
Exemple #10
0
        protected override void OnInputEnabled()
        {
            Co.RepeatAscending(0.5f, 4f, Instructions.Count, (int i) => {
                // Wait until the view is loaded
                if (!Loaded)
                {
                    return;
                }

                // Remove the previous instruction
                if (i > 0)
                {
                    Instructions[i - 1].Animate(new UIAnimator.FadeOut(0.2f, () => {
                        Instructions[i - 1].Visible = false;
                        ShowInstruction(i);
                    }));
                }
                else
                {
                    ShowInstruction(i);
                }
            }, () => {
                if (Loaded)
                {
                    Elements["next"].Visible = true;
                    Elements["next"].Animate(new UIAnimator.FadeIn(0.5f));
                }
            });
        }
Exemple #11
0
 void Rotate(float duration, System.Action onEnd)
 {
     // if (rotateCo != null && rotateCo.gameObject.activeSelf)
     // rotateCo.Stop (false);
     Co.Start(duration, UpdateRotation, onEnd);
     // rotateCo = Co.Start (duration, UpdateRotation, onEnd);
 }
Exemple #12
0
    public void RunCoinToAvatarAnimation(string coinCount, string avatarColor)
    {
        // Introduce the coin
        AnimElementUI coin = CreateAnimation();

        coin.SpriteName    = "coin";
        coin.Text          = "+" + coinCount;
        coin.Size          = new Vector2(50, 50);
        coin.LocalPosition = new Vector3(-50, 25, 0);
        coin.TextPadding   = new Vector2(-10, 0);
        coin.Animate(new UIAnimator.Expand(0.5f));

        Co.WaitForSeconds(1f, () => {
            // Introduce the avatar
            Vector3 avatarPosition = new Vector3(50, 25f, 0);
            AnimElementUI avatar   = CreateAnimation();
            avatar.AvatarName      = avatarColor;
            avatar.Size            = new Vector2(75, 75);
            avatar.LocalPosition   = avatarPosition;
            avatar.Animate(new UIAnimator.Expand(0.5f));

            Co.WaitForSeconds(1f, () => {
                // Move the coin to the avatar and shrink out
                coin.Animate(new UIAnimator.Move(1f, avatarPosition, () => {
                    coin.Destroy();
                    avatar.Animate(new UIAnimator.Shrink(0.5f, () => {
                        avatar.Destroy();
                    }));
                }));
            });
        });
    }
        void Slide(float to)
        {
            if (anim.Animate(new UIAnimator.Slide(slideTime, to, () => {
                // Normalize positions
                inactiveContainer.RectTransform.SetAnchoredPositionX(0f);
                activeContainer.RectTransform.SetAnchoredPositionX(-to);
                RectTransform.SetAnchoredPositionX(0f);

                // Unload the previous view
                activeContainer.UnloadView();

                // Swap the active and inactive containers
                UpdateActiveContainer();

                // Inform the newly active container that the animation has finished & input is being accepted
                activeContainer.SetInputEnabled();

                // Enable the raycaster so that input is accepted again (small pause so that players don't accidently 'double press' buttons)
                Co.WaitForSeconds(0.05f, () => {
                    Raycaster.enabled = true;
                });
            })))
            {
                // Disable the raycaster while animating so that the user can't "double press" buttons
                Raycaster.enabled = false;
                inactiveContainer.RectTransform.SetAnchoredPositionX(-to);
            }
        }
Exemple #14
0
    private void OnGUI()
    {
        GUILayout.Label("コルーチン実行状況 " + _count);

        if (GUILayout.Button("コルーチン実行"))
        {
            EndCoroutine();
            _loop_coroutine = Co.Begin(Loop());
            // or
            // _loop_coroutine = Loop().Begin();
        }
        if (_loop_coroutine != null)
        {
            if (GUILayout.Button("コルーチン一時停止"))
            {
                Co.Pause(_loop_coroutine, true);
                // or
                // _loop_coroutine.Pause(true);
            }
            if (GUILayout.Button("コルーチン再開"))
            {
                Co.Pause(_loop_coroutine, false);
                // or
                // _loop_coroutine.Pause(false);
            }
            if (GUILayout.Button("コルーチン停止"))
            {
                EndCoroutine();
            }
        }
        if (GUILayout.Button("Tween実行"))
        {
            _tweens.Play().Begin();
        }
    }
Exemple #15
0
 void OnGUI()
 {
     if (instances.Count > 0 && instances[0].Controller.DataLoaded)
     {
         return;
     }
     GUILayout.BeginHorizontal();
     if (instances.Count < 4 && GUILayout.Button("Run test"))
     {
         GotoView("lobby");
         Co.YieldWhileTrue(() => { return(!ClientsConnected()); }, () => {
             instances[0].Dispatcher.ScheduleMessage("RunTest");
         });
     }
     if (instances.Count < 4 && GUILayout.Button("Add player"))
     {
         AddPlayer();
     }
     if (instances.Count == 0)
     {
         GUILayout.Label(" OR: skip to view: ");
         gotoView = GUILayout.TextField(gotoView, 25, GUILayout.Width(50));
         if (gotoView != "" && ValidView(gotoView))
         {
             if (GUILayout.Button("Go"))
             {
                 GotoView(gotoView);
             }
         }
     }
     GUILayout.EndHorizontal();
 }
 public static IEnumerator Play(this CoTween[] tweens, string group_name = "", bool is_reverse = false)
 {
     foreach (var tween in tweens)
     {
         if (string.IsNullOrEmpty(group_name))
         {
             Co.Begin(tween.Play(is_reverse));
         }
         else if (tween.groupName == group_name)
         {
             Co.Begin(tween.Play(is_reverse));
         }
     }
     foreach (var tween in tweens)
     {
         if (string.IsNullOrEmpty(group_name))
         {
             while (tween.isPlaying && tween.playType == CoTween.ePlayType.PlayOnce)
             {
                 yield return(null);
             }
         }
         else if (tween.groupName == group_name)
         {
             while (tween.isPlaying && tween.playType == CoTween.ePlayType.PlayOnce)
             {
                 yield return(null);
             }
         }
     }
 }
	/**
	 *	Private methods
	 */

	void Register (string clientId, Response.Room room) {

		// Add room data to ConnectionInfo
		connection.clientId = clientId;
		connection.room = room;

		// Listen for dropped clients
		Co.InvokeWhileTrue (0.5f, () => { return Application.isPlaying && connection.connected; }, () => {

			Emit<Response.DroppedClients> ("checkDropped", connection.roomId, (Response.DroppedClients res) => {

				// Ignore if this client has been dropped
				if (dropped)
					return;

				// Send a message if a client was dropped or if previously dropped clients have reconnected
				if (res.dropped && !hasDroppedClients) {

					if (onUpdateDroppedClients != null)
						onUpdateDroppedClients (true);

					hasDroppedClients = true;
					
				} else if (!res.dropped && hasDroppedClients) {

					if (onUpdateDroppedClients != null)
						onUpdateDroppedClients (false);

					hasDroppedClients = false;
				}

			});
		});
	}
Exemple #18
0
 void Rotate(float duration, System.Action onEnd)
 {
     if (rotateCo != null)
     {
         rotateCo.Stop(false);
     }
     rotateCo = Co.Start(duration, UpdateRotation, onEnd);
 }
Exemple #19
0
 void EndCoroutine()
 {
     Co.End(_loop_coroutine);
     // or
     // _loop_coroutine.End();
     _count          = 0;
     _loop_coroutine = null;
 }
Exemple #20
0
 void Translate(float speed)
 {
     if (translateCo != null)
     {
         translateCo.Stop(false);
     }
     translateCo = Co.Start(TranslateTime / speed, UpdateTranslation, () => { EndMove(trajectory.target); });
 }
Exemple #21
0
 protected override void OnInputEnabled()
 {
     Co.WaitForSeconds(5f, () => {
         Elements["timeout"].Animate(new UIAnimator.FadeIn(0.5f, () => {
             Elements["menu"].Animate(new UIAnimator.FadeIn(0.5f));
         }));
     });
 }
Exemple #22
0
 public void Print()
 {
     Console.WriteLine(Nombre);
     foreach (CorreoElect Co in Correos)
     {
         Console.WriteLine(Co.getCorreo());
     }
 }
 public void StartTimer(float startTime = 0f)
 {
     Co.StartCoroutine(startTime, duration, OnUpdateTime, () => {
         if (onEnd != null)
         {
             onEnd();
         }
     });
 }
Exemple #24
0
    private void Start()
    {
        Co.Delay(() => Debug.Log("after 1 second"), 1f);
        Co.Delay(() => Debug.Log("after 2 seconds"), 2f);

        var plainClass = new PlainClass();

        plainClass.TestCoroutine();
    }
Exemple #25
0
 void OnSetDeck(NetMessage msg)
 {
     // Wait a frame to ensure that DeckManager sets the deck before referencing it
     Co.WaitForFixedUpdate(() => {
         Game.Dispatcher.ScheduleMessage("StartGame");
         Co.YieldWhileTrue(() => { return(!Game.Controller.DataLoaded); }, () => {
             AllGotoView("roles");
         });
     });
 }
Exemple #26
0
 public void RemoveSeed()
 {
     ObjectPool.Destroy <Seed> (seed);
     seed      = null;
     duration += 1;
     if (duration <= durations.Length - 1)
     {
         coSeed = Co.Start(durations[duration], ProduceSeed, OnProduceSeed);
     }
 }
Exemple #27
0
    public static void Main()
    {
        var co = new Co();

        co.Start(() =>
        {
            Console.WriteLine("Hello");
            co.Stop();
        });
    }
Exemple #28
0
    private void _PostUIProgressMessage()
    {
        EditorUIProgressInfo progressInfo = new EditorUIProgressInfo();

        progressInfo.msg   = msg;
        progressInfo.curr  = curr;
        progressInfo.total = total;
        EditorCoroutineMessage newMsg =
            new EditorCoroutineMessage(taskID, EditorCoroutineMessage.Message.PROGRESS_UI, progressInfo, null);

        Co.PostUIMessage(newMsg);
    }
Exemple #29
0
        static void ElapseTime()
        {
            foreach (var group in Inventory.Groups)
            {
                foreach (Item item in group.Value.Items)
                {
                    ((Loan)item).AddTime();
                }
            }

            Co.Start(repaymentTime, OnElapseTime, ElapseTime);
        }
    IEnumerator _EditorPlay(CoTween[] tweens, string filter)
    {
        IEnumerator coroutine = Co.Begin(tweens.Play(filter));

        _is_playing = true;
        while (coroutine.IsUpdating())
        {
            yield return(null);
        }
        _is_playing = false;
        tweens.Reset(filter);
    }