コード例 #1
0
ファイル: Bullet.cs プロジェクト: ajalahtiri/SnowyCastle
 public Bullet(Texture2D tex, L2Sprite e)
 {
     texture    = tex;
     center     = new Vector2(texture.Width / 2, texture.Height / 2);
     live       = false;
     this.enemy = e;
 }
コード例 #2
0
        public void enemyShoot(L2Sprite enemy)
        {
            Bullet newB = new Bullet((content.Load <Texture2D>("Textures\\eBullet")), enemy);

            newB.velocity  = new Vector2((float)Math.Sin(enemy.rotation), (float)Math.Cos(enemy.rotation)) * new Vector2(-5f, 4f);
            newB.screenPos = enemy.getPos() + newB.velocity * 3;
            newB.live      = true;

            if (evilBullets.Count < 5)
            {
                shoot.Play();
                evilBullets.Add(newB);
            }
        }
コード例 #3
0
        public void updateEvilBullets(L2Sprite enemy)
        {
            foreach (Bullet b in evilBullets)
            {
                b.screenPos += b.velocity;
                if (Vector2.Distance(b.screenPos, enemy.getPos()) > 600)
                {
                    b.live = false;
                }
            }

            for (int i = 0; i < evilBullets.Count; i++)
            {
                if (!evilBullets[i].live)
                {
                    evilBullets.RemoveAt(i);
                    i--;
                }
            }
        }
コード例 #4
0
        public override void LoadContent()
        {
            if (content == null)
            {
                content = new ContentManager(SManager.Game.Services, "Content");
            }

            //background
            spriteBatch = new SpriteBatch(SManager.GraphicsDevice);
            background  = new Background();
            Texture2D bg = content.Load <Texture2D>("Textures\\space");

            background.Load(SManager.GraphicsDevice, bg);
            viewportRect = new Rectangle(0, 0, SManager.GraphicsDevice.Viewport.Width, SManager.GraphicsDevice.Viewport.Height);
            healthBar    = content.Load <Texture2D>("Textures\\2health");

            //enemies
            enemies  = new List <L2Enemy>(1000000);
            inactive = new List <L2Enemy>(1000000);
            hit      = new List <L2Enemy>(1000000);
            eTex     = content.Load <Texture2D>("Textures\\eSpaceship");

            //player
            pTex    = content.Load <Texture2D>("Textures\\pSpaceship");
            pSprite = new L2Player(pTex, new Vector2(pTex.Height / 2, pTex.Height / 2), new Vector2(300, 420), new Rectangle(0, 0, pTex.Width, pTex.Height), new Vector2(0, 0));

            //sounds
            explode = content.Load <SoundEffect>("Sounds\\2explode");
            shoot   = content.Load <SoundEffect>("Sounds\\2shoot");
            damage  = content.Load <SoundEffect>("Sounds\\2hit");
            music   = content.Load <Song>("Sounds\\Epsilon Indi");
            MediaPlayer.Play(music);

            //text
            periclesFont = content.Load <SpriteFont>("Fonts\\Pericles");
        }
コード例 #5
0
ファイル: Bullet.cs プロジェクト: ajalahtiri/SnowyCastle
 public virtual bool CollidesWith(L2Sprite sprite)
 {
     return(this.BoundingBox.Intersects(sprite.BoundingBox));
 }