Example #1
0
        private void OnObjectsBlown(List <Point> objects, FieldObjects blownReason)
        {
            var image     = Source.GetImage("Explosion");
            var tailParts = _cutTails.Any() ? _cutTails.Dequeue() : null;

            foreach (var part in tailParts ?? new List <PictureBox>())
            {
                part.Image = image;
            }
            foreach (var obj in objects)
            {
                _fieldView[obj.X, obj.Y].Image = image;
            }

            var countdown = new Timer {
                Interval = 300
            };

            countdown.Tick += (sender, args) =>
            {
                ClearExplosion(tailParts, objects);
                countdown.Stop();
            };
            countdown.Start();
        }
Example #2
0
        public void GenerateNewRandomObject(FieldObjectType fieldObjectType, Random random)
        {
            int         index       = random.Next(Grounds.Count);
            FieldObject fieldObject = Grounds[index];

            fieldObject.ObjectType = fieldObjectType;
            FieldObjects.Add(fieldObject);
            Grounds.RemoveAt(index);
        }
Example #3
0
        private void DrawItem(Point position, FieldObjects objType)
        {
            var location = new Point(position.X * _cellSize, position.Y * _cellSize);
            var newItem  = new PictureBox();

            newItem.Image    = Source.GetImage(objType.ToString());
            newItem.Size     = new Size(_cellSize, _cellSize);
            newItem.Location = location;
            if (_fieldView[position.X, position.Y] == null)
            {
                _fieldView[position.X, position.Y] = newItem;
                _mainField.Controls.Add(newItem);
            }
            else
            {
                RemoveObject(position);
                DrawItem(position, objType);
            }
        }