Skip to content

Adventure (campaign) save feature implementation #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# IDE-Specific Files
.vs

# Build Artifacts
bin/
obj/

# Auto-Generated Files
*.Designer.cs
19 changes: 13 additions & 6 deletions SpaceShooter/Events/EventManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,29 @@ public class EventManager
public List<LogEvent> Logs
{
get { return log; }
set { log = value; }
}


List<InventoryItem> inventoryPool;
List<Event> eventPool;
public List<InventoryItem> inventoryPool;
public List<Event> eventPool;

List<Event> dangerPool;
public List<Event> dangerPool;
public int dangerPoolCount
{
get { return dangerPool.Count; }
}


List<Event> wormPool;
public List<Event> wormPool;
public int wormPoolCount
{
get { return wormPool.Count; }
}


List<Event> unlockableEventPool;
SysMenuManager menuManager;
public List<Event> unlockableEventPool;
public SysMenuManager menuManager;



Expand Down Expand Up @@ -544,11 +545,17 @@ public void AddLog(Rectangle img, string txt)
}
}

[Serializable]
public class LogEvent
{
public Rectangle image;
public string description;

public LogEvent()
{
this.image = Rectangle.Empty;
this.description = "";
}
public LogEvent(Rectangle img, string txt)
{
this.image = img;
Expand Down
11 changes: 10 additions & 1 deletion SpaceShooter/Flotilla.SDL2.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
Expand All @@ -22,6 +22,8 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -34,6 +36,7 @@
<ConsolePause>false</ConsolePause>
<PlatformTarget>x86</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<Optimize>true</Optimize>
Expand All @@ -44,6 +47,7 @@
<ConsolePause>false</ConsolePause>
<PlatformTarget>x86</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Steam|x86' ">
<Optimize>true</Optimize>
Expand All @@ -54,6 +58,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ConsolePause>false</ConsolePause>
<PlatformTarget>x86</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
Expand Down Expand Up @@ -237,6 +242,7 @@
<Compile Include="System\Level.cs" />
<Compile Include="System\Options.cs" />
<Compile Include="System\StorageManager.cs" />
<Compile Include="System\CampaignManager.cs" />
<Compile Include="UI\BasePopup.cs" />
<Compile Include="UI\CampaignMenu.cs" />
<Compile Include="UI\CommandMenu.cs" />
Expand Down Expand Up @@ -336,4 +342,7 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion SpaceShooter/Flotilla.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@
<Compile Include="System\Level.cs" />
<Compile Include="System\Options.cs" />
<Compile Include="System\StorageManager.cs" />
<Compile Include="System\CampaignManager.cs" />
<Compile Include="UI\BasePopup.cs" />
<Compile Include="UI\CampaignMenu.cs" />
<Compile Include="UI\CommandMenu.cs" />
Expand Down Expand Up @@ -448,4 +449,4 @@ if $(ConfigurationName)==ReleaseDemo del glow.xnb
if $(ConfigurationName)==Release cd WindowsContent
if $(ConfigurationName)==Release del trial.bmp</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions SpaceShooter/Inventory/BeamShield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public itBeamShield(float amount)
name = iResource.BeamArmor;
description = string.Format(iResource.BeamArmorDescription,
displayStat);
constructorParam = amount;
}
}
}
1 change: 1 addition & 0 deletions SpaceShooter/Inventory/BlesoRailChamber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public itBlesoRailChamber(float bulletSpeed)
name = iResource.BlesoRailChamber;
description = string.Format(iResource.BlesoRailChamberDescription,
displayStat);
constructorParam = bulletSpeed;
}
}
}
4 changes: 4 additions & 0 deletions SpaceShooter/Inventory/InventoryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ namespace SpaceShooter
/// <summary>
/// A carryable item.
/// </summary>
[Serializable]
public class InventoryItem
{
public Rectangle image = Rectangle.Empty;
public string name = "Default Item";
public string description = "Default Description";

public GameEffect gameEffect;

// Used to keep effect value for serialization
public float? constructorParam = null;
}
}
1 change: 1 addition & 0 deletions SpaceShooter/Inventory/JamalAutoDoc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public itJamalAutoDoc(float healSpeed)
name = iResource.JamalAutoDoc;
description = string.Format( iResource.JamalAutoDocDescription,
displayStat);
constructorParam = healSpeed;
}
}
}
1 change: 1 addition & 0 deletions SpaceShooter/Inventory/KeshiaEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public itKeshiaEngine(float engineSpeed)
image = sprite.inventory.Engine;
name = iResource.KeshiaEngine;
description = string.Format( iResource.KeshiaEngineDescription, displayStat);
constructorParam = engineSpeed;
}
}
}
1 change: 1 addition & 0 deletions SpaceShooter/Inventory/itMuyoShield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public itMuyoShield(float amount)
name = iResource.BotosShield;
description = string.Format(iResource.BotosShieldDescription,
displayStat);
constructorParam = amount;
}
}
}
1 change: 1 addition & 0 deletions SpaceShooter/Inventory/itRashadFireCon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public itRashadFireCon(float fireSpeed)
name = iResource.RashadFireCon;
description = string.Format( iResource.RashadFireConDescription,
displayStat);
constructorParam = fireSpeed;
}
}
}
1 change: 1 addition & 0 deletions SpaceShooter/Inventory/itRoachShield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public itRoachShield(float amount)
name = iResource.RoachShield;
description = string.Format(iResource.RoachShieldDescription,
displayStat);
constructorParam = amount;
}
}
}
22 changes: 20 additions & 2 deletions SpaceShooter/Resource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion SpaceShooter/Resource.resx
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ SIGN IN NOW?</value>
<value>PAUSED</value>
</data>
<data name="MenuCampaign" xml:space="preserve">
<value>ADVENTURE {0}</value>
<value>START ADVENTURE {0}</value>
</data>
<data name="MenuQuit" xml:space="preserve">
<value>QUIT</value>
Expand Down Expand Up @@ -2464,4 +2464,10 @@ THIS CELESTIAL WEAPON</value>
<data name="MenuCreditsAdditionalWriting" xml:space="preserve">
<value>ADDITIONAL WRITING</value>
</data>
<data name="MenuCampaignContinue" xml:space="preserve">
<value>CONTINUE ADVENTURE {0}</value>
</data>
<data name="MenuReturnToMain" xml:space="preserve">
<value>SAVE AND RETURN TO MAIN MENU</value>
</data>
</root>
2 changes: 1 addition & 1 deletion SpaceShooter/Simulation/PlayerCommander.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4096,7 +4096,7 @@ public override void Draw(GameTime gameTime)

}

