Ejemplo n.º 1
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.TryGetComponent(out Block block))
     {
         if (!block.IsFrozen)
         {
             BlockEntered?.Invoke(block);
             Destroy(block.gameObject);
         }
     }
 }
Ejemplo n.º 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;
                }
            }
        }