예제 #1
0
        public DragBubble(DragBubbleType type, Dictionary<BubbleState, Texture2D> textureList, Texture2D lineTexture, EffectHandler effectHandler, Vector2 pos1, Vector2 pos2)
        {
            this.type = type;
            this.currentState = DragBubbleState.APPEARING;
            this.handTextureList = textureList;
            this.lineTexture = lineTexture;
            this.lineAlpha = GameConfig.LINE_ALPHA;
            this.lockCount = GameConfig.LOCK_COUNT;
            this.popCount = GameConfig.DRAG_BUBBLE_POPCOUNT;
            this.effectHandler = effectHandler;

            //create first hand bubble
            bubble1 = new Bubble(pos1.X, pos1.Y, handTextureList, BubbleType.HAND);
            bubble1.setStayingDuration(GameConfig.DRAGBUBBLE_DURATION);

            //create second hand bubble
            bubble2 = new Bubble((int)pos2.X, pos2.Y, handTextureList, BubbleType.INACTIVE_STATIC_HAND);
            bubble2.setStayingDuration(GameConfig.DRAGBUBBLE_DURATION);

            radianAngle = MathUtil.getPIAngle(bubble1.pos, bubble2.pos);
            float width = MathUtil.getDistance(bubble1.pos, bubble2.pos);
            lineRectangle = new Rectangle(0, 0, (int)width, 13);

            xSpeedUnit = (float)Math.Cos(radianAngle);
            ySpeedUnit = (float)Math.Sin(radianAngle);
        }
예제 #2
0
        public BubbleSet(BubbleSetType type, Dictionary<BubbleState, Texture2D> textureList, Texture2D lineTexture, EffectHandler effectHandler, Vector2 pos1, Vector2 pos2)
        {
            this.type = type;
            this.currentState = BubbleSetState.APPEARING;
            this.handTextureList = textureList;
            this.lineTexture = lineTexture;
            this.lineAlpha = GameConfig.LINE_ALPHA;
            this.effectHandler = effectHandler;

            bubbles = new List<Bubble>();

            switch (type)
            {
                case BubbleSetType.HANDHAND:
                    Vector2 randomPoint = Randomizer.createRandomPoint();

                    //create first hand bubble
                    Bubble bubble1 = new Bubble(pos1.X, pos1.Y, handTextureList, BubbleType.HAND);
                    bubble1.setStayingDuration(GameConfig.SETBUBBLE_DURATION);
                    bubbles.Add(bubble1);

                    //create second hand bubble
                    Bubble bubble2 = new Bubble(pos2.X, pos2.Y, handTextureList, BubbleType.HAND);
                    bubble2.setStayingDuration(GameConfig.SETBUBBLE_DURATION);
                    bubbles.Add(bubble2);

                    lineRotation = (float)Math.Atan2(bubble2.yPos - bubble1.yPos, bubble2.xPos - bubble1.xPos);
                    scaleX = (float)(Math.Sqrt((Math.Pow(bubble2.xPos - bubble1.xPos, 2) + Math.Pow(bubble2.yPos - bubble1.yPos, 2))) / GameConfig.BUBBLE_WIDTH);
                    scaleVector = new Vector2(scaleX, 1.0f);
                    break;

            }
        }
예제 #3
0
 private void DrawLine(Bubble bubble1, Bubble bubble2, SpriteBatch sprite)
 {
     sprite.Draw(lineTexture, bubble1.pos, null, Color.White * lineAlpha, lineRotation, Vector2.One*5, scaleVector, SpriteEffects.None, 0);
 }
