protected GameObj(Position position, char body, ConsoleColor color) { this.Color = color; this.position = position; this.body = body; this.IsDestroyed = false; }
public CollisionData(Position collisionForceDirection, List<string> hitObjectsCollisionGroupStrings) { this.CollisionForceDirection = collisionForceDirection; this.hitObjectsCollisionGroupStrings = new List<string>(); foreach (var str in hitObjectsCollisionGroupStrings) { this.hitObjectsCollisionGroupStrings.Add(str); } }
public void MoveUp() { this.Memento = this.Position; this.Position.Y--; }
public void MoveRight() { this.Memento = this.Position; this.Position.X++; }
public void MoveLeft() { this.Memento = this.Position; this.Position.X--; }
public void MoveDown() { this.Memento = this.Position; this.Position.Y++; }
public Human(Position position, char body, int health, ConsoleColor color) : base(position, body, color) { Health = health; }
public MedicKit(Position topLeft) : base(topLeft, 'H', ConsoleColor.Red) { }
public Item(Position topLeft, char body, ConsoleColor color) : base(topLeft, body, color) { }
public void ClearTrail(Position position) { Console.SetCursorPosition(position.X, position.Y); Console.Write(' '); }
public Gate(Position position) : base(position, 'G', ConsoleColor.Green) { }
public Wall(Position topLeft) : base(topLeft, '█', ConsoleColor.Blue) { }
private static void HandleMovingWithStaticCollisions(List<Zombie> movingObjects, List<GameObj> staticObjects) { foreach (var movingObject in movingObjects) { int verticalIndex = VerticalCollisionIndex(movingObject, staticObjects); int horizontalIndex = HorizontalCollisionIndex(movingObject, staticObjects); Position movingCollisionForceDirection = new Position(0, 0); if (verticalIndex != -1) { movingCollisionForceDirection.Y = -movingObject.Speed.Y; staticObjects[verticalIndex].RespondToCollision( new CollisionData(new Position(movingObject.Speed.Y, 0), movingObject.GetCollisionGroupString()) ); } if (horizontalIndex != -1) { movingCollisionForceDirection.X = -movingObject.Speed.X; staticObjects[horizontalIndex].RespondToCollision( new CollisionData(new Position(0, movingObject.Speed.X), movingObject.GetCollisionGroupString()) ); } int diagonalIndex = -1; if (horizontalIndex == -1 && verticalIndex == -1) { diagonalIndex = DiagonalCollisionIndex(movingObject, staticObjects); if (diagonalIndex != -1) { movingCollisionForceDirection.Y = -movingObject.Speed.Y; movingCollisionForceDirection.X = -movingObject.Speed.X; staticObjects[diagonalIndex].RespondToCollision( new CollisionData(new Position(movingObject.Speed.Y, 0), movingObject.GetCollisionGroupString()) ); } } List<string> hitByMovingCollisionGroups = new List<string>(); if (verticalIndex != -1) { hitByMovingCollisionGroups.Add(staticObjects[verticalIndex].GetCollisionGroupString()); } if (horizontalIndex != -1) { hitByMovingCollisionGroups.Add(staticObjects[horizontalIndex].GetCollisionGroupString()); } if (diagonalIndex != -1) { hitByMovingCollisionGroups.Add(staticObjects[diagonalIndex].GetCollisionGroupString()); } if (verticalIndex != -1 || horizontalIndex != -1 || diagonalIndex != -1) { movingObject.RespondToCollision( new CollisionData(movingCollisionForceDirection, hitByMovingCollisionGroups) ); } } }
public CollisionData(Position collisionForceDirection, string objectCollisionGroupString) { this.CollisionForceDirection = collisionForceDirection; this.hitObjectsCollisionGroupStrings = new List<string>(); this.hitObjectsCollisionGroupStrings.Add(objectCollisionGroupString); }
public Zombie(Position topLeft, int health) : base(topLeft, '#', health, ConsoleColor.DarkYellow) { }
public Key(Position topLeft) : base(topLeft, 'K', ConsoleColor.Yellow) { }
public Obstacle(Position position, char body, ConsoleColor color) : base(position, body, color) { }
private Player(Position position, int health) : base(position, 'o', health, ConsoleColor.Cyan) { }