public override void DrawGhost(int x, int y, MicroWorld.Graphics.Renderer renderer, Component.Rotation rotation)
        {
            if (texture0cw == null)
            {
                return;
            }
            switch (rotation)
            {
            case Component.Rotation.cw0:
                renderer.Draw(texture0cw, new Rectangle(x, y, 48, 24), new Color(1f, 1f, 1f, 0.5f));
                renderer.Draw(textureCenter0cw, new Rectangle(x, y, 48, 24), new Color(0.8f, 0f, 0f, 0.5f));
                break;

            case Component.Rotation.cw90:
                renderer.Draw(texture90cw, new Rectangle(x, y, 24, 48), new Color(1f, 1f, 1f, 0.5f));
                renderer.Draw(textureCenter90cw, new Rectangle(x, y, 24, 48), new Color(0.8f, 0f, 0f, 0.5f));
                break;

            case Component.Rotation.cw180:
                renderer.Draw(texture180cw, new Rectangle(x, y, 48, 24), new Color(1f, 1f, 1f, 0.5f));
                renderer.Draw(textureCenter180cw, new Rectangle(x, y, 48, 24), new Color(0.8f, 0f, 0f, 0.5f));
                break;

            case Component.Rotation.cw270:
                renderer.Draw(texture270cw, new Rectangle(x, y, 24, 48), new Color(1f, 1f, 1f, 0.5f));
                renderer.Draw(textureCenter270cw, new Rectangle(x, y, 24, 48), new Color(0.8f, 0f, 0f, 0.5f));
                break;

            default:
                break;
            }
        }
