コード例 #1
0
 public void Init(Sprite iSprite, Material iMat, DecalLayer iType, string iName)
 {
     gameObject.name = iName;
     layer           = iType;
     meshFilter      = GetComponent <MeshFilter>();
     meshRenderer    = GetComponent <MeshRenderer>();
     sprite          = iSprite;
     _material       = iMat;
     _material.SetTexture("_MainTex", iSprite.texture);
     meshRenderer.material = iMat;
 }
コード例 #2
0
        private void UpdateDecalMode()
        {
            if (Input.KeyboardTapped(Keys.S))
            {
                textBoxStack.Add(new SelectColorBox(ColorBoxEnter, decalColor));
            }
            if (Input.KeyboardTapped(Keys.U))
            {
                decalsBack.Sort();
                decalsFront.Sort();
            }
            if (Input.KeyboardTapped(Keys.L))
            {
                int num = TextureBin.LoadTexturesFromDirectory("Content\\Decals");
                textBoxStack.Add(new TextBox(null, "Loaded " + num.ToString() + " new textures.", TextBoxEnter));
            }
            if (Input.KeyboardTapped(Keys.Enter))
            {
                textBoxStack.Add(new SelectTextureBox(TextureBoxEnter));
            }
            if (Input.KeyboardTapped(Keys.F))
            {
                System.Diagnostics.Process.Start("explorer.exe", "Content\\Decals");
            }
            if (Input.KeyboardTapped(Keys.H))
            {
                textBoxStack.Add(new TextBox(null, "HOW TO ADD NEW DECALS: Open the decals folder by pressing F.\nThen drag .PNG images into the decals folder.\nThen return to the game, and press L to load the new images into the decals bin.\n\nFURTHER NOTES: Adjust the drift values on decals to make them look like they have depth.\nWhen placing drifting decals, hold LShift to ensure they are properly aligned\nto a grid.\nIf decals are overlapping incorrectly, press U to sort decals by drift.", TextBoxEnter));
            }
            if (Input.KeyboardTapped(Keys.Left))
            {
                decalLayer = DecalLayer.Back;
            }
            if (Input.KeyboardTapped(Keys.Right))
            {
                decalLayer = DecalLayer.Front;
            }
            if (Input.IsKeyDown(Keys.LeftControl))
            {
                if (Input.MouseLeftButtonTapped)
                {
                    foreach (Decal d in decalsFront)
                    {
                        Vector2 decalOnScreen = d.position - (d.origin + (camera - d.origin) * d.drift);
                        if ((decalOnScreen - (Input.MousePosition * zoom)).Length() < 14)
                            decalsFront.BufferRemove(d);
                    }
                    foreach (Decal d in decalsBack)
                    {
                        Vector2 decalOnScreen = d.position - (d.origin + (camera - d.origin) * d.drift);
                        if ((decalOnScreen - (Input.MousePosition * zoom)).Length() < 14)
                            decalsBack.BufferRemove(d);
                    }
                    decalsFront.ApplyBuffers();
                    decalsBack.ApplyBuffers();
                }
            }
            else
            {
                if (Input.IsKeyDown(Keys.A))
                {
                    if (Input.MouseScrollDown || Input.KeyboardTapped(Keys.Down))
                        decalAngle -= MathHelper.Pi / 12;
                    if (Input.MouseScrollUp || Input.KeyboardTapped(Keys.Up))
                        decalAngle += MathHelper.Pi / 12;
                }
                else if (Input.IsKeyDown(Keys.D))
                {
                    if (Input.MouseScrollDown || Input.KeyboardTapped(Keys.Down))
                        decalDrift -= 0.05f;
                    if (Input.MouseScrollUp || Input.KeyboardTapped(Keys.Up))
                        decalDrift += 0.05f;
                }
                else
                {
                    if (Input.MouseScrollDown || Input.KeyboardTapped(Keys.Down))
                        decalScale -= 0.25f;
                    if (Input.MouseScrollUp || Input.KeyboardTapped(Keys.Up))
                        decalScale += 0.25f;
                }

                if (Input.MouseLeftButtonTapped && decal != null)
                {
                    if (decalLayer == DecalLayer.Front)
                        this.decalsFront.Add(new Decal(snapMouse, decal, decalOrigin, decalColor, decalScale, decalAngle, decalDrift));
                    else
                        this.decalsBack.Add(new Decal(snapMouse, decal, decalOrigin, decalColor, decalScale, decalAngle, decalDrift));
                }
            }
        }
