예제 #1
0
        public void AddBlock(BreakOutBlock block)
        {
            if (block != null)
            {
                //removes any blocks occupying the same location as the block being added
                foreach (var b in _blocks)
                {
                    if (block.GetX() == b.GetX())
                    {
                        if (block.GetY() == b.GetY())
                        {
                            _blocks.Remove(b);
                        }
                    }
                }

                _blocks.Add(block);
            }
        }
예제 #2
0
        public void AddBlock(BreakOutBlock block)
        {
            if (block != null)
            {
                //removes any blocks occupying the same location as the block being added
                foreach (var b in _blocks)
                {
                    if (block.GetX() == b.GetX())
                    {
                        if (block.GetY() == b.GetY())
                        {
                            _blocks.Remove(b);
                        }
                    }
                }

                _blocks.Add(block);
            }
        }
예제 #3
0
 private void DecrementType(BreakOutBlock block)
 {
     switch (block.GetType())
     {
         case Blocktype.Strong3:
             block.SetType(Blocktype.Strong2);
             block.SetColor(Color.Salmon);
             _score += 100;
             break;
         case Blocktype.Strong2:
             block.SetType(Blocktype.Standard);
             block.SetColor(Color.White);
             _score += 100;
             break;
         case Blocktype.Standard:
             block.SetType(Blocktype.Dead);
             _score += 100;
             break;
         case Blocktype.Ball:
             var rand = new Random();
             _ballList.Add(new BreakOutBall(block.GetX() + 39, block.GetY() + 18, (float).2 * (rand.Next(4) + 1), (float).5));
             _ballList.Add(new BreakOutBall(block.GetX() + 39, block.GetY() + 18, (float).2 * (rand.Next(4) + 1), (float).5));
             _lives += 2;
             _balls += 2;
             block.SetType(Blocktype.Dead);
             _score += 100;
             break;
         default:
             break;
     }
 }