Example #1
0
        public Player(GameMain a_gameMain)
        {
            m_gameMain = a_gameMain;

            this.Name     = "Player";
            m_fAngleStep  = (float)(5.0 * Math.PI / 180);
            MemberName    = "Ship";
            this.RegPoint = (this.Member.Size.ToEPointF() * 0.5f).ToEPoint();

            #region Set up particle system (for thrusters)
            m_particleSystem = new Endogine.ParticleSystem.ParticleEmitter();
            //m_particleSystem.Parent = this;
            m_particleSystem.LocZ = LocZ - 1;

            SortedList aColors = new SortedList();
            aColors.Add(0.0, System.Drawing.Color.FromArgb(255, 255, 0));
            aColors.Add(0.5, System.Drawing.Color.FromArgb(255, 0, 0));
            aColors.Add(1.0, System.Drawing.Color.FromArgb(0, 0, 0));
            m_particleSystem.SetColorList(aColors);

            SortedList aSizes = new SortedList();
            aSizes.Add(0.0, 1.0);
            aSizes.Add(1.0, 0.0);
            m_particleSystem.SetSizeList(aSizes);

            m_particleSystem.MaxParticles            = 100;
            m_particleSystem.NumNewParticlesPerFrame = 0;

            m_fThrustParticles = 2;

            m_particleSystem.Gravity  = 0;
            m_particleSystem.Speed    = 5;
            m_particleSystem.SizeFact = 0.3f;

            m_particleSystem.ParticlePicRef = PicRef.GetOrCreate("Particle");
            m_particleSystem.SourceRect     = new ERectangle(0, 0, 10, 10);
            m_particleSystem.RegPoint       = new EPoint(5, 5);
            m_particleSystem.LocZ           = 100;
            #endregion

            #region Keys setup
            m_keysSteering = new KeysSteering();
            this.m_keysSteering.AddKeyPreset(KeysSteering.KeyPresets.ArrowsSpace);
            this.m_keysSteering.AddKeyPreset(KeysSteering.KeyPresets.awsdCtrlShift);
            this.m_keysSteering.AddPair("left", "right");
            this.m_keysSteering.AddPair("up", "down");
            //m_keysSteering.ReceiveEndogineKeys(m_endogine);
            m_keysSteering.KeyEvent += new KeyEventHandler(m_keysSteering_KeyEvent);
            #endregion
        }
Example #2
0
        public Player(GameMain a_gameMain)
        {
            m_gameMain = a_gameMain;

            this.Name = "Player";
            m_fAngleStep = (float)(5.0*Math.PI/180);
            MemberName = "Ship";
            this.RegPoint = (this.Member.Size.ToEPointF()*0.5f).ToEPoint();

            #region Set up particle system (for thrusters)
            m_particleSystem = new Endogine.ParticleSystem.ParticleEmitter();
            //m_particleSystem.Parent = this;
            m_particleSystem.LocZ = LocZ-1;

            SortedList aColors = new SortedList();
            aColors.Add(0.0, System.Drawing.Color.FromArgb(255,255,0));
            aColors.Add(0.5, System.Drawing.Color.FromArgb(255,0,0));
            aColors.Add(1.0, System.Drawing.Color.FromArgb(0,0,0));
            m_particleSystem.SetColorList(aColors);

            SortedList aSizes = new SortedList();
            aSizes.Add(0.0, 1.0);
            aSizes.Add(1.0, 0.0);
            m_particleSystem.SetSizeList(aSizes);

            m_particleSystem.MaxParticles = 100;
            m_particleSystem.NumNewParticlesPerFrame = 0;

            m_fThrustParticles = 2;

            m_particleSystem.Gravity = 0;
            m_particleSystem.Speed = 5;
            m_particleSystem.SizeFact = 0.3f;

            m_particleSystem.ParticlePicRef = PicRef.GetOrCreate("Particle");
            m_particleSystem.SourceRect = new ERectangle(0,0,10,10);
            m_particleSystem.RegPoint = new EPoint(5,5);
            m_particleSystem.LocZ = 100;
            #endregion

            #region Keys setup
            m_keysSteering = new KeysSteering();
            this.m_keysSteering.AddKeyPreset(KeysSteering.KeyPresets.ArrowsSpace);
            this.m_keysSteering.AddKeyPreset(KeysSteering.KeyPresets.awsdCtrlShift);
            this.m_keysSteering.AddPair("left", "right");
            this.m_keysSteering.AddPair("up", "down");
            //m_keysSteering.ReceiveEndogineKeys(m_endogine);
            m_keysSteering.KeyEvent+=new KeyEventHandler(m_keysSteering_KeyEvent);
            #endregion
        }
