@@ -0,0 +1,54 @@
using ECS_Proto.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using ECS_Proto.Game.GameObjects;
using OpenTK;
using ECS_Proto.Core.Component;

namespace ECS_Proto.Game.Map
{
class MapLoader
{
string Path = "map.txt";
public BaseObject[,] LoadAndParseMap()
{
string[] mapLines = File.ReadAllLines(Path);
BaseObject[,] retBo = new BaseObject[mapLines.Length, mapLines[0].Length];
for (int y = 0; y < mapLines.Length; y++)
{
string line = mapLines[y];
for (int x = 0; x < line.Length; x++)
{
char c = line[x];
retBo[y, x] = GetTile(c, new Vector2(y, x));
}
}

return retBo;
}

private BaseObject GetTile(char c, Vector2 pos)
{
BaseObject retBo = null;

switch (c)
{
case '.':
retBo = new Floor();
break;
case '#':
retBo = new Wall();
break;
case '~':
retBo = new Space();
break;
}
retBo.GetComponent<Transform>().Position = pos;
return retBo;
}
}
}
@@ -0,0 +1,20 @@
using ECS_Proto.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ECS_Proto.Game.Map
{
class MapManager : BaseObject
{
MapLoader mapLoader;
BaseObject[,] map;
public override void Start()
{
mapLoader = new Map.MapLoader();
map = mapLoader.LoadAndParseMap();
}
}
}
@@ -1,5 +1,4 @@
using ECS_Proto.Core;
using ECS_Proto.Game.GameObjects.World;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -11,16 +10,13 @@ namespace ECS_Proto.Game.Player
class PlayerManager : BaseObject
{
PlayerObject Player;
Tree debugTree;
public override void Start()
{
Player = new PlayerObject();
debugTree = new Tree();
}

public override void Update(float delta)
{

}
}
}
@@ -2,7 +2,8 @@
using ECS_Proto.Core.Component;
using ECS_Proto.Core.Injector;
using ECS_Proto.Core.Render;
using ECS_Proto.Game.GameObjects;
using ECS_Proto.Game.Input;
using OpenTK.Input;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -20,18 +21,37 @@ public override void Start()
RenderComp r = this.GetComponent<RenderComp>();
r.Char = '@';
transform = GetComponent<Transform>();
this.Inject();
}

float timer = 0;
public override void Update(float delta)
void OnInject(InputManager input)
{
input.RegisterInput(this, 255);
}

void OnKeyDown(Key k)
{
if (timer <= 1)
timer += delta;
else
switch (k)
{
timer = 0;
transform.Position += new OpenTK.Vector2(1, 0);
case Key.D:
transform.Position += new OpenTK.Vector2(1, 0);
break;
case Key.S:
transform.Position += new OpenTK.Vector2(0, 1);
break;
case Key.Q:
transform.Position += new OpenTK.Vector2(-1, 0);
break;
case Key.Z:
transform.Position += new OpenTK.Vector2(0, -1);
break;
}
}

float timer = 0;
public override void Update(float delta)
{

}
}
}
@@ -0,0 +1,20 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~###########################~~~~~~
~~~~~#...........................#.~~~~
~~~~~#............................#~~~~
~~~~~#............................#~~~~
~~~~~#............................#~~~~
~~~~~#............................#~~~~
~~~~~#............................#~~~~
~~~~~#............................#~~~~
~~~~~#............................#~~~~
~~~~~#............................#~~~~
~~~~~~############################~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~