Example #1
0
    public bool CheckSatisfied(BlockMap existingBlocks)
    {
        if (blocks.Count == 0)
        {
            return(true);
        }
        bool result = false;

        foreach (var existing in existingBlocks)
        {
            bool satisfied = true;
            foreach (var block in blocks)
            {
                var mappedToBlock = existingBlocks.Get(existing.X + block.X, existing.Y + block.Y);
                if (mappedToBlock == null ||
                    mappedToBlock.Color != block.Color ||
                    mappedToBlock.OnFire)
                {
                    satisfied = false;
                    break;
                }
            }
            if (satisfied)
            {
                result = true;
                foreach (var block in blocks)
                {
                    var mappedToBlock = existingBlocks.Get(existing.X + block.X, existing.Y + block.Y);
                    mappedToBlock.Satisfied = true;
                }
            }
        }
        return(result);
    }
 static void ExplorePosition(int x, int y, BlockMap closeList, List <Vector2Int> openList)
 {
     if (closeList.Get(x, y) == null)
     {
         openList.Add(new Vector2Int(x, y));
     }
 }