protected void TryMove(SimModel simModel, SimState simState, Vector2 newLocation) { var oldLocation = Location; Location = newLocation; var collidingObjects = simModel.DetectCollisions(this).ToList(); if (collidingObjects.Count > 0) { Location = oldLocation; RaiseCollision(simModel, simState, collidingObjects); } }
public GameCollisionEventArgs(SimModel simModel, SimState simState, List <SimObject> collidingObjects) { SimModel = simModel; SimState = simState; CollidingObjects = collidingObjects; }
protected virtual void OnUpdate(SimModel simModel, SimState simState) { }
public void Update(SimModel simModel, SimState simState) { Updating.Raise(this, new GameStateUpdateEventArgs(simModel, simState)); OnUpdate(simModel, simState); TryMove(simModel, simState, Location.Add(Velocity)); }
protected void RaiseCollision(SimModel simModel, SimState simState, List <SimObject> collidingObjects) { Collision.Raise(this, new GameCollisionEventArgs(simModel, simState, collidingObjects)); }
protected override void OnUpdate(SimModel simModel, SimState simState) { }
protected virtual void OnSimObjectUpdating(SimObject simObject, SimModel simModel, SimState simState) { }
protected virtual void OnSimObjectCollision(SimObject sender, SimModel simModel, SimState simState, List <SimObject> collidingObjects) { }