public void Update(ListPage page) { if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true) { if (_state != ListItemStatesEnum.selected) { _state = ListItemStatesEnum.hover; } if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released && MouseInput.MouseStateOld.LeftButton == ButtonState.Pressed) { page.CloseOthers(this); _state = ListItemStatesEnum.selected; } } else { if (_state != ListItemStatesEnum.selected) { _state = ListItemStatesEnum.none; } } if (_state == ListItemStatesEnum.selected) { foreach (Keys key in Enum.GetValues(typeof(Keys))) { if (KeyboardInput.KeyboardStateNew.IsKeyDown(key)) { Game1.STP.ControlKeys[_key] = key; _state = ListItemStatesEnum.none; } } } }
public void Update() { if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu())) { if (MouseInput.ScrolledDown()) { _offset -= 64f; } if (MouseInput.ScrolledUp()) { _offset += 64f; } } if (_offset < -((32 * _items.Count) - Boundary.Size.Y + 32)) { _offset = -((32 * _items.Count) - Boundary.Size.Y + 32); } if (_offset > 0) { _offset = 0; } for (int i = 0; i < _items.Count; i++) { _items[i].Move(_offset); _items[i].Update(this); } }
public void UpdateBase() { _doubleClickTime.Update(); if (CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true) { if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released && MouseInput.MouseStateOld.LeftButton == ButtonState.Pressed) { if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true && CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true) { _doubleClickTime.Reset(); if (_doubleClickTime.Ready == false) { _clicks++; } else { _clicks = 1; _doubleClickTime.Reset(); } Selected = true; } if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == false) { Selected = false; } } } }
public override void Draw() { if (Selected == true) { Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackSelected"], _boundary.Position, sourceRectangle: new Rectangle(0, 0, 256 + 16, 256 + 16)); } else if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true && CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true) { Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackHover"], _boundary.Position, sourceRectangle: new Rectangle(0, 0, 256 + 16, 256 + 16)); } Game1.SpriteBatchGlobal.Draw(_tex, _boundary.Position + new Vector2(8)); }
public override void Draw() { if (Selected == true) { Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackSelected"], _boundary.Position, Color.White); } else if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true && CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true) { Game1.SpriteBatchGlobal.Draw(Game1.Textures["TileBackHover"], _boundary.Position, Color.White); } Game1.SpriteBatchGlobal.Draw(Game1.Textures[_tile.TextureName], _boundary.Position + new Vector2(4), sourceRectangle: new Rectangle(new Point(_tile.IndexInPicture.X * 32, _tile.IndexInPicture.Y * 32), new Point(32)), scale: new Vector2(1)); }
public static void DrawEntityCursor() { if (CompareF.RectangleVsVector2(new RectangleF(Editor.EditMap.MapBoundary.Size * Globals.ScreenRatio.X, Editor.EditMap.MapBoundary.Position), MouseInput.MouseStateNew.Position.ToVector2() + Camera2DEditor.PositionPoint * Globals.ScreenRatio.X) == true) { if (EditorMenu.Radios.IndexSelected != 2) { Game1.SpriteBatchGlobal.Draw(Game1.Textures["CursorGrid"], MouseInput.MousePositionGridBetter(), scale: new Vector2(1)); } } if (EditorMenu.Radios.IndexSelected == 2) { DrawMouseEntity(); } }
protected virtual void DamageToNPC(Map map, IProjectile projectile) { foreach (Inpc npc in map.MapNpcs) { if (npc.Friendly == false) { List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(npc, new LineObject(npc, _track.Line)); if ((intersections?.Count > 0 || CompareF.RectangleVsVector2(npc.Boundary, _track.Line.End) == true) && (_from is Player)) { Damage(npc, projectile); break; } } } }
public bool InClickable() { if (Droped == false) { Clickable = new RectangleF(_width, 32, __position.X, __position.Y); } else { Clickable = new RectangleF(_width, names.GetLength(0) * 32 + 32, __position.X, __position.Y); } if (CompareF.RectangleVsVector2(Clickable, MouseInput.MouseRealPosMenu()) == true) { return(true); } return(false); }
public void Update() { if (MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed && MouseInput.MouseStateOld.LeftButton == ButtonState.Released) { if (CompareF.RectangleVsVector2(_boudary, MouseInput.MouseRealPosMenu()) == true) { _grabed = GraberState.grabed; } } else if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released) { if (CompareF.RectangleVsVector2(_boudary, MouseInput.MouseRealPosMenu()) == true) { _grabed = GraberState.hover; } else { _grabed = GraberState.none; } } if (_grabed == GraberState.grabed) { _boudary.Position = new Vector2(MouseInput.MouseRealPosMenu().X, _boudary.Position.Y) - new Vector2(_boudary.Size.X / 2, 0); } if (_boudary.Position.X < _position.X - _boudary.Size.X / 2) { _boudary.Position = new Vector2(_position.X - _boudary.Size.X / 2, _boudary.Position.Y); } if (_boudary.Position.X > _position.X + 255 - _boudary.Size.X / 2) { _boudary.Position = new Vector2(_position.X + 255 - _boudary.Size.X / 2, _boudary.Position.Y); } if (_onChange != null) { if (_grabed == GraberState.grabed) { _onChange(GetValue()); } } }
public void Update(Map map) { base.Update(map, this); foreach (Inpc npc in map.MapNpcs) { if (npc.Friendly == false) { List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(npc, new LineObject(npc, _track.Line)); if ((intersections?.Count > 0 || CompareF.RectangleVsVector2(npc.Boundary, _track.Line.End) == true) && (_from is Player)) { Damage(npc); AfterCollision(map, new Vector2Object(npc, _position)); map.MapProjectiles.Remove(this); break; } } } Vector2Object hitPos = null; if (OutOfmap(this, out hitPos) == true) { } if (RemoveOnMapCollision(map.MapTree, this, out hitPos) == true) { AfterCollision(map, hitPos); } if (CollisionWithMovables(map, this, out hitPos) == true) { AfterCollision(map, hitPos); } if (_wet == true) { _velocity /= 4; } }
public override void Draw() { if (Selected == true) { Game1.SpriteBatchGlobal.DrawAtlas(Game1.Textures["SaveBackground"], _boundary.Position + new Vector2(0, 16), new Point(736, 256), new Point(0, 2)); } else { if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu()) == true && CompareF.RectangleVsVector2(_listBoundary, MouseInput.MouseRealPosMenu()) == true) { Game1.SpriteBatchGlobal.DrawAtlas(Game1.Textures["SaveBackground"], _boundary.Position + new Vector2(0, 16), new Point(736, 256), new Point(0, 1)); } else { Game1.SpriteBatchGlobal.DrawAtlas(Game1.Textures["SaveBackground"], _boundary.Position + new Vector2(0, 16), new Point(736, 256), new Point(0, 0)); } } Game1.SpriteBatchGlobal.Draw(_preview, _boundary.Position + new Vector2(16) + new Vector2(0, 16), scale: new Vector2((256f - 32f) / Globals.WinRenderSize.Y)); DrawString.DrawText(_saveName, _boundary.Position + new Vector2(576, 16) + new Vector2(0, 16), Align.center, new Color(255, 255, 255), FontType.small); }
protected virtual bool CollisionWithMovables(Map map, IProjectile projectile, out Vector2Object hit) { foreach (IRectanglePhysics rec in map.MapMovables) { List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(rec, new LineObject(rec, _track.Line)); if (intersections?.Count > 0) { Game1.mapLive.MapProjectiles.Remove(projectile); hit = CompareF.NearestVector(_track.Line.Start, intersections); return(true); } if (CompareF.RectangleVsVector2(rec, _track.Line.End) == true) { Game1.mapLive.MapProjectiles.Remove(projectile); hit = new Vector2Object(rec, _track.Line.End); return(true); } } hit = null; return(false); }
public void Update(float contentSize) { ContentSize = contentSize; if (ContentSize > ContentContainerSize) { if (CompareF.RectangleVsVector2(_bar, MouseInput.MouseRealPosMenu()) == true && MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed && MouseInput.MouseStateOld.LeftButton == ButtonState.Released) { _grabed = true; _grabOffset = MouseInput.MouseRealPosMenu().Y - _bar.Position.Y; } if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released) { _grabed = false; _grabOffset = 0; } _up.Update(); _down.Update(); Set(); } }
public void Update() { _oldSelectedIndex = SelectedIndex; _scrollBar.Update(GetLenghtOfContent()); if (CompareF.RectangleVsVector2(Boundary, MouseInput.MouseRealPosMenu())) { if (MouseInput.ScrolledDown()) { _scrollBar.ScroolDown(); } if (MouseInput.ScrolledUp()) { _scrollBar.ScroolUp(); } } Set(); SelectedIndex = null; foreach (IHolderItem tile in Items) { tile.Update(); if (tile.Selected == true) { SelectedIndex = tile.Index; } } if (ChangedSelection() == true) { _method?.Invoke(); } }
public bool Update() { bool returnClicked = false; _border.Position = Position; if (_locked == false) { if (_clickedIn == false) { if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == true) { StateOfButton = ButtonStates.hover; } else { StateOfButton = ButtonStates.none; } } if (_clickedIn == true) { if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == true && MouseInput.MouseStateNew.LeftButton == ButtonState.Released) { _method?.Invoke(); _methodWindow?.Invoke(_changeWin); _methodIndex?.Invoke(_index); Game1.soundSelect.Play(); returnClicked = true; } if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == false && MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed) { StateOfButton = ButtonStates.none; } if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == true && MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed) { StateOfButton = ButtonStates.pressed; } } if (_clickedIn == false && _clickedOut == false) { if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == false && MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed) { _clickedOut = true; } if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == true && MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed && MouseInput.MouseStateOld.LeftButton == ButtonState.Released) { _clickedIn = true; StateOfButton = ButtonStates.pressed; } } if (MouseInput.MouseStateNew.LeftButton == ButtonState.Released) { _clickedIn = false; _clickedOut = false; if (CompareF.RectangleVsVector2(_border, MouseInput.MouseRealPosMenu()) == true) { StateOfButton = ButtonStates.hover; } else { StateOfButton = ButtonStates.none; } } } else { StateOfButton = ButtonStates.locked; } return(returnClicked); }
public void Update(Map map) { UpdateLine(); _hurtTimer.Update(); List <Vector2Object> intersectionsPlayer = CompareF.LineIntersectionRectangle(Game1.PlayerInstance.Boundary, new LineObject(Game1.PlayerInstance, _track.Line)); if (intersectionsPlayer?.Count > 0 && (_from is Inpc)) { Game1.PlayerInstance.TakeDamage(5); } foreach (Inpc npc in map.MapNpcs) { if (npc.Friendly == false) { List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(npc, new LineObject(npc, _track.Line)); if ((intersections != null && intersections.Count > 0 && (_from is Player)) || CompareF.RectangleVsVector2(npc.Boundary, _track.Line.End) == true) { if (_hurtTimer.Ready == true) { npc.Stun(); npc.KineticDamage(_damage); npc.Push(_velocity * 0.1f); _hurtTimer.Reset(); i++; } break; } if (i > 4) { Game1.mapLive.MapProjectiles.Remove(this); } } } Vector2Object hitPos = null; if (OutOfmap(this, out hitPos) == true) { BurstParticles(hitPos.Vector2); } if (RemoveOnMapCollision(map.MapTree, this, out hitPos) == true) { BurstParticles(hitPos.Vector2); } if (CollisionWithMovables(map, this, out hitPos) == true) { BurstParticles(hitPos.Vector2); } GetWet(map); if (_wet) { Game1.mapLive.MapProjectiles.Remove(this); } _velocity.Y += 0.03f; _trailTimer.Update(); if (_trailTimer.Ready == true) { List <Vector2> vectors = LineSegmentF.PointsOnLine(_position, _oldInterpol, 64); Vector2 random = new Vector2(Globals.GlobalRandom.Next(-_maximums, _maximums + 1), Globals.GlobalRandom.Next(-_maximums, _maximums + 1)); foreach (Vector2 vector in vectors) { for (int i = 0; i < 3; i++) { Game1.mapLive.mapParticles.Add(new ParticleCircleFlame(vector + new Vector2(Globals.GlobalRandom.Next(-16, 17), Globals.GlobalRandom.Next(-16, 17)), Game1.Textures["FlameCircle"])); } } _trailTimer.Reset(); _oldInterpol = _position + random; } _trail.Update(_position, _velocity, 1); }
public void Update(Map map) { _size = (float)Math.Sin(Game1.Time * 32) / 8 + 0.5f; _particleTime.Update(); if (_ballTime.Ready) { _effects.Add(new EnerergyCircle(new CircleF(_position, 16), 16, _velocity)); _ballTime.Reset(); } List <Vector2> trackVectors = LineSegmentF.PointsOnLine(_position, _oldPosition, 64); if (_particleTime.Ready == true) { foreach (Vector2 vector in trackVectors) { Game1.mapLive.mapParticles.Add(new ParticleBlackDrop(vector, _velocity, Game1.Textures["BlackParticle"])); } _particleTime.Reset(); } UpdateLine(); _lightTime.Update(); _ballTime.Update(); GetWet(map); int j = 0; foreach (Inpc npc in map.MapNpcs.Reverse <Inpc>()) { if (j < 8) { if (npc.Friendly == false) { List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(npc, new LineObject(npc, _track.Line)); if (intersections != null && intersections.Count > 0) { Damage(npc, this); break; } else if (CompareF.RectangleVsVector2(npc.Boundary, _track.Line.End) == true) { Damage(npc, this); break; } if (_lightTime.Ready) { if (LightningAttack.StrikeLightning(_position, npc, _damage) == true) { j++; } _lightTime.Reset(); } } } } Vector2Object hitPos = null; if (OutOfmap(this, out hitPos) == true) { AfterCollision(map, hitPos); } if (RemoveOnMapCollision(map.MapTree, this, out hitPos) == true) { AfterCollision(map, hitPos); } if (CollisionWithMovables(map, this, out hitPos) == true) { AfterCollision(map, hitPos); } if (_wet == true) { Game1.mapLive.MapProjectiles.Remove(this); } foreach (IEffect effect in _effects.Reverse <IEffect>()) { effect.Update(_effects); } }
public void Update(Map map) { if (_wet == false) { _trail.Update(_position, _velocity, 1); } UpdateLine(); _bubbleTime.Update(); _InWater = false; if (CompareF.LineBoundaryVsMap(map.WaterTree, _track).Count > 0) { _InWater = true; if (_bubbleTime.Ready == true) { Game1.mapLive.mapParticles.Add(new ParticleBubble(_position)); _bubbleTime.Reset(); } } if (_wet == true && _wet != _wetPreviousFrame) { _velocity /= 4; _trail.LeftParticle(); } foreach (Inpc npc in map.MapNpcs) { if (npc.Friendly == false) { List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(npc, new LineObject(npc, _track.Line)); if ((intersections?.Count > 0 || CompareF.RectangleVsVector2(npc.Boundary, _track.Line.End) == true) && (_from is Player)) { Damage(new Vector2Object(npc, _position), npc); AfterCollision(map, new Vector2Object(npc, _position)); break; } } } Vector2Object hitPos = null; if (OutOfmap(this, out hitPos) == true) { AfterCollision(map, new Vector2Object(Game1.mapLive, _position)); } if (CollisionWithMovables(map, this, out hitPos) == true) { AfterCollision(map, hitPos); } if (RemoveOnMapCollision(map.MapTree, this, out hitPos) == true) { AfterCollision(map, hitPos); } _velocity = CompareF.RotateVector2(_velocity, (float)(Math.Sin(Game1.Time * 16) / 64f)); _timeTrail.Update(); if (_timeTrail.Ready == true || _wet == true) { if (_wet == false) { List <Vector2> vectors = LineSegmentF.PointsOnLine(_position.ShiftOverDistance(32, (float)(CompareF.VectorToAngle(_velocity) + Math.PI)), _oldInterpol, 64); foreach (Vector2 vector in vectors) { for (int i = 0; i < 3; i++) { Game1.mapLive.mapParticles.Add(new ParticleCircleSmoke(vector + new Vector2(Globals.GlobalRandom.Next(-8, 9), Globals.GlobalRandom.Next(-8, 9)), Game1.Textures["SmokeCircle"])); } } } _timeTrail.Reset(); _oldInterpol = _position; } _wetPreviousFrame = _wet; GetWet(map); }
public bool Update() { _textOld = Text; if (MouseInput.MouseClickedLeft() == true) { if (CompareF.RectangleVsVector2(_boundary, MouseInput.MouseRealPosMenu()) == true) { IsActive = true; _cursor = (int)Math.Round(MouseInput.MouseRealPosMenu().X - _boundary.Position.X) / 16; if (_cursor > Text.Length) { _cursor = Text.Length; } if (_cursor < 0) { _cursor = 0; } MakeVisible(); } else { IsActive = false; MakeVisible(); } } if (IsActive == true) { keys = KeyboardInput.GetPressedKeys(); _backSpace.Update(); _left.Update(); _right.Update(); _blink.Update(); if (_blink.Ready == true) { _cursorVisible = !_cursorVisible; _blink.Reset(); } foreach (Keys key in keys) { int number = (int)key; if (_type == textBoxType.text || _type == textBoxType.fileName) { if (number >= 65 && number <= 90) { if (_cursor <= Text.Length) { Text = Text.Insert(_cursor + _offset, key.ToString()); CursorAdd(); MakeVisible(); } } if (key == Keys.Space) { if (_cursor <= Text.Length) { Text = Text.Insert(_cursor + _offset, " "); CursorAdd(); MakeVisible(); } } } if (number >= 96 && number <= 105) { if (_cursor <= Text.Length) { Text = Text.Insert(_cursor + _offset, (number - 96).ToString()); CursorAdd(); MakeVisible(); } } if (number >= 48 && number <= 57) { if (_cursor <= Text.Length) { Text = Text.Insert(_cursor + _offset, (number - 48).ToString()); CursorAdd(); MakeVisible(); } } if (key == Keys.OemMinus || key == Keys.Subtract) { if (_cursor <= Text.Length) { Text = Text.Insert(_cursor + _offset, "-"); CursorAdd(); MakeVisible(); } } } if (KeyboardInput.KeyboardStateNew.IsKeyDown(Keys.Back) == true && KeyboardInput.KeyboardStateOld.IsKeyDown(Keys.Back) == true) { if (_backSpace.Ready == true) { if (_cursor > 0 || _offset > 0) { Text = Text.Remove(_cursor - 1 + _offset, 1); MakeVisible(); _backSpace.Reset(); } if (_offset > 0) { _offset--; } else if (_cursor > 0) { _cursor--; } } } if (KeyboardInput.KeyboardStateNew.IsKeyDown(Keys.Left) == true && KeyboardInput.KeyboardStateOld.IsKeyDown(Keys.Left) == true) { if (_left.Ready == true) { if (_cursor > 0) { _cursor--; } else if (_offset > 0) { _offset--; } MakeVisible(); _left.Reset(); } } if (KeyboardInput.KeyboardStateNew.IsKeyDown(Keys.Right) == true && KeyboardInput.KeyboardStateOld.IsKeyDown(Keys.Right) == true) { if (_right.Ready == true) { if (_cursor < Text.Length) { if (_cursor < (int)((_boundary.Size.X - 16) / 16)) { _cursor++; } else if (_offset < Text.Length - (int)((_boundary.Size.X - 16) / 16)) { _offset++; } } MakeVisible(); _right.Reset(); } } } int i = 0; Parsed = int.TryParse(Text, out i); Valid = true; if ((Text.IndexOfAny(Path.GetInvalidFileNameChars()) != -1 && _type == textBoxType.fileName) || Text == "") { Valid = false; } if (_type == textBoxType.number && Parsed == true && (i < _min || i > _max)) { Valid = false; } if (Parsed == false && _type == textBoxType.number) { Valid = false; } if (_changeMehod != null) { _changeMehod?.Invoke(); return(true); } else { return(false); } }
//Test public List <Vector2Object> FindIntersectLine(LineSegmentF line) { List <Vector2Object> vectors = new List <Vector2Object>(); if (HasChilds == true) { if (CompareF.LineIntersectionRectangle(LeftBottom.Boundary, new LineObject(null, line)).Count > 0 || CompareF.RectangleVsVector2(LeftBottom.Boundary, line.End)) { vectors.AddRange(LeftBottom.FindIntersectLine(line)); } if (CompareF.LineIntersectionRectangle(LeftTop.Boundary, new LineObject(null, line)).Count > 0 || CompareF.RectangleVsVector2(LeftTop.Boundary, line.End)) { vectors.AddRange(LeftTop.FindIntersectLine(line)); } if (CompareF.LineIntersectionRectangle(RightBottom.Boundary, new LineObject(null, line)).Count > 0 || CompareF.RectangleVsVector2(RightBottom.Boundary, line.End)) { vectors.AddRange(RightBottom.FindIntersectLine(line)); } if (CompareF.LineIntersectionRectangle(RightTop.Boundary, new LineObject(null, line)).Count > 0 || CompareF.RectangleVsVector2(RightTop.Boundary, line.End)) { vectors.AddRange(RightTop.FindIntersectLine(line)); } return(vectors); } else { if (LevelSize == QuadTreeSizes.Size_32 && Holder != null && (CompareF.LineIntersectionRectangle(Boundary, new LineObject(null, line)).Count > 0 || CompareF.RectangleVsVector2(Boundary, line.End))) { vectors = CompareF.LineIntersectionRectangle(Boundary, new LineObject(null, line)); return(vectors); } return(vectors); } }