Skip to content

Commit

Permalink
Merge pull request #13 from SneakyTactician/TileBasedDev
Browse files Browse the repository at this point in the history
Tile based dev
  • Loading branch information
TBye101 authored Apr 13, 2018
2 parents 1cff692 + 6ca1c77 commit 6b142c8
Show file tree
Hide file tree
Showing 60 changed files with 1,019 additions and 458 deletions.
16 changes: 12 additions & 4 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
SneakyTactician <[email protected]>
[Version 0.0.0.6]
### GUI
*Stone is now rendered
### API
*Stone is now generated in world
*Abstracted pathfinding so that we can support any algorithm with a little tweaking/a bridge between how each algorithm stores the path found
*Pathfinding now forbides living creatures from moving on tiles with marble.
### Tweaks
*Ordering a unit now clears previous orders
### Bugs
*

[Version 0.0.0.5]
### GUI
*Living creatures are now being rendered
*Living creatures can now be individually selected and order to a location

#### API
*

### Bugs
*Main menu fails to show when pressing escape (Issue #11)
*Discovered that main menu fails to show when pressing escape (Issue #11)

[Version 0.0.0.4]
### GUI
Expand Down
10 changes: 0 additions & 10 deletions EarthWithMagic.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicalLifeAPI", "MagicalLi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicalLifeSettings", "MagicalLifeSettings\MagicalLifeSettings.csproj", "{76B12B63-DF5D-40FD-8E90-03395095DD71}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicalLifeAPITests", "MagicalLifeAPITests\MagicalLifeAPITests.csproj", "{565125B9-D61B-49B4-9DBB-39CBF2D77882}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MagicalLifeGUIWindows", "MagicalLifeGUIWindows\MagicalLifeGUIWindows.csproj", "{9096A50A-058B-40F4-80A7-3C4D8725B658}"
EndProject
Global
Expand All @@ -41,14 +39,6 @@ Global
{76B12B63-DF5D-40FD-8E90-03395095DD71}.Release|Any CPU.Build.0 = Release|Any CPU
{76B12B63-DF5D-40FD-8E90-03395095DD71}.Release|x86.ActiveCfg = Release|Any CPU
{76B12B63-DF5D-40FD-8E90-03395095DD71}.Release|x86.Build.0 = Release|Any CPU
{565125B9-D61B-49B4-9DBB-39CBF2D77882}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{565125B9-D61B-49B4-9DBB-39CBF2D77882}.Debug|Any CPU.Build.0 = Debug|Any CPU
{565125B9-D61B-49B4-9DBB-39CBF2D77882}.Debug|x86.ActiveCfg = Debug|Any CPU
{565125B9-D61B-49B4-9DBB-39CBF2D77882}.Debug|x86.Build.0 = Debug|Any CPU
{565125B9-D61B-49B4-9DBB-39CBF2D77882}.Release|Any CPU.ActiveCfg = Release|Any CPU
{565125B9-D61B-49B4-9DBB-39CBF2D77882}.Release|Any CPU.Build.0 = Release|Any CPU
{565125B9-D61B-49B4-9DBB-39CBF2D77882}.Release|x86.ActiveCfg = Release|Any CPU
{565125B9-D61B-49B4-9DBB-39CBF2D77882}.Release|x86.Build.0 = Release|Any CPU
{9096A50A-058B-40F4-80A7-3C4D8725B658}.Debug|Any CPU.ActiveCfg = Debug|x86
{9096A50A-058B-40F4-80A7-3C4D8725B658}.Debug|x86.ActiveCfg = Debug|x86
{9096A50A-058B-40F4-80A7-3C4D8725B658}.Debug|x86.Build.0 = Debug|x86
Expand Down
40 changes: 0 additions & 40 deletions MagicalLifeAPI/DataTypes/Point3D.cs

This file was deleted.

7 changes: 4 additions & 3 deletions MagicalLifeAPI/Entities/Entity Factory/HumanFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MagicalLifeAPI.DataTypes;
using MagicalLifeAPI.Entities.Humanoid;
using MagicalLifeAPI.Util;
using Microsoft.Xna.Framework;

namespace MagicalLifeAPI.Entities.Entity_Factory
{
Expand All @@ -22,18 +23,18 @@ public class HumanFactory
/// <summary>
/// The fastest a human could possibly be without starting down a class path.
/// </summary>
private readonly int MaxHumanMovement = 50;
private readonly int MaxHumanMovement = 2;

/// <summary>
/// The slowest a human could possibly be without some significant injuries.
/// </summary>
private readonly int MinHumanMovement = 25;
private readonly int MinHumanMovement = 1;

/// <summary>
/// Returns a fully generated human character.
/// </summary>
/// <returns></returns>
public Human GenerateHuman(Point3D location)
public Human GenerateHuman(Point location)
{
int health = StaticRandom.Rand(this.MinHumanHealthPerLevel, this.MaxHumanHealthPerLevel + 1);
int movement = StaticRandom.Rand(this.MinHumanMovement, this.MaxHumanMovement + 1);
Expand Down
4 changes: 2 additions & 2 deletions MagicalLifeAPI/Entities/Eventing/LivingEventArg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public class LivingEventArg
{
public Living Living { get; set; }

public Point3D Location { get; private set; }
public Microsoft.Xna.Framework.Point Location { get; private set; }

/// <summary>
/// Constructs a <see cref="LivingEventArg"/>.
/// </summary>
/// <param name="living"></param>
public LivingEventArg(Living living, Point3D location)
public LivingEventArg(Living living, Microsoft.Xna.Framework.Point location)
{
this.Living = living;
this.Location = location;
Expand Down
3 changes: 2 additions & 1 deletion MagicalLifeAPI/Entities/Humanoid/Human.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MagicalLifeAPI.DataTypes;
using MagicalLifeAPI.GUI;
using Microsoft.Xna.Framework;

namespace MagicalLifeAPI.Entities.Humanoid
{
Expand All @@ -8,7 +9,7 @@ namespace MagicalLifeAPI.Entities.Humanoid
/// </summary>
public class Human : Living
{
public Human(int health, int movementSpeed, Point3D location) : base(health, movementSpeed, location)
public Human(int health, int movementSpeed, Point location) : base(health, movementSpeed, location)
{
}

Expand Down
9 changes: 5 additions & 4 deletions MagicalLifeAPI/Entities/Living.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using DijkstraAlgorithm.Pathing;
using MagicalLifeAPI.DataTypes;
using MagicalLifeAPI.DataTypes;
using MagicalLifeAPI.Entities.Eventing;
using MagicalLifeAPI.Entities.Movement;
using MagicalLifeAPI.Entities.Util;
using MagicalLifeAPI.GUI;
using MagicalLifeAPI.Pathfinding;
using MagicalLifeAPI.Universal;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;

Expand All @@ -18,7 +19,7 @@ public abstract class Living : Selectable
/// <summary>
/// A queue that holds the queued movement steps up for this living creature.
/// </summary>
public Queue<PathSegment> QueuedMovement { get; set; } = new Queue<PathSegment>();
public Queue<PathLink> QueuedMovement { get; set; } = new Queue<PathLink>();

/// <summary>
/// How many hit points this creature has.
Expand All @@ -45,7 +46,7 @@ public abstract class Living : Selectable
/// </summary>
/// <param name="health"></param>
/// <param name="movementSpeed"></param>
protected Living(int health, int movementSpeed, Point3D location)
protected Living(int health, int movementSpeed, Point location)
{
this.Health = new Util.Attribute(health);
this.MovementSpeed = new Util.Attribute(movementSpeed);
Expand Down
18 changes: 9 additions & 9 deletions MagicalLifeAPI/Entities/Movement/EntityWorldMovement.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using DijkstraAlgorithm.Pathing;
using MagicalLifeAPI.Entities.Util.Modifier_Remove_Conditions;
using MagicalLifeAPI.Entities.Util.Modifier_Remove_Conditions;
using MagicalLifeAPI.Pathfinding;
using MagicalLifeAPI.World;
using System;
using System.Collections.Generic;
Expand All @@ -17,17 +17,17 @@ public static class EntityWorldMovement
/// <param name="entity"></param>
public static void MoveEntity(ref Living entity)
{
Queue<PathSegment> path = entity.QueuedMovement;
Queue<PathLink> path = entity.QueuedMovement;
while (entity.MovementSpeed.GetValue() > 0 && path.Count > 0)
{
PathSegment destination = path.Dequeue();
Tile sourceTile = WorldUtil.GetTileByID(World.World.mainWorld.Tiles, destination.Origin.Id);
Tile destinationTile = WorldUtil.GetTileByID(World.World.mainWorld.Tiles, destination.Destination.Id);
PathLink section = path.Dequeue();
Tile sourceTile = World.World.mainWorld.Tiles[section.Origin.X, section.Origin.Y];
Tile destinationTile = World.World.mainWorld.Tiles[section.Destination.X, section.Destination.Y];
string modifierReason = "Moved onto a " + destinationTile.GetName() + " tile";
entity.MovementSpeed.AddModifier(new Tuple<long, IModifierRemoveCondition, string>(-1 * destinationTile.MovementCost, new TimeRemoveCondition(1), modifierReason));
World.World.mainWorld.Tiles[sourceTile.Location.X, sourceTile.Location.Y, sourceTile.Location.Z].Living = null;
entity.MovementSpeed.AddModifier(new Tuple<Int32, IModifierRemoveCondition, string>(-1 * destinationTile.MovementCost, new TimeRemoveCondition(1), modifierReason));
World.World.mainWorld.Tiles[sourceTile.Location.X, sourceTile.Location.Y].Living = null;
entity.MapLocation = destinationTile.Location;
World.World.mainWorld.Tiles[destinationTile.Location.X, destinationTile.Location.Y, destinationTile.Location.Z].Living = entity;
World.World.mainWorld.Tiles[destinationTile.Location.X, destinationTile.Location.Y].Living = entity;
}
}

Expand Down
Loading

0 comments on commit 6b142c8

Please sign in to comment.