コード例 #3
0
        private void UpdateDecalMode()
        {
            if (Input.KeyboardTapped(Keys.S))
            {
                textBoxStack.Add(new SelectColorBox(ColorBoxEnter, decalColor));
            }
            if (Input.KeyboardTapped(Keys.U))
            {
                decalsBack.Sort();
                decalsFront.Sort();
            }
            if (Input.KeyboardTapped(Keys.L))
            {
                int num = TextureBin.LoadTexturesFromDirectory("Content\\Decals");
                textBoxStack.Add(new TextBox(null, "Loaded " + num.ToString() + " new textures.", TextBoxEnter));
            }
            if (Input.KeyboardTapped(Keys.Enter))
            {
                textBoxStack.Add(new SelectTextureBox(TextureBoxEnter));
            }
            if (Input.KeyboardTapped(Keys.F))
            {
                System.Diagnostics.Process.Start("explorer.exe", "Content\\Decals");
            }
            if (Input.KeyboardTapped(Keys.H))
            {
                textBoxStack.Add(new TextBox(null, "HOW TO ADD NEW DECALS: Open the decals folder by pressing F.\nThen drag .PNG images into the decals folder.\nThen return to the game, and press L to load the new images into the decals bin.\n\nFURTHER NOTES: Adjust the drift values on decals to make them look like they have depth.\nWhen placing drifting decals, hold LShift to ensure they are properly aligned\nto a grid.\nIf decals are overlapping incorrectly, press U to sort decals by drift.", TextBoxEnter));
            }
            if (Input.KeyboardTapped(Keys.Left))
            {
                decalLayer = DecalLayer.Back;
            }
            if (Input.KeyboardTapped(Keys.Right))
            {
                decalLayer = DecalLayer.Front;
            }
            if (Input.IsKeyDown(Keys.LeftControl))
            {
                if (Input.MouseLeftButtonTapped)
                {
                    foreach (Decal d in decalsFront)
                    {
                        Vector2 decalOnScreen = d.position - (d.origin + (camera - d.origin) * d.drift);
                        if ((decalOnScreen - (Input.MousePosition * zoom)).Length() < 14)
                        {
                            decalsFront.BufferRemove(d);
                        }
                    }
                    foreach (Decal d in decalsBack)
                    {
                        Vector2 decalOnScreen = d.position - (d.origin + (camera - d.origin) * d.drift);
                        if ((decalOnScreen - (Input.MousePosition * zoom)).Length() < 14)
                        {
                            decalsBack.BufferRemove(d);
                        }
                    }
                    decalsFront.ApplyBuffers();
                    decalsBack.ApplyBuffers();
                }
            }
            else
            {
                if (Input.IsKeyDown(Keys.A))
                {
                    if (Input.MouseScrollDown || Input.KeyboardTapped(Keys.Down))
                    {
                        decalAngle -= MathHelper.Pi / 12;
                    }
                    if (Input.MouseScrollUp || Input.KeyboardTapped(Keys.Up))
                    {
                        decalAngle += MathHelper.Pi / 12;
                    }
                }
                else if (Input.IsKeyDown(Keys.D))
                {
                    if (Input.MouseScrollDown || Input.KeyboardTapped(Keys.Down))
                    {
                        decalDrift -= 0.05f;
                    }
                    if (Input.MouseScrollUp || Input.KeyboardTapped(Keys.Up))
                    {
                        decalDrift += 0.05f;
                    }
                }
                else
                {
                    if (Input.MouseScrollDown || Input.KeyboardTapped(Keys.Down))
                    {
                        decalScale -= 0.25f;
                    }
                    if (Input.MouseScrollUp || Input.KeyboardTapped(Keys.Up))
                    {
                        decalScale += 0.25f;
                    }
                }

                if (Input.MouseLeftButtonTapped && decal != null)
                {
                    if (decalLayer == DecalLayer.Front)
                    {
                        this.decalsFront.Add(new Decal(snapMouse, decal, decalOrigin, decalColor, decalScale, decalAngle, decalDrift));
                    }
                    else
                    {
                        this.decalsBack.Add(new Decal(snapMouse, decal, decalOrigin, decalColor, decalScale, decalAngle, decalDrift));
                    }
                }
            }
        }