public override bool Fire(Vector2f target) { if (this.isReadForNextShot()) { Vector2f dir = AppMath.Vec2NormalizeReturn(target - owner.Bounds.center); Vector2f toSpreadTarget = AppMath.GetRandomVecBySpread(dir, spread); this.Shot(toSpreadTarget); decreaseAmmo(); owner.Scene.Assets.PlaySound("cg1", 2); /* * this.owner.Scene.QueueAction(() => * { * var e = this.owner.Scene.ParticleManager["explosions"] as cExplosionController; * e.Line(new EmissionInfo(this.owner.Bounds.center, toSpreadTarget)); * * }); */ } return(false); }
protected override void initParticle(EmissionInfo emission) { Particle particle = emission.Particle; particle.Pos = emission.StartPosition; particle.LastPos = particle.Pos; particle.ViewPos = particle.Pos; particle.MaxSpeed = AppMath.GetRandomNumber(minSpeed, maxSpeed); //700, 900 | (400, 600); //3, 8//Math->GetRandomNumber(510, 800); // 2000.0f if (!AppMath.Vec2IsZero(emission.EmitDirection)) { Vector2f particleDirection = AppMath.GetRandomVecBySpread(emission.EmitDirection, this.maxSpread); particle.Vel = new Vector2f(particleDirection.X * particle.MaxSpeed, particleDirection.Y * particle.MaxSpeed); } else { // float angle = (float)cAppMath.DegressToRadian(cAppMath.GetRandomNumber(0, 360));//sDivisions * m_Angles; particle.Vel = AppMath.GetRandomUnitVec() * particle.MaxSpeed; // particle.Vel = new Vector2f((float)Math.Cos(angle) * particle.MaxSpeed, (float)Math.Sin(angle) * particle.MaxSpeed); } //float dir = Math->GetRandomClamped(); //particle.m_Vel = sf::Vector2f(Math->GetRandomClamped() * particle.m_MaxSpeed, Math->GetRandomClamped() *particle.m_MaxSpeed); particle.SlowDown = slowDown; //0.92f; //particle.m_SlowDown = (float)Math->GetRandomDoubleInRange(0.55, 0.7); //0.6f; //phs->AddForce( sf::Vector2f(Math->GetRandomClamped() * phs->MaxSpeed, Math->GetRandomClamped() * phs->MaxSpeed) ); Vector2u uSize = this.renderStates.Texture.Size; particle.Scale = (float)AppMath.GetRandomDoubleInRange(this.minScale, this.maxScale); particle.Dims = new Vector2f(uSize.X * particle.Scale, uSize.Y * particle.Scale); particle.ScaleSpeed = -AppMath.GetRandomNumber(5, 20); //10.50 particle.Color = Utils.GetRandomBlueColor(); particle.Opacity = 255.0f; particle.Life = 1.0f; particle.Fade = 80; // 90; //Math->GetRandomNumber(100, 240); particle.Intersects = false; }
private void empower(Particle particle) { particle.Pos = particle.StartPos; particle.LastPos = particle.Pos; particle.ViewPos = particle.Pos; particle.MaxSpeed = AppMath.GetRandomNumber(30, 50); //200,400 | 700, 900 | (400, 600); //3, 8//Math->GetRandomNumber(510, 800); // 2000.0f //------------------------------------------------------------------------------------------------ float angle = (float)AppMath.DegressToRadian(AppMath.GetRandomNumber(0, 360));//sDivisions * m_Angles; particle.Rotation = angle; // Vector2f dirUnit = cAppMath.GetRandomUnitVec(); Vector2f dirUnit = AppMath.GetRandomVecBySpread(new Vector2f(0.0f, -1.0f), AppMath.DegressToRadian(6)); particle.Vel = dirUnit * particle.MaxSpeed; //------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------ //particle.m_Vel = sf::Vector2f(Math->GetRandomClamped() * particle.m_MaxSpeed, Math->GetRandomClamped() *particle.m_MaxSpeed); particle.SlowDown = 1.0f; //0.92f; //particle.m_SlowDown = (float)Math->GetRandomDoubleInRange(0.55, 0.7); //0.6f; //phs->AddForce( sf::Vector2f(Math->GetRandomClamped() * phs->MaxSpeed, Math->GetRandomClamped() * phs->MaxSpeed) ); Vector2u uSize = this.renderStates.Texture.Size; particle.Scale = (float)AppMath.GetRandomDoubleInRange(this.minScale, this.maxScale); particle.Dims = new Vector2f(uSize.X * particle.Scale, uSize.Y * particle.Scale); particle.ScaleSpeed = (float)AppMath.GetRandomNumber(15, 25) / 100.0f; particle.Color = Utils.GetRandomColor(250, 250, 1, 160, 0, 0); // GetRandomRedColor(); particle.Opacity = 255.0f; particle.Fade = AppRandom.GetRandomNumber(10, 40); particle.Life = 15.0f; particle.Intersects = false; }