public static void CheckPlayerCollisions(SpriteAccess[] OtherPlayers, ParticleAccess CurrParticles, SoundAccess Sounds)
        {
            //for each player
            foreach (PlayableCharacterAccess CurrPlayer in OtherPlayers)
            {
                //for each weapon
                foreach (WeaponAccess CurrWeapon in WeaponManagerAccess.AllWeapons)
                {
                    //Check collisions against players
                    if (CurrWeapon.TypeOfWeapon != WeaponType.Grenade)
                    {
                        if (CurrWeapon.CollisionRects.CheckObjectRectAgainst(CurrPlayer, CurrWeapon.Frame, CurrWeapon.X, CurrWeapon.Y) != CollisionRectAccess.HitSide.None)
                        {
                            //remove weapon
                            //kill player
                            CurrPlayer.State  = PlayableCharacterAccess.PlayerState.Explode;
                            CurrWeapon.IsDead = true;

                            //Add explosion
                            if (CurrWeapon.TypeOfWeapon == WeaponType.SlideMine || CurrWeapon.TypeOfWeapon == WeaponType.Mine)
                            {
                                //CurrParticles.AddExplosion(new Vector3(CurrPlayer.X, CurrPlayer.Y, SpaceAndTime.SpriteZLocation));
                                CurrParticles.AddExplosion(new Vector3(CurrPlayer.X / 17, CurrPlayer.Y / 17, 0.0f));
                                Sounds.PlayExplosion();
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        //Creates a camera viewpoint and starts drawing the screen
        public void StartDrawing(int NewWidth, int NewHeight, float ViewAngle, float NearRange, float FarRange)
        {
            this._ScreenWidth  = NewWidth;
            this._ScreenHeight = NewHeight;

            //Make form
            this.ClientSize = new System.Drawing.Size(this._ScreenWidth, this._ScreenHeight);
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

            this.Show();
            this.Camera = new CameraAccess(this.device, this._ScreenWidth / this._ScreenHeight, ViewAngle, NearRange, FarRange);

            this.Goo  = new GooAccess(this.device, this.CardShader, this.Camera.ViewMatrix, this.Camera.ProjectionMatrix);
            this.Wall = new WallAccess(this.device, this.CardShader, this.Camera.ViewMatrix, this.Camera.ProjectionMatrix);

            this.Particles = new ParticleAccess(this.device);

            //Tell screen there is an active world to draw
            // and reset the parameters such as lighting, culling, blending
            this.ResetSettings();
        }