int commandPoints = 2000;
public int commandPoints = 2000;
Vector2 expBarPos = new Vector2(150, 515);
bool expBarHover = false;
bool smitePowerActive = false;
Expand Down
1 change: 1 addition & 0 deletions SpaceShooter/Simulation/SpaceShip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class SpaceShipAIData
public Collideable targetShip;
}

[Serializable]
public class SpaceShipStats
{
public int kills = 0;
Expand Down
20 changes: 20 additions & 0 deletions SpaceShooter/Simulation/shipData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,26 @@ public static class Cars
public static Rectangle Dorado = new Rectangle(0, 0, 64, 64);
}
*/

private static readonly Dictionary<ModelType, ShipData> ShipDataByName = new Dictionary<ModelType, ShipData>
{
{ ModelType.shipBeamFrigate, BeamFrigate },
{ ModelType.shipBeamGunship, BeamGunship },
{ ModelType.shipCapitalShip, Battleship },
{ ModelType.shipDestroyer, Destroyer },
{ ModelType.shipGunship, Gunship },
{ ModelType.shipDreadnought, Dreadnought },
{ ModelType.shipFighter, Fighter }
};

public static ShipData GetShipDataByModelType(ModelType modelType)
{
if (ShipDataByName.TryGetValue(modelType, out var shipData))
{
return shipData;
}
throw new ArgumentException($"Ship type '{modelType}' not found.");
}
}

public static class DamageTypes
Expand Down
Loading