Beispiel #1
0
            public Menu()
                : base(128, 240)
            {
                // 设定menu层级高于MapLayer
                SetLayer(101);
                // 不锁定menu移动
                SetLocked(false);
                SetLimitMove(false);
                // 锁定Actor拖拽
                SetActorDrag(false);
                SetDelay(500);
                // 设定Menu背景
                LImage image = LImage.CreateImage(this.GetWidth(),
                                                  this.GetHeight(), true);
                LGraphics g = image.GetLGraphics();

                g.SetColor(0, 0, 0, 125);
                g.FillRect(0, 0, GetWidth(), GetHeight());
                g.SetColor(LColor.white);
                g.SetFont(15);
                g.DrawString("我是可拖拽菜单", 12, 25);
                g.Dispose();
                SetBackground(image.GetTexture());

                BulletTurret bulletTurret = new BulletTurret();

                bulletTurret.SetLocation(18, 64);


                BombTurret bombTurret = new BombTurret();

                bombTurret.SetLocation(78, 64);


                PoisonTurret poisonTurret = new PoisonTurret();

                poisonTurret.SetLocation(18, 134);


                LaserTurret laserTurret = new LaserTurret();

                laserTurret.SetLocation(78, 134);

                Button button = new Button();

                button.SetLocation(27, 196);

                // 复合LPaper到Layer
                Add(bulletTurret);
                Add(bombTurret);
                Add(poisonTurret);
                Add(laserTurret);
                Add(button);
            }
Beispiel #2
0
        public LTexture LoadBarColor(LColor c1, LColor c2, LColor c3)
        {
            if (colors.Count > 10)
            {
                lock (colors)
                {
                    foreach (LTexture tex2d in colors.Values)
                    {
                        if (tex2d != null)
                        {
                            tex2d.Destroy();
                        }
                    }
                    colors.Clear();
                }
            }
            int hash = 1;

            hash = LSystem.Unite(hash, c1.GetRGB());
            hash = LSystem.Unite(hash, c2.GetRGB());
            hash = LSystem.Unite(hash, c3.GetRGB());
            LTexture texture = null;

            lock (colors)
            {
                texture = (LTexture)CollectionUtils.Get(colors, hash);
            }
            if (texture == null)
            {
                LImage    image = LImage.CreateImage(8, 8, false);
                LGraphics g     = image.GetLGraphics();
                g.SetColor(c1);
                g.FillRect(0, 0, 4, 4);
                g.SetColor(c2);
                g.FillRect(4, 0, 4, 4);
                g.SetColor(c3);
                g.FillRect(0, 4, 4, 4);
                g.Dispose();
                texture = image.GetTexture();
                CollectionUtils.Put(colors, hash, texture);
            }
            return(this.texture = texture);
        }
Beispiel #3
0
        public static LTexture CreateTexture(int width, int height, LColor c)
        {
            LImage    image = LImage.CreateImage(width, height, false);
            LGraphics g     = image.GetLGraphics();

            g.SetColor(c);
            g.FillRect(0, 0, width, height);
            g.Dispose();
            LTexture tex2d = image.GetTexture();

            if (image != null)
            {
                image.Dispose();
                image = null;
            }
            return(tex2d);
        }
Beispiel #4
0
 public void DrawWidth(GLEx g, int x, int y)
 {
     try {
         if (drawTexWidth == null)
         {
             LImage    img = LImage.CreateImage(width, height, true);
             LGraphics gl  = img.GetLGraphics();
             for (int i = 0; i < width; i++)
             {
                 gl.SetColor(
                     (start.GetRed() * (width - i)) / width
                     + (end.GetRed() * i) / width,
                     (start.GetGreen() * (width - i)) / width
                     + (end.GetGreen() * i) / width,
                     (start.GetBlue() * (width - i)) / width
                     + (end.GetBlue() * i) / width, alpha);
                 gl.DrawLine(i, 0, i, height);
             }
             drawTexWidth = new LTexture(GLLoader.GetTextureData(img),
                                         Loon.Core.Graphics.Opengl.LTexture.Format.SPEED);
             gl.Dispose();
             gl = null;
         }
         g.DrawTexture(drawTexWidth, x, y);
     } catch (Exception) {
         for (int i = 0; i < width; i++)
         {
             g.SetColorValue(
                 (start.GetRed() * (width - i)) / width
                 + (end.GetRed() * i) / width,
                 (start.GetGreen() * (width - i)) / width
                 + (end.GetGreen() * i) / width,
                 (start.GetBlue() * (width - i)) / width
                 + (end.GetBlue() * i) / width, alpha);
             g.DrawLine(i + x, y, i + x, y + height);
         }
     }
 }
