Esempio n. 1
0
        private void GetCluster(List <Block> list)
        {
            Block        up         = TileMap.GetBlock(X, (short)(Z - 1));
            Block        right      = TileMap.GetBlock((short)(X + 1), Z);
            Block        down       = TileMap.GetBlock(X, (short)(Z + 1));
            Block        left       = TileMap.GetBlock((short)(X - 1), Z);
            List <Block> neighbours = new List <Block>();

            if (up != null)
            {
                neighbours.Add(up);
            }
            if (right != null)
            {
                neighbours.Add(right);
            }
            if (down != null)
            {
                neighbours.Add(down);
            }
            if (left != null)
            {
                neighbours.Add(left);
            }

            list.Add(this);
            foreach (Block neighbour in neighbours)
            {
                if (neighbour.Color == Color && !list.Contains(neighbour))
                {
                    neighbour.GetCluster(list);
                }
            }
        }
Esempio n. 2
0
        void TryTriggerChainReaction(short hitX, short hitZ)
        {
            TileMap tileMap = GameManager.Instance.TileMap;
            Block   block   = tileMap.GetBlock(hitX, hitZ);

            if (block != null)
            {
                block.StartChainReaction();
            }
        }