Beispiel #2
0
        public void DrawAOE(MicroWorld.Graphics.Renderer renderer, float opacityMultiplier)
        {
            var p = parent as Lamp;

            MicroWorld.Graphics.RenderHelper.DrawDottedCircle(p.Luminosity, Position + GetSize() / 2, (int)(p.Luminosity / 2),
                                                              (float)((Main.Ticks % 40) * 2 * Math.PI / 40f / (int)(p.Luminosity / 4)), renderer, Color.White);
        }
        public override void DrawGhost(int x, int y, MicroWorld.Graphics.Renderer renderer, Component.Rotation rotation)
        {
            if (texture0cw == null)
            {
                return;
            }
            switch (rotation)
            {
            case Component.Rotation.cw0:
                renderer.Draw(texture0cw, new Rectangle(x, y, (int)GetSizeRotated(rotation).X, (int)GetSizeRotated(rotation).Y),
                              new Color(1f, 1f, 1f, 0.5f));
                break;

            case Component.Rotation.cw90:
                renderer.Draw(texture90cw, new Rectangle(x, y, (int)GetSizeRotated(rotation).X, (int)GetSizeRotated(rotation).Y),
                              new Color(1f, 1f, 1f, 0.5f));
                break;

            /*
             * case Component.Rotation.cw180:
             * renderer.Draw(texture180cw, new Rectangle(x, y, (int)GetSizeRotated(rotation).X, (int)GetSizeRotated(rotation).Y),
             *  new Color(1f, 1f, 1f, 0.5f));
             * break;
             * case Component.Rotation.cw270:
             * renderer.Draw(texture270cw, new Rectangle(x, y, (int)GetSizeRotated(rotation).X, (int)GetSizeRotated(rotation).Y),
             *  new Color(1f, 1f, 1f, 0.5f));
             * break;//*/
            default:
                renderer.Draw(texture0cw, new Vector2(x, y) + GetCenter(parent.ComponentRotation), null,
                              new Color(1f, 1f, 1f, 0.5f), rotation.GetHashCode() * (float)Math.PI / 2f,
                              GetCenter(parent.ComponentRotation), 1);
                break;
            }
        }
        public override void Draw(MicroWorld.Graphics.Renderer renderer)
        {
            if (texture0cw == null)
            {
                return;
            }
            if (!CanDraw())
            {
                return;
            }
            Photoresistor p = parent as Photoresistor;

            switch (parent.ComponentRotation)
            {
            case Component.Rotation.cw0:
                renderer.Draw(texture0cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                break;

            case Component.Rotation.cw90:
                renderer.Draw(texture90cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                break;

            case Component.Rotation.cw180:
            case Component.Rotation.cw270:
            default:
                break;
            }
        }
Beispiel #5
0
 public override void DrawBorder(MicroWorld.Graphics.Renderer renderer)
 {
     #region Dotted Lines
     if (DrawPath != null && DrawPath.Count > 0)
     {
         MicroWorld.Graphics.RenderHelper.DrawDottedLinesToBorders(
             DrawPath.ToArray(), Color.White, renderer, true);
     }
     else
     {
         if (Size.X == -1)
         {
             MicroWorld.Graphics.RenderHelper.DrawDottedLines(
                 new float[] { Position.X, Position.X },
                 new float[] { Position.Y, Position.Y },
                 new float[] { float.MaxValue, Position.X },
                 new float[] { Position.Y, float.MaxValue },
                 Color.White, renderer, true);
         }
         else
         {
             MicroWorld.Graphics.RenderHelper.DrawDottedLines(
                 new float[] { Position.X, Position.X, Size.X, Size.X },
                 new float[] { Position.Y, Position.Y, Size.Y, Size.Y },
                 new float[] { float.MaxValue, Position.X, Size.X, float.MaxValue },
                 new float[] { Position.Y, float.MaxValue, float.MaxValue, Size.Y },
                 Color.White, renderer, true);
         }
     }
     #endregion
 }
Beispiel #6
0
        public void DrawToFBO(MicroWorld.Graphics.Renderer renderer)
        {
            var p = parent as Frame;

            renderer.EnableFBO(p.fbo);
            renderer.GraphicsDevice.Clear(Color.Transparent);
            var s = Settings.GameScale;

            Settings.GameScale = MicroWorld.Graphics.Camera.ZOOM_MAX;
            var t = Shortcuts.camera.Center;
            var a = Shortcuts.camera.VisibleRectangle;

            Shortcuts.camera.Center = Position + new Vector2(a.Width / 2, a.Height / 2);

            renderer.Begin();

            DrawFrame((int)Position.X, (int)Position.Y, (int)(Position.X + Size.X), (int)(Position.Y + Size.Y), renderer, 1f, true);

            for (int i = 0; i < p.containsComponents.Length; i++)
            {
                if (!renderer.IsDrawing)
                {
                    renderer.Begin();
                }
                p.containsComponents[i].Graphics.IgnoreNextDraw = true;
                p.containsComponents[i].Graphics.Draw(renderer);
            }

            renderer.End();
            Shortcuts.camera.Center = t;
            Settings.GameScale      = s;
            renderer.DisableFBO();
        }
Beispiel #7
0
 public static void DrawBorder(List <Vector2> p, MicroWorld.Graphics.Renderer renderer)
 {
     #region Dotted Lines
     MicroWorld.Graphics.RenderHelper.DrawDottedLinesToBorders(
         p.ToArray(), Color.White, renderer, true);
     #endregion
 }
Beispiel #8
0
        public override void DrawGhost(int x, int y, MicroWorld.Graphics.Renderer renderer, Component.Rotation rotation)
        {
            if (texture0cw == null)
            {
                return;
            }
            switch (rotation)
            {
            case Component.Rotation.cw0:
                renderer.Draw(texture0cw, new Rectangle(x, y, (int)GetSizeRotated(rotation).X, (int)GetSizeRotated(rotation).Y),
                              new Color(1f, 1f, 1f, 0.5f));
                break;

            case Component.Rotation.cw90:
                renderer.Draw(texture90cw, new Rectangle(x, y, (int)GetSizeRotated(rotation).X, (int)GetSizeRotated(rotation).Y),
                              new Color(1f, 1f, 1f, 0.5f));
                break;

            case Component.Rotation.cw180:
                break;

            case Component.Rotation.cw270:
                break;

            default:
                break;
            }
        }
 /// <summary>
 /// Use this to render component.
 /// SpriteBatch is already set to draw. It should be in the same state at the end
 /// </summary>
 /// <param name="renderer"></param>
 public virtual void Draw(MicroWorld.Graphics.Renderer renderer)
 {
     if (!CanDraw())
     {
         return;
     }
 }
Beispiel #10
0
        public override void Draw(MicroWorld.Graphics.Renderer renderer)
        {
            if (jointbg == null)
            {
                return;
            }
            if (!CanDraw())
            {
                return;
            }
            if (!Visible)
            {
                return;
            }
            renderer.Draw(jointbg, new Rectangle((int)Position.X, (int)Position.Y, 8, 8), Color.White);
            renderer.Draw(jointoverlay, new Rectangle((int)Position.X, (int)Position.Y, 8, 8), Color.Red * (float)((parent as Joint).Voltage / 5f));

            //renderer.DrawString(MicroWorld.Graphics.GUI.GUIEngine.font, Math.Round((parent as Joint).Voltage, 2).ToString(), Position, Color.Red, MicroWorld.Graphics.Renderer.TextAlignment.Left);

            /*
             * String s = Math.Round(((Joint)parent).Voltage, 2).ToString();
             *
             * renderer.DrawString(MicroWorld.Graphics.GUI.Elements.TextBox.defaultFont, s,
             *  Position, Color.White);//*/
        }
Beispiel #11
0
        public void DrawGhost(MicroWorld.Graphics.Renderer renderer, int x1, int y1, int x2, int y2)
        {
            var c = ComponentsManager.GetComponent(x1, y1);

            if (c != null)
            {
                x1 = (int)(c.Graphics.Position.X + c.Graphics.GetSize().X / 2);
                y1 = (int)(c.Graphics.Position.Y + c.Graphics.GetSize().Y / 2);
            }
            else
            {
                return;
            }
            var c2 = ComponentsManager.GetComponent(x2, y2);

            if (c2 != null)
            {
                x2 = (int)(c2.Graphics.Position.X + c2.Graphics.GetSize().X / 2);
                y2 = (int)(c2.Graphics.Position.Y + c2.Graphics.GetSize().Y / 2);
            }
            if (c2 == null || c2 is Properties.IRotator || c2 is Properties.IRotatable)
            {
                (Graphics as Graphics.RotatableConnectorGraphics).DrawConnector(x1, y1, x2, y2, renderer, 0.6f);
                Components.Graphics.RotatableConnectorGraphics.DrawBorder(new Vector2(x1, y1), new Vector2(x2, y2), renderer);
            }
        }
Beispiel #12
0
        private void DrawCircle(MicroWorld.Graphics.Renderer renderer, float state)
        {
            Vector2 Center = circleCenter + Position;

            state = state > 1 ? 1 : state < 0 ? 0 : state;
            float acur = astart + 2 * (float)Math.PI * state;
            List <VertexPositionColorTexture> vs = new List <VertexPositionColorTexture>();

            vs.Add(new VertexPositionColorTexture(
                       new Vector3(Center.X, Center.Y, 0),
                       circleColor,
                       new Vector2(0.5f, 0.5f)));
            vs.Add(GetVForAngle(astart));
            if (acur > Math.PI * 5 / 4)
            {
                vs.Add(new VertexPositionColorTexture(
                           new Vector3(Center.X - circle.Width / 2 / divider, Center.Y + circle.Height / 2 / divider, 0),
                           circleColor,
                           new Vector2(0f, 1f)));
                vs.Add(vs[vs.Count - 1]);
                vs.Add(vs[0]);
            }
            if (acur > Math.PI * 7 / 4)
            {
                vs.Add(new VertexPositionColorTexture(
                           new Vector3(Center.X + circle.Width / 2 / divider, Center.Y + circle.Height / 2 / divider, 0),
                           circleColor,
                           new Vector2(1f, 1f)));
                vs.Add(vs[vs.Count - 1]);
                vs.Add(vs[0]);
            }
            if (acur > Math.PI * 9 / 4)
            {
                vs.Add(new VertexPositionColorTexture(
                           new Vector3(Center.X + circle.Width / 2 / divider, Center.Y - circle.Height / 2 / divider, 0),
                           circleColor,
                           new Vector2(1f, 0f)));
                vs.Add(vs[vs.Count - 1]);
                vs.Add(vs[0]);
            }
            if (acur > Math.PI * 11 / 4)
            {
                vs.Add(new VertexPositionColorTexture(
                           new Vector3(Center.X - circle.Width / 2 / divider, Center.Y - circle.Height / 2 / divider, 0),
                           circleColor,
                           new Vector2(0f, 0f)));
                vs.Add(vs[vs.Count - 1]);
                vs.Add(vs[0]);
            }


            vs.Add(GetVForAngle(acur));


            var a = vs.ToArray();

            renderer.GraphicsDevice.Textures[0] = circle;
            renderer.GraphicsDevice.DrawUserPrimitives <VertexPositionColorTexture>(PrimitiveType.TriangleList, a, 0, a.Length / 3);
        }
Beispiel #13
0
 public override void DrawGhost(int x, int y, MicroWorld.Graphics.Renderer renderer, Component.Rotation rotation)
 {
     if (jointbg == null)
     {
         return;
     }
     renderer.Draw(jointbg, new Rectangle(x, y, 8, 8), new Color(1f, 1f, 1f, 0.5f));
 }
Beispiel #14
0
        public override void DrawBorder(MicroWorld.Graphics.Renderer renderer)
        {
            base.DrawBorder(renderer);

            float a = (float)((Main.Ticks % 1200) * Math.PI / 600f);
            float r = (parent.Logics as Logics.TeslaCoilLogics).Range;

            MicroWorld.Graphics.RenderHelper.DrawDottedCircle(r, Center, (int)(r / 2), a, renderer, Color.White);
        }
Beispiel #15
0
        public override void Draw(MicroWorld.Graphics.Renderer renderer)
        {
            if (texture == null)
            {
                return;
            }
            if (!CanDraw())
            {
                return;
            }
            Components.old.SegmentDisplay4 p = (Components.old.SegmentDisplay4)parent;
            Logics.SegmentDisplay4Logics   l = p.Logics as Logics.SegmentDisplay4Logics;

            if (!wasAOEDrawn && AOEOpacity > 0 && !MicroWorld.Graphics.GraphicsEngine.IsSelectedGlowPass)
            {
                DrawAOE(renderer, 1f);
                wasAOEDrawn = false;
            }

            renderer.Draw(texture, new Rectangle((int)Position.X, (int)Position.Y, (int)Size.X, (int)Size.Y),
                          new Rectangle(0, 0, (int)Size.X * 4, (int)Size.Y * 4), Color.White);
            //curnumbers
            for (int j = 0; j < 4; j++)
            {
                for (int i = 0; i < 8; i++)
                {
                    if ((l.digits[j] & (1 << i)) != 0)
                    {
                        renderer.Draw(mask,
                                      new Rectangle((int)Position.X + DigitsPositions[j], (int)Position.Y + 7, (int)DigitSize.X, (int)DigitSize.Y),
                                      new Rectangle(i * 44, 0, (int)DigitSize.X * 4, (int)DigitSize.Y * 4),
                                      DisplayColor * ((float)p.W[i * 4 + j].VoltageDropAbs / 5f));
                    }
                }
            }
            //last
            for (int c = 0; c < l.digitsold.Length; c++)
            {
                if (l.digitsold[c] == null)
                {
                    break;
                }
                for (int j = 0; j < 4; j++)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        if ((l.digitsold[c][j] & (1 << i)) != 0)
                        {
                            renderer.Draw(mask,
                                          new Rectangle((int)Position.X + DigitsPositions[j], (int)Position.Y + 7, (int)DigitSize.X, (int)DigitSize.Y),
                                          new Rectangle(i * 44, 0, (int)DigitSize.X * 4, (int)DigitSize.Y * 4),
                                          DisplayColor * 0.1f);
                        }
                    }
                }
            }
        }
