示例#1
0
        protected GameObj(Position position, char body, ConsoleColor color)
        {
            this.Color = color;
            this.position = position;
            this.body = body;

            this.IsDestroyed = false;
        }
示例#2
0
        public CollisionData(Position collisionForceDirection, List<string> hitObjectsCollisionGroupStrings)
        {
            this.CollisionForceDirection = collisionForceDirection;

            this.hitObjectsCollisionGroupStrings = new List<string>();

            foreach (var str in hitObjectsCollisionGroupStrings)
            {
                this.hitObjectsCollisionGroupStrings.Add(str);
            }
        }
示例#3
0
 public void MoveUp()
 {
     this.Memento = this.Position;
     this.Position.Y--;
 }
示例#4
0
 public void MoveRight()
 {
     this.Memento = this.Position;
     this.Position.X++;
 }
示例#5
0
 public void MoveLeft()
 {
     this.Memento = this.Position;
     this.Position.X--;
 }
示例#6
0
 public void MoveDown()
 {
     this.Memento = this.Position;
     this.Position.Y++;
 }
示例#7
0
 public Human(Position position, char body, int health, ConsoleColor color)
     : base(position, body, color)
 {
     Health = health;
 }
示例#8
0
 public MedicKit(Position topLeft)
     : base(topLeft, 'H', ConsoleColor.Red)
 {
 }
示例#9
0
 public Item(Position topLeft, char body, ConsoleColor color)
     : base(topLeft, body, color)
 {
 }
示例#10
0
 public void ClearTrail(Position position)
 {
     Console.SetCursorPosition(position.X, position.Y);
     Console.Write(' ');
 }
示例#11
0
 public Gate(Position position)
     : base(position, 'G', ConsoleColor.Green)
 {
 }
示例#12
0
 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)
                            );
                }
            }
        }
示例#14
0
 public CollisionData(Position collisionForceDirection, string objectCollisionGroupString)
 {
     this.CollisionForceDirection = collisionForceDirection;
     this.hitObjectsCollisionGroupStrings = new List<string>();
     this.hitObjectsCollisionGroupStrings.Add(objectCollisionGroupString);
 }
示例#15
0
 public Zombie(Position topLeft, int health)
     : base(topLeft, '#', health, ConsoleColor.DarkYellow)
 {
 }
示例#16
0
 public Key(Position topLeft)
     : base(topLeft, 'K', ConsoleColor.Yellow)
 {
 }
示例#17
0
 public Obstacle(Position position, char body, ConsoleColor color)
     : base(position, body, color)
 {
 }
示例#18
0
 private Player(Position position, int health)
     : base(position, 'o', health, ConsoleColor.Cyan)
 {
 }