コード例 #1
0
        //foreach line of the shotgun i need to update the lines based on the player center,
        //and rotate it and give it length, then update the graphical lines
        public override void Update(Vector2 playerCenter, Vector2 playerVelocity, float rotationAngle, int accuracy, bool shotFired, TimeSpan elapsedTime)
        {
            base.Update(playerCenter, playerVelocity, rotationAngle, accuracy, shotFired, elapsedTime);
            if (!Firing)
            {
                float accuracyInRadians = WEAPON_RANDOM.Next(0, accuracy) * ((float)Math.PI / 180);
                //TODO: add a random so its either plus or minus accuracy
                float centerVector = rotationAngle - accuracyInRadians;

                float leftAngle = centerVector - (Spread / (NumberOfBullets - 1));
                LeftAngle = leftAngle;
                foreach (Line line in m_BulletLines)
                {
                    line.Update(playerCenter, leftAngle, SightRange);
                    leftAngle += (float)(Spread / (NumberOfBullets - 1));
                }
                m_CurrentShotInfo = new SpriteInfo(playerCenter, playerVelocity, rotationAngle, NumberOfBullets, leftAngle);
            }
            //firing a shot, save the state
            if (!Firing && shotFired && CanFire())
            {
                if (m_ShotSound != null)
                {
                    m_ShotSound.Stop();
                    m_ShotSound.Dispose();
                }
                if (m_ReloadSound != null)
                {
                    m_ReloadSound.Stop();
                    m_ReloadSound.Dispose();
                }
                m_ShotSound = SoundBank.GetSoundInstance("SoundShotgun");
                m_ShotSound.Play();
                Firing = true;
                m_FireAnimation.SpriteInfo = m_CurrentShotInfo;
                CanDamage = true;
                if (m_FireAnimation.CanStartAnimating())
                {
                    m_FireAnimation.Finished = false;
                }
            }
        }
コード例 #2
0
ファイル: Plasma.cs プロジェクト: louisMyu/GameName1
        //foreach line of the shotgun i need to update the lines based on the player center,
        //and rotate it and give it length, then update the graphical lines
        public override void Update(Vector2 playerCenter, Vector2 playerVelocity, float rotationAngle, int accuracy, bool shotFired, TimeSpan elapsedTime)
        {
            base.Update(playerCenter, playerVelocity, rotationAngle, accuracy, shotFired, elapsedTime);
            //float accuracyInRadians = WEAPON_RANDOM.Next(0, accuracy) * ((float)Math.PI / 180);
            //TODO: add a random so its either plus or minus accuracy
            float centerVector = rotationAngle;

            m_CurrentShotInfo = new SpriteInfo(playerCenter, playerVelocity, rotationAngle, NumberOfBullets, LeftAngle);

            m_Bullets.RemoveAll(x => x.CanDelete);
            foreach (Bullet b in m_Bullets)
            {
                b.Update(elapsedTime);
            }
            //firing a shot, save the state
            if (shotFired && CanFire())
            {
                Bullet temp = new Bullet(m_CurrentShotInfo, 10);
                temp.LoadContent();
                m_Bullets.Add(temp);
                m_ElapsedFrames = FireRate;

                if (m_ShotSound != null)
                {
                    m_ShotSound.Stop();
                    m_ShotSound.Dispose();
                }
                m_ShotSound = SoundBank.GetSoundInstance("SoundPlasmaShot");
                m_ShotSound.Play();
            }
            if (m_Bullets.Count > 0)
            {
                BulletsExist = true;
            }
            else
            {
                BulletsExist = false;
            }
        }
コード例 #3
0
 public void SetSpriteInfo(SpriteInfo info)
 {
     m_SpriteInfo = info;
 }