Ejemplo 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建一个文本区域,可以设置是否包含文本框
        /// </summary>
        public static Renderer CreateTextAera(int width, int height, bool hasRect)
        {
            GameObject gameObject = new GameObject(posList: Utils.CreateRecMesh(width, height));
            var        renderCom  = gameObject.AddComponent <Renderer>();

            if (hasRect)
            {
                var box = UIFactroy.CreateBoxDrawingRect(new Vector2(-1, -1), height, width);
                box.Parent = gameObject;
            }
            return(renderCom);
        }
Ejemplo n.º 3
0
        public override void Awake()
        {
            //添加边框对象
            BoxDrawing        = UIFactroy.CreateBoxDrawingRect(Position - new Vector2(1, 1), 2, 6);
            BoxDrawing.Parent = GameObject;

            //上面的label 长度6 表示技能名字
            var obj = new GameObject("StateLabel", "UI", GameObject, new Vector2(0, 1), Utils.CreateLineMesh(6));

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

            //下面的label长度6 表示技能cd
            obj       = new GameObject("CDLabel", "UI", GameObject, new Vector2(0, 0), Utils.CreateLineMesh(6));
            labelDown = obj.AddComponent <Renderer>();
            labelDown.Init(RendererMode.UI, (int)Layer.Label);
        }
Ejemplo n.º 4
0
        public override void Awake()
        {
            //这个类是单例且不会随场景销毁的
            Instance = this;

            helpTextBox = UIFactroy.CreateTextBox(new Vector2(Config.ScreenWidth - 12, 0), 5, 10);
            helpTextBox.GameObject.Parent = GameObject;
            var drawing = UIFactroy.CreateBoxDrawingRect(new Vector2(Config.ScreenWidth - 12, 6), 1, 10);

            drawing.Parent = GameObject;
            returnBtn      = UIFactroy.CreateButton(new Vector2(Config.ScreenWidth - 11, 7), "回到主界面", Return, 10);
            returnBtn.GameObject.Parent = GameObject;

            InitText();

            SceneManager.DontDestroyOnLoad(GameObject);
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
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);
        }