Exemplo n.º 1
0
    public void AddBubbleRelative(int row, int col)
    {
        Bubble           bubble     = GameConst.bubbles[row, col];
        BubbleInlineBox  inlineBox  = GameConst.bubbles[row, col].GetComponent <BubbleInlineBox>();
        BubbleOutlineBox outlineBox = GameConst.bubbles[row, col].GetComponent <BubbleOutlineBox>();

        if (behurtBox.BoxInline(inlineBox))
        {
            BubbleNode node = new BubbleNode();
            node.bubbleRelative = BubbleRelative.Inline;
            node.bubbleRow      = row;
            node.bubbleCol      = col;
            RelativeDitionary.Add(row * GameConst.width + col, node);
        }
        else if (colliderBox.BoxInline(outlineBox))
        {
            BubbleNode node = new BubbleNode();
            node.bubbleRelative = BubbleRelative.OutLine;
            node.bubbleRow      = row;
            node.bubbleCol      = col;
            RelativeDitionary.Add(row * GameConst.width + col, node);
        }
        else
        {
            BubbleNode node = new BubbleNode();
            node.bubbleRelative = BubbleRelative.OutEdge;
            node.bubbleRow      = row;
            node.bubbleCol      = col;
            RelativeDitionary.Add(row * GameConst.width + col, node);
        }
    }
Exemplo n.º 2
0
    public void resetBox()
    {
        BubbleOutlineBox box1 = GetComponent <BubbleOutlineBox>();
        BubbleInlineBox  box2 = GetComponent <BubbleInlineBox>();

        box1.resetBox();
        box2.resetBox();
    }
Exemplo n.º 3
0
    public bool InBubbleRelative(int row, int col)
    {
        Bubble           bubble     = GameConst.bubbles[row, col];
        BubbleInlineBox  inlineBox  = GameConst.bubbles[row, col].GetComponent <BubbleInlineBox>();
        BubbleOutlineBox outlineBox = GameConst.bubbles[row, col].GetComponent <BubbleOutlineBox>();

        if (behurtBox.BoxInline(inlineBox))
        {
            return(true);
        }
        else if (colliderBox.BoxInline(outlineBox))
        {
            return(true);
        }
        return(false);
    }
Exemplo n.º 4
0
    void OutlineUpdateBoxTransform(int row, int col)
    {
        BubbleInlineBox  inlineBox  = GameConst.bubbles[row, col].GetComponent <BubbleInlineBox>();
        BubbleOutlineBox outlineBox = GameConst.bubbles[row, col].GetComponent <BubbleOutlineBox>();

        if (behurtBox.BoxInline(inlineBox))
        {
            Vector2 direct = Vector2.zero;
            if (behurtBox.Center.x < inlineBox.Center.x)
            {
                direct.x = 1;
            }
            else if (behurtBox.Center.x > inlineBox.Center.x)
            {
                direct.x = -1;
            }
            if (behurtBox.Center.y > inlineBox.Center.y)
            {
                direct.y = 1;
            }
            else if (behurtBox.Center.y < inlineBox.Center.y)
            {
                direct.y = -1;
            }
            if (direction == PopDirection.HORIZONTAL)
            {
                offsetX(behurtBox, inlineBox, direct);
                if (behurtBox.BoxInline(inlineBox))
                {
                    offsetY(behurtBox, inlineBox, direct);
                }
            }
            else
            {
                offsetY(behurtBox, inlineBox, direct);
                if (behurtBox.BoxInline(inlineBox))
                {
                    offsetX(behurtBox, inlineBox, direct);
                }
            }
        }
    }
Exemplo n.º 5
0
    void UpdateBubbleRelative()
    {
        List <int> newList = new List <int>();

        foreach (KeyValuePair <int, BubbleNode> kv in RelativeDitionary)
        {
            BubbleNode node = kv.Value;
            int        key  = kv.Key;
            if (GameConst.bubbles[node.bubbleRow, node.bubbleCol] == null)
            {
                newList.Add(key);
                continue;
            }
            BubbleInlineBox  inlineBox  = GameConst.bubbles[node.bubbleRow, node.bubbleCol].GetComponent <BubbleInlineBox>();
            BubbleOutlineBox outlineBox = GameConst.bubbles[node.bubbleRow, node.bubbleCol].GetComponent <BubbleOutlineBox>();
            switch (node.bubbleRelative)
            {
            case BubbleRelative.Inline:
                if (!behurtBox.BoxInline(inlineBox))
                {
                    node.bubbleRelative = BubbleRelative.OutLine;
                }
                break;

            case BubbleRelative.OutLine:
                if (!colliderBox.BoxInline(outlineBox))
                {
                    node.bubbleRelative = BubbleRelative.OutEdge;
                    newList.Add(key);
                }
                break;

            case BubbleRelative.OutEdge:
                break;
            }
        }
        foreach (int node in newList)
        {
            RelativeDitionary.Remove(node);
        }
    }