public BodyMovementPaintingAction(BodyMovementType bodyMovementType) { type = bodyMovementType; //randomize location RandomGenerator randomGenerator = ServiceManager.Instance.GetService<RandomGenerator>(ServiceType.RandomGenerator); rotation = (float)randomGenerator.NextDouble(-.261, .261); //-15 degress to +15 degrees xcoord = randomGenerator.NextXLocation(); double sizeMultiplier = 1; switch (type) { case BodyMovementType.HipShake: ycoord = randomGenerator.NextYLocation(33, 66); sizeMultiplier = randomGenerator.NextDouble(.05, .10); //texture is large. random size 5% to 10% of texture break; case BodyMovementType.LeftKick: case BodyMovementType.RightKick: ycoord = randomGenerator.NextYLocation(50,100); break; case BodyMovementType.JumpStyle1: case BodyMovementType.JumpStyle2: ycoord = randomGenerator.NextYLocation(0, 40); sizeMultiplier = randomGenerator.NextDouble(.15, .3); break; default: ycoord = randomGenerator.NextYLocation(); break; } Texture2D texture = GetTexture(type); width = (int)(texture.Width * sizeMultiplier); height = (int)(texture.Height * sizeMultiplier); _deathDate = DateTime.Now + LifeSpan; }
Texture2D GetTexture(BodyMovementType bodyMovementType) { Texture2D texture = null; switch (type) { case BodyMovementType.HipShake: texture = spiralTexture; break; case BodyMovementType.LeftKick: texture = grassTexture; break; case BodyMovementType.RightKick: texture = grassTexture; break; case BodyMovementType.JumpStyle1: texture = jump1Texture; break; case BodyMovementType.JumpStyle2: texture = jump2Texture; break; } return texture; }
SpriteEffects GetEffects(BodyMovementType bodyMovementType) { SpriteEffects effects = SpriteEffects.None; if (bodyMovementType == BodyMovementType.LeftKick) { effects = SpriteEffects.FlipHorizontally; } else if (bodyMovementType == BodyMovementType.JumpStyle1 || bodyMovementType == BodyMovementType.JumpStyle2) { effects = SpriteEffects.FlipVertically; } return effects; }