Exemplo n.º 1
0
        public static ImageEffect FadeOutDialog(float time)
        {
            EffectBuilder builder = new EffectBuilder();
            ImageEffect   e       = builder.UI(null)
                                    .TotalTime(time)
                                    .Init(() =>
            {
                dialog.GetComponent <UIWidget>().alpha = 1;
            })
                                    .AnimateUpdate((aim, totaltime, nowtime) =>
            {
                if (nowtime < totaltime)
                {
                    float t = Mathf.MoveTowards(dialog.GetComponent <UIWidget>().alpha, 0, 1 / totaltime * Time.fixedDeltaTime);
                    dialog.GetComponent <UIWidget>().alpha = t;
                }
            })
                                    .Finish(() =>
            {
                dialog.GetComponent <UIWidget>().alpha = 0;
                //dialoglabel.text = "";
                //namelabel.text = "";
            })
                                    .Get();

            return(e);
        }
Exemplo n.º 2
0
        public static ImageEffect MoveByDepth(int depth, Vector3 final, float time)
        {
            UI2DSprite ui = null;

            if (charaPanel.transform.Find("sprite" + depth) != null)
            {
                ui = charaPanel.transform.Find("sprite" + depth).GetComponent <UI2DSprite>();
            }
            else
            {
                return(null);
            }
            EffectBuilder builder = new EffectBuilder();
            Vector3       origin  = ui.transform.localPosition;
            ImageEffect   e       = builder.UI(ui)
                                    .TotalTime(time)
                                    .Init(() => { })
                                    .AnimateUpdate((aim, totaltime, nowtime) =>
            {
                if (nowtime < totaltime)
                {
                    float x = Mathf.MoveTowards(aim.transform.localPosition.x, final.x, Math.Abs(final.x - aim.transform.localPosition.x) / (totaltime - nowtime) * Time.fixedDeltaTime);
                    float y = Mathf.MoveTowards(aim.transform.localPosition.y, final.y, Math.Abs(final.y - aim.transform.localPosition.y) / (totaltime - nowtime) * Time.fixedDeltaTime);
                    aim.transform.localPosition = new Vector3(x, y);
                }
            })
                                    .Finish(() => { })
                                    .Get();

            return(e);
        }
Exemplo n.º 3
0
        /* 采用了krkr的图像处理方式
         * Depth为图像的唯一编号
         * 表示了深度,数字越大越靠前
         */
        public static ImageEffect SetSpriteByDepth(int depth, Sprite sprite)
        {
            UI2DSprite ui = null;

            if (charaPanel.transform.Find("sprite" + depth) != null)
            {
                ui = charaPanel.transform.Find("sprite" + depth).GetComponent <UI2DSprite>();
            }
            else
            {
                GameObject go = Resources.Load("Prefab/Character") as GameObject;
                go = NGUITools.AddChild(charaPanel, go);
                go.transform.name = "sprite" + depth;
                ui = go.GetComponent <UI2DSprite>();
            }
            EffectBuilder builder = new EffectBuilder();
            ImageEffect   e       = builder.UI(ui)
                                    .TotalTime(0)
                                    .Init(() =>
            {
                ui.alpha    = 0;
                ui.depth    = depth;
                ui.sprite2D = sprite;
                ui.MakePixelPerfect();
            })
                                    .AnimateUpdate((aim, totaltime, nowtime) => { }).Get();

            return(e);
        }
Exemplo n.º 4
0
        public static ImageEffect FadeOutByDepth(int depth, float time)
        {
            UI2DSprite ui;

            if (charaPanel.transform.Find("sprite" + depth) != null)
            {
                ui = charaPanel.transform.Find("sprite" + depth).GetComponent <UI2DSprite>();
            }
            else
            {
                return(null);
            }
            EffectBuilder builder = new EffectBuilder();
            ImageEffect   e       = builder.UI(ui)
                                    .TotalTime(time)
                                    .Init(() => { ui.alpha = 1; })
                                    .AnimateUpdate((aim, totaltime, nowtime) =>
            {
                if (nowtime < totaltime)
                {
                    aim.alpha = Mathf.MoveTowards(aim.alpha, 0, 1 / totaltime * Time.fixedDeltaTime);
                }
            })
                                    .Finish(() => { ui.alpha = 0; })
                                    .Get();

            return(e);
        }
Exemplo n.º 5
0
        public static ImageEffect ChangeSprite(UI2DSprite ui, Sprite sprite)
        {
            EffectBuilder builder = new EffectBuilder();
            ImageEffect   e       = builder.UI(ui)
                                    .TotalTime(0)
                                    .Init(() => { ui.sprite2D = sprite; })
                                    .AnimateUpdate((aim, totaltime, nowtime) => { })
                                    .Get();

            return(e);
        }
Exemplo n.º 6
0
        public static ImageEffect BlockClick(bool block)
        {
            EffectBuilder builder = new EffectBuilder();
            ImageEffect   e       = builder.UI(null)
                                    .TotalTime(0)
                                    .Init(() => { click.SetActive(block); })
                                    .Finish(() => { })
                                    .AnimateUpdate((aim, totaltime, nowtime) => { })
                                    .Get();

            return(e);
        }
