예제 #1
0
        public void CheckInterSect()
        {
            if (!player.isUnbeatable)
            {
                foreach (LinkedList <Bullet> bulletList in highLightBullet)
                {
                    if (CheckInterSectList(bulletList, player.hitCircle))
                    {
                        DeadAnime da = new DeadAnime(ImageName.DEAD, player.getPosition(), Color.White, myRan);
                        deadAnime.Add(da);
                        player.setDead();
                        ClearAllBullet();
                        pauseBarrageManager(120);
                        playerLife--;
                        deadSound.Play(0.8f * seVol, 0, 0);
                    }
                }
                foreach (LinkedList <Bullet> bulletList in normalBullet)
                {
                    if (CheckInterSectList(bulletList, player.hitCircle))
                    {
                        DeadAnime da = new DeadAnime(ImageName.DEAD, player.getPosition(), Color.White, myRan);
                        deadAnime.Add(da);
                        player.setDead();
                        ClearAllBullet();
                        pauseBarrageManager(120);
                        playerLife--;
                        deadSound.Play(0.8f * seVol, 0, 0);
                    }
                }
            }
            Enemy e;

            for (int i = 0; i < enemy.Count; i++)
            {
                e = enemy[i];
                foreach (LinkedList <Bullet> bulletList in shoujoBullet)
                {
                    if (CheckInterSectList(bulletList, e.hitCircle) && e.getSpriteState() == SpriteState.LIVE)
                    {
                        e.HP--;
                    }
                }
                if (e.HP <= 0)
                {
                    if (!isBoss)
                    {
                        e.setSpriteState(SpriteState.DISAPPEAR);
                        DeadAnime da = new DeadAnime(ImageName.DEAD, e.getPosition(), Color.White, myRan);
                        tanSound.Play(0.6f * seVol, 0, 0);
                        deadAnime.Add(da);
                        Scorecount += 200;
                        if (e.getSpriteFrameNumber() < 200)
                        {
                            Scorecount += 200 - e.getSpriteFrameNumber();
                        }
                    }
                    else
                    {
                        ClearAllBullet();
                        bossSpellID++;
                        if (bossSpellID >= bossSpellNum)
                        {
                            Scorecount += 4000;
                            myBoss.setSpriteState(SpriteState.DISAPPEAR);
                            DeadAnime da = new DeadAnime(ImageName.DEAD, e.getPosition(), Color.White, myRan);
                            tanSound.Play(0.8f * seVol, 0, 0);
                            deadAnime.Add(da);
                            if (prePlayerLife == playerLife)
                            {
                                foreach (BarrageManager bm in enemyBarrage)
                                {
                                    if (bm.isMyOwner(e) && bm.getFrameCount() < 5940)
                                    {
                                        Scorecount += 5940 - bm.getFrameCount();
                                    }
                                }
                            }
                        }
                        else
                        {
                            Scorecount += 2000;
                            tanSound.Play(0.8f * seVol, 0, 0);
                            removeBarrageManager(e);
                            if (prePlayerLife == playerLife)
                            {
                                foreach (BarrageManager bm in enemyBarrage)
                                {
                                    if (bm.isMyOwner(e) && bm.getFrameCount() < 5940)
                                    {
                                        Scorecount += 5940 - bm.getFrameCount();
                                    }
                                }
                            }
                            LoadBossSpell(bossSpellID);
                        }
                    }
                }
                if (e.getSpriteState() == SpriteState.DISAPPEAR)
                {
                    enemy.Remove(e);
                    removeBarrageManager(e);
                    i--;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 允许游戏组件进行自我更新。
        /// </summary>
        /// <param name="gameTime">提供计时值的快照。</param>
        public override void Update(GameTime gameTime)
        {
            if (!pause)
            {
                // TODO: 在此处添加更新代码
                player.Update(gameTime, gameBounds);//更新玩家
                foreach (BarrageManager barrage in enemyBarrage)
                {
                    barrage.Update(gameTime, gameBounds);
                }
                if (Keyboard.GetState().IsKeyDown(Keys.Z))
                {
                    shoujoBarrageManager.Update(gameTime, gameBounds);
                    timeSinceLastShoot += gameTime.ElapsedGameTime.Milliseconds;
                    if (timeSinceLastShoot > 80)
                    {
                        timeSinceLastShoot = 0;
                        shootSound.Play(0.6f * seVol, 0, 0);
                    }
                }
                Enemy nearlyEnemy = null;
                float min         = 2000;
                foreach (Enemy e in enemy)
                {
                    e.Update(gameTime, gameBounds);
                    Vector2 distance = e.getPosition() - player.getPosition();
                    if (distance.Length() < min)
                    {
                        nearlyEnemy = e;
                        min         = distance.Length();
                    }
                }
                for (int i = 0; i < deadAnime.Count; i++)
                {
                    DeadAnime da = deadAnime[i];
                    da.Update(gameTime, gameBounds);
                    if (da.getSpriteState() == SpriteState.DISAPPEAR)
                    {
                        deadAnime.Remove(da);
                        i--;
                    }
                }
                shoujoBarrageManager.setTarget(nearlyEnemy);
                UpdateBullet(gameTime);
                CheckInterSect();

                if (enemy.Count == 0 && scriptID < scriptNum)
                {
                    scriptID++;
                    if (scriptID < scriptNum)
                    {
                        LoadEnemy(scriptID);
                    }
                    else
                    {
                        player.setClear();
                        ClearAllBullet();
                    }
                }
            }
            base.Update(gameTime);
        }