Beispiel #5
0
 public void DrawHeight(GLEx g, int x, int y)
 {
     try {
         if (drawTexHeight == null)
         {
             LImage    img = LImage.CreateImage(width, height, true);
             LGraphics gl  = img.GetLGraphics();
             for (int i = 0; i < height; i++)
             {
                 gl.SetColor(
                     (start.GetRed() * (height - i)) / height
                     + (end.GetRed() * i) / height,
                     (start.GetGreen() * (height - i)) / height
                     + (end.GetGreen() * i) / height,
                     (start.GetBlue() * (height - i)) / height
                     + (end.GetBlue() * i) / height, alpha);
                 gl.DrawLine(0, i, width, i);
             }
             drawTexHeight = new LTexture(GLLoader.GetTextureData(img),
                                          Loon.Core.Graphics.Opengl.LTexture.Format.SPEED);
             gl.Dispose();
             gl = null;
         }
         g.DrawTexture(drawTexHeight, x, y);
     } catch (Exception) {
         for (int i = 0; i < height; i++)
         {
             g.SetColorValue(
                 (start.GetRed() * (height - i)) / height
                 + (end.GetRed() * i) / height,
                 (start.GetGreen() * (height - i)) / height
                 + (end.GetGreen() * i) / height,
                 (start.GetBlue() * (height - i)) / height
                 + (end.GetBlue() * i) / height, alpha);
             g.DrawLine(x, i + y, x + width, i + y);
         }
     }
 }
Beispiel #6
0
 public void DrawHeight(LGraphics g, int x, int y)
 {
     try {
         if (drawImgHeight == null)
         {
             drawImgHeight = LImage.CreateImage(width, height, true);
             LGraphics gl = drawImgHeight.GetLGraphics();
             for (int i = 0; i < height; i++)
             {
                 gl.SetColor(
                     (start.GetRed() * (height - i)) / height
                     + (end.GetRed() * i) / height,
                     (start.GetGreen() * (height - i)) / height
                     + (end.GetGreen() * i) / height,
                     (start.GetBlue() * (height - i)) / height
                     + (end.GetBlue() * i) / height, alpha);
                 gl.DrawLine(0, i, width, i);
             }
             gl.Dispose();
             gl = null;
         }
         g.DrawImage(drawImgHeight, x, y);
     } catch (Exception) {
         for (int i = 0; i < height; i++)
         {
             g.SetColor(
                 (start.GetRed() * (height - i)) / height
                 + (end.GetRed() * i) / height,
                 (start.GetGreen() * (height - i)) / height
                 + (end.GetGreen() * i) / height,
                 (start.GetBlue() * (height - i)) / height
                 + (end.GetBlue() * i) / height, alpha);
             g.DrawLine(x, i + y, x + width, i + y);
         }
     }
 }
Beispiel #7
0
 public void DrawWidth(LGraphics g, int x, int y)
 {
     try {
         if (drawImgWidth == null)
         {
             drawImgWidth = LImage.CreateImage(width, height, true);
             LGraphics gl = drawImgWidth.GetLGraphics();
             for (int i = 0; i < width; i++)
             {
                 gl.SetColor(
                     (start.GetRed() * (width - i)) / width
                     + (end.GetRed() * i) / width,
                     (start.GetGreen() * (width - i)) / width
                     + (end.GetGreen() * i) / width,
                     (start.GetBlue() * (width - i)) / width
                     + (end.GetBlue() * i) / width, alpha);
                 gl.DrawLine(i, 0, i, height);
             }
             gl.Dispose();
             gl = null;
         }
         g.DrawImage(drawImgWidth, x, y);
     } catch (Exception) {
         for (int i = 0; i < width; i++)
         {
             g.SetColor(
                 (start.GetRed() * (width - i)) / width
                 + (end.GetRed() * i) / width,
                 (start.GetGreen() * (width - i)) / width
                 + (end.GetGreen() * i) / width,
                 (start.GetBlue() * (width - i)) / width
                 + (end.GetBlue() * i) / width, alpha);
             g.DrawLine(i + x, y, i + x, y + height);
         }
     }
 }
Beispiel #8
0
        private void InitDesktop()
        {
            if (desktop != null && sprites != null)
            {
                return;
            }
            this.desktop = new Desktop(this, GetWidth(), GetHeight());
            this.sprites = new Sprites(GetWidth(), GetHeight());
            if (dialog == null)
            {
                LImage tmp = LImage.CreateImage(GetWidth() - 20,
                                                GetHeight() / 2 - 20, true);
                LGraphics g = tmp.GetLGraphics();
                g.SetColor(0, 0, 0, 125);
                g.FillRect(0, 0, tmp.GetWidth(), tmp.GetHeight());
                g.Dispose();
                g      = null;
                dialog = new LTexture(GLLoader.GetTextureData(tmp));
                if (tmp != null)
                {
                    tmp.Dispose();
                    tmp = null;
                }
            }
            this.message = new LMessage(dialog, 0, 0);
            this.message.SetFontColor(LColor.white);
            int size = message.GetWidth() / (message.GetMessageFont().GetSize());

            if (LSystem.scaleWidth != 1 || LSystem.scaleHeight != 1)
            {
                if (size % 2 != 0)
                {
                    size = size + 2;
                }
                else
                {
                    size = size + 3;
                }
            }
            else
            {
                if (size % 2 != 0)
                {
                    size = size - 3;
                }
                else
                {
                    size = size - 4;
                }
            }
            this.message.SetMessageLength(size);
            this.message.SetLocation((GetWidth() - message.GetWidth()) / 2,
                                     GetHeight() - message.GetHeight() - 10);
            this.message.SetVisible(false);
            this.select = new LSelect(dialog, 0, 0);
            this.select.SetLocation(message.X(), message.Y());
            this.scrCG = new AVGCG();
            this.desktop.Add(message);
            this.desktop.Add(select);
            this.select.SetVisible(false);
        }