diff --git a/MLGUIWindows/GUI/New World Menu/NewWorldMenuLayout1920x1080.cs b/MLGUIWindows/GUI/New World Menu/NewWorldMenuLayout1920x1080.cs
index 965243c6..a6fe83e6 100644
--- a/MLGUIWindows/GUI/New World Menu/NewWorldMenuLayout1920x1080.cs
+++ b/MLGUIWindows/GUI/New World Menu/NewWorldMenuLayout1920x1080.cs
@@ -2,7 +2,7 @@
namespace MagicalLifeGUIWindows.GUI.New
{
- public class NewWorldMenuLayout1920x1080
+ public static class NewWorldMenuLayout1920x1080
{
///
/// The Y position at which all world size s are displayed at.
diff --git a/MLGUIWindows/Input/Specialized Handlers/LivingMoveOrderInputHandler.cs b/MLGUIWindows/Input/Specialized Handlers/LivingMoveOrderInputHandler.cs
index dbfc485a..c50ae976 100644
--- a/MLGUIWindows/Input/Specialized Handlers/LivingMoveOrderInputHandler.cs
+++ b/MLGUIWindows/Input/Specialized Handlers/LivingMoveOrderInputHandler.cs
@@ -9,6 +9,7 @@
using MagicalLifeAPI.Util;
using MagicalLifeAPI.World.Data;
using MagicalLifeGUIWindows.Input.History;
+using System;
using System.Collections.Generic;
using System.Linq;
@@ -70,9 +71,6 @@ private void Move(HasComponents selectable, Point2D target)
Extensions.EnqueueCollection(movementComponent.QueuedMovement, pth);
}
break;
-
- default:
- break;
}
}
}
diff --git a/MLGUIWindows/Screens/LogoScreen.cs b/MLGUIWindows/Screens/LogoScreen.cs
index 88bb33c8..970ede13 100644
--- a/MLGUIWindows/Screens/LogoScreen.cs
+++ b/MLGUIWindows/Screens/LogoScreen.cs
@@ -18,6 +18,8 @@ public class LogoScreen
protected Rectangle TextZone { get; set; }
+
+
protected string Text { get; set; }
protected SpriteFont Font = Game1.AssetManager.Load(TextureLoader.FontMainMenuFont12x);
@@ -32,6 +34,7 @@ public class LogoScreen
///
protected int Half { get; set; }
+
protected Texture2D Logo { get; set; }
protected Color Mask { get; set; }
@@ -41,17 +44,45 @@ public class LogoScreen
///
/// The resource path to the logo file that is to be displayed.
/// How many seconds to show the logo.
- public LogoScreen(string logo, float duration, string text = "")
+ public LogoScreen(string logo, float duration)
{
this.Frames = (int)duration * LogoScreen.FPS;
this.Half = this.Frames / 2;
this.Logo = Game1.AssetManager.Load(logo);
this.DisplayZone = this.CalculateDisplayLocation();
- this.Text = text;
+ this.Text = "";
this.CalculateTextZone();
this.Mask = Color.Black;
}
+ ///
+ ///
+ ///
+ /// The resource path to the logo file that is to be displayed.
+ /// How many seconds to show the logo.
+ public LogoScreen(string logo, float duration, string text)
+ {
+ this.Frames = (int)duration * LogoScreen.FPS;
+ this.Half = this.Frames / 2;
+ this.Logo = Game1.AssetManager.Load(logo);
+ this.DisplayZone = this.CalculateDisplayLocation();
+ this.InitText(text);
+ this.CalculateTextZone();
+ this.Mask = Color.Black;
+ }
+
+ private void InitText(string text)
+ {
+ if (!string.IsNullOrWhiteSpace(text))
+ {
+ this.Text = text;
+ }
+ else
+ {
+ Text = "";
+ }
+ }
+
public void Skip()
{
this.Frames = 0;
diff --git a/MagicalLife.sln b/MagicalLife.sln
index bbe2356b..9d89f4ae 100644
--- a/MagicalLife.sln
+++ b/MagicalLife.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2010
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.28917.181
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{09293283-6E6D-4652-A633-5B70452244DA}"
ProjectSection(SolutionItems) = preProject
@@ -33,7 +33,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicalLifeServerStandard",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicalLifeSettingsStandard", "MagicalLifeSettingsStandard\MagicalLifeSettingsStandard.csproj", "{EC7FD282-023D-4926-A766-19B36AEAC4C2}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicalLifeAPITest", "MagicalLifeAPITest\MagicalLifeAPITest.csproj", "{9CA6C7EF-99BC-4066-BB9D-0613E248B91D}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicalLifeAPITest", "MagicalLifeAPITest\MagicalLifeAPITest.csproj", "{9CA6C7EF-99BC-4066-BB9D-0613E248B91D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MagicalLifeMod", "MagicalLifeMod\MagicalLifeMod.csproj", "{89B9DD2D-4904-4491-B111-E43A750E440B}"
EndProject
@@ -41,6 +41,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoGUI", "MonoGUI\MonoGUI.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLGUIWindows", "MLGUIWindows\MLGUIWindows.csproj", "{94CBCEE0-960D-4B20-B7C5-020C24022A79}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MonoLib", "MonoLib\MonoLib.csproj", "{893380B0-B822-4AAA-85DF-8E83A7620340}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -156,6 +158,18 @@ Global
{94CBCEE0-960D-4B20-B7C5-020C24022A79}.Release|x64.ActiveCfg = Release|x86
{94CBCEE0-960D-4B20-B7C5-020C24022A79}.Release|x86.ActiveCfg = Release|x86
{94CBCEE0-960D-4B20-B7C5-020C24022A79}.Release|x86.Build.0 = Release|x86
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Debug|x64.Build.0 = Debug|Any CPU
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Debug|x86.Build.0 = Debug|Any CPU
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Release|Any CPU.Build.0 = Release|Any CPU
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Release|x64.ActiveCfg = Release|Any CPU
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Release|x64.Build.0 = Release|Any CPU
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Release|x86.ActiveCfg = Release|Any CPU
+ {893380B0-B822-4AAA-85DF-8E83A7620340}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/MagicalLifeAPIStandard/Combat/Damage.cs b/MagicalLifeAPIStandard/Combat/Damage.cs
new file mode 100644
index 00000000..4576b6ef
--- /dev/null
+++ b/MagicalLifeAPIStandard/Combat/Damage.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+
+namespace MagicalLifeAPI.Combat
+{
+ [DebuggerDisplay("DamageType = {DamageTypes} \n DamageAmount = {DamageAmount} ")]
+ public class Damage : DamageBase
+ {
+ public Damage(DamageTypes type, float damageAmount) : base(type, damageAmount)
+ {
+ }
+
+ public static Damage operator +(Damage damage, float amount)
+ {
+ return new Damage(damage.DamageTypes, damage.DamageAmount + amount);
+ }
+
+ public static Damage operator -(Damage damage, float amount)
+ {
+ return new Damage(damage.DamageTypes, damage.DamageAmount - amount);
+ }
+
+ public static Damage operator -(Damage damage, Resistance resistance)
+ {
+ if (resistance.DamageTypes == damage.DamageTypes)
+ {
+ return new Damage(damage.DamageTypes, damage.DamageAmount - resistance.DamageAmount);
+ }
+ else
+ {
+ throw new ArgumentException("Damage types of damage and resistance are not equal.");
+ }
+
+ }
+
+
+
+
+ public static Damage operator *(Damage damage, float amount)
+ {
+ return new Damage(damage.DamageTypes, damage.DamageAmount * amount);
+ }
+
+ public static Damage operator /(Damage damage, float amount)
+ {
+ return new Damage(damage.DamageTypes, damage.DamageAmount / amount);
+ }
+
+ }
+}
diff --git a/MagicalLifeAPIStandard/Combat/DamageBase.cs b/MagicalLifeAPIStandard/Combat/DamageBase.cs
new file mode 100644
index 00000000..25a99f36
--- /dev/null
+++ b/MagicalLifeAPIStandard/Combat/DamageBase.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MagicalLifeAPI.Combat
+{
+ public abstract class DamageBase : IEquatable
+ {
+
+ public readonly DamageTypes DamageTypes;
+
+ public DamageBase()
+ {
+ DamageTypes = DamageTypes.FromValue(0);
+ DamageAmount = 10;
+ }
+
+ public DamageBase(DamageTypes type, float damageAmount)
+ {
+ DamageTypes = type;
+ DamageAmount = damageAmount;
+ }
+
+ public float DamageAmount { get; set; }
+
+ public override bool Equals(object obj)
+ {
+ if (obj is DamageBase)
+ {
+ return Equals(obj as DamageBase);
+ }
+ return false;
+
+ }
+
+ public bool Equals(DamageBase other)
+ {
+ return EqualityComparer.Default.Equals(DamageTypes, other.DamageTypes) &&
+ DamageAmount == other.DamageAmount;
+ }
+
+ public override int GetHashCode()
+ {
+ var hashCode = -424489883;
+ hashCode = hashCode * -1521134295 + EqualityComparer.Default.GetHashCode(DamageTypes);
+ hashCode = hashCode * -1521134295 + DamageAmount.GetHashCode();
+ return hashCode;
+ }
+
+ public static bool operator ==(DamageBase left, DamageBase right)
+ {
+ return EqualityComparer.Default.Equals(left, right);
+ }
+
+ public static bool operator !=(DamageBase left, DamageBase right)
+ {
+ return !(left == right);
+ }
+
+
+
+ }
+}
diff --git a/MagicalLifeAPIStandard/Combat/DamageTypes.cs b/MagicalLifeAPIStandard/Combat/DamageTypes.cs
new file mode 100644
index 00000000..a7b6b6ca
--- /dev/null
+++ b/MagicalLifeAPIStandard/Combat/DamageTypes.cs
@@ -0,0 +1,127 @@
+using MagicalLifeAPI.Properties;
+using MonoGUI.MonoLib.CustomTypes;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace MagicalLifeAPI.Combat
+{
+ public class DamageTypes : Enumeration, IEquatable
+ {
+ public static readonly DamageTypes Poison = new DamageTypes(1, Lang.Poison);
+
+ public static readonly DamageTypes Magic = new DamageTypes(2, Lang.Magic);
+
+ public static readonly DamageTypes Fire = new DamageTypes(3, Lang.Fire);
+
+ public static readonly DamageTypes Crushing = new DamageTypes(4, Lang.Crushing);
+
+ public static readonly DamageTypes Piercing = new DamageTypes(5, Lang.Piercing);
+
+ public static readonly ICollection List = new List { Piercing, Crushing, Fire, Magic, Poison };
+
+ protected DamageTypes(int id, string name) : base(id, name)
+ {
+ }
+
+ ///
+ /// Adds the type of the damage.
+ ///
+ /// The damage.
+ /// If the new damage type was registered
+ public bool AddDamageType(DamageTypes damage)
+ {
+ if(!List.Contains(damage))
+ {
+ List.Add(damage);
+ return true;
+ }
+ return false;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (!(obj is DamageTypes))
+ {
+ return false;
+ }
+
+ DamageTypes damageTypes = obj as DamageTypes;
+ return Equals(damageTypes);
+ }
+
+ public override string ToString()
+ {
+ return Name;
+ }
+
+ public override int GetHashCode()
+ {
+ const int hash = 397;
+ return hash * Id.GetHashCode() * Name.GetHashCode();
+ }
+
+ public static bool operator ==(DamageTypes left, DamageTypes right)
+ {
+ if (left is null)
+ {
+ return right is null;
+ }
+
+ return left.Equals(right);
+ }
+
+ public static bool operator !=(DamageTypes left, DamageTypes right)
+ {
+ return !(left == right);
+ }
+
+ public static bool operator <(DamageTypes left, DamageTypes right)
+ {
+ return left is null ? !(right is null) : left.CompareTo(right) < 0;
+ }
+
+ public static bool operator <=(DamageTypes left, DamageTypes right)
+ {
+ return left is null || left.CompareTo(right) <= 0;
+ }
+
+ public static bool operator >(DamageTypes left, DamageTypes right)
+ {
+ return !(left is null) && left.CompareTo(right) > 0;
+ }
+
+ public static bool operator >=(DamageTypes left, DamageTypes right)
+ {
+ return left is null ? right is null : left.CompareTo(right) >= 0;
+ }
+
+
+ public static DamageTypes FromString(string roleString)
+ {
+ return List.Single(r => string.Equals(r.Name, roleString, StringComparison.OrdinalIgnoreCase));
+ }
+
+ public static DamageTypes FromValue(int value)
+ {
+ return List.Single(r => r.Id == value);
+ }
+
+ public bool Equals(DamageTypes other)
+ {
+
+ if (!other.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ if (other.Id != Id)
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/MagicalLifeAPIStandard/Combat/IArmor.cs b/MagicalLifeAPIStandard/Combat/IArmor.cs
new file mode 100644
index 00000000..2f63c2a9
--- /dev/null
+++ b/MagicalLifeAPIStandard/Combat/IArmor.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MagicalLifeAPI.Combat
+{
+ public interface IArmor
+ {
+ List Resistances { get; }
+
+
+ }
+}
diff --git a/MagicalLifeAPIStandard/Combat/Resistance.cs b/MagicalLifeAPIStandard/Combat/Resistance.cs
new file mode 100644
index 00000000..d549de96
--- /dev/null
+++ b/MagicalLifeAPIStandard/Combat/Resistance.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+
+namespace MagicalLifeAPI.Combat
+{
+ [DebuggerDisplay("DamageType = {DamageTypes} \n DamageAmount = {DamageAmount} ")]
+ public class Resistance : DamageBase
+ {
+ public Resistance() :base()
+ {
+
+ }
+
+ public Resistance(DamageTypes damageTypes, float damageAmount ) :base(damageTypes,damageAmount)
+ {
+
+ }
+ }
+}
diff --git a/MagicalLifeAPIStandard/DataTypes/Attribute/Attribute32.cs b/MagicalLifeAPIStandard/DataTypes/Attribute/Attribute32.cs
index 478f250a..dccd842f 100644
--- a/MagicalLifeAPIStandard/DataTypes/Attribute/Attribute32.cs
+++ b/MagicalLifeAPIStandard/DataTypes/Attribute/Attribute32.cs
@@ -8,6 +8,8 @@ namespace MagicalLifeAPI.DataTypes.Attribute
[ProtoContract]
public class Attribute32
{
+ private static readonly string BaseValueText = "Base Value";
+
///
/// The int value is applied to the value of this attribute, while the is used to determine if the modifier will wear off.
/// The string value is a display message/reason as to why the modifier was applied.
@@ -17,7 +19,7 @@ public class Attribute32
public Attribute32(Int32 value) : this()
{
- this.AddModifier(new Modifier32(value, new NeverRemoveCondition(), "Base value"));
+ this.Modifiers.Add(new Modifier32(value, new NeverRemoveCondition(), BaseValueText));
}
public Attribute32()
@@ -43,6 +45,11 @@ public void AddModifier(Modifier32 modifier)
this.Modifiers.Add(modifier);
}
+ public void AddModifiers(IList modifiers)
+ {
+ this.Modifiers.AddRange(modifiers);
+ }
+
public void WearOff()
{
lock (this.Modifiers)
@@ -70,5 +77,33 @@ public void SetBaseValue(int value)
this.Modifiers.RemoveAt(0);
this.Modifiers.Insert(0, baseValue);
}
+
+ public static Attribute32 operator+ (Attribute32 a, Attribute32 b)
+ {
+ Attribute32 ret = new Attribute32();
+ ret.AddModifiers(a.Modifiers);
+ ret.AddModifiers(b.Modifiers);
+ return ret;
+ }
+
+ public static Attribute32 operator- (Attribute32 a, Attribute32 b)//Write tests, test, then come up with generic solution to combine with the other types of attributes
+ {
+ Attribute32 ret = new Attribute32();
+ ret.AddModifiers(a.Modifiers);
+
+ foreach (Modifier32 item in b.Modifiers)
+ {
+ if (ret.Modifiers.Contains(item))
+ {
+ ret.Modifiers.Remove(item);
+ }
+ else
+ {
+ ret.Modifiers.Add(new Modifier32(item.Value * -1, item.RemoveCondition, "-" + item.Explanation));
+ }
+ }
+
+ return ret;
+ }
}
}
\ No newline at end of file
diff --git a/MagicalLifeAPIStandard/DataTypes/Collection/ProtoArray.cs b/MagicalLifeAPIStandard/DataTypes/Collection/ProtoArray.cs
index 9799337d..28be3d2c 100644
--- a/MagicalLifeAPIStandard/DataTypes/Collection/ProtoArray.cs
+++ b/MagicalLifeAPIStandard/DataTypes/Collection/ProtoArray.cs
@@ -1,4 +1,6 @@
-using System.Collections;
+using System;
+using System.Collections;
+using System.Collections.Generic;
namespace MagicalLifeAPI.DataTypes
{
@@ -6,7 +8,7 @@ namespace MagicalLifeAPI.DataTypes
/// An 2D array that should have the basic functions of a normal 2D array, but must be compatible with Protobuf-net.
///
[ProtoBuf.ProtoContract(IgnoreListHandling = true)]
- public class ProtoArray
+ public class ProtoArray : ICollection, ICollection
{
///
/// The width of this array.
@@ -26,6 +28,14 @@ public class ProtoArray
[ProtoBuf.ProtoMember(3)]
public T[] Data { get; set; }
+ public int Count => Data.Length;
+
+ public bool IsReadOnly => Data.IsReadOnly;
+
+ public bool IsSynchronized => Data.IsSynchronized;
+
+ public object SyncRoot => Data.SyncRoot;
+
public ProtoArray(int width, int height)
{
this.Width = width;
@@ -61,5 +71,86 @@ public IEnumerator GetEnumerator()
{
return this.Data.GetEnumerator();
}
+
+ ///
+ /// Adds an item to the .
+ ///
+ /// The object to add to the .
+ public void Add(T item)
+ {
+ Data[Data.Length - 1] = item;
+ }
+
+ ///
+ /// Removes all items from the .
+ ///
+ public void Clear()
+ {
+ Data = new T[Data.Length];
+ }
+
+ ///
+ /// Determines whether the contains a specific value.
+ ///
+ /// The object to locate in the .
+ ///
+ /// true if item is found in the ; otherwise, false.
+ ///
+ public bool Contains(T item)
+ {
+ foreach(T element in Data)
+ {
+ if(item.Equals(element))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void CopyTo(T[] array, int arrayIndex)
+ {
+ Data.CopyTo(array, arrayIndex);
+ }
+
+ ///
+ /// Removes the first occurrence of a specific object from the .
+ ///
+ /// The object to remove from the .
+ ///
+ /// true if item was successfully removed from the ; otherwise, false. This method also returns false if item is not found in the original .
+ ///
+ public bool Remove(T item)
+ {
+ if(!Contains(item))
+ {
+ return false;
+ }
+ else
+ {
+ for( int i = 0; i < Data.Length; i++)
+ {
+ if(Data[i].Equals(item))
+ {
+ Data[i] = default;
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ foreach(T item in Data)
+ {
+ yield return item;
+ }
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ Data.CopyTo(array, index);
+ }
}
}
\ No newline at end of file
diff --git a/MagicalLifeAPIStandard/DataTypes/Collection/ProtoQueue.cs b/MagicalLifeAPIStandard/DataTypes/Collection/ProtoQueue.cs
index 917f6388..2f969667 100644
--- a/MagicalLifeAPIStandard/DataTypes/Collection/ProtoQueue.cs
+++ b/MagicalLifeAPIStandard/DataTypes/Collection/ProtoQueue.cs
@@ -9,7 +9,7 @@ namespace MagicalLifeAPI.DataTypes
/// A protobuf-net compatible FIFO (first in first out) Queue class
///
[ProtoContract]
- public class ProtoQueue : ICollection
+ public class ProtoQueue : ICollection, ICollection
{
[ProtoMember(1)]
internal List Data = new List();
@@ -30,6 +30,10 @@ public int Count
///
public bool IsReadOnly => false;
+ public bool IsSynchronized => ((ICollection)Data).IsSynchronized;
+
+ public object SyncRoot => ((ICollection)Data).SyncRoot;
+
///
/// Returns an enumerator that iterates through the collection.
///
@@ -161,5 +165,10 @@ public bool Remove(T item)
{
throw new NotSupportedException();
}
+
+ public void CopyTo(Array array, int index)
+ {
+ ((ICollection)Data).CopyTo(array, index);
+ }
}
}
\ No newline at end of file
diff --git a/MagicalLifeAPIStandard/DataTypes/R-Tree/RTree.cs b/MagicalLifeAPIStandard/DataTypes/R-Tree/RTree.cs
index 52f2b5de..02df8fcf 100644
--- a/MagicalLifeAPIStandard/DataTypes/R-Tree/RTree.cs
+++ b/MagicalLifeAPIStandard/DataTypes/R-Tree/RTree.cs
@@ -20,6 +20,7 @@
// Ported to C# By Dror Gluska, April 9th, 2009
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
@@ -568,8 +569,7 @@ private Node SplitNode(Node n, Rectangle newRect, int newId)
Array.Copy(initialEntryStatus, 0, entryStatus, 0, maxNodeEntries);
- Node newNode = null;
- newNode = new Node(getNextNodeId(), n.level, maxNodeEntries);
+ Node newNode = new Node(getNextNodeId(), n.level, maxNodeEntries);
nodeMap.Add(newNode.nodeId, newNode);
PickSeeds(n, newRect, newId, newNode); // this also sets the entryCount to 1
@@ -1149,6 +1149,8 @@ private Rectangle CalculateMBR(Node n)
return mbr;
}
+
+
public int Count
{
get
diff --git a/MagicalLifeAPIStandard/MagicalLifeAPIStandard.csproj b/MagicalLifeAPIStandard/MagicalLifeAPIStandard.csproj
index b64641b5..7c3ecef0 100644
--- a/MagicalLifeAPIStandard/MagicalLifeAPIStandard.csproj
+++ b/MagicalLifeAPIStandard/MagicalLifeAPIStandard.csproj
@@ -53,6 +53,7 @@
+
@@ -70,4 +71,7 @@
+
+
+
\ No newline at end of file
diff --git a/MagicalLifeAPIStandard/Properties/Lang.Designer.cs b/MagicalLifeAPIStandard/Properties/Lang.Designer.cs
index ca378168..cea1ea32 100644
--- a/MagicalLifeAPIStandard/Properties/Lang.Designer.cs
+++ b/MagicalLifeAPIStandard/Properties/Lang.Designer.cs
@@ -60,6 +60,15 @@ internal Lang() {
}
}
+ ///
+ /// Looks up a localized string similar to Crushing.
+ ///
+ internal static string Crushing {
+ get {
+ return ResourceManager.GetString("Crushing", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Dirt.
///
@@ -69,6 +78,15 @@ public static string Dirt {
}
}
+ ///
+ /// Looks up a localized string similar to Fire.
+ ///
+ internal static string Fire {
+ get {
+ return ResourceManager.GetString("Fire", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Grass.
///
@@ -114,6 +132,15 @@ public static string Log {
}
}
+ ///
+ /// Looks up a localized string similar to Magic.
+ ///
+ internal static string Magic {
+ get {
+ return ResourceManager.GetString("Magic", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Maple Tree.
///
@@ -141,6 +168,15 @@ public static string OakTree {
}
}
+ ///
+ /// Looks up a localized string similar to Piercing.
+ ///
+ internal static string Piercing {
+ get {
+ return ResourceManager.GetString("Piercing", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Pine Tree.
///
@@ -150,6 +186,15 @@ public static string PineTree {
}
}
+ ///
+ /// Looks up a localized string similar to Poison.
+ ///
+ internal static string Poison {
+ get {
+ return ResourceManager.GetString("Poison", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Stone.
///
diff --git a/MagicalLifeAPIStandard/Properties/Lang.resx b/MagicalLifeAPIStandard/Properties/Lang.resx
index effc3bb6..d963a056 100644
--- a/MagicalLifeAPIStandard/Properties/Lang.resx
+++ b/MagicalLifeAPIStandard/Properties/Lang.resx
@@ -117,9 +117,15 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ Crushing
+
Dirt
+
+ Fire
+
Grass
@@ -135,6 +141,9 @@
Log
+
+ Magic
+
Maple Tree
@@ -144,9 +153,15 @@
Oak Tree
+
+ Piercing
+
Pine Tree
+
+ Poison
+
Stone
diff --git a/MagicalLifeAPITest/.refsignored b/MagicalLifeAPITest/.refsignored
deleted file mode 100644
index e69de29b..00000000
diff --git a/MagicalLifeAPITest/Combat/ResistancesTest.cs b/MagicalLifeAPITest/Combat/ResistancesTest.cs
new file mode 100644
index 00000000..fbc48e39
--- /dev/null
+++ b/MagicalLifeAPITest/Combat/ResistancesTest.cs
@@ -0,0 +1,43 @@
+using MagicalLifeAPI.Combat;
+using MagicalLifeAPI.DataTypes.Attribute;
+using MagicalLifeAPI.Entity;
+using MagicalLifeAPI.Entity.Humanoid;
+using MagicalLifeAPI.Entity.Util.Modifier;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace MagicalLifeAPITest.Combat
+{
+ public class ResistancesTest
+ {
+ [Fact]
+ public void CanSubtractDamage()
+ {
+ Resistance resistance = new Resistance(DamageTypes.Fire, 20);
+ Damage damage = new Damage(DamageTypes.Fire, 30);
+
+ Damage expectedDamage = new Damage(DamageTypes.Fire, 10);
+
+ Assert.Equal(expectedDamage, damage - resistance);
+
+ }
+
+ [Fact]
+ public void CanRemoveHealth()
+ {
+ Living living = new Human();
+ living.Health.SetBaseValue(50);
+
+ Damage damage = new Damage(DamageTypes.Fire, 30);
+
+
+ //living.Health
+
+ //Assert.Equal(living.Health,0);
+ }
+ }
+}
diff --git a/MagicalLifeAPITest/Components/HasComponentsTests.cs b/MagicalLifeAPITest/Components/HasComponentsTests.cs
index f1bc9089..156e940d 100644
--- a/MagicalLifeAPITest/Components/HasComponentsTests.cs
+++ b/MagicalLifeAPITest/Components/HasComponentsTests.cs
@@ -7,18 +7,18 @@
using MagicalLifeAPI.Load;
using MagicalLifeAPI.Networking.Serialization;
using MagicalLifeAPI.World.Base;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
using System.Collections.Generic;
+using Xunit;
namespace MagicalLifeAPITest.Components
{
- [TestClass]
- public class HasComponentsTests
+ public class HasComponentsTests : IDisposable
{
private bool Initialized { get; set; }
- [TestInitialize]
- public void TestInitialize()
+
+ public HasComponentsTests()
{
if (!this.Initialized)
{
@@ -36,11 +36,7 @@ public void TestInitialize()
}
}
- [TestCleanup]
- public void TestCleanup()
- {
- MasterLog.Close();
- }
+
private HasComponents CreateHasComponents()
{
@@ -54,7 +50,7 @@ private HasComponents CreateHasComponents()
return components;
}
- [TestMethod]
+ [Fact]
public void GetExactComponent_StateUnderTest_ExpectedBehavior()
{
// Arrange
@@ -66,12 +62,12 @@ public void GetExactComponent_StateUnderTest_ExpectedBehavior()
DropWhenCompletelyHarvested result3 = unitUnderTest.GetExactComponent();
// Assert
- Assert.IsNotNull(result);
- Assert.IsNull(result2);
- Assert.IsNotNull(result3);
+ Assert.NotNull(result);
+ Assert.Null(result2);
+ Assert.NotNull(result3);
}
- [TestMethod]
+ [Fact]
public void GetComponent_StateUnderTest_ExpectedBehavior()
{
// Arrange
@@ -82,11 +78,11 @@ public void GetComponent_StateUnderTest_ExpectedBehavior()
ComponentHarvestable result2 = unitUnderTest.GetComponent();
// Assert
- Assert.IsNotNull(result);
- Assert.IsNotNull(result2);
+ Assert.NotNull(result);
+ Assert.NotNull(result2);
}
- [TestMethod]
+ [Fact]
public void AddComponent_StateUnderTest_ExpectedBehavior()
{
// Arrange
@@ -98,13 +94,13 @@ public void AddComponent_StateUnderTest_ExpectedBehavior()
unitUnderTest.AddComponent(component);
// Assert
- Assert.IsTrue(unitUnderTest.HasComponent());
- Assert.IsTrue(unitUnderTest.GetExactComponent() != null);
- Assert.IsTrue(unitUnderTest.GetComponent() != null);
- Assert.IsTrue(unitUnderTest.GetComponent() != null);
+ Assert.True(unitUnderTest.HasComponent());
+ Assert.True(unitUnderTest.GetExactComponent() != null);
+ Assert.True(unitUnderTest.GetComponent() != null);
+ Assert.True(unitUnderTest.GetComponent() != null);
}
- [TestMethod]
+ [Fact]
public void HasComponent_StateUnderTest_ExpectedBehavior()
{
// Arrange
@@ -114,10 +110,10 @@ public void HasComponent_StateUnderTest_ExpectedBehavior()
bool result = unitUnderTest.HasComponent();
// Assert
- Assert.IsTrue(result);
+ Assert.True(result);
}
- [TestMethod]
+ [Fact]
public void TestHasComponentSerialization()
{
// Arrange
@@ -126,24 +122,61 @@ public void TestHasComponentSerialization()
// Act
byte[] data = ProtoUtil.Serialize(unitUnderTest);
- Assert.IsNotNull(data, "Serialization failed");
+ Assert.NotNull(data);
HasComponents deserialized = ProtoUtil.Deserialize(data);
// Assert
- Assert.IsNotNull(deserialized, "Deserialization failed");
-
- Assert.IsTrue(unitUnderTest.HasComponent());
- Assert.IsNotNull(unitUnderTest.GetExactComponent());
- Assert.IsNotNull(unitUnderTest.GetComponent());
- Assert.IsNotNull(unitUnderTest.GetComponent());
-
- Assert.IsTrue(deserialized.HasComponent());
- Assert.IsNotNull(deserialized.GetExactComponent());
- Assert.IsNotNull(deserialized.GetComponent());
- Assert.IsNotNull(deserialized.GetComponent());
- Assert.IsNotNull(deserialized.GetExactComponent(), "Components didn't serialize properly");
- Assert.IsNotNull(deserialized.GetExactComponent(), "Components didn't serialize properly");
+ Assert.NotNull(deserialized);
+
+ Assert.True(unitUnderTest.HasComponent());
+ Assert.NotNull(unitUnderTest.GetExactComponent());
+ Assert.NotNull(unitUnderTest.GetComponent());
+ Assert.NotNull(unitUnderTest.GetComponent());
+
+ Assert.True(deserialized.HasComponent());
+ Assert.NotNull(deserialized.GetExactComponent());
+ Assert.NotNull(deserialized.GetComponent());
+ Assert.NotNull(deserialized.GetComponent());
+ Assert.NotNull(deserialized.GetExactComponent());
+ Assert.NotNull(deserialized.GetExactComponent());
+ }
+
+ #region IDisposable Support
+ private bool disposedValue = false; // To detect redundant calls
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!disposedValue)
+ {
+ if (disposing)
+ {
+ MasterLog.Close();
+ // TODO: dispose managed state (managed objects).
+ }
+
+ // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
+ // TODO: set large fields to null.
+
+ disposedValue = true;
+ }
+ }
+
+ // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
+ ~HasComponentsTests()
+ {
+ // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
+ Dispose(false);
+ }
+
+ // This code added to correctly implement the disposable pattern.
+ public void Dispose()
+ {
+ // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
+ Dispose(true);
+ // TODO: uncomment the following line if the finalizer is overridden above.
+ GC.SuppressFinalize(this);
}
+ #endregion
}
}
\ No newline at end of file
diff --git a/MagicalLifeAPITest/DataType/AttributeTest.cs b/MagicalLifeAPITest/DataType/AttributeTest.cs
new file mode 100644
index 00000000..46707d96
--- /dev/null
+++ b/MagicalLifeAPITest/DataType/AttributeTest.cs
@@ -0,0 +1,47 @@
+using MagicalLifeAPI.DataTypes.Attribute;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Xunit;
+
+namespace MagicalLifeAPITest.DataType
+{
+ public class AttributeTest
+ {
+ [Fact]
+ public void TestAttributeAddition()
+ {
+ Attribute32 testAttribute1 = new Attribute32(10);
+ Attribute32 testAttribute2 = new Attribute32(15);
+
+ testAttribute1 += testAttribute2;
+
+ Assert.True(testAttribute1.GetValue() == 25);
+ Assert.True(testAttribute2.GetValue() == 15);
+ }
+
+ [Fact]
+ public void TestAttributeSubtractionBiggerMinusSmaller()
+ {
+ Attribute32 testAttribute1 = new Attribute32(10);
+ Attribute32 testAttribute2 = new Attribute32(15);
+
+ testAttribute2 -= testAttribute1;
+
+ Assert.True(testAttribute2.GetValue() == 5);
+ Assert.True(testAttribute1.GetValue() == 10);
+ }
+
+ [Fact]
+ public void TestAttributeSubtractionSmallerMinusBigger()
+ {
+ Attribute32 testAttribute1 = new Attribute32(10);
+ Attribute32 testAttribute2 = new Attribute32(15);
+
+ testAttribute1 -= testAttribute2;
+
+ Assert.True(testAttribute2.GetValue() == 15);
+ Assert.True(testAttribute1.GetValue() == -5);
+ }
+ }
+}
diff --git a/MagicalLifeAPITest/MagicalLifeAPITest.csproj b/MagicalLifeAPITest/MagicalLifeAPITest.csproj
index cddf7738..c164ffcd 100644
--- a/MagicalLifeAPITest/MagicalLifeAPITest.csproj
+++ b/MagicalLifeAPITest/MagicalLifeAPITest.csproj
@@ -1,127 +1,27 @@
-
-
-
-
+
+
- Debug
- AnyCPU
- {9CA6C7EF-99BC-4066-BB9D-0613E248B91D}
- Library
- Properties
- MagicalLifeAPITest
- MagicalLifeAPITest
- v4.7.1
- 512
- {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 15.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
- $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
- False
- UnitTest
-
-
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- x64
- 7.1
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- 7.1
+ netcoreapp2.1
+
+ false
+
-
- ..\packages\MSTest.TestFramework.1.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll
-
-
- ..\packages\MSTest.TestFramework.1.4.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
-
-
- ..\packages\MonoGame.Framework.WindowsDX.3.7.1.189\lib\net45\MonoGame.Framework.dll
-
-
- ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll
-
-
- ..\packages\protobuf-net.2.4.0\lib\net40\protobuf-net.dll
-
-
- ..\packages\SharpDX.4.2.0\lib\net45\SharpDX.dll
-
-
- ..\packages\SharpDX.Direct2D1.4.2.0\lib\net45\SharpDX.Direct2D1.dll
-
-
- ..\packages\SharpDX.Direct3D11.4.2.0\lib\net45\SharpDX.Direct3D11.dll
-
-
- ..\packages\SharpDX.Direct3D9.4.2.0\lib\net45\SharpDX.Direct3D9.dll
-
-
- ..\packages\SharpDX.DXGI.4.2.0\lib\net45\SharpDX.DXGI.dll
-
-
- ..\packages\SharpDX.Mathematics.4.2.0\lib\net45\SharpDX.Mathematics.dll
-
-
- ..\packages\SharpDX.MediaFoundation.4.2.0\lib\net45\SharpDX.MediaFoundation.dll
-
-
- ..\packages\SharpDX.XAudio2.4.2.0\lib\net45\SharpDX.XAudio2.dll
-
-
- ..\packages\SharpDX.XInput.4.2.0\lib\net45\SharpDX.XInput.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
- {1f068781-8fee-4ac2-a8ae-2251c558cf28}
- MagicalLifeAPIStandard
-
-
- {551af4ec-5ae6-408c-9825-1471b53d4414}
- MagicalLifeServerStandard
-
+
+
+
+
-
-
+
+ System
+
-
-
-
-
-
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
diff --git a/MagicalLifeAPITest/Networking/Serialization/ProtoUtilTests.cs b/MagicalLifeAPITest/Networking/Serialization/ProtoUtilTests.cs
new file mode 100644
index 00000000..bd7ce7ed
--- /dev/null
+++ b/MagicalLifeAPITest/Networking/Serialization/ProtoUtilTests.cs
@@ -0,0 +1,26 @@
+using MagicalLifeServer;
+using Xunit;
+
+namespace MagicalLifeAPITests1.Networking.Serialization
+{
+
+ public class ProtoUtilTests
+ {
+ [Fact]
+ public void TestJobSerialization()
+ {
+ }
+
+
+ private void WorldTest()
+ {
+ //Assert.Fail();//Need to rewrite the world serialization/deserialization test.
+ }
+
+
+ private void Setup()
+ {
+ Server.Load();
+ }
+ }
+}
\ No newline at end of file
diff --git a/MagicalLifeAPITest/Properties/AssemblyInfo.cs b/MagicalLifeAPITest/Properties/AssemblyInfo.cs
index 8d095a3d..2634d8c4 100644
--- a/MagicalLifeAPITest/Properties/AssemblyInfo.cs
+++ b/MagicalLifeAPITest/Properties/AssemblyInfo.cs
@@ -1,17 +1,8 @@
using System.Reflection;
using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("MagicalLifeAPITest")]
[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("MagicalLifeAPITest")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("9ca6c7ef-99bc-4066-bb9d-0613e248b91d")]
-
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
\ No newline at end of file
diff --git a/MagicalLifeAPITest/Util/StaticRandomTests.cs b/MagicalLifeAPITest/Util/StaticRandomTests.cs
index 8774aeec..86d09587 100644
--- a/MagicalLifeAPITest/Util/StaticRandomTests.cs
+++ b/MagicalLifeAPITest/Util/StaticRandomTests.cs
@@ -1,19 +1,13 @@
using MagicalLifeAPI.Util;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
+using Xunit;
namespace MagicalLifeTests.Util
{
- [TestClass]
public class StaticRandomTests
{
- [TestMethod]
- public void RandTest()
- {
- this.TestPositive();
- }
-
- private void TestPositive()
+ [Fact]
+ public void RandTestPositive()
{
double min = 15;
double max = 18;
@@ -22,15 +16,11 @@ private void TestPositive()
{
double result = StaticRandom.Rand(min, max);
- if (result < min || result > max || result < 0)
- {
-#if DEBUG
- Console.WriteLine("Min: " + min.ToString());
- Console.WriteLine("Max: " + max.ToString());
- Console.WriteLine("Result: " + result.ToString());
-#endif
- Assert.Fail("Invalid result: ");
- }
+ Assert.False(result < min);
+
+ Assert.False(result > max);
+
+ Assert.False(result < 0);
min -= .05;
max -= .05;
diff --git a/MagicalLifeAPITest/packages.config b/MagicalLifeAPITest/packages.config
deleted file mode 100644
index a87edd33..00000000
--- a/MagicalLifeAPITest/packages.config
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/MonoLib/MonoLib.csproj b/MonoLib/MonoLib.csproj
new file mode 100644
index 00000000..dbdcea46
--- /dev/null
+++ b/MonoLib/MonoLib.csproj
@@ -0,0 +1,7 @@
+
+
+
+ netstandard2.0
+
+
+
diff --git a/MonoLib/MonoLib/CustomTypes/Enumeration.cs b/MonoLib/MonoLib/CustomTypes/Enumeration.cs
new file mode 100644
index 00000000..54a952f1
--- /dev/null
+++ b/MonoLib/MonoLib/CustomTypes/Enumeration.cs
@@ -0,0 +1,108 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+
+namespace MonoGUI.MonoLib.CustomTypes
+{
+ public abstract class Enumeration : IComparable, IEquatable
+ {
+ public string Name { get; private set; }
+
+ public int Id { get; private set; }
+
+ protected Enumeration(int id, string name)
+ {
+ Id = id;
+ Name = name;
+ }
+
+ public override string ToString() => Name;
+
+ public static IEnumerable GetAll() where T : Enumeration
+ {
+ var fields = typeof(T).GetFields(BindingFlags.Public |
+ BindingFlags.Static |
+ BindingFlags.DeclaredOnly);
+
+ return fields.Select(f => f.GetValue(null)).Cast();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (!(obj is Enumeration otherValue))
+ return false;
+
+ var typeMatches = GetType().Equals(obj.GetType());
+ var valueMatches = Id.Equals(otherValue.Id);
+
+ return typeMatches && valueMatches;
+ }
+
+
+ public int CompareTo(object obj) => Id.CompareTo(((Enumeration)obj).Id);
+
+ public bool Equals(Enumeration other)
+ {
+ return other != null
+ && Name == other.Name
+ && Id == other.Id;
+ }
+
+ public override int GetHashCode()
+ {
+ var hashCode = 1460282102;
+ hashCode = (hashCode * -1521134295) + EqualityComparer.Default.GetHashCode(Name);
+ hashCode = (hashCode * -1521134295) + Id.GetHashCode();
+ return hashCode;
+ }
+
+ public static bool operator ==(Enumeration left, Enumeration right)
+ {
+ if (left is null)
+ {
+ return right is null;
+ }
+
+ return left.Equals(right);
+ }
+
+ public static bool operator !=(Enumeration left, Enumeration right)
+ {
+ return !(left == right);
+ }
+
+ public static bool operator <(Enumeration left, Enumeration right)
+ {
+ return left is null ? !(right is null) : left.CompareTo(right) < 0;
+ }
+
+ public static bool operator <=(Enumeration left, Enumeration right)
+ {
+ return (left is null) || left.CompareTo(right) <= 0;
+ }
+
+ public static bool operator >(Enumeration left, Enumeration right)
+ {
+ return !(left is null) && left.CompareTo(right) > 0;
+ }
+
+ public static bool operator >=(Enumeration left, Enumeration right)
+ {
+ return (left is null) ? (right is null) : left.CompareTo(right) >= 0;
+ }
+
+
+
+
+ //public static Enumeration FromString(string roleString)
+ //{
+ // return new List().Single(r => string.Equals(r.Name, roleString, StringComparison.OrdinalIgnoreCase));
+ //}
+
+ //public abstract
+
+ // Other utility methods ...
+ }
+}