예제 #1
0
        public override void Hit(int amount, cGameObject entity_by)
        {
            base.Hit(amount, entity_by);

            if (this.health <= 0)
            {
                this.Kill(entity_by);
                //this.Scene.ParticleManager.AddNormalBloodExplosion(this.Bounds.center);


                return;
            }

            //this.spriteControl.ChangeState(new cSpriteState(MotionType.FALL, this.spriteControl.getCurrentState().HorizontalFacing));
            //this.Scene.ParticleManager.AddLittleBloodExplosion(this.Bounds.center, 3);

            this.Scene.QueueAction(
                () =>
            {
                Scene.Assets.PlaySound("body_hit1", 8);
                var e = pscene.ParticleManager["explosions"] as cExplosionController;
                // e.LittleBlood(new Particles.EmissionInfo(this.Bounds.center));
                var dir = AppMath.Vec2NormalizeReturn(entity_by.Velocity);

                float maxLen = (float)AppMath.GetRandomDoubleInRange(10.0, this.Bounds.diagonalLength());
                Vector2f end = AppMath.ScaleVector(entity_by.Position, AppMath.Vec2NormalizeReturn(dir), maxLen);

                // approximately:
                Vector2f point = AppMath.GetRandomPointOnLine(entity_by.Position, end);
                e.LittleLine(new Particles.EmissionInfo(point, dir));
            });
        }
예제 #2
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;
        }
        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;
        }