Skip to content

Commit

Permalink
update to v1.0.5
Browse files Browse the repository at this point in the history
add two new map
  • Loading branch information
Yvees committed Jul 12, 2018
1 parent 203d795 commit 86b1223
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 23 deletions.
5 changes: 5 additions & 0 deletions api/CreateGame_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ Content-Type: application/json
}
```

支持的地图列表:
- 小地图: RectSmall
- 中型地图: RectMid
- 大型地图: RectLarge

### 返回结果
Status Code: 200

Expand Down
4 changes: 2 additions & 2 deletions src/monitor/MagCore.Monitor/Modules/ApiReq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace MagCore.Monitor.Modules
{
public static class ApiReq
{
//private static string _url = "http://106.75.33.221:6000/";
private static string _url = "http://localhost:6000/";
private static string _url = "http://106.75.33.221:6000/";
//private static string _url = "http://localhost:6000/";

public static HttpClient CreateReq()
{
Expand Down
2 changes: 1 addition & 1 deletion src/monitor/MagCore.Monitor/Modules/GameLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class GameLoader

internal static Dictionary<int, Player> Players = null;

private static IMapLoader _map = null;
internal static IMapLoader _map = null;
public static void Update()
{
//init a new thread to refresh the game list
Expand Down
6 changes: 3 additions & 3 deletions src/monitor/MagCore.Monitor/Modules/KeyboardHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public static void Update()
var key = keys[0];
if (key >= Keys.D1 && key < (Keys)(Keys.D1 + GameListLoader.Games.Count))
{
ScreenHandler.ChangeSize(10, 10);

var sel = key - Keys.D1;
GameLoader.Load(sel);
}

ScreenHandler.ChangeSize(GameLoader._map.Width, GameLoader._map.Height);
}

}
break;
Expand Down
3 changes: 3 additions & 0 deletions src/monitor/MagCore.Monitor/Modules/Map/IMapLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ public interface IMapLoader
void Draw(SpriteBatch sb, GameTime gt);

Cell Locate(int x, int y);

int Height { get; }
int Width { get; }
}
}
28 changes: 24 additions & 4 deletions src/monitor/MagCore.Monitor/Modules/Map/RectMapLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,26 @@ public class RectMapLoader : IMapLoader

private Color _color = Color.White;

private Position _origin = new Position(0, 0);
//private Position _origin = new Position(0, 0);

public int Height
{
get
{
return Rows.Count;
}
}
public int Width
{
get
{
if (Rows.Count > 0)
return Rows[0].Cells.Count;
else
return 0;
}
}


public RectMapLoader()
{
Expand All @@ -42,8 +61,8 @@ public void SetMapData(dynamic data)
count++;
}

_origin.X = (Global.Graphics.PreferredBackBufferWidth - (Rows[0].Count * 16)) / 2;
_origin.Y = (Global.Graphics.PreferredBackBufferHeight - (Rows.Count * 16)) / 2;
//_origin.X = (Global.Graphics.PreferredBackBufferWidth - (Rows[0].Count * 16)) / 2;
//_origin.Y = (Global.Graphics.PreferredBackBufferHeight - (Rows.Count * 16)) / 2;
}

public void LoadContent(ContentManager content)
Expand All @@ -66,7 +85,8 @@ public void Draw(SpriteBatch sb, GameTime gt)
for (int j = 0; j < row.Count; j++)
{
Cell cell = row.Cells[j];
Rectangle rect = new Rectangle(j * 16 + _origin.X, i * 16 + _origin.Y, 16, 16);
//Rectangle rect = new Rectangle(j * 16 + _origin.X, i * 16 + _origin.Y, 16, 16);
Rectangle rect = new Rectangle(j * 16, i * 16, 16, 16);
switch (cell.Type)
{
case 0:
Expand Down
4 changes: 2 additions & 2 deletions src/monitor/MagCore.Monitor/Modules/ScreenHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public static void Reset()

public static void ChangeSize(int col, int row)
{
Global.Graphics.PreferredBackBufferWidth = col * 16 + 2;
Global.Graphics.PreferredBackBufferHeight = row * 16 + 2;
Global.Graphics.PreferredBackBufferWidth = col * 16;
Global.Graphics.PreferredBackBufferHeight = row * 16;
Global.Graphics.ApplyChanges();
}
}
Expand Down
23 changes: 18 additions & 5 deletions src/sdk/JustRush/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ static void Main(string[] args)
ServerHelper.Initialize("http://106.75.33.221:6000/");
//ServerHelper.Initialize("http://localhost:6000/");

map = MapHelper.GetMap("RectSmall");
game = new Game(map.Rows.Count, map.Rows[0].Count);

Player:
Console.WriteLine("Enter nickname:");
input = Console.ReadLine();
Expand All @@ -38,11 +35,17 @@ static void Main(string[] args)
}

string gameId = string.Empty;
string mapName = string.Empty;
Console.WriteLine("1: Create a new game");
Console.WriteLine("2: Join a game");
input = Console.ReadLine();
if (input == "1")
{
map = MapHelper.GetMap("RectSmall");
game = new Game(map.Rows.Count, map.Rows[0].Count);
gameId = GameHelper.CreateGame("RectSmall");

}
else
{
Console.WriteLine("Game list:");
Expand All @@ -57,15 +60,24 @@ static void Main(string[] args)
{
for (int i = 0; i < list.Length; i++)
{
Console.WriteLine(i.ToString() + " : " + list[i]);
if (list[i].state == 0)
{
Console.WriteLine("{0} : {1} 地图:{2}", i, list[i].id.ToString(), list[i].map.ToString());
}

}
}
Console.WriteLine("Select a game to join:");
input = Console.ReadLine();
if (Int32.TryParse(input.Trim(), out int sel)
&& sel >= 0 && sel < list.Length)
{
gameId = list[sel];
gameId = list[sel].id.ToString();
mapName = list[sel].map.ToString();

map = MapHelper.GetMap(mapName);
game = new Game(map.Rows.Count, map.Rows[0].Count);

}
else
{
Expand All @@ -74,6 +86,7 @@ static void Main(string[] args)
}
}


game.Id = gameId;

if (!GameHelper.JoinGame(gameId, self.Id))
Expand Down
9 changes: 3 additions & 6 deletions src/sdk/MagCore.Sdk/Helper/GameHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,18 @@ public static bool GetGame(string gameId, ref Game game)
return false;
}

public static string[] GameList()
public static dynamic[] GameList()
{
var code = ApiReq.CreateReq()
.WithMethod("api/game", "get")
.GetResult(out string json);
if (code == System.Net.HttpStatusCode.OK)
{
var result = DynamicJson.Parse(json);
List<string> games = new List<string>();
List<dynamic> games = new List<dynamic>();
foreach (var item in result)
{
if ((int)item.state == 0)
{
games.Add(item.id.ToString());
}
games.Add(item);
}

return games.ToArray();
Expand Down
6 changes: 6 additions & 0 deletions src/server/MagCore.Server/MagCore.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
</ItemGroup>

<ItemGroup>
<None Update="Maps\RectLarge.map">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Maps\RectMid.map">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Maps\RectSmall.map">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
53 changes: 53 additions & 0 deletions src/server/MagCore.Server/Maps/RectLarge.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
E=4
S=0
D=0
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111
33 changes: 33 additions & 0 deletions src/server/MagCore.Server/Maps/RectMid.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
E=4
S=0
D=0
111111111111111111111111111111
100011111111111111111111110001
101111111111111111111111111101
101001111111111111111111100101
111011111111111111111111110111
111110111111111111111111011111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111110111111111111111111011111
111011111111111111111111110111
101001111111111111111111100101
101111111111111111111111111101
100011111111111111111111110001
111111111111111111111111111111

0 comments on commit 86b1223

Please sign in to comment.