Exemplo n.º 1
0
        public override void Awake()
        {
            rayCastTargetCom = AddComponent <RayCastTarget>();
            rayCastTargetCom.OnMoveInEvent  += () => { Select(true); };
            rayCastTargetCom.OnMoveOutEvent += () => { Select(false); };

            //添加边框对象
            BoxDrawing        = UIFactroy.CreateBoxDrawingRect(Position - new Vector2(1, 1), 2, 25);
            BoxDrawing.Parent = GameObject;
            Select(false);

            //添加Label对象
            List <Vector2> posList = new List <Vector2>();

            for (int i = 0; i < 25; i++)
            {
                posList.Add(new Vector2(i, 0));
            }
            for (int i = 18; i < 25; i++)
            {
                posList.Add(new Vector2(i, -1));
            }
            GameObject labelObj = new GameObject("StateLabel", "UI", GameObject, new Vector2(0, 1), posList);

            labelCom = labelObj.AddComponent <Renderer>();
            labelCom.Init(RendererMode.UI, (int)Layer.Label);
            //添加血条对象
            progressBar = ProgressBarChar.Create(length: 18);
            progressBar.GameObject.Parent = GameObject;
            progressBar.LocalPosition     = new Vector2(0, 0);
        }
Exemplo n.º 2
0
        public static ProgressBarChar Create(int length = 10, float maxValue = 100, float value = 50, char fillChar = '>', char emptyChar = '-')
        {
            ProgressBarChar progressBar = GameObject.CreateWith <ProgressBarChar>("ProgressBar", "UI", posList: Utils.CreateLineMesh(length));

            progressBar.AddComponent <Renderer>().Init(RendererMode.UI, -5);

            progressBar.maxValue  = maxValue;
            progressBar.curValue  = value;
            progressBar.Length    = length;
            progressBar.progress  = value / maxValue;
            progressBar.fillChar  = fillChar;
            progressBar.emptyChar = emptyChar;

            progressBar.DrawProgress();
            return(progressBar);
        }
Exemplo n.º 3
0
        public override void Awake()
        {
            //添加边框对象
            BoxDrawing        = UIFactroy.CreateBoxDrawingRect(Position - new Vector2(1, 1), 4, 24);
            BoxDrawing.Parent = GameObject;

            label1  = Utils.CreateLabel(24, parent: GameObject, localPosition: new Vector2(0, 3));
            label2  = Utils.CreateLabel(24, parent: GameObject, localPosition: new Vector2(0, 2));
            labelHP = Utils.CreateLabel(8, parent: GameObject, localPosition: new Vector2(0, 1));
            labelMP = Utils.CreateLabel(8, parent: GameObject, localPosition: new Vector2(0, 0));

            hpSlider = ProgressBarChar.Create(16);
            hpSlider.GameObject.Parent = GameObject;
            hpSlider.LocalPosition     = new Vector2(8, 1);

            mpSlider = ProgressBarChar.Create(16);
            mpSlider.GameObject.Parent = GameObject;
            mpSlider.LocalPosition     = new Vector2(8, 0);
            mpSlider.fullColor         = Color.Blue;
            mpSlider.enableColor       = false;
        }
Exemplo n.º 4
0
        public override void Awake()
        {
            //添加边框对象
            BoxDrawing        = UIFactroy.CreateBoxDrawingRect(Position - new Vector2(1, 1), 2, 30);
            BoxDrawing.Parent = GameObject;

            //左上的的label 长度20 表示正在释放的技能的名字和施法时间等
            var obj = new GameObject("StateLabel", "UI", GameObject, new Vector2(0, 1), Utils.CreateLineMesh(20));

            labelUp = obj.AddComponent <Renderer>();
            labelUp.Init(RendererMode.UI, (int)Layer.Label);

            //上面的条表示公cd
            progressCommonCD = ProgressBarChar.Create(10, fillChar: '<');
            progressCommonCD.GameObject.Parent = GameObject;
            progressCommonCD.LocalPosition     = new Vector2(20, 1);
            progressCommonCD.emptyColor        = Color.Green;
            progressCommonCD.fullColor         = Color.Red;

            //下面的用实心进度条 表示施法条
            progressCasting = ProgressBar.Create(30);
            progressCasting.GameObject.Parent = GameObject;
            progressCasting.LocalPosition     = new Vector2(0, 0);
        }