Kinda save settings
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<PublishReadyToRun>false</PublishReadyToRun>
|
||||
<TieredCompilation>false</TieredCompilation>
|
||||
<Platforms>AnyCPU;x86</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
@@ -12,6 +13,9 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<OutputPath></OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
|
||||
<OutputPath />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Icon.ico" />
|
||||
<None Remove="Icon.bmp" />
|
||||
|
||||
@@ -3,13 +3,61 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
namespace EvilSatellites
|
||||
{
|
||||
public static class GameSettings
|
||||
{
|
||||
public static string SettingsDirectory = Environment.SpecialFolder.Personal + "/EvilSatellites";
|
||||
public static string SettingsFile = SettingsDirectory + "/settings.dat";
|
||||
public static bool PreferSAPI = true;
|
||||
public static bool UseForceFeedback = true;
|
||||
public static bool EnableAI = true;
|
||||
|
||||
public static void SaveSettings()
|
||||
{
|
||||
if (!Directory.Exists(SettingsDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(SettingsDirectory);
|
||||
}
|
||||
try
|
||||
{
|
||||
var file = new BinaryWriter(File.Open(SettingsFile, FileMode.Create));
|
||||
file.Write(PreferSAPI);
|
||||
file.Write(UseForceFeedback);
|
||||
file.Write(EnableAI);
|
||||
file.Close();
|
||||
} catch (Exception e)
|
||||
{
|
||||
DavyKager.Tolk.Output("Error saving settings: " + e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void ReadSettings()
|
||||
{
|
||||
if (!Directory.Exists(SettingsDirectory))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!File.Exists(SettingsFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var file = new BinaryReader(File.OpenRead(SettingsFile));
|
||||
PreferSAPI = file.ReadBoolean();
|
||||
UseForceFeedback = file.ReadBoolean();
|
||||
EnableAI = file.ReadBoolean();
|
||||
file.Close();
|
||||
} catch (Exception e)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ namespace EvilSatellites.Objects
|
||||
sfxTaps.Destroy();
|
||||
sfxElevator.Destroy();
|
||||
sfxDamage.Destroy();
|
||||
CurrentWeapon.Destroy();
|
||||
return;
|
||||
}
|
||||
override public void Update(GameTime gameTime)
|
||||
@@ -109,19 +110,19 @@ namespace EvilSatellites.Objects
|
||||
Move(Movement);
|
||||
if (Turning == -1)
|
||||
{
|
||||
RotateY(0.035f);
|
||||
RotateY(0.025f);
|
||||
}
|
||||
if (Turning == 1)
|
||||
{
|
||||
RotateY(-0.035f);
|
||||
RotateY(-0.025f);
|
||||
}
|
||||
if (Elevating == -1)
|
||||
{
|
||||
RotateX(-0.035f);
|
||||
RotateX(-0.025f);
|
||||
}
|
||||
if (Elevating == 1)
|
||||
{
|
||||
RotateX(0.035f);
|
||||
RotateX(0.025f);
|
||||
}
|
||||
sfxEngine.Pitch = 0.5 + (Movement.Length() / MaxSpeed.Length()) * 4;
|
||||
sfxWhine.Pitch = 0.5 + (Movement.Length() / MaxSpeed.Length()) * 1;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace EvilSatellites
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
|
||||
GameSettings.ReadSettings();
|
||||
DavyKager.Tolk.Load();
|
||||
if (GameSettings.PreferSAPI)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace EvilSatellites.Screens
|
||||
public virtual void Activate()
|
||||
{
|
||||
CursorPosition = 0;
|
||||
Tolk.Output(MenuOptions.Title, true);
|
||||
Tolk.Output(MenuOptions.Title, false);
|
||||
Tolk.Output(MenuOptions.Description, false);
|
||||
Tolk.Output(MenuOptions.Entries[CursorPosition].Name);
|
||||
Manager.Sound.PlayOneshot(@"sfx/ui/menuOpen.wav");
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace EvilSatellites.Screens
|
||||
}
|
||||
if (CursorPosition == 4)
|
||||
{
|
||||
GameSettings.SaveSettings();
|
||||
Manager.RemoveScreen(this);
|
||||
Manager.AddScreen(new MainMenuScreen());
|
||||
}
|
||||
|
||||
@@ -30,5 +30,6 @@ namespace EvilSatellites.Weapons
|
||||
public virtual void Stop() { }
|
||||
public virtual void Update(GameTime time) { }
|
||||
public abstract void Reload(int amount);
|
||||
public abstract void Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,5 +18,6 @@ namespace EvilSatellites.Weapons
|
||||
int MaxAmmo { get; set; }
|
||||
int RemainingAmmo { get; set; }
|
||||
WeaponState State { get; set; }
|
||||
void Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,5 +130,15 @@ namespace EvilSatellites.Weapons
|
||||
sfxReload.Play();
|
||||
Screen.Manager.Vibrations.AddVibration(1, 1, 500);
|
||||
}
|
||||
|
||||
public override void Destroy()
|
||||
{
|
||||
sfxEmpty.Destroy();
|
||||
sfxReload.Destroy();
|
||||
sfxShoot.Destroy();
|
||||
sfxSpindown.Destroy();
|
||||
sfxSpinning.Destroy();
|
||||
sfxSpinup.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user