Beispiel #16
0
        public override void DrawBorder(MicroWorld.Graphics.Renderer renderer)
        {
            base.DrawBorder(renderer);

            var p = parent as MovementDetector;

            MicroWorld.Graphics.RenderHelper.DrawDottedCircle(p.Range, Position + GetSize() / 2, (int)(p.Range / 2),
                                                              (float)((Main.Ticks % 40) * 2 * Math.PI / 40f / (int)(p.Range / 4)), renderer, Color.White);
        }
Beispiel #17
0
        public override void DrawGhost(int x, int y, MicroWorld.Graphics.Renderer renderer, Component.Rotation rotation)
        {
            if (texture0cw == null)
            {
                return;
            }

            renderer.Draw(texture0cw, new Rectangle(x, y, (int)GetSizeRotated(rotation).X, (int)GetSizeRotated(rotation).Y),
                          new Color(1f, 1f, 1f, 0.5f));
        }
Beispiel #18
0
        internal override void PostDraw(MicroWorld.Graphics.Renderer renderer)
        {
            Wire p = (Wire)parent;

            if (!Visible && Settings.DrawInvisibleWires)
            {
                renderer.GraphicsDevice.Textures[0] = Shortcuts.pixel;
                renderer.DrawLine(p.J1.Graphics.Center.X, p.J1.Graphics.Center.Y, p.J2.Graphics.Center.X, p.J2.Graphics.Center.Y, Color.Lime, Color.Lime);
            }
        }
