-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from SneakyTactician/TileBasedDev
Tile based dev
- Loading branch information
Showing
26 changed files
with
275 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,18 @@ | ||
SneakyTactician <[email protected]> | ||
|
||
[Version 0.0.0.2] | ||
### Features | ||
*Living creatures are now rendered | ||
|
||
#### API | ||
*Living creatures are now supported | ||
|
||
### Tweaks | ||
* | ||
|
||
### Bugs | ||
* | ||
|
||
[Version 0.0.0.1] | ||
|
||
### Features | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using MagicalLifeAPI.Entities.Humanoid; | ||
using MagicalLifeAPI.Util; | ||
|
||
namespace MagicalLifeAPI.Entities.Entity_Factory | ||
{ | ||
/// <summary> | ||
/// Used to initialize a new human properly. | ||
/// </summary> | ||
public class HumanFactory | ||
{ | ||
/// <summary> | ||
/// The maximum number of hitpoints that a human could get per level. | ||
/// </summary> | ||
private readonly int MaxHumanHealthPerLevel = 10; | ||
|
||
/// <summary> | ||
/// The minimum number of hitpoints that a human could get per level. | ||
/// </summary> | ||
private readonly int MinHumanHealthPerLevel = 2; | ||
|
||
/// <summary> | ||
/// The fastest a human could possibly be without starting down a class path. | ||
/// </summary> | ||
private readonly int MaxHumanMovement = 50; | ||
|
||
/// <summary> | ||
/// The slowest a human could possibly be without some significant injuries. | ||
/// </summary> | ||
private readonly int MinHumanMovement = 25; | ||
|
||
/// <summary> | ||
/// Returns a fully generated human character. | ||
/// </summary> | ||
/// <returns></returns> | ||
public Human GenerateHuman() | ||
{ | ||
int health = StaticRandom.Rand(this.MinHumanHealthPerLevel, this.MaxHumanHealthPerLevel + 1); | ||
int movement = StaticRandom.Rand(this.MinHumanMovement, this.MaxHumanMovement + 1); | ||
|
||
return new Human(health, movement); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace MagicalLifeAPI.Entities.Humanoid | ||
{ | ||
/// <summary> | ||
/// A class that holds logic for control of regular humans. | ||
/// </summary> | ||
public class Human : Living | ||
{ | ||
public Human(int health, int movementSpeed) : base(health, movementSpeed) | ||
{ | ||
} | ||
|
||
public override string GetTextureName() | ||
{ | ||
return "Basic Human.png"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using MagicalLifeAPI.Entities.Util; | ||
using MagicalLifeAPI.Universal; | ||
|
||
namespace MagicalLifeAPI.Entities | ||
{ | ||
/// <summary> | ||
/// All living things inherit from this, and utilize it. | ||
/// </summary> | ||
public abstract class Living : Unique | ||
{ | ||
/// <summary> | ||
/// How many hit points this creature has. | ||
/// </summary> | ||
public Attribute Health { get; set; } | ||
|
||
/// <summary> | ||
/// How fast this creature can move. | ||
/// </summary> | ||
public Attribute MovementSpeed { get; set; } | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Living"/> base class. | ||
/// </summary> | ||
/// <param name="health"></param> | ||
/// <param name="movementSpeed"></param> | ||
public Living(int health, int movementSpeed) | ||
{ | ||
this.Health = new Attribute(health); | ||
this.MovementSpeed = new Attribute(movementSpeed); | ||
} | ||
|
||
/// <summary> | ||
/// Returns the name of the texture. | ||
/// </summary> | ||
/// <returns></returns> | ||
public abstract string GetTextureName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using MagicalLifeAPI.Entities.Util.IModifierRemoveConditions; | ||
using MagicalLifeAPI.Universal; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MagicalLifeAPI.Entities.Util | ||
{ | ||
public class Attribute | ||
{ | ||
public Attribute() | ||
{ | ||
MajorEvents.TurnEnd += this.MajorEvents_TurnEnd; | ||
} | ||
|
||
public Attribute(int value) : this() | ||
{ | ||
this.AddModifier(new Tuple<long, IModifierRemoveCondition, string>(value, new NeverRemoveCondition(), "Base value")); | ||
} | ||
|
||
private void MajorEvents_TurnEnd(object sender, EventArgs e) | ||
{ | ||
List<Tuple<Int64, IModifierRemoveCondition, string>> remove = new List<Tuple<Int64, IModifierRemoveCondition, string>>(); | ||
foreach (Tuple<Int64, IModifierRemoveCondition, string> item in this.Modifiers) | ||
{ | ||
if (item.Item2.WearOff()) | ||
{ | ||
remove.Add(item); | ||
} | ||
} | ||
|
||
foreach (Tuple<Int64, IModifierRemoveCondition, string> item in remove) | ||
{ | ||
this.Modifiers.Remove(item); | ||
} | ||
} | ||
|
||
public Int64 GetValue() | ||
{ | ||
Int64 ret = 0; | ||
foreach (Tuple<Int64, IModifierRemoveCondition, string> item in this.Modifiers) | ||
{ | ||
ret += item.Item1; | ||
} | ||
return ret; | ||
} | ||
|
||
/// <summary> | ||
/// The int value is applied to the value of this attribute, while the <see cref="IModifierRemoveCondition"/> 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. | ||
/// </summary> | ||
public List<Tuple<Int64, IModifierRemoveCondition, string>> Modifiers { get; private set; } = new List<Tuple<Int64, IModifierRemoveCondition, string>>(); | ||
|
||
/// <summary> | ||
/// Adds a modifier to the modifiers list. | ||
/// </summary> | ||
/// <param name="modifier"></param> | ||
public void AddModifier(Tuple<Int64, IModifierRemoveCondition, string> modifier) | ||
{ | ||
this.Modifiers.Add(modifier); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace MagicalLifeAPI.Entities.Util | ||
{ | ||
/// <summary> | ||
/// Utilized to allow for custom events/circumstances to be used to determine when a modifier wears off. | ||
/// </summary> | ||
public interface IModifierRemoveCondition | ||
{ | ||
/// <summary> | ||
/// Returns true if this modifier should be removed from the attribute it is effecting. | ||
/// </summary> | ||
/// <returns></returns> | ||
bool WearOff(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
MagicalLifeAPI/Entities/Util/IModifierRemoveConditions/NeverRemoveCondition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace MagicalLifeAPI.Entities.Util.IModifierRemoveConditions | ||
{ | ||
/// <summary> | ||
/// We shall never remove this modifier. | ||
/// </summary> | ||
public class NeverRemoveCondition : IModifierRemoveCondition | ||
{ | ||
public bool WearOff() | ||
{ | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.