private void ActionGrenade()
        {
            //Gun 21 to 22
            this._State = PlayerState.Grenade;

            if (this.Frame < 21 || this.Frame > 22)
            {
                this.Frame = 21;
            }
            else if (this.Frame == 21)
            {
                this.Frame = 22;

                this.ItemCount--;
                WeaponManagerAccess.CreateWeapon(this.ParentDevice, WeaponType.Grenade, this.X, this.Y, this.Z, this.FaceLeft);
            }
            else
            {
                this.Frame = 29;
                if (this.FaceLeft == true)
                {
                    this.State = PlayerState.StandLeft;
                }
                else
                {
                    this.State = PlayerState.StandRight;
                }
            }

            this.VelocityX = 0.0f;
            this.ApplyNormalGravity();
        }
        private void ActionMine()
        {
            if (this.Frame < 40 || this.Frame > 42)
            {
                this.State = PlayerState.Mine;
                this.Frame = 40;
            }
            else if (this.Frame == 41)
            {
                this.Frame++;
                WeaponManagerAccess.CreateWeapon(this.ParentDevice, WeaponType.Mine, this.X, this.Y, this.Z, this.FaceLeft);
            }
            else if (this.Frame == 42)
            {
                this.Frame = 29;
                if (this.FaceLeft == true)
                {
                    this.State = PlayerState.StandLeft;
                }
                else
                {
                    this.State = PlayerState.StandRight;
                }

                this.ItemCount--;
            }
            else
            {
                this.Frame++;
            }

            this.VelocityX = 0.0f;

            this.ApplyNormalGravity();
        }
Exemple #3
0
        //Animate the game objects if the screen has focus
        private void Animate()
        {
            //Animate only if enough time has passed
            if (SpaceAndTime.TimeToUpdate)
            {
                if (/*this.Screen.HasFocus*/ true)
                {
                    //Move Players
                    for (uint i = 0; i < this.PlayableCharacters.Length; i++)
                    {
                        //Change the state of each sprite
                        this.PlayableCharacters[i].ChangeState(this.Background);
                    }

                    // Move weapons
                    WeaponManagerAccess.MoveWeapons(this.Background);

                    // Move Bubbles
                    this.BubbleManager.AnimateBubbles();
                    this.BubbleManager.MoveBubbles();

                    // Player to weapon collisions
                    WeaponManagerAccess.CheckPlayerCollisions(this.PlayableCharacters, this.Screen.Particles, this.sound);

                    // Player to bubble collisions
                    this.BubbleManager.CheckPlayerCollisions(this.PlayableCharacters);

                    // Player to player collisions
                    for (uint i = 0; i < this.PlayableCharacters.Length; i++)
                    {
                        //Only check for a collision if the player is local
                        // the remote machine can check for its own collisions
                        if (this.PlayableCharacters[i].Location == SpriteAccess.LocationMode.Local)
                        {
                            //Check each sprite for collisions with other sprites
                            this.PlayableCharacters[i].CheckEnemyCollision(this.PlayableCharacters, i);
                        }
                    }
                }
                else
                {
                    //The game has lost focus. sleep
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
Exemple #4
0
        private void Draw()
        {
            this.Screen.StartDraw();

            this.Background.Draw();
            this.Screen.device.RenderState.CullMode = Microsoft.DirectX.Direct3D.Cull.None;
            SpriteAccess.DrawSpriteArray(this.PlayableCharacters);

            WeaponManagerAccess.DrawWeapons();

            this.BubbleManager.DrawBubbles();

            this.Screen.Particles.Draw();

            this.Writer.WriteScoreLeft("Player One Score: " + this.PlayableCharacters[1].DeathCount.ToString());
            this.Writer.WriteScoreRight("Player Two Score: " + this.PlayableCharacters[0].DeathCount.ToString());

            this.Screen.EndDraw();
        }
        private void ActionGun()
        {
            //Gun 18 to 20
            this._State = PlayerState.Shoot;

            if (this.Frame < 18 || this.Frame > 20)
            {
                this.Frame = 18;
            }
            else if (this.Frame == 20)
            {
                this.Frame = 29;
                if (this.FaceLeft == true)
                {
                    this.State = PlayerState.StandLeft;
                }
                else
                {
                    this.State = PlayerState.StandRight;
                }

                this.ItemCount--;
            }
            else
            {
                this.Frame++;
                if (this.Frame == 19)
                {
                    WeaponManagerAccess.CreateWeapon(this.ParentDevice, WeaponType.Bullet, this.X, this.Y, this.Z, this.FaceLeft);
                    this.Sounds.PlayGunShot();
                }
            }

            this.VelocityX = 0.0f;

            this.ApplyNormalGravity();
        }