Example #3
0
        public override void EnterFrame()
        {
            if (m_explosion != null)
            {
                m_nExplodingFrame++;
                if (m_nExplodingFrame <= 5)
                {
                    m_explosion.NumNewParticlesPerFrame = 1.0f * (1.0f - (float)m_nExplodingFrame / 5);
                }
                m_explosion.Loc = this.Loc;

//				m_explosion.Dispose();
//				m_explosion = null;
            }
            if (m_smoke != null)
            {
                m_smoke.Loc = this.Loc;
            }

            if (!m_bDying)
            {
                if (m_keysSteering.GetKeyActive("up"))
                {
                    this.Velocity -= m_pntGravity * 2;
                }
            }
            this.Velocity += m_pntGravity;

            base.EnterFrame();

            if (GameMain.Instance.CaveWalls.CheckCollision(this) || GameMain.Instance.Obstacles.CheckCollision(this))
            {
                if (m_explosion == null)
                {
                    m_explosion                 = new Endogine.ParticleSystem.ParticleEmitter();
                    m_explosion.Rect            = new ERectangleF(0, 0, 20, 20);
                    m_explosion.SprayangleRange = (float)Math.PI * 2;
                    m_explosion.AddedVelocity.X = this.Velocity.X;
                    m_explosion.Speed           = 5;
                    m_explosion.Gravity         = m_pntGravity.Y;
                    //MemberSpriteBitmap mbParticle = (MemberSpriteBitmap)EndogineHub.Instance.CastLib.GetOrCreate("Particle");
                    //mbParticle.CenterRegPoint();
                    m_explosion.ParticlePicRef = PicRef.GetOrCreate("Particle");

                    SortedList aColors = new SortedList();
                    aColors.Add(0.0, System.Drawing.Color.FromArgb(255, 255, 0));
                    aColors.Add(0.5, System.Drawing.Color.FromArgb(255, 0, 0));
                    aColors.Add(1.0, System.Drawing.Color.FromArgb(0, 0, 0));
                    m_explosion.SetColorList(aColors);

                    SortedList aSizes = new SortedList();
                    aSizes.Add(0.0, 0.3);
                    m_explosion.SetSizeList(aSizes);

                    m_explosion.NumNewParticlesPerFrame = 10;
                }
                m_explosion.Loc = this.Loc;
                if (m_nExplodingFrame > 6)
                {
                    m_explosion.NumNewParticlesPerFrame = 10;
                }
                m_nExplodingFrame = 1;

                this.LocY       -= this.Velocity.Y * 2;
                this.Velocity.Y *= -0.7f;

                if (!m_bDying)
                {
                    m_bDying = true;

                    m_smoke = new Endogine.ParticleSystem.ParticleEmitter();
                    m_smoke.ParticlePicRef          = PicRef.GetOrCreate("Particle");
                    m_smoke.Rect                    = new ERectangleF(0, 0, 20, 20);
                    m_smoke.SprayangleRange         = (float)Math.PI * 2;
                    m_smoke.AddedVelocity.Y         = -1;
                    m_smoke.Speed                   = 0;
                    m_smoke.Gravity                 = 0;
                    m_smoke.NumNewParticlesPerFrame = 0.4f;

                    SortedList aColors = new SortedList();
                    aColors.Add(0.0, System.Drawing.Color.FromArgb(127, 127, 127));
                    aColors.Add(1.0, System.Drawing.Color.FromArgb(0, 0, 0));
                    m_smoke.SetColorList(aColors);

                    SortedList aSizes = new SortedList();
                    aSizes.Add(0.0, 1.0);
                    m_smoke.SetSizeList(aSizes);
                }
            }
        }