Exemple #1
0
        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(600, 800); //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.Vel = new Vector2f((float)Math.Cos(angle) * particle.MaxSpeed, (float)Math.Sin(angle) * particle.MaxSpeed);
            //------------------------------------------------------------------------------------------------
            //------------------------------------------------------------------------------------------------

            //particle.m_Vel = sf::Vector2f(Math->GetRandomClamped() * particle.m_MaxSpeed, Math->GetRandomClamped() *particle.m_MaxSpeed);
            particle.SlowDown = 0.98f; //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(10, 50);
            particle.Color      = Utils.GetRandomRedColor();
            particle.Opacity    = 255.0f;
            particle.Life       = 1.0f;
            particle.Fade       = 60; //Math->GetRandomNumber(100, 240);

            particle.Intersects = false;
        }
 public cWeapon(cGameObject owner, int firing_frequency, string bullet_breed_id)
 {
     this.owner           = owner;
     this.firingFrequency = firing_frequency;
     this.regulator       = new cRegulator();
     this.regulator.resetByFrequency(firing_frequency);
     this.spread         = (float)AppMath.DegressToRadian(2);
     this.bulletsPerShot = 1;
     this.bulletBreedID  = bullet_breed_id;
 }
Exemple #3
0
 public cMachineGun(cGameObject owner, int firing_frequency, string bullet_breed_id = "simple-bullet")
     : base(owner, firing_frequency, bullet_breed_id)
 {
     this.maxAmmo          = 300;
     this.currentAmmo      = maxAmmo;
     this.magazineCapacity = 30;
     this.timeToReload     = 1.5f;
     this.spread           = (float)AppMath.DegressToRadian(4);
     this.bulletsPerShot   = 1;
 }
        public static void Update()
        {
            if (shaking)
            {
                m_CurrentRadius *= m_DiminishFactor;                                                                     //diminish radius each frame
                m_CurrentAngle  += (150.0f + AppRandom.GetRandomNumber(0, 60));                                          //pick new angle
                float rad = (float)AppMath.DegressToRadian(m_CurrentAngle);
                m_Offset = new Vector2f((float)Math.Sin(rad) * m_CurrentRadius, (float)Math.Cos(rad) * m_CurrentRadius); //create offset 2d vector

                m_CurrentCenterPos = m_DefaultCenter + m_Offset;
                //set centre of viewport

                if (m_CurrentRadius < m_MinShakeRadius) //2.0f
                {
                    StopShake();
                }
            }
        }
        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;
        }
Exemple #6
0
 public cShotgun(cGameObject owner, int firing_frequency, string bullet_breed_id = "simple-bullet")
     : base(owner, firing_frequency, bullet_breed_id)
 {
     this.spread         = (float)AppMath.DegressToRadian(3);
     this.bulletsPerShot = 4;
 }