예제 #1
0
파일: Enemy.cs 프로젝트: Red94/ShootEmUp
        //enemy shoot function
        public void EnemyShoot()
        {
            //shoot only if the bulletdelay resets
            if (bulletDelay >= 0)
                bulletDelay--;

            if (bulletDelay <= 0)
            {
                //create new bullet and position it front and center of enemy shop
                Bullet newBullet = new Bullet(bulletTexture);
                newBullet.position = new Vector2(position.X + texture.Width / 2 - newBullet.texture.Width / 2, position.Y + 30);

                newBullet.isVisible = true;

                if (bulletList.Count() < 20)
                    bulletList.Add(newBullet);
            }

            if (bulletDelay == 0)
                bulletDelay = 80;
        }
예제 #2
0
파일: Player.cs 프로젝트: Red94/ShootEmUp
        //function used to set the position of the bullets
        public void Shoot()
        {
            //shoot only if bulletDelay resets
            if (bulletDelay >= 0)
                bulletDelay--;

            //if the bulletDelay is at 0, create a new bullet at the player position and show it, then add the bullet to the list
            if (bulletDelay <= 0)
            {
                Bullet newBullet;

                //the switch for wich power up has what
                switch (power)
                {
                    case powerUP.one:
                            newBullet = new Bullet(bulletTexture);
                            newBullet.position = new Vector2(position.X + 32 - newBullet.texture.Width / 2, position.Y + 30);

                            //making the bullet visible
                            newBullet.isVisible = true;

                            if (bulletLists.Count() < 20)
                                bulletLists.Add(newBullet);
                        break;

                     case powerUP.two:
                        for (int i = 1; i <= 2; i++)
                        {
                            newBullet = new Bullet(bulletTexture);
                            newBullet.position = new Vector2(position.X + (25 * i) - newBullet.texture.Width / 2, position.Y + 30);

                            //making the bullet visible
                            newBullet.isVisible = true;

                            if (bulletLists.Count() < 20)
                                bulletLists.Add(newBullet);

                        }
                        break;

                    case powerUP.three:
                        for (int i = 1; i <= 3; i++)
                        {
                            newBullet = new Bullet(bulletTexture);
                            newBullet.position = new Vector2(position.X + 32 - newBullet.texture.Width / 2, position.Y + 30);

                            if (i == 1)
                                newBullet.direction = 245;

                            if (i == 2)
                                newBullet.direction = 270;

                            if (i == 3)
                                newBullet.direction = 295;

                            //making the bullet visible
                            newBullet.isVisible = true;

                            if (bulletLists.Count() < 20)
                                bulletLists.Add(newBullet);
                        }
                        break;

                }

              }

            //reset bulletDelay
            if (bulletDelay == 0)
                bulletDelay = 10;
        }