Beispiel #19
0
 public override void DrawGhost(int x, int y, MicroWorld.Graphics.Renderer renderer, Component.Rotation rotation)
 {
     if (texture == null)
     {
         return;
     }
     renderer.Draw(texture, new Rectangle(x, y, (int)GetSizeRotated(rotation).X, (int)GetSizeRotated(rotation).Y),
                   new Color(1f, 1f, 1f, 0.5f));
     //renderer.Draw(texture, new Vector2(x, y) + GetCenter(rotation), null, new Color(1f, 1f, 1f, 0.5f),
     //    rotation.GetHashCode() * (float)Math.PI / 2f, GetCenter(rotation), 1);
 }
        public override void DrawBorder(MicroWorld.Graphics.Renderer renderer)
        {
            var p = parent as RotatableConnector;

            if (p.ConnectedComponent1 != null && p.ConnectedComponent2 != null)
            {
                DrawBorder(p.ConnectedComponent1.Graphics.Position + p.ConnectedComponent1.Graphics.GetSize() / 2,
                           p.ConnectedComponent2.Graphics.Position + p.ConnectedComponent2.Graphics.GetSize() / 2,
                           renderer);
            }
        }
        /// <summary>
        /// Renders a dotted border around the component
        /// Called for ghosts.
        /// Sets up parameters and call DrawBorder(Renderer)
        /// </summary>
        /// <param name="renderer"></param>
        public virtual void DrawBorder(float x, float y, Component.Rotation rot, MicroWorld.Graphics.Renderer renderer)
        {
            var a = parent.ComponentRotation;

            parent.ComponentRotation = rot;
            var b = position;

            position = new Vector2(x, y);
            DrawBorder(renderer);
            position = b;
            parent.ComponentRotation = a;
        }
