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);
            }
        }
Exemple #2
0
 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));
 }
Exemple #6
0
 protected override void OnUpdate(SimModel simModel, SimState simState)
 {
 }
Exemple #7
0
 protected virtual void OnSimObjectUpdating(SimObject simObject, SimModel simModel, SimState simState)
 {
 }
Exemple #8
0
 protected virtual void OnSimObjectCollision(SimObject sender, SimModel simModel, SimState simState, List <SimObject> collidingObjects)
 {
 }