public PaddleHit(GameState state, Paddle target, float[] velocity, float[] position) : base(state) { Target = target; Velocity[0] = velocity[0]; Velocity[1] = velocity[1]; Position[0] = position[0]; Position[1] = position[1]; if (target == state.AiPaddle) Type = SparkleType.SPARKLE_AI; else if (target == state.PlayerPaddle) Type = SparkleType.SPARKLE_PLAYER; else Type = SparkleType.SPARKLE_WALL; }
/** Create a new sparkle group */ public void CreateSparkles(float[] Position, float[] Velocity, SparkleType type) { var factory = new SparkFactory() { Source = new float[2] { Position[0], Position[1] }, Velocity = new float[3] { Velocity[0], Math.Sign(Velocity[1]) * 10f, 0f }, Lifespan = 1.0f, LifespanVar = 0.5f, Count = 10, CountVar = 2, Tint = new float[4] { 1.0f, 1.0f, 1.0f, 1.0f } }; /* Custom per type */ factory.VelocityVar [2] = nRand.Float(0f, 50f); if (type == SparkleType.SPARKLE_WALL) { factory.Velocity [1] = 0; factory.Velocity [0] = Math.Sign(Velocity [0]) * 10f; factory.VelocityVar [0] = 20f; factory.VelocityVar [1] = 30f; factory.Tint = new float[4] { 0.5f, 0.5f, 1.0f, 1.0f }; } else { factory.Velocity [0] = Velocity [0]; factory.Velocity [1] = Math.Sign(Velocity [1]) * 10f; factory.VelocityVar [0] = 20f; factory.VelocityVar [1] = 30f; factory.Tint = new float[4] { 1.0f, 1.0f, 0.5f, 1.0f }; } var items = factory.Manufacture(); foreach (var i in items) { var m = new nMotion(i, new SparkAnim()); _sparkles.Add(m); } }