public override void Update(SimulationEntity entity, Simulation simulation) { if (_useGravity) { entity.Velocity.Y += Gravity; entity.Velocity.X *= Friction; //Caps your speed in specific axis if (System.Math.Abs(entity.Velocity.X) > MaxSpeed.X) { entity.Velocity.X = entity.Velocity.X > 0 ? MaxSpeed.X : -MaxSpeed.X; } if (System.Math.Abs(entity.Velocity.Y) > MaxSpeed.Y) { entity.Velocity.Y = entity.Velocity.Y > 0 ? MaxSpeed.Y : -MaxSpeed.Y; } entity.Rotation = (float)System.Math.Atan2(entity.Velocity.Y, entity.Velocity.X) + (float)(System.Math.PI / 2); } entity.Position.Add(entity.Velocity); //Collision Test Collision.DetectCollision(simulation, entity); if (!_hitTarget) { return; } CombatService.FightPeople(entity, _targetsHit, simulation); simulation.RemoveEntity(entity.EntityId); }
public void Use(Simulation simulation, SimulationEntity entity, IItem item) { if (entity.ControlState != null && entity.ControlState.LeftClick) { int reach = simulation.World.WorldOptions.WorldScale * item.Configuration.Reach; List <SimulationEntity> targets; if (entity.Facing == DirectionFacing.Left) { targets = simulation.World.QueryEntities(new Rectangle(entity.Left - reach, entity.Top + entity.Height / 2, reach, 2), new List <string> { "melee" }, entity.EntityId); } else { targets = simulation.World.QueryEntities(new Rectangle(entity.Right, entity.Top + entity.Height / 2, reach, 2), new List <string> { "melee" }, entity.EntityId); } CombatService.FightPeople(entity, targets, simulation); } }