Exemplo n.º 1
0
 public void CheckCollsion(CollsionComponent x)
 {
     if (CollsionDetector.OverLapping(Bounds, x.Bounds))
     {
         Add(x);
     }
 }
 public override void Clear()
 {
     if (CollsionDetector.Inside(Bounds, Settings.Instance.Gamebounds))
     {
         base.Clear();
     }
 }
Exemplo n.º 3
0
        public UserInterlfaceContainer CreateInfoPannel(Selector selector, Shape bounds)
        {
            UserInterlfaceContainer ui = new UserInterlfaceContainer(selector, true);

            GameObject pannel = CreatePanel(bounds);

            ui.Add(pannel);

            Point2D   startLocation = bounds.Copy().Add(Settings.PORTRAT_SPACING);
            Rectangle portratBounds = new Rectangle(startLocation, Settings.PORTRAT_SIZE, Settings.PORTRAT_SIZE);

            foreach (GameObject i in selector.GameObjects)
            {
                ui.Add(CreatePortart(selector, i, portratBounds.Copy()));

                portratBounds.Add(new Point2D(portratBounds.Size + Settings.PORTRAT_SPACING, 0));

                if (!CollsionDetector.Inside(portratBounds, bounds.HitBox))
                {
                    portratBounds.X  = startLocation.X;
                    portratBounds.Y += portratBounds.Height + Settings.PORTRAT_SPACING;
                }

                if (!CollsionDetector.Inside(portratBounds, bounds.HitBox))
                {
                    break;
                }
            }

            return(ui);
        }
Exemplo n.º 4
0
 public MoveCommand(Point2D target)
 {
     if (CollsionDetector.Inside(target, Settings.Instance.MiniMapSize))
     {
         _target = Utils.FromBoundsToWorld(target, Settings.Instance.MiniMapSize);
     }
     else
     {
         _target = Utils.ToWorld(target);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Returns if the Mouse is over the bounds if it has
        /// not been used anywhere else
        /// </summary>
        /// <param name="bounds"> the area </param>
        /// <param name="buttons"> Which button state Combinations it should look for </param>
        /// <returns></returns>
        public bool OverLapped(int hash, Rectangle bounds, List <MouseButtonState> buttons)
        {
            if (_chosen == 0 && CollsionDetector.Inside(ScreenPostion, bounds))
            {
                if (buttons != null && buttons.Any(i => _buttonStates[i.Button] == i.State))
                {
                    _chosen = hash;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 6
0
        public virtual void Move(WorldGraphicsComponent toMove, long deltaTime)
        {
            double speed = _speed * deltaTime;

            if (!CollsionDetector.OverLapping(toMove.Center, _target))
            {
                /*
                 *      I hate movement so i stole this is form here
                 *      http://stackoverflow.com/questions/13849185/moving-an-object-along-a-straight-line-at-a-constant-speed-from-point-a-to-b
                 */

                double tx    = _target.X - toMove.Center.X;
                double ty    = _target.Y - toMove.Center.Y;
                double dist  = Math.Sqrt(tx * tx + ty * ty);
                double rad   = Math.Atan2(ty, tx);
                double angle = rad / Math.PI * 180;

                double velX = (tx / dist) * speed;
                double velY = (ty / dist) * speed;

                toMove.Center = toMove.Center.Add(new Point2D(velX, velY));
            }
        }
Exemplo n.º 7
0
 public static bool InsideGameBounds(Point2D pt)
 {
     return(CollsionDetector.Inside(pt, Settings.Instance.Gamebounds));
 }
Exemplo n.º 8
0
 public static bool InsideGameBounds(Rectangle rect)
 {
     return(CollsionDetector.Inside(rect, Settings.Instance.Gamebounds));
 }