Пример #1
0
        public void RenderObject(GameObject obj)
        {
            Console.ForegroundColor = obj.Color;
            int left = obj.Left;
            int top = obj.Top;

            for (int row = 0; row < obj.Height; row++)
            {
                for (int col = 0; col < obj.Width; col++)
                {
                    Console.SetCursorPosition(left + col, top + row);
                    Console.Write(obj.Body[row, col]);
                }
            }
        }
Пример #2
0
 public GameObjectArgs(GameObject obj)
 {
     this.obj = obj;
 }
Пример #3
0
        public void AddObject(GameObject obj)
        {
            if (obj is Bomb)
            {
                if (bombs.Count < bombLimit)
                {
                    Bomb bomb = obj as Bomb;
                    bomb.OnExplode += CatchExplosion;
                    this.bombs.Add(bomb);
                    this.renderedObjects.Add(bomb);
                }
            }
            else if (obj is IndestructibleBlock)
            {
                this.renderedObjects.Add(new IndestructibleBrick(obj.Left, obj.Top));
                this.renderedObjects.Add(new IndestructibleBrick(obj.Left+1, obj.Top));
                this.renderedObjects.Add(new IndestructibleBrick(obj.Left + 2, obj.Top));
                this.renderedObjects.Add(new IndestructibleBrick(obj.Left, obj.Top+1));
                this.renderedObjects.Add(new IndestructibleBrick(obj.Left+1, obj.Top+1));
                this.renderedObjects.Add(new IndestructibleBrick(obj.Left + 2, obj.Top + 1));

            }
            else if (obj is DestructibleBlock)
            {
                this.renderedObjects.Add(new DestructibleBrick(obj.Left, obj.Top));
                this.renderedObjects.Add(new DestructibleBrick(obj.Left + 1, obj.Top));
                this.renderedObjects.Add(new DestructibleBrick(obj.Left + 2, obj.Top));
                this.renderedObjects.Add(new DestructibleBrick(obj.Left, obj.Top + 1));
                this.renderedObjects.Add(new DestructibleBrick(obj.Left + 1, obj.Top + 1));
                this.renderedObjects.Add(new DestructibleBrick(obj.Left + 2, obj.Top + 1));
            }
            else
            {
                this.renderedObjects.Add(obj);
            }
        }