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); }
public DragBubble(DragBubbleType type, Dictionary<BubbleState, Texture2D> textureList, Texture2D lineTexture, EffectHandler effectHandler, float minDistance = 50) { 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; createSet(minDistance); }
private void updateState() { switch (currentState) { case DragBubbleState.APPEARING: if (bubble1.currentState == BubbleState.NORMAL_STATE) { currentState = DragBubbleState.NORMAL; } break; case DragBubbleState.NORMAL: lockCtr = 0; break; case DragBubbleState.HOVERED: lockCtr++; if (lockCtr >= lockCount) { currentState = DragBubbleState.LOCKED_IN; bubble1.setState(BubbleState.LOCKED_IN); } break; case DragBubbleState.LOCKED_IN: //do something break; case DragBubbleState.POP_STATE: case DragBubbleState.DISAPPEARING: lineAlpha -= 0.020f; if (lineAlpha <= 0f) { currentState = DragBubbleState.REMOVAL_STATE; } break; } }
private void updateAllBubbles() { bubble1.Update(); bubble2.Update(); if (bubble1.currentState == BubbleState.DISAPPEARING) { currentState = DragBubbleState.DISAPPEARING; } else if (bubble2.currentState == BubbleState.HIGHLIGHTED_STATE) { popCtr += 1; if (popCtr >= popCount) { currentState = DragBubbleState.POP_STATE; bubble1.setState(BubbleState.POP_STATE); bubble2.setState(BubbleState.POP_STATE); effectHandler.addEffect((int)bubble1.xPos, (int)bubble1.yPos, 20); effectHandler.addEffect((int)bubble1.xPos, (int)bubble1.yPos, 10, Color.Yellow); effectHandler.addEffect((int)bubble1.xPos, (int)bubble1.yPos, 5, Color.White); } } else { popCtr = 0; } }