Beispiel #22
0
        public override void Draw(MicroWorld.Graphics.Renderer renderer)
        {
            if (texture0cw == null)
            {
                return;
            }
            if (!CanDraw())
            {
                return;
            }
            Motor p = parent as Motor;
            //Components.Logics.MotorLogics l = (Components.Logics.MotorLogics)parent.Logics;

            var s = GetSizeRotated(parent.ComponentRotation);

            switch (parent.ComponentRotation)
            {
            case Component.Rotation.cw0:
                renderer.Draw(cog, new Rectangle((int)Position.X + 16, (int)Position.Y, 32, 32), null, Color.White, cogRotation, new Vector2(64.5f, 64.5f));
                renderer.Draw(texture0cw,
                              new Rectangle((int)Position.X, (int)Position.Y - 16,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y + 16), null,
                              Color.White);
                break;

            case Component.Rotation.cw90:
                renderer.Draw(cog, new Rectangle((int)Position.X + 32, (int)Position.Y + 16, 32, 32), null, Color.White, cogRotation, new Vector2(64.5f, 64.5f));
                renderer.Draw(texture90cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X + 16, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                break;

            case Component.Rotation.cw180:
                renderer.Draw(cog, new Rectangle((int)Position.X + 16, (int)Position.Y + 32, 32, 32), null, Color.White, cogRotation, new Vector2(64.5f, 64.5f));
                renderer.Draw(texture180cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y + 16), null,
                              Color.White);
                break;

            case Component.Rotation.cw270:
                renderer.Draw(cog, new Rectangle((int)Position.X, (int)Position.Y + 16, 32, 32), null, Color.White, cogRotation, new Vector2(64.5f, 64.5f));
                renderer.Draw(texture270cw,
                              new Rectangle((int)Position.X - 16, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X + 16, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                break;

            default:
                break;
            }
        }
Beispiel #23
0
        public void DrawAOE(MicroWorld.Graphics.Renderer renderer, float opacityMultiplier)
        {
            var   p    = parent as Coil;
            float a    = (float)((Main.Ticks % 1200) * Math.PI / 600f);
            float r    = p.FieldRadius;
            float rabs = Math.Abs(r);

            float[] radiuses = new float[4];
            int     d        = (int)(Main.Ticks % 80) / 2;

            if (r < 0)
            {
                radiuses[0] = rabs - d;
                radiuses[1] = rabs - d - 40;
                radiuses[2] = rabs - d - 80;
                radiuses[3] = rabs - d - 120;
            }
            else
            {
                radiuses[0] = rabs + d - 160;
                radiuses[1] = rabs + d - 120;
                radiuses[2] = rabs + d - 80;
                radiuses[3] = rabs + d - 40;
            }
            if (radiuses[0] < 0)
            {
                radiuses[0] = 0;
            }
            if (radiuses[1] < 0)
            {
                radiuses[1] = 0;
            }
            if (radiuses[2] < 0)
            {
                radiuses[2] = 0;
            }
            if (radiuses[3] < 0)
            {
                radiuses[3] = 0;
            }

            MicroWorld.Graphics.RenderHelper.DrawDottedCircle(rabs, Position + GetSize() / 2, (int)(rabs / 2),
                                                              a, renderer, Color.White * 0.4f);

            MicroWorld.Graphics.RenderHelper.DrawDottedCircle(radiuses[0], Position + GetSize() / 2, (int)(rabs / 2),
                                                              a, renderer, Color.White * (float)((float)d / 40f));
            MicroWorld.Graphics.RenderHelper.DrawDottedCircle(radiuses[1], Position + GetSize() / 2, (int)(rabs / 2),
                                                              a, renderer, Color.White);
            MicroWorld.Graphics.RenderHelper.DrawDottedCircle(radiuses[2], Position + GetSize() / 2, (int)(rabs / 2),
                                                              a, renderer, Color.White);
            MicroWorld.Graphics.RenderHelper.DrawDottedCircle(radiuses[3], Position + GetSize() / 2, (int)(rabs / 2),
                                                              a, renderer, Color.White * (float)((float)(40 - d) / 40f));
        }
Beispiel #24
0
        public override void Draw(MicroWorld.Graphics.Renderer renderer)
        {
            if (texture0cw == null)
            {
                return;
            }
            if (!CanDraw())
            {
                return;
            }
            Components.Logics.DelayerLogics l = (Components.Logics.DelayerLogics)parent.Logics;

            UpdateFBO();

            switch (parent.ComponentRotation)
            {
            case Component.Rotation.cw0:
                renderer.Draw(texture0cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                renderer.Draw(fbo, new Rectangle((int)Position.X + 12, (int)Position.Y + 7, 24, 10), null, Color.White);
                break;

            case Component.Rotation.cw90:
                renderer.Draw(texture90cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                renderer.Draw(fbo, new Rectangle((int)Position.X + 17, (int)Position.Y + 12, 24, 10), null, Color.White, (float)Math.PI / 2, Vector2.Zero);
                break;

            case Component.Rotation.cw180:
                renderer.Draw(texture180cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                renderer.Draw(fbo, new Rectangle((int)Position.X + 36, (int)Position.Y + 17, 24, 10), null, Color.White, (float)Math.PI, Vector2.Zero);
                break;

            case Component.Rotation.cw270:
                renderer.Draw(texture270cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                renderer.Draw(fbo, new Rectangle((int)Position.X + 7, (int)Position.Y + 36, 24, 10), null, Color.White, (float)-Math.PI / 2, Vector2.Zero);
                break;

            default:
                break;
            }
        }
Beispiel #25
0
        public void DrawTrajectory(MicroWorld.Graphics.Renderer renderer)
        {
            float rad = 100f;
            var   p   = parent as Motor;

            if (p.connector != null)
            {
                var a1 = p.connector.ConnectedComponent1.Graphics.Position + p.connector.ConnectedComponent1.Graphics.GetSize() / 2;
                var a2 = p.connector.ConnectedComponent2.Graphics.Position + p.connector.ConnectedComponent2.Graphics.GetSize() / 2;
                rad = Math.Abs((a2 - a1).Length());
            }
            else
            {
                return;
            }

            MicroWorld.Graphics.RenderHelper.DrawDottedCircle(rad, Position + GetSize() / 2, 60, (float)((Main.Ticks % 40) * Math.PI / 40f / 15f), renderer, Color.White);
            return;

            float opacity = 1f;

            VertexPositionColorTexture[] arr = new VertexPositionColorTexture[60];

            double  d   = (float)((Main.Ticks % 40)) * Math.PI / 40f / 15f;
            int     c   = 0;
            Vector2 off = Position + GetSize() / 2;

            for (double i = 0; i <= Math.PI * 2 - 0.001d; i += Math.PI / 30d)
            {
                arr[c] = new VertexPositionColorTexture(
                    new Vector3((float)Math.Cos(i + d) * rad + off.X, (float)Math.Sin(i + d) * rad + off.Y, 0),
                    Color.White * opacity, new Vector2());
                c++;
            }

            Main.renderer.Draw(MicroWorld.Graphics.GraphicsEngine.pixel, new Rectangle(0, 0, 0, 0), Color.White);
            bool a = renderer.IsDrawing;
            bool b = renderer.IsScaeld;

            if (renderer.IsDrawing)
            {
                renderer.End();
            }

            renderer.GraphicsDevice.DrawUserPrimitives <VertexPositionColorTexture>(PrimitiveType.LineList,
                                                                                    arr, 0, arr.Length / 2);

            if (a)
            {
                renderer.Begin(b);
            }
        }
Beispiel #26
0
        public override void Draw(MicroWorld.Graphics.Renderer renderer)
        {
            if (texture0cw == null)
            {
                return;
            }
            if (!CanDraw())
            {
                return;
            }
            Motor p = parent as Motor;

            Components.Logics.MotorLogics l = (Components.Logics.MotorLogics)parent.Logics;

            var s = GetSizeRotated(parent.ComponentRotation);

            switch (parent.ComponentRotation)
            {
            case Component.Rotation.cw0:
                renderer.Draw(texture0cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                renderer.Draw(overlay0cw,
                              new Rectangle((int)(Position.X + s.X / 2), (int)(Position.Y + s.Y / 2), (int)s.X, (int)s.Y), null,
                              Color.White, l.Angle, new Vector2(96, 80));
                break;

            case Component.Rotation.cw90:
                renderer.Draw(texture90cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                renderer.Draw(overlay90cw,
                              new Rectangle((int)(Position.X + s.X / 2), (int)(Position.Y + s.Y / 2), (int)s.X, (int)s.Y), null,
                              Color.White, l.Angle, new Vector2(80, 96));
                break;

            case Component.Rotation.cw180:
                break;

            case Component.Rotation.cw270:
                break;

            default:
                break;
            }


            //renderer.DrawStringLeft(MicroWorld.Graphics.GUI.Elements.TextBox.defaultFont, ((Resistor)parent).Resistance.ToString(),
            //    Position, Color.White);
        }
Beispiel #27
0
        public override void Draw(MicroWorld.Graphics.Renderer renderer)
        {
            if (texture0cw == null)
            {
                return;
            }
            if (!CanDraw())
            {
                return;
            }
            Components.Logics.CapacitorLogics l = (Components.Logics.CapacitorLogics)parent.Logics;

            switch (parent.ComponentRotation)
            {
            case Component.Rotation.cw0:
                renderer.Draw(texture0cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                renderer.Draw(texturePlateLeft0cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              (l.CurCharge > 0 ? Color.Blue : Color.Red) * (float)Math.Abs(l.CurCharge / l.Capacitance));
                renderer.Draw(texturePlateRight0cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              (l.CurCharge < 0 ? Color.Blue : Color.Red) * (float)Math.Abs(l.CurCharge / l.Capacitance));
                break;

            case Component.Rotation.cw90:
                renderer.Draw(texture90cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                renderer.Draw(texturePlateLeft90cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              (l.CurCharge > 0 ? Color.Blue : Color.Red) * (float)Math.Abs(l.CurCharge / l.Capacitance));
                renderer.Draw(texturePlateRight90cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              (l.CurCharge < 0 ? Color.Blue : Color.Red) * (float)Math.Abs(l.CurCharge / l.Capacitance));
                break;

            case Component.Rotation.cw180:
            case Component.Rotation.cw270:
            default:
                break;
            }

            //renderer.DrawStringLeft(MicroWorld.Graphics.GUI.GUIEngine.font, l.CurCharge.ToString(), Position, Color.Red);
        }
        /// <summary>
        /// Renders a dotted border around the component
        /// </summary>
        /// <param name="renderer"></param>
        public virtual void DrawBorder(MicroWorld.Graphics.Renderer renderer)
        {
            var s = GetSizeRotated(parent.ComponentRotation);

            #region Dotted Lines
            MicroWorld.Graphics.RenderHelper.DrawDottedLines(
                new float[] { position.X, position.X + s.X, position.X, position.X },
                new float[] { position.Y, position.Y, position.Y, position.Y + s.Y },
                new float[] { position.X, position.X + s.X, float.MaxValue, float.MaxValue },
                new float[] { float.MaxValue, float.MaxValue, position.Y, position.Y + s.Y },
                Color.White, renderer, true);
            #endregion
        }
Beispiel #29
0
        public override void Draw(MicroWorld.Graphics.Renderer renderer)
        {
            if (texture0cw == null)
            {
                return;
            }
            if (!CanDraw())
            {
                return;
            }
            Magnet p = parent as Magnet;

            if (!wasAOEDrawn && AOEOpacity > 0 && !MicroWorld.Graphics.GraphicsEngine.IsSelectedGlowPass)
            {
                DrawAOE(renderer, 1f);
                wasAOEDrawn = false;
            }
            switch (parent.ComponentRotation)
            {
            case Component.Rotation.cw0:
                renderer.Draw(p.pole == MagnetPole.S ? textureB0cw : texture0cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                break;

            case Component.Rotation.cw90:
                renderer.Draw(p.pole == MagnetPole.S ? textureB90cw : texture90cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                break;

            case Component.Rotation.cw180:
                renderer.Draw(p.pole == MagnetPole.S ? textureB180cw : texture180cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                break;

            case Component.Rotation.cw270:
                renderer.Draw(p.pole == MagnetPole.S ? textureB270cw : texture270cw,
                              new Rectangle((int)Position.X, (int)Position.Y,
                                            (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null,
                              Color.White);
                break;

            default:
                break;
            }
        }
Beispiel #30
0
        public override void Draw(MicroWorld.Graphics.Renderer renderer)
        {
            //renderer.DrawString(MicroWorld.Graphics.GUI.GUIEngine.font, Math.Round((parent as Wire).Current, 3).ToString(), (parent as Wire).J1.Graphics.Center, Color.Red, MicroWorld.Graphics.Renderer.TextAlignment.Left);

            if (!Visible)
            {
                return;
            }
            if (!CanDraw())
            {
                return;
            }

            Wire  p  = (Wire)parent;
            Color cs = new Color(0.8f, 0.8f, 0.8f);

            if (Settings.GameState != Settings.GameStates.Stopped)
            {
                cs = p.VoltageDropAbs > 0.001 ? new Color(1f, 0.8f, 0.8f) : Color.White;
            }

            //renderer.DrawString(MicroWorld.Graphics.GUI.GUIEngine.font, electrons.Count.ToString(), DrawPath[0], Color.Red, MicroWorld.Graphics.Renderer.TextAlignment.Left);

            Color c = p.IsBurnt ? Color.Red : cs;

            for (int j = 0; j < DrawPath.Count - 1; j++)
            {
                renderer.Draw(Shortcuts.pixel, new Rectangle((int)DrawPath[j].X - 2, (int)DrawPath[j].Y - 2,
                                                             (int)(DrawPath[j + 1].X - DrawPath[j].X) + 4, (int)(DrawPath[j + 1].Y - DrawPath[j].Y) + 4), c);
                renderer.Draw(Shortcuts.pixel, new Rectangle((int)DrawPath[j].X - 2, (int)DrawPath[j].Y - 2, 4, 4), c);
            }

            float scale = 0.5f + (float)p.J1.Voltage / 10f;

            scale = (scale > 1f ? 1f : scale < 0 ? 0 : scale) * 2;
            float   scale2 = scale * 2;
            Vector2 tv;

            try
            {
                for (int i = 0; i < electrons.Count; i++)
                {
                    tv = Vector2.Lerp(DrawPath[electrons[i].curind], DrawPath[electrons[i].curind + 1], electrons[i].lerpState);
                    renderer.Draw(Electron.texture, tv.X - scale, tv.Y - scale, scale2, scale2, Color.Orange);
                }
            }
            catch
            {
                GenerateElectrons();
            }
        }