Example #1
0
        public void DisplaySoundTitle(string name)
        {
            IHudTextControl hTC = ((IHudTextControl)this.GetControl("MusicTitle"));

            if (hTC != null)
            {
                hTC.Text       = name;
                hTC.TimeLiving = 0;
                hTC.Visible    = true;
            }
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            #region Update HUD with AmmoInfo
            if (this == manager.PrimaryWeapon)
            {
                IHudTextControl control = game.GameStates.Hud.GetControl("weapon1_magazine") as IHudTextControl;
                if (control != null)
                {
                    control.Text = AmmoInMagazine.ToString();
                    if (state == WeaponState.FIRING || state == WeaponState.FIRING_LOOP)
                    {
                        control.Effect = HUDEffectType.PULSE;
                    }
                    else
                    {
                        control.Effect = HUDEffectType.NONE;
                    }
                }


                IHudTextControl control2 = game.GameStates.Hud.GetControl("weapon1_ammo") as IHudTextControl;
                if (control2 != null)
                {
                    control2.Text = ammoType.ToString() + ": " + Ammo.ToString();
                }
            }

            if (this == manager.SecondaryWeapon)  //TODO: Irgendwie updated der das nicht richtig
            {
                IHudTextControl control = game.GameStates.Hud.GetControl("weapon2_magazine") as IHudTextControl;
                if (control != null)
                {
                    control.Text = AmmoInMagazine.ToString();
                    if (state == WeaponState.FIRING || state == WeaponState.FIRING_LOOP)
                    {
                        control.Effect = HUDEffectType.PULSE;
                    }
                    else
                    {
                        control.Effect = HUDEffectType.NONE;
                    }
                }

                IHudTextControl control2 = game.GameStates.Hud.GetControl("weapon2_ammo") as IHudTextControl;
                if (control2 != null)
                {
                    control2.Text = ammoType.ToString() + ": " + Ammo.ToString();
                }
            }
            #endregion

            #region WEAPON_STATE_MACHINE
            switch (state)
            {
            case WeaponState.NOTHING:
                break;

            case WeaponState.AMMO_EMPTY:
                // Stop Firing-Loop Sound if playing
                if (soundFiring != null)
                {
                    soundFiring.Loop = false;
                    soundFiring.Stop();
                    isLooping = false;
                }

                if (isEmpty)
                {
                    if (!WaitFor("AmmoEmpty", TimeSpan.FromMilliseconds(desc.SoundAmmoEmptyMilliseconds)))
                    {
                        break;
                    }
                    else
                    {
                        isEmpty = false;
                    }
                }
                if (!isEmpty)
                {
                    isEmpty = true;
                    ResetWait("AmmoEmpty");
                    // Play AmmoEmpty Sound
                    if (soundAmmoEmpty != null)
                    {
                        soundAmmoEmpty.Play();
                    }
                    OnAmmoEmpty();
                }

                break;

            case WeaponState.RELOADING:
                if (isReloading)
                {
                    if (!WaitFor("Reloading", TimeSpan.FromMilliseconds(desc.SoundReloadMilliseconds)))
                    {
                        break;
                    }
                    else
                    {
                        isReloading = false;
                        if (desc.LoopedFire)
                        {
                            state = WeaponState.FIRING_LOOP;
                        }
                        else
                        {
                            state = WeaponState.FIRING;
                        }
                        OnReload();
                    }
                }
                if (!isReloading)
                {
                    isReloading = true;
                    ResetWait("Reloading");
                    // Play AmmoEmpty Sound
                    if (soundReload != null)
                    {
                        soundReload.Play();
                    }
                }
                // Update player HUD crosshair by ELC
                break;

            case WeaponState.START_FIRE:
                // Update player HUD crosshair by ELC
                if (isStarted)
                {
                    if (!WaitFor("StartFire", TimeSpan.FromMilliseconds(desc.SoundStartMilliseconds)))
                    {
                        break;
                    }
                    else
                    {
                        if (desc.LoopedFire)
                        {
                            state = WeaponState.FIRING_LOOP;
                        }
                        else
                        {
                            state = WeaponState.FIRING;
                        }
                        isStarted = false;
                        OnFireStarted(Vector3.Transform(desc.ProjectileOffset, GlobalTransformation), direction);
                        break;
                    }
                }
                if (!isStarted)
                {
                    isStarted = true;
                    ResetWait("StartFire");
                    // Play StartFire Sound
                    if (soundStartFire != null)
                    {
                        soundStartFire.Play();
                    }
                    OnFireStart(Vector3.Transform(desc.ProjectileOffset, GlobalTransformation), direction);
                }
                break;

            case WeaponState.FIRING_LOOP:
                if (!DescreaseAmmo())
                {
                    break;
                }

                if (!isLooping)
                {
                    // Play Firing-Loop Sound
                    isLooping = true;
                    if (soundFiring != null)
                    {
                        soundFiring.Loop = true;
                    }
                }
                OnFiring(Vector3.Transform(desc.ProjectileOffset, GlobalTransformation), direction);
                state = WeaponState.FIRE_PAUSED;
                break;



            case WeaponState.FIRING:
                if (!DescreaseAmmo())
                {
                    break;
                }

                if (soundFiring != null)
                {
                    soundFiring.Stop();
                    soundFiring.Play();
                }
                OnFiring(Vector3.Transform(desc.ProjectileOffset, GlobalTransformation), direction);
                state = WeaponState.FIRE_PAUSED;
                break;



            case WeaponState.FIRE_PAUSED:
                if (WaitFor("FirePause", TimeSpan.FromMilliseconds(desc.FirePause)))
                {
                    ResetWait("FirePause");
                    if (desc.LoopedFire)
                    {
                        state = WeaponState.FIRING_LOOP;
                    }
                    else
                    {
                        state = WeaponState.FIRING;
                    }
                }

                break;



            case WeaponState.STOP_FIRE:
                isStarted = false;
                if (desc.LoopedFire && isLooping)
                {
                    // Stop Firing-Loop Sound
                    if (soundFiring != null)
                    {
                        soundFiring.Loop = false;
                        soundFiring.Stop();
                    }
                    isLooping = false;
                }

                if (isStopping)
                {
                    if (!WaitFor("StopFire", TimeSpan.FromMilliseconds(desc.SoundStopMilliseconds)))
                    {
                        break;
                    }
                    else
                    {
                        state      = WeaponState.NOTHING;
                        isStopping = false;
                        break;
                    }
                }
                if (!isStopping)
                {
                    isStopping = true;
                    ResetWait("StopFire");
                    //Play StartFire Sound
                    if (soundStopFire != null)
                    {
                        soundStopFire.Play();
                    }
                    OnFireStop(GlobalPosition, direction);
                }
                break;


            default:
                break;
            }
            #endregion
        }