public SpatialTrigger(BoundingBox on, BoundingBox off, bool useBoxOff, Thing2D trigger) { m_onBox = on; m_offBox = off; m_useBoxOff = useBoxOff; Trigger = trigger; }
public Vector2f FindOffset() { LastOffset = ViewOffset; Vector2f centre; if (CameraSubject != null) { centre = CameraSubject.Position; } else if (CurrentScreen != null) { centre = CurrentScreen.Bounds.Centre.Clone(); } else { centre = Game.ScreenCentre; } ViewOffset = Game.ScreenSize*0.5f - centre; if (CurrentScreen == null) return ViewOffset; Bounds = CurrentScreen.Bounds.Clone; Bounds.Right -= Game.Width; //Bounds.Left += Game.Width/2; Bounds.Top -= Game.Height; //Bounds.Bottom += Game.Height/2; ViewOffset *= -1; ViewOffset.Clamp(Bounds); ViewOffset *= -1; return ViewOffset; }
public bool Overlaps(BoundingBox _other) { bool yIntersect = Top < _other.Top && Top > _other.Bottom || _other.Top < Top && _other.Top > Bottom; bool xIntersect = Left < _other.Right && Left > _other.Left || _other.Left < Right && _other.Left > Left; return yIntersect && xIntersect; }
private ResizeableBox makeBox(String title, BoundingBox box) { var rBox = new ResizeableBox(m_keyboard, new Vector2f(), null); rBox.backgroundColour = new Colour(1,0.2f,0.8f,1); rBox.Bounds = box.Clone; rBox.SetLabel(title); items.Add(rBox); return rBox; }
private ResizeableBox makeBox(String title) { Vector2f bottomLeft = m_game.Camera.CameraSubject.Position; BoundingBox box = new BoundingBox(bottomLeft, bottomLeft + new Vector2f(5)); return makeBox(title, box); }
private bool MouseOnTop() { top = new BoundingBox(Position.X, Position.Y+Size.Y-bounds, Position.X + Size.X, Position.Y+Size.Y); return top.Contains(m_keyboard.MousePos); }
private bool MouseOnRight() { right = new BoundingBox(Position.X + Size.X - bounds, Position.Y, Position.X + Size.X, Position.Y + Size.Y); return right.Contains(m_keyboard.MousePos); }
private bool MouseOnLeft() { left = new BoundingBox(Position.X, Position.Y, Position.X + bounds, Position.Y + Size.Y); return left.Contains(m_keyboard.MousePos); }
private bool MouseOnBottom() { bottom = new BoundingBox(Position.X, Position.Y, Position.X + Size.X, Position.Y+bounds); return bottom.Contains(m_keyboard.MousePos); }
private bool MouseInMiddle() { middle = new BoundingBox(Position.X + bounds, Position.Y+bounds, Position.X+Size.X-bounds, Position.Y+Size.Y-bounds); return middle.Contains(m_keyboard.MousePos); }
public EditorCursor(UserInput keys, BoundingBox bounds) { m_keys = keys; m_bounds = bounds; }
public void Clamp(BoundingBox bounds) { if (X > bounds.Right) X = bounds.Right; else if (X < bounds.Left) X = bounds.Left; if (Y < bounds.Bottom) Y = bounds.Bottom; else if (Y > bounds.Top) Y = bounds.Top; }
public override void Setup(Game _game, UserInput _keyboard, ScreenMessage _message) { base.Setup(_game, _keyboard, _message); deathTimer = 0; startTimer = 0; winTimer = 0; m_tilemap = new TileMap(levelFile); m_size = new Vector2i(m_tilemap.Width, m_tilemap.Height); Bounds.Right = m_size.X; Bounds.Top = m_size.Y; m_house = new ObjectHouse(m_tilemap); StarryBackground bg = new StarryBackground(m_tilemap.Size); bg.Layer = Layer.Pixelly; m_house.AddDrawable(bg); gangsterNo1 = new Hero(m_keyboard, m_house); gangsterNo1.Position = m_tilemap.locationData.start.point; gangsterNo1.PlaceInWorld(m_tilemap); m_house.AddDrawable(gangsterNo1); m_house.AddUpdateable(gangsterNo1); m_house.Add<IShootable>(gangsterNo1); m_game.SetCameraSubject(gangsterNo1); m_tilemap.Create(m_house, _game); m_house.AddDrawable(m_tilemap); m_tilemap.Priority = Priority.Middle; endzone = m_tilemap.locationData.end.box; // fx // pixelly pixellyEffect = new Effect( new Vector2i(Game.SmallScreenWidth/2, Game.SmallScreenHeight/2), new Vector2i(Game.ScreenWidth, Game.ScreenHeight), new Vector2i(Game.Width, Game.Height)){ CaptureLayer = Layer.Pixelly, Layer = Layer.FX, Priority = Priority.Back, Scaling = Sprite.ScaleType.Pixelly }; pixellyEffect.SetHUD(_game.Camera); m_house.AddDrawable(pixellyEffect); m_house.AddUpdateable(pixellyEffect); m_house.Add<IGrabing>(pixellyEffect); // fading fadingEffect = new Effect( new Vector2i(Game.ScreenWidth, Game.ScreenHeight), new Vector2i(Game.ScreenWidth, Game.ScreenHeight), new Vector2i(Game.Width, Game.Height)){ CaptureLayer = Layer.Blurry | Layer.Pixelly | Layer.Normal | Layer.FX, Layer = Layer.Fade, Priority = Priority.Front }; fadingEffect.SetHUD(_game.Camera); fadingEffect.SetFading(1f, new Colour(0,0,0,1), new Colour(0,0,0,0)); fadingEffect.SetBackground(new Colour(0,0,0,1f)); m_house.AddDrawable(fadingEffect); m_house.AddUpdateable(fadingEffect); m_house.Add<IGrabing>(fadingEffect); // messages welcome_message = new Text("Welcome to the Magnum House..."); welcome_message.SetHUD(m_game.Camera); welcome_message.CentreOn(Game.Size.ToF()/2); welcome_message.Priority = Priority.Front; welcome_message.Layer = Layer.Normal; welcome_message.Transparency = 0f; m_house.AddDrawable(welcome_message); }
public BoxDescription(String name, BoundingBox box) { this.box = box; this.name = name; }
protected ResizeableBox NewBox(BoundingBox bb, Colour colour) { ResizeableBox box = new ResizeableBox(m_keyboard, bb.Size, null); box.Bounds = bb; box.backgroundColour = colour; items.Add(box); return box; }
public SpatialTrigger(BoundingBox box, Thing2D trigger) : this(box, null, false, trigger) { }