Пример #1
0
        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);
            }
        }
Пример #2
0
 public GameCollisionEventArgs(SimModel simModel, SimState simState, List <SimObject> collidingObjects)
 {
     SimModel         = simModel;
     SimState         = simState;
     CollidingObjects = collidingObjects;
 }
Пример #3
0
 protected virtual void OnUpdate(SimModel simModel, SimState simState)
 {
 }
Пример #4
0
 public void Update(SimModel simModel, SimState simState)
 {
     Updating.Raise(this, new GameStateUpdateEventArgs(simModel, simState));
     OnUpdate(simModel, simState);
     TryMove(simModel, simState, Location.Add(Velocity));
 }
Пример #5
0
 protected void RaiseCollision(SimModel simModel, SimState simState, List <SimObject> collidingObjects)
 {
     Collision.Raise(this, new GameCollisionEventArgs(simModel, simState, collidingObjects));
 }
Пример #6
0
 protected override void OnUpdate(SimModel simModel, SimState simState)
 {
 }
Пример #7
0
 protected virtual void OnSimObjectUpdating(SimObject simObject, SimModel simModel, SimState simState)
 {
 }
Пример #8
0
 protected virtual void OnSimObjectCollision(SimObject sender, SimModel simModel, SimState simState, List <SimObject> collidingObjects)
 {
 }