Пример #1
0
        public override void Render(SpriteBatch spriteBatch)
        {
            //render tounge behind everything else
            if (tounge.isOut)
            {
                Renderer.DrawLine(spriteBatch,
                                  Sprites.tounge,
                                  new Vector2((x + 4) * Renderer.cam.scale, (y + 4) * Renderer.cam.scale),
                                  new Vector2(tounge.x * Renderer.cam.scale, tounge.y * Renderer.cam.scale));
            }

            if (isSquishing && isSelected)
            {
                //draw mouse angle line
                Renderer.DrawLine(spriteBatch,
                                  Sprites.dragLine,
                                  new Vector2((x + 4) * Renderer.cam.scale, (y + 4) * Renderer.cam.scale),
                                  new Vector2(InputManager.mouseX, InputManager.mouseY));
            }

            if (automatic)
            {
                spriteBatch.Draw(Sprites.autoStatus, Renderer.GetRenderRect(x + 2, y - 6, 4, 4), Color.White);
            }

            base.Render(spriteBatch);
        }
Пример #2
0
        public static void Update()
        {
            List <Entity> entityList = EntityManager.GetEntities();

            //set mode
            if (InputManager.MouseRightDown())
            {
                mode = CursorMode.BoundingBox;
            }
            else
            {
                mode = CursorMode.Normal;
            }

            if (mode == CursorMode.BoundingBox)
            {
                if (InputManager.MouseRightJustPressed())
                {
                    boundingA = new Vector2(InputManager.mouseX, InputManager.mouseY);
                    boundingB = new Vector2(InputManager.mouseX, InputManager.mouseY);
                }

                if (InputManager.MouseRightHeld())
                {
                    if (boundingB.X < boundingA.X || boundingB.Y < boundingA.Y)
                    {
                        updatingB = false;
                    }
                    else
                    {
                        updatingB = true;
                    }

                    if (updatingB)
                    {
                        boundingB = new Vector2(InputManager.mouseX, InputManager.mouseY);
                    }
                    else
                    {
                        boundingA = new Vector2(InputManager.mouseX, InputManager.mouseY);
                    }
                }

                //select all frogs in range
                foreach (Entity e in entityList)
                {
                    if (e.GetType() == typeof(Frog))
                    {
                        Rectangle frogScreenPos = Renderer.GetRenderRect(e.x, e.y, e.width, e.height);

                        if (CollisionSolver.IsColliding(
                                frogScreenPos.X,
                                frogScreenPos.Y,
                                frogScreenPos.Width,
                                frogScreenPos.Height,
                                boundingA.X,
                                boundingA.Y,
                                (int)(boundingB.X - boundingA.X),
                                (int)(boundingB.Y - boundingA.Y)))
                        {
                            ((Frog)e).isInGroup = true;
                        }
                        else
                        {
                            ((Frog)e).isInGroup = false;
                        }
                    }
                }
            }
            else
            {
                if (InputManager.MouseRightJustReleased())
                {
                    //deselect all frogs in range
                    foreach (Entity e in entityList)
                    {
                        if (e.GetType() == typeof(Frog))
                        {
                            Rectangle frogScreenPos = Renderer.GetRenderRect(e.x, e.y, e.width, e.height);

                            if (CollisionSolver.IsColliding(
                                    frogScreenPos.X,
                                    frogScreenPos.Y,
                                    frogScreenPos.Width,
                                    frogScreenPos.Height,
                                    boundingA.X,
                                    boundingA.Y,
                                    (int)(boundingB.X - boundingA.X),
                                    (int)(boundingB.Y - boundingA.Y)))
                            {
                                ((Frog)e).isInGroup = false;
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
 public virtual void Render(SpriteBatch spriteBatch)
 {
     spriteBatch.Draw(sprite, Renderer.GetRenderRect(x, y, width, height), Color.White);
 }