public static void HandleCollision(Skier skier, List <GameObject> obstacles) { // Taking body`s coordinates of the skier List <FieldCoordinates> skierProfile = skier.GetCollisionProfile(); // Checking for collision between skier and all other objects foreach (var obj in obstacles) { if (obj.CanCollideWith(skier.GetCollisionName())) { // Taking obstacle`s coordinates List <FieldCoordinates> objProfile = obj.GetCollisionProfile(); if (HaveCollision(skierProfile, objProfile)) { if (obj.GetCollisionName() == Bonus.CollisionName) { obj.RespondToCollision(new CollisionData(obj.GetCollisionName())); } else if (obj.GetCollisionName() == Tree.CollisionName) { skier.RespondToCollision(new CollisionData(obj.GetCollisionName())); } } } } }
public static void HandleCollision(Skier skier, List<GameObject> obstacles) { // Taking body`s coordinates of the skier List<FieldCoordinates> skierProfile = skier.GetCollisionProfile(); // Checking for collision between skier and all other objects foreach (var obj in obstacles) { if (obj.CanCollideWith(skier.GetCollisionName())) { // Taking obstacle`s coordinates List<FieldCoordinates> objProfile = obj.GetCollisionProfile(); if(HaveCollision(skierProfile, objProfile)) { if (obj.GetCollisionName() == Bonus.CollisionName) { obj.RespondToCollision(new CollisionData(obj.GetCollisionName())); } else if (obj.GetCollisionName() == Tree.CollisionName) { skier.RespondToCollision(new CollisionData(obj.GetCollisionName())); } } } } }
private void AddSkier(GameObject obj) { this.skier = obj as Skier; }
static void Initialize(Engine engine) { Skier skier = new Skier(new FieldCoordinates(15, FieldCols / 2)); engine.AddObject(skier); }