Skip to content

Commit

Permalink
MusicPlayer update
Browse files Browse the repository at this point in the history
  • Loading branch information
Memorix101 committed May 11, 2019
1 parent efbe308 commit 2022321
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
8 changes: 5 additions & 3 deletions Engine_XNA3/GameEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static class GameEngine
private static bool _isFullScreen;
public static Vector2 ScreenSize;

public static MusicPlayer musicPlayer;

public static void Startup(Game game, GraphicsDeviceManager graphics)
{
Expand Down Expand Up @@ -75,6 +76,9 @@ public static void Update(GameTime gameTime)
ScreenEffects.Instance.Update(gameTime);

DebugRenderer.Update(gameTime);

if (musicPlayer != null)
musicPlayer.Update();
}

public static void Render(GameTime gameTime)
Expand All @@ -92,7 +96,6 @@ public static ContentManager ContentManager
get { return _contentManager; }
}


public static ICamera Camera
{
get { return _camera; }
Expand All @@ -116,7 +119,6 @@ public static float AspectRatio
}
}


public static SpriteBatch SpriteBatch
{
get { return _spriteBatch; }
Expand All @@ -127,4 +129,4 @@ public static int Fps
get { return _fpsCounter.FrameRate; }
}
}
}
}
4 changes: 4 additions & 0 deletions OpenC1_XNA3.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
&lt;Assembly Path="D:\SourceTree\OpenC1_XNA3\packages\SharpDX.DirectSound.2.5.0\lib\net20\SharpDX.DirectSound.dll" /&gt;&#xD;
&lt;/AssemblyExplorer&gt;</s:String></wpf:ResourceDictionary>
9 changes: 3 additions & 6 deletions OpenC1_XNA3/BasicEffect2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace OpenC1
{
class BasicEffect2
{

// Fields
private EffectParameter alphaParam;
private EffectParameter ambientLightColorParam;
Expand Down Expand Up @@ -41,7 +40,6 @@ class BasicEffect2

Effect _effect;


public BasicEffect2()
{
_effect = GameEngine.ContentManager.Load<Effect>("Content/BasicEffect2");
Expand Down Expand Up @@ -96,7 +94,6 @@ public void CommitChanges()
_effect.CommitChanges();
}


public void EnableDefaultLighting()
{
this.LightingEnabled = true;
Expand Down Expand Up @@ -152,9 +149,9 @@ private void InitializeEffectParams()

private void UpdateShaderIndex()
{
bool lightingEnabled2 = true;
int num = ((this.vertexColorEnabled ? 1 : 0) | (this.textureEnabled ? 2 : 0)) | (lightingEnabled2 ? 4 : 0);
num += ((lightingEnabled2 && this.preferPerPixelLighting) && this.hasPS20) ? 4 : 0;
bool lightingEnabled2 = true;
int num = ((this.vertexColorEnabled ? 1 : 0) | (this.textureEnabled ? 2 : 0)) | (lightingEnabled2 ? 4 : 0);
num += ((lightingEnabled2 && this.preferPerPixelLighting) && this.hasPS20) ? 4 : 0;
this.shaderIndexParam.SetValue(num);
}

Expand Down
9 changes: 1 addition & 8 deletions OpenC1_XNA3/Race.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ class Race
public PedestrianController Peds;

public static Race Current;

private MusicPlayer _musicPlayer;


public RaceFile ConfigFile { get; private set; }

public Race(string filename, string playerVehicleFile)
Expand Down Expand Up @@ -143,8 +141,6 @@ public Race(string filename, string playerVehicleFile)

RaceTime = new RaceTimeController();

_musicPlayer = new MusicPlayer();

PhysX.Instance.Scene.SetActorGroupPairFlags(PhysXConsts.TrackId, PhysXConsts.VehicleId, ContactPairFlag.Forces | ContactPairFlag.OnStartTouch | ContactPairFlag.OnTouch);
PhysX.Instance.Scene.SetActorGroupPairFlags(PhysXConsts.VehicleId, PhysXConsts.NonCarId, ContactPairFlag.Forces | ContactPairFlag.OnStartTouch | ContactPairFlag.OnTouch);
PhysX.Instance.Scene.SetActorGroupPairFlags(PhysXConsts.TrackId, PhysXConsts.NonCarId, ContactPairFlag.OnTouch);
Expand All @@ -156,8 +152,6 @@ public void Update()
{
RaceTime.Update();

_musicPlayer.Update();

if (!RaceTime.IsStarted)
{
if ((int)RaceTime.TotalTime == 2 && !RaceTime.CountingDown)
Expand Down Expand Up @@ -384,7 +378,6 @@ public void OnPedestrianHit(Pedestrian ped, Vehicle vehicle)

public void ExitAndReturnToMenu()
{
_musicPlayer.Stop();
ResourceCache.Clear();
foreach (var d in Drivers)
d.Vehicle.Audio.Stop();
Expand Down
5 changes: 4 additions & 1 deletion OpenC1_XNA3/Screens/MainMenuScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using OpenC1.HUD;
using Microsoft.Xna.Framework.Input;
using OneAmEngine;
using OneAmEngine.Audio;

namespace OpenC1.Screens
{
Expand All @@ -26,7 +27,9 @@ public MainMenuScreen(BaseMenuScreen parent)

GameVars.Palette = new PaletteFile(GameVars.BasePath + "reg\\palettes\\drrender.pal");
}


GameEngine.musicPlayer = new MusicPlayer();
GameEngine.musicPlayer.Play();

_inAnimation = new AnimationPlayer(LoadAnimation("MAI2COME.fli"), 1);
_inAnimation.Play(false);
Expand Down
2 changes: 0 additions & 2 deletions OpenC1_XNA3/Screens/PlayGameScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ public PlayGameScreen(IGameScreen parent)
_modes.Add(new OpponentEditMode());
_modes.Add(new PedEditMode());
GameMode.Current = _modes[_currentEditMode];

}


public void Update()
{
PhysX.Instance.Simulate();
Expand Down

0 comments on commit 2022321

Please sign in to comment.