Mission backend.

This commit is contained in:
Michael 2017-06-24 19:52:57 -04:00
parent 9c1a409f24
commit ad7328882b
5 changed files with 51 additions and 1 deletions

View file

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.WinForms
{
class MissionAttribute
{
}
}

View file

@ -357,6 +357,7 @@
<Compile Include="MainMenu\MainMenu.Designer.cs">
<DependentUpon>MainMenu.cs</DependentUpon>
</Compile>
<Compile Include="MissionAttribute.cs" />
<Compile Include="Oobe.cs">
<SubType>Form</SubType>
</Compile>

View file

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShiftOS.Engine
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class MissionAttribute : StoryAttribute
{
public MissionAttribute(string id, string friendlyName, string friendlyDesc, ulong codepointAward, string assigner) : base(id)
{
Name = friendlyName;
Description = friendlyDesc;
CodepointAward = codepointAward;
Assigner = assigner;
}
public string Name { get; private set; }
public string Description { get; private set; }
public string Assigner { get; set; }
}
}

View file

@ -139,6 +139,7 @@
<Compile Include="Localization.cs" />
<Compile Include="LoginManager.cs" />
<Compile Include="Lunix.cs" />
<Compile Include="MissionAttribute.cs" />
<Compile Include="NotificationDaemon.cs" />
<Compile Include="OutOfBoxExperience.cs" />
<Compile Include="Paths.cs" />

View file

@ -141,7 +141,7 @@ namespace ShiftOS.Engine
{
foreach (var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static))
{
foreach (var attrib in Array.FindAll(mth.GetCustomAttributes(false), a => a is StoryAttribute))
foreach (var attrib in Array.FindAll(mth.GetCustomAttributes(false), a => a is StoryAttribute || a is MissionAttribute))
{
var story = attrib as StoryAttribute;
if (story.StoryID == stid)
@ -157,6 +157,17 @@ namespace ShiftOS.Engine
SaveSystem.CurrentSave.PickupPoint = Context.Id;
Context.OnComplete += () =>
{
if(story is MissionAttribute)
{
var mission = story as MissionAttribute;
ConsoleEx.ForegroundColor = ConsoleColor.Yellow;
ConsoleEx.Bold = true;
Console.WriteLine(" - mission complete - ");
ConsoleEx.Bold = false;
ConsoleEx.ForegroundColor = ConsoleColor.White;
Console.WriteLine($"{mission.Name} successfully finished. You have earned {mission.CodepointAward} Codepoints for your efforts.");
SaveSystem.CurrentSave.Codepoints += mission.CodepointAward;
}
StoryComplete?.Invoke(stid);
SaveSystem.CurrentSave.PickupPoint = null;
};
@ -209,5 +220,6 @@ namespace ShiftOS.Engine
/// </summary>
public string StoryID { get; private set; }
public ulong CodepointAward { get; protected set; }
}
}