예제 #4
0
        private void createSet()
        {
            bubbles = new List<Bubble>();

            switch (type)
            {
                case BubbleSetType.HANDHAND:
                    Vector2 randomPoint = Randomizer.createRandomPoint();

                    //create first hand bubble
                    Bubble bubble1 = new Bubble((int)randomPoint.X, (int)randomPoint.Y, handTextureList, BubbleType.HAND);
                    bubble1.setStayingDuration(GameConfig.SETBUBBLE_DURATION);
                    bubbles.Add(bubble1);

                    //create second hand bubble
                    randomPoint = Randomizer.createRandomPoint();
                    Bubble bubble2 = new Bubble((int)randomPoint.X, (int)randomPoint.Y, handTextureList, BubbleType.HAND);
                    bubble2.setStayingDuration(GameConfig.SETBUBBLE_DURATION);
                    bubbles.Add(bubble2);

                    lineRotation = (float)Math.Atan2(bubble2.yPos - bubble1.yPos, bubble2.xPos - bubble1.xPos);
                    scaleX = (float)(Math.Sqrt((Math.Pow(bubble2.xPos - bubble1.xPos, 2) + Math.Pow(bubble2.yPos - bubble1.yPos, 2))) / GameConfig.BUBBLE_WIDTH);
                    scaleVector = new Vector2(scaleX, 1.0f);
                    break;

            }
        }
예제 #5
0
        private void updateSoloBubbles()
        {
            for (iter1 = 0; iter1 < bubblesOnScreen.Count; iter1++)
            {
                refBub = bubblesOnScreen[iter1];
                refBub.Update();

                if (refBub.isReadyForRemoval())
                {
                    bubblesOnScreen.RemoveAt(iter1--);
                    continue;

                }
                else if ( refBub.isActive() )
                {
                    switch (refBub.bubbleType)
                    {
                        case BubbleType.HAND:
                            if (kinector.isColliding(refBub.collisionBox, JointType.HandRight) || kinector.isColliding(refBub.collisionBox, JointType.HandLeft))
                            {
                                refBub.setState(BubbleState.HIGHLIGHTED_STATE);
                                if (refBub.popCounter >= refBub.popTime-1)
                                {
                                    effectHandler.addEffect((int)refBub.xPos, (int)refBub.yPos, 20);
                                    effectHandler.addEffect((int)refBub.xPos, (int)refBub.yPos, 10, Color.White);
                                }
                            }
                            else
                            {
                                refBub.setState(BubbleState.NORMAL_STATE);
                            }
                            break;
                    }
                }
            }
        }
예제 #6
0
        private void updateDragBubbles()
        {
            for (iter1 = 0; iter1 < dragBubblesOnScreen.Count; iter1++)
            {
                if (dragBubblesOnScreen[iter1].currentState != DragBubbleState.REMOVAL_STATE)
                {
                    //update the bubble's state
                    dragBubblesOnScreen[iter1].Update();

                    refBub = dragBubblesOnScreen[iter1].bubble1;

                    if (refBub.isActive())
                    {
                        switch (refBub.bubbleType)
                        {
                            case BubbleType.HAND:
                                if (dragBubblesOnScreen[iter1].currentState != DragBubbleState.LOCKED_IN)
                                {
                                    if (kinector.isColliding(refBub.collisionBox, JointType.HandRight))
                                    {
                                        refBub.setState(BubbleState.HIGHLIGHTED_STATE);
                                        refBub.jointHovering = JointType.HandRight;
                                        dragBubblesOnScreen[iter1].currentState = DragBubbleState.HOVERED;
                                    }
                                    else if (kinector.isColliding(refBub.collisionBox, JointType.HandLeft))
                                    {
                                        refBub.setState(BubbleState.HIGHLIGHTED_STATE);
                                        refBub.jointHovering = JointType.HandLeft;
                                        dragBubblesOnScreen[iter1].currentState = DragBubbleState.HOVERED;
                                    }
                                    else
                                    {
                                        refBub.setState(BubbleState.NORMAL_STATE);
                                        dragBubblesOnScreen[iter1].currentState = DragBubbleState.NORMAL;
                                        allHighlighted = false;
                                    }
                                }
                                else
                                {

                                    dragBubblesOnScreen[iter1].follow(refBub.jointHovering==JointType.HandRight?kinector.getHandPosition(JointType.HandRight):kinector.getHandPosition(JointType.HandLeft));

                                }
                                break;
                        }
                    }

                    dragBubblesOnScreen[iter1].resetPopCounters();

                }
                else
                {
                    dragBubblesOnScreen.RemoveAt(iter1--);
                    continue;
                }

            }
        }
