Exemple #1
0
        //string _Score = "0:0";
        #endregion

        #region Constructor
        public PongScreen(Game game)
        {
            //XNA objects
            _game = game;
            //Pong objects
            _ball       = new Ball(_game, _margin);
            _blockLeft  = new BlockLeft(_game, _margin);
            _blockRight = new BlockRight(_game, _margin);

            //XNA-Pong objects integration in the game
            _game.Components.Add(_ball);
            _game.Components.Add(_blockLeft);
            _game.Components.Add(_blockRight);
        }
Exemple #2
0
        public IEnumerable <IAstNode> Visit()
        {
            IAstNode node = Block.First;

            while (node != null)
            {
                //We reached a child block, visit the nodes inside.
                while (node is AstBlock childBlock)
                {
                    Block = childBlock;

                    node = childBlock.First;

                    BlockEntered?.Invoke(this, new BlockVisitationEventArgs(Block));
                }

                //Node may be null, if the block is empty.
                if (node != null)
                {
                    IAstNode next = Next(node);

                    yield return(node);

                    node = next;
                }

                //We reached the end of the list, go up on tree to the parent blocks.
                while (node == null && Block.Type != AstBlockType.Main)
                {
                    BlockLeft?.Invoke(this, new BlockVisitationEventArgs(Block));

                    node = Next(Block);

                    Block = Block.Parent;
                }
            }
        }