/** ********************************************************************************************** ********************************************************************************************** **/ public void addRandomRocket() { try { int width = _canvas.Width; int height = _canvas.Height; int widthDivision = 100; int widthInner = width - (widthDivision * 2); int height4 = (int)(height / 4); double angle = (_rng.NextDouble() * 30.0d) + 75.0d; ; double speed = (_rng.NextDouble() * 45.0) + (double)height4; double explode = (_rng.NextDouble() * 2.0) + 1.5d; int xPos = (int)(widthDivision + ((double)_rng.NextDouble() * widthInner)); int yPos = height; Point position = new Point(xPos, yPos); Rocket rocket = new Rocket(_rng, angle, speed); rocket.setExplodeTime(explode); rocket.setPosition(position); //double sparkLifespan = 1.5; //rocket.setSparkLifespan(sparkLifespan); //rocket.setColor(Color.FromArgb(213, 141, 27)); rocket.setColor(Color.WhiteSmoke); addRocket(rocket); } catch (Exception e) { } }
/** ********************************************************************************************** ********************************************************************************************** **/ public void checkExplode(RocketQueue rocketQueue) { try { if (lastRocket || exploded || dead) { return; } if (time >= explodeTime) { int[] numSparkChoice = new int[] { 5, 8, 10 }; int numSparks = numSparkChoice[_rng.Next(0, 2)]; //int numSparks = 20; //System.out.println(numSparks); double rotation = (360 / numSparks); double sparkAngle = 5; double sparkSpeed = _rng.NextDouble() * 20 + 10 ; double lifespan = 2.0; double sparkLifespan = 1.5; int sparkSize = 2; Color randomColor = makeRandomColor(); for (int i = 0; i < numSparks; i++) { Rocket rocket = new Rocket(_rng, sparkAngle, sparkSpeed); rocket.setPosition(calculatePosition()); rocket.setSparkLifespan(sparkLifespan); rocket.setLifespan(lifespan); rocket.setLastRocket(true); rocket.setColor(randomColor); rocket.setSize(sparkSize); rocketQueue.addRocket(rocket); sparkAngle += rotation; } exploded = true; dead = true; } } catch (Exception e) { } }