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; } }
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); }
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; } }
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; } }