コード例 #1
0
ファイル: Enemy.cs プロジェクト: marcinczajkowski/Fruiter
        //Enemy Shoot function
        public void EnemyShoot()
        {
            // shoot only if bulletdelay resets
            if (bulletDelay >= 0)
            {
                bulletDelay--;
            }
            if (bulletDelay <= 0)
            {
                //new bullet and position it in front of the enemy
                Bullet newBullet = new Bullet(bulletTexture);
                newBullet.position = new Vector2(position.X + texture.Width / 2 - newBullet.texture.Width / 2, position.Y + texture.Height); //change 30 to texture.Height?

                newBullet.isVisible = true;

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

            // reset bullet delay
            if (bulletDelay == 0)
            {
                bulletDelay = 150;
            }
        }
コード例 #2
0
ファイル: Basket.cs プロジェクト: marcinczajkowski/Fruiter
        // Shoot start
        public void Shoot()
        {
            // shoot if bullet delay resets
            if (bulletDelay >= 0)
            {
                bulletDelay--;
            }
            // create a new bullet at Basket position, make it visible and add it to the list
            if (bulletDelay <= 0)
            {
                sm.BasketShootSound.Play();
                Bullet newBullet = new Bullet(bulletTexture);
                newBullet.position = new Vector2(position.X + (texture.Width / 2) - newBullet.texture.Width / 2, position.Y + (texture.Height / 2));
                newBullet.isVisible = true;

                // how many bullet are visible on screen at one time
                if (bulletList.Count() < 20)
                {
                    bulletList.Add(newBullet);
                }
            }
            // reset bullet delay
            if (bulletDelay == 0)
            {
                bulletDelay = 10;
            }
        }