/// <summary> /// Constructs a new item entitiy. /// </summary> /// <param name="location">Position of the item (point).</param> /// <param name="itemType">Type of item (itemtype).</param> public ItemEntity(Point location, ItemType itemType) : base("Item" + itemType.ToString(), InitBounding(location, itemType), 1) { _itemType = itemType; _flag = itemType == ItemType.Star; _movement = new Gravity(new Vector(0, -3), new Vector(0, 0.1), 1.8); }
/// <summary> /// Constructs bullet entity. /// </summary> /// <param name="bulletColour">Colour of bullet.</param> /// <param name="bulletType">Type of bullet.</param> /// <param name="owner">Owner of bullet.</param> /// <param name="position">Spawn position of bullet.</param> /// <param name="trajectory">Trajectory of bullet.</param> public BulletEntity(BulletColour bulletColour, BulletType bulletType, Entity owner, Point position, Vector trajectory) : base(bulletType.ToString() + bulletColour.ToString(), InitBounding(bulletType, position, trajectory), 1) { _bulletColour = bulletColour; _bulletType = bulletType; _owner = owner; _trajectory = trajectory; _grazed = false; _movement = new Linear(trajectory); }
/// <summary> /// Processes entity movement. /// </summary> public override void ProcessMovement() { if(_flag) { Vector velocity = new Vector(GameObjects.Player.Hitbox.Centroid, Hitbox.Centroid); if(velocity.Magnitude > 5) { velocity.Magnitude = 5; } _movement = new Linear(velocity); } _movement.step(); Offset(_movement.Velocity); }