예제 #7
0
        private void updateBubbleSets()
        {
            for (iter1 = 0; iter1 < bubbleSetsOnScreen.Count; iter1++)
            {
                if (bubbleSetsOnScreen[iter1].currentState != BubbleSetState.REMOVAL_STATE)
                {
                    //update the bubble's state
                    bubbleSetsOnScreen[iter1].Update();

                    //we assume first that all bubbles are touched until we found one that isn't
                    allHighlighted = true;

                    for (iter3 = 0; iter3 < bubbleSetsOnScreen[iter1].bubbles.Count; iter3++)
                    {
                        refBub = bubbleSetsOnScreen[iter1].bubbles[iter3];

                        if (refBub.isActive())
                        {
                            switch (refBub.bubbleType)
                            {
                                case BubbleType.HAND:
                                    if (kinector.isColliding(refBub.collisionBox, JointType.HandRight) || kinector.isColliding(refBub.collisionBox, JointType.HandLeft))
                                    {
                                        refBub.setState(BubbleState.HIGHLIGHTED_STATE);
                                    }
                                    else
                                    {
                                        refBub.setState(BubbleState.NORMAL_STATE);
                                        allHighlighted = false;
                                    }
                                    break;
                            }
                        }
                    }

                    if (!allHighlighted)
                    {
                        //we start counting to popping only when all bubbles are highlighted/touched
                        bubbleSetsOnScreen[iter1].resetPopCounters();
                    }
                }
                else
                {
                    bubbleSetsOnScreen.RemoveAt(iter1--);
                    continue;
                }

            }
        }
예제 #8
0
 private bool isColliding(Bubble bubble1, Bubble bubble2)
 {
     return bubble1.collisionBox.Intersects(bubble2.collisionBox);
 }
예제 #9
0
        private void createSet(float minDistance)
        {
            switch (type)
            {
                case DragBubbleType.HAND:
                    Vector2 randomPoint;

                    //create first hand bubble
                    randomPoint = Randomizer.createRandomPoint();
                    bubble1 = new Bubble((int)randomPoint.X, (int)randomPoint.Y, handTextureList, BubbleType.HAND);
                    //bubble1 = new Bubble(100, 100, handTextureList, BubbleType.HAND);
                    bubble1.setStayingDuration(GameConfig.DRAGBUBBLE_DURATION);

                    //create second hand bubble
                    double randomAngle = Randomizer.randomRadian();
                    int randDistance = Randomizer.random((int)minDistance, (int)minDistance);
                    //randomPoint = new Vector2((float)Math.Cos(randomAngle)*randDistance, (float)Math.Sin(randomAngle)*randDistance);
                    randomPoint = Randomizer.createRandomPoint();
                    bubble2 = new Bubble((int)randomPoint.X, (int)randomPoint.Y, handTextureList, BubbleType.INACTIVE_STATIC_HAND);
                    //bubble2 = new Bubble(400, 400, handTextureList, BubbleType.INACTIVE_STATIC_HAND);
                    bubble2.setStayingDuration(GameConfig.DRAGBUBBLE_DURATION);

                    radianAngle = MathUtil.getPIAngle(bubble1.pos, bubble2.pos);
                    float width = MathUtil.getDistance(bubble1.pos, bubble2.pos);
                    lineRectangle = new Rectangle(0, 0, (int)width, 13);

                    xSpeedUnit = (float) Math.Cos(radianAngle);
                    ySpeedUnit = (float) Math.Sin(radianAngle);
                    break;

            }
        }