Exemplo n.º 7
0
        public static ImageEffect FadeOut(UI2DSprite sprite, float time)
        {
            EffectBuilder builder = new EffectBuilder();
            ImageEffect   e       = builder.UI(sprite)
                                    .TotalTime(time)
                                    .Alpha(1)
                                    .AnimateUpdate((aim, totaltime, nowtime) =>
            {
                if (nowtime < totaltime)
                {
                    aim.alpha = Mathf.MoveTowards(aim.alpha, 0, 1 / totaltime * Time.fixedDeltaTime);
                }
            }).Get();

            return(e);
        }
Exemplo n.º 8
0
        public static ImageEffect Move(UI2DSprite sprite, Vector3 origin, Vector3 final, float time)
        {
            EffectBuilder builder = new EffectBuilder();
            ImageEffect   e       = builder.UI(sprite)
                                    .TotalTime(time)
                                    .Init(() => { sprite.transform.position = origin; })
                                    .Finish(() => { sprite.transform.position = final; })
                                    .AnimateUpdate((aim, totaltime, nowtime) =>
            {
                if (nowtime < totaltime)
                {
                    aim.alpha = Mathf.MoveTowards(aim.alpha, 1, 1 / totaltime * Time.fixedDeltaTime);
                }
            }).Get();

            return(e);
        }
Exemplo n.º 9
0
        public static ImageEffect SetDialog(bool open)
        {
            EffectBuilder builder = new EffectBuilder();
            ImageEffect   e       = builder.UI(null)
                                    .TotalTime(0)
                                    .Init(() =>
            {
                dialog.SetActive(open);
                dialog.GetComponent <UIWidget>().alpha = 0;
                //namelabel.text = "";
                //dialoglabel.text = "";
                //dialog.transform.Find("NextIcon_Sprite").gameObject.SetActive(false);
            })
                                    .AnimateUpdate((aim, totaltime, nowtime) => { })
                                    .Finish(() => { })
                                    .Get();

            return(e);
        }
Exemplo n.º 10
0
        public static ImageEffect SetDefaultPostionByDepth(int depth, string pstr)
        {
            UI2DSprite ui = null;

            if (charaPanel.transform.Find("sprite" + depth) != null)
            {
                ui = charaPanel.transform.Find("sprite" + depth).GetComponent <UI2DSprite>();
            }
            else
            {
                return(null);
            }
            float x;

            switch (pstr)
            {
            case "left":
                x = -320;
                break;

            case "middle":
                x = 0;
                break;

            case "right":
                x = 320;
                break;

            default:
                x = 0;
                break;
            }
            EffectBuilder builder = new EffectBuilder();
            ImageEffect   e       = builder.UI(ui)
                                    .TotalTime(0)
                                    .Init(() =>
            {
                ui.transform.localPosition = new Vector3(x, -360 + ui.height / 2);
            })
                                    .AnimateUpdate((aim, totaltime, nowtime) => { }).Get();

            return(e);
        }
Exemplo n.º 11
0
        public static ImageEffect SetPostionByDepth(int depth, Vector3 position)
        {
            UI2DSprite ui = null;

            if (charaPanel.transform.Find("sprite" + depth) != null)
            {
                ui = charaPanel.transform.Find("sprite" + depth).GetComponent <UI2DSprite>();
            }
            else
            {
                return(null);
            }
            EffectBuilder builder = new EffectBuilder();
            ImageEffect   e       = builder.UI(ui)
                                    .TotalTime(0)
                                    .Init(() =>
            {
                ui.transform.localPosition = position;
            })
                                    .AnimateUpdate((aim, totaltime, nowtime) => { }).Get();

            return(e);
        }
Exemplo n.º 12
0
 public static ImageEffect ChangeByDepth(int depth, Sprite sprite)
 {
     if (charaPanel.transform.Find("sprite" + depth) == null)
     {
         return(null);
     }
     else
     {
         EffectBuilder builder = new EffectBuilder();
         UI2DSprite    ui      = charaPanel.transform.Find("sprite" + depth).GetComponent <UI2DSprite>();
         ImageEffect   e       = builder.UI(ui)
                                 .TotalTime(0)
                                 .Init(() =>
         {
             ui.sprite2D = sprite;
             ui.MakePixelPerfect();
         })
                                 .AnimateUpdate((aim, totaltime, nowtime) => { })
                                 .Finish(() => { })
                                 .Get();
         return(e);
     }
 }
Exemplo n.º 13
0
 public static ImageEffect DeleteSpriteByDepth(int depth)
 {
     if (charaPanel.transform.Find("sprite" + depth) == null)
     {
         return(null);
     }
     else
     {
         EffectBuilder builder = new EffectBuilder();
         UI2DSprite    ui      = charaPanel.transform.Find("sprite" + depth).GetComponent <UI2DSprite>();
         ImageEffect   e       = builder.UI(ui)
                                 .TotalTime(0)
                                 .Init(() => {
             //if (charaPanel.transform.Find("sprite" + depth) != null)
             //if(ui!=null)
             // GameObject.Destroy(ui.transform.gameObject);
             ui.sprite2D = null;
         })
                                 .AnimateUpdate((aim, totaltime, nowtime) => { })
                                 .Finish(() => {  })
                                 .Get();
         return(e);
     }
 }