diff --git a/ZoFo/Content/Content.mgcb b/ZoFo/Content/Content.mgcb
index 00506e5..e47b105 100644
--- a/ZoFo/Content/Content.mgcb
+++ b/ZoFo/Content/Content.mgcb
@@ -34,6 +34,15 @@
/processorParam:TextureFormat=Compressed
/build:Fonts/Font3.spritefont
+#begin MapData/TileMaps/main.tmj
+/copy:MapData/TileMaps/main.tmj
+
+#begin MapData/TileMaps/main.tmx
+/copy:MapData/TileMaps/main.tmx
+
+#begin MapData/TileSets/TileSet 1.tsj
+/copy:MapData/TileSets/TileSet 1.tsj
+
#begin sounds/Loot.wav
/importer:WavImporter
/processor:SoundEffectProcessor
diff --git a/ZoFo/Content/MapData/TileMaps/main.tmj b/ZoFo/Content/MapData/TileMaps/main.tmj
new file mode 100644
index 0000000..ae7c346
--- /dev/null
+++ b/ZoFo/Content/MapData/TileMaps/main.tmj
@@ -0,0 +1,167 @@
+{ "compressionlevel":-1,
+ "height":20,
+ "infinite":true,
+ "layers":[
+ {
+ "chunks":[
+ {
+ "data":[24, 24, 24, 28, 29, 24, 24, 24, 28, 46, 29, 24, 25, 115, 45, 46,
+ 24, 24, 24, 25, 23, 24, 24, 24, 50, 2, 51, 24, 50, 2, 2, 2,
+ 24, 24, 24, 50, 32, 29, 24, 24, 24, 24, 24, 24, 24, 24, 24, 28,
+ 28, 29, 24, 28, 10, 32, 29, 24, 24, 28, 46, 29, 24, 24, 24, 50,
+ 47, 23, 24, 50, 32, 10, 32, 46, 29, 50, 2, 51, 24, 24, 24, 24,
+ 1, 32, 29, 90, 25, 23, 50, 2, 32, 29, 24, 90, 28, 29, 24, 24,
+ 51, 50, 32, 29, 50, 51, 90, 24, 25, 45, 46, 29, 25, 23, 24, 90,
+ 24, 24, 50, 32, 46, 29, 24, 28, 10, 2, 2, 51, 50, 51, 24, 90,
+ 24, 24, 24, 50, 2, 32, 46, 10, 32, 29, 24, 90, 24, 24, 24, 90,
+ 29, 24, 89, 24, 24, 50, 3, 23, 50, 32, 46, 46, 46, 46, 29, 24,
+ 51, 24, 24, 28, 29, 24, 25, 23, 24, 25, 1, 2, 3, 111, 45, 29,
+ 24, 90, 24, 50, 51, 24, 25, 23, 28, 47, 23, 89, 50, 3, 115, 23,
+ 24, 24, 24, 24, 24, 89, 50, 32, 47, 1, 51, 24, 24, 50, 2, 51,
+ 28, 29, 24, 24, 24, 24, 28, 10, 2, 51, 24, 24, 24, 24, 24, 28,
+ 10, 32, 29, 24, 24, 24, 25, 23, 28, 29, 90, 24, 24, 90, 24, 50,
+ 32, 10, 51, 24, 24, 24, 50, 32, 10, 32, 29, 24, 90, 28, 29, 24],
+ "height":16,
+ "width":16,
+ "x":-16,
+ "y":-16
+ },
+ {
+ "data":[10, 51, 24, 90, 24, 25, 23, 28, 29, 24, 24, 24, 24, 24, 24, 24,
+ 51, 24, 28, 29, 24, 50, 32, 10, 51, 24, 24, 24, 24, 24, 24, 24,
+ 29, 28, 10, 32, 46, 29, 50, 32, 29, 24, 24, 24, 24, 24, 24, 24,
+ 51, 25, 23, 50, 2, 32, 29, 25, 23, 24, 24, 28, 29, 24, 90, 24,
+ 24, 25, 23, 24, 24, 25, 23, 50, 51, 24, 24, 50, 32, 29, 24, 90,
+ 24, 50, 32, 29, 90, 25, 45, 29, 24, 24, 24, 24, 50, 51, 24, 89,
+ 24, 89, 50, 51, 24, 25, 114, 23, 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 28, 29, 24, 50, 2, 51, 24, 24, 90, 28, 29, 24, 24, 28,
+ 24, 24, 25, 23, 89, 24, 24, 24, 28, 46, 29, 25, 23, 24, 24, 50,
+ 28, 46, 10, 51, 24, 28, 46, 29, 25, 111, 45, 10, 51, 28, 29, 24,
+ 50, 2, 51, 24, 24, 25, 115, 45, 10, 3, 1, 51, 24, 25, 23, 24,
+ 24, 24, 24, 24, 24, 50, 2, 2, 32, 10, 51, 24, 90, 25, 23, 24,
+ 24, 24, 24, 24, 24, 24, 24, 24, 50, 51, 24, 24, 24, 25, 23, 24,
+ 46, 29, 24, 24, 24, 24, 24, 89, 24, 24, 24, 28, 46, 47, 23, 90,
+ 2, 32, 29, 24, 24, 28, 46, 46, 29, 24, 24, 25, 1, 3, 23, 89,
+ 24, 50, 32, 29, 24, 25, 1, 3, 23, 24, 89, 50, 32, 10, 51, 24],
+ "height":16,
+ "width":16,
+ "x":0,
+ "y":-16
+ },
+ {
+ "data":[24, 24, 24, 24, 90, 24, 89, 24, 89, 24, 50, 51, 89, 24, 24, 24,
+ 24, 28, 29, 28, 29, 24, 24, 24, 24, 28, 29, 24, 24, 24, 28, 29,
+ 24, 25, 23, 50, 51, 24, 24, 28, 29, 50, 51, 24, 24, 24, 25, 45,
+ 90, 50, 51, 28, 29, 24, 24, 25, 23, 24, 24, 28, 29, 24, 50, 3,
+ 24, 24, 28, 10, 51, 90, 90, 50, 51, 24, 24, 50, 51, 24, 24, 50,
+ 24, 24, 25, 45, 29, 24, 28, 29, 24, 24, 24, 24, 24, 28, 29, 24,
+ 90, 24, 50, 2, 51, 28, 10, 51, 90, 24, 28, 29, 24, 25, 45, 46,
+ 29, 90, 24, 24, 24, 50, 51, 24, 24, 28, 10, 32, 46, 10, 3, 1,
+ 32, 29, 24, 90, 24, 24, 24, 24, 28, 47, 23, 50, 2, 51, 50, 51,
+ 25, 23, 24, 24, 28, 46, 46, 46, 47, 114, 45, 29, 24, 24, 24, 24,
+ 50, 32, 29, 24, 50, 3, 111, 111, 115, 111, 1, 32, 29, 24, 24, 24,
+ 24, 50, 51, 24, 28, 10, 2, 2, 2, 2, 32, 10, 51, 24, 24, 89,
+ 24, 24, 89, 90, 25, 23, 24, 24, 24, 24, 50, 32, 46, 46, 29, 89,
+ 24, 24, 24, 90, 25, 23, 89, 24, 28, 29, 90, 50, 2, 2, 51, 24,
+ 24, 24, 24, 28, 10, 51, 24, 28, 47, 45, 29, 24, 24, 24, 24, 24,
+ 24, 24, 24, 25, 23, 24, 90, 50, 2, 2, 32, 46, 46, 46, 46, 46],
+ "height":16,
+ "width":16,
+ "x":16,
+ "y":-16
+ },
+ {
+ "data":[10, 32, 46, 29, 24, 24, 24, 25, 23, 50, 32, 29, 24, 50, 32, 46,
+ 51, 50, 2, 32, 29, 24, 24, 25, 45, 29, 25, 23, 24, 24, 25, 1,
+ 24, 24, 24, 25, 23, 28, 46, 10, 2, 51, 50, 51, 24, 24, 50, 51,
+ 90, 89, 90, 50, 51, 50, 2, 51, 24, 24, 28, 29, 90, 24, 24, 24,
+ 90, 28, 46, 29, 90, 24, 24, 24, 90, 24, 50, 51, 90, 24, 90, 28,
+ 29, 50, 2, 51, 24, 24, 24, 89, 24, 24, 24, 24, 24, 89, 24, 50,
+ 23, 24, 24, 28, 46, 29, 90, 90, 24, 89, 24, 28, 29, 24, 24, 24,
+ 32, 46, 29, 25, 115, 45, 29, 24, 90, 24, 24, 25, 23, 24, 24, 28,
+ 10, 2, 32, 47, 115, 1, 51, 24, 24, 24, 24, 25, 23, 24, 28, 10,
+ 32, 29, 50, 2, 2, 51, 24, 24, 24, 24, 24, 25, 23, 28, 10, 51,
+ 50, 51, 89, 24, 24, 89, 24, 28, 29, 24, 24, 50, 32, 10, 32, 46,
+ 24, 24, 90, 90, 28, 46, 29, 50, 51, 24, 24, 24, 25, 23, 25, 115,
+ 24, 90, 24, 24, 50, 2, 32, 29, 24, 24, 90, 24, 25, 45, 10, 2,
+ 24, 24, 24, 24, 24, 24, 50, 32, 29, 24, 24, 28, 10, 3, 23, 24,
+ 90, 24, 24, 24, 24, 89, 90, 50, 32, 29, 90, 50, 51, 50, 32, 46,
+ 46, 29, 24, 90, 24, 24, 24, 24, 50, 51, 28, 29, 24, 24, 50, 2],
+ "height":16,
+ "width":16,
+ "x":-16,
+ "y":0
+ },
+ {
+ "data":[46, 46, 10, 32, 46, 47, 23, 25, 23, 89, 24, 24, 25, 23, 90, 24,
+ 2, 2, 32, 47, 1, 2, 51, 25, 23, 24, 28, 29, 50, 32, 29, 24,
+ 24, 90, 50, 3, 23, 24, 28, 10, 51, 28, 47, 45, 29, 25, 23, 28,
+ 24, 24, 24, 50, 51, 28, 47, 23, 24, 50, 3, 114, 45, 10, 51, 50,
+ 29, 24, 24, 89, 24, 25, 114, 45, 46, 46, 10, 2, 2, 32, 29, 89,
+ 51, 24, 24, 24, 24, 50, 3, 111, 115, 115, 23, 24, 24, 50, 32, 29,
+ 24, 28, 29, 24, 24, 24, 25, 1, 2, 2, 51, 90, 24, 90, 50, 51,
+ 29, 50, 32, 29, 28, 29, 25, 23, 24, 24, 89, 28, 29, 24, 24, 24,
+ 51, 24, 50, 51, 50, 32, 10, 32, 46, 29, 24, 50, 51, 24, 90, 24,
+ 24, 24, 24, 24, 89, 50, 32, 10, 2, 32, 46, 29, 89, 28, 29, 24,
+ 29, 90, 24, 24, 24, 24, 50, 51, 28, 10, 3, 23, 28, 10, 51, 24,
+ 23, 89, 24, 24, 90, 24, 24, 24, 50, 32, 10, 51, 50, 51, 24, 24,
+ 51, 24, 24, 24, 24, 24, 24, 24, 24, 50, 32, 46, 46, 29, 28, 46,
+ 24, 24, 24, 90, 24, 24, 24, 24, 24, 24, 50, 3, 1, 32, 47, 115,
+ 46, 29, 24, 89, 24, 24, 24, 89, 24, 24, 24, 25, 45, 10, 3, 111,
+ 2, 51, 28, 29, 28, 29, 24, 28, 46, 46, 46, 10, 2, 51, 50, 2],
+ "height":16,
+ "width":16,
+ "x":0,
+ "y":0
+ },
+ {
+ "data":[28, 29, 28, 10, 32, 46, 29, 24, 24, 28, 10, 2, 2, 2, 2, 2,
+ 50, 51, 50, 51, 25, 115, 45, 46, 29, 50, 51, 24, 24, 24, 24, 24,
+ 29, 24, 89, 24, 50, 3, 115, 114, 23, 24, 24, 24, 24, 24, 24, 24,
+ 51, 90, 24, 89, 24, 50, 2, 2, 51, 24, 89, 24, 24, 28, 46, 29,
+ 24, 90, 24, 24, 89, 24, 90, 28, 29, 24, 24, 24, 28, 10, 2, 51,
+ 24, 24, 24, 24, 28, 29, 90, 50, 51, 28, 29, 24, 25, 23, 24, 24,
+ 28, 29, 24, 24, 50, 32, 29, 28, 29, 50, 51, 89, 50, 32, 29, 24,
+ 50, 51, 24, 24, 24, 50, 32, 10, 51, 24, 89, 24, 24, 25, 23, 24,
+ 24, 24, 24, 24, 24, 24, 50, 32, 29, 24, 24, 24, 24, 50, 51, 24,
+ 90, 24, 24, 24, 24, 24, 24, 25, 45, 29, 24, 24, 24, 89, 28, 29,
+ 24, 24, 24, 24, 28, 29, 24, 25, 1, 51, 24, 24, 24, 24, 50, 32,
+ 28, 29, 28, 29, 50, 32, 46, 10, 51, 28, 29, 24, 24, 24, 24, 50,
+ 47, 45, 10, 51, 24, 50, 2, 32, 46, 47, 23, 24, 89, 90, 24, 24,
+ 111, 115, 23, 24, 24, 90, 24, 50, 2, 2, 32, 29, 24, 89, 28, 46,
+ 1, 2, 51, 28, 46, 46, 29, 24, 28, 29, 50, 32, 29, 28, 47, 111,
+ 51, 24, 24, 50, 3, 114, 23, 24, 50, 32, 46, 47, 23, 25, 111, 111],
+ "height":16,
+ "width":16,
+ "x":16,
+ "y":0
+ }],
+ "class":"Tile",
+ "height":48,
+ "id":1,
+ "name":"\u0421\u043b\u043e\u0439 \u0442\u0430\u0439\u043b\u043e\u0432 1",
+ "opacity":1,
+ "startx":-16,
+ "starty":-32,
+ "type":"tilelayer",
+ "visible":true,
+ "width":48,
+ "x":0,
+ "y":0
+ }],
+ "nextlayerid":2,
+ "nextobjectid":1,
+ "orientation":"orthogonal",
+ "renderorder":"right-down",
+ "tiledversion":"1.10.2",
+ "tileheight":16,
+ "tilesets":[
+ {
+ "firstgid":1,
+ "source":"TileSets\/TileSet 1.tsj"
+ }],
+ "tilewidth":16,
+ "type":"map",
+ "version":"1.10",
+ "width":30
+}
\ No newline at end of file
diff --git a/ZoFo/Content/MapData/TileMaps/main.tmx b/ZoFo/Content/MapData/TileMaps/main.tmx
new file mode 100644
index 0000000..4cafd72
--- /dev/null
+++ b/ZoFo/Content/MapData/TileMaps/main.tmx
@@ -0,0 +1,116 @@
+
+
diff --git a/ZoFo/Content/MapData/TileSets/TileSet 1.tsj b/ZoFo/Content/MapData/TileSets/TileSet 1.tsj
new file mode 100644
index 0000000..3388a9e
--- /dev/null
+++ b/ZoFo/Content/MapData/TileSets/TileSet 1.tsj
@@ -0,0 +1,166 @@
+{ "class":"Tile",
+ "columns":22,
+ "grid":
+ {
+ "height":24,
+ "orientation":"orthogonal",
+ "width":24
+ },
+ "image":"..\/..\/..\/..\/Content\/Textures\/Background\/TilesetFloor.png",
+ "imageheight":417,
+ "imagewidth":352,
+ "margin":0,
+ "name":"TileSet 1",
+ "spacing":0,
+ "tilecount":572,
+ "tiledversion":"1.10.2",
+ "tileheight":16,
+ "tiles":[
+ {
+ "id":27,
+ "probability":0.5
+ },
+ {
+ "id":28,
+ "probability":0.5
+ },
+ {
+ "id":49,
+ "probability":0.5
+ },
+ {
+ "id":50,
+ "probability":0.5
+ },
+ {
+ "id":88,
+ "probability":0.100000001490116
+ },
+ {
+ "id":89,
+ "probability":0.100000001490116
+ },
+ {
+ "id":110,
+ "probability":2
+ },
+ {
+ "id":111,
+ "probability":0.100000001490116
+ },
+ {
+ "id":112,
+ "probability":0.100000001490116
+ }],
+ "tilewidth":16,
+ "type":"tileset",
+ "version":"1.10",
+ "wangsets":[
+ {
+ "colors":[
+ {
+ "color":"#ff0000",
+ "name":"Sand",
+ "probability":1,
+ "tile":23
+ },
+ {
+ "color":"#00ff00",
+ "name":"SandStone",
+ "probability":0.3,
+ "tile":110
+ }],
+ "name":"\u041f\u0435\u0441\u0447\u0430\u043d\u044b\u0439",
+ "tile":-1,
+ "type":"corner",
+ "wangtiles":[
+ {
+ "tileid":0,
+ "wangid":[0, 2, 0, 1, 0, 2, 0, 2]
+ },
+ {
+ "tileid":1,
+ "wangid":[0, 2, 0, 1, 0, 1, 0, 2]
+ },
+ {
+ "tileid":2,
+ "wangid":[0, 2, 0, 2, 0, 1, 0, 2]
+ },
+ {
+ "tileid":9,
+ "wangid":[0, 2, 0, 1, 0, 2, 0, 1]
+ },
+ {
+ "tileid":22,
+ "wangid":[0, 1, 0, 1, 0, 2, 0, 2]
+ },
+ {
+ "tileid":23,
+ "wangid":[0, 1, 0, 1, 0, 1, 0, 1]
+ },
+ {
+ "tileid":24,
+ "wangid":[0, 2, 0, 2, 0, 1, 0, 1]
+ },
+ {
+ "tileid":27,
+ "wangid":[0, 1, 0, 2, 0, 1, 0, 1]
+ },
+ {
+ "tileid":28,
+ "wangid":[0, 1, 0, 1, 0, 2, 0, 1]
+ },
+ {
+ "tileid":31,
+ "wangid":[0, 1, 0, 2, 0, 1, 0, 2]
+ },
+ {
+ "tileid":44,
+ "wangid":[0, 1, 0, 2, 0, 2, 0, 2]
+ },
+ {
+ "tileid":45,
+ "wangid":[0, 1, 0, 2, 0, 2, 0, 1]
+ },
+ {
+ "tileid":46,
+ "wangid":[0, 2, 0, 2, 0, 2, 0, 1]
+ },
+ {
+ "tileid":49,
+ "wangid":[0, 2, 0, 1, 0, 1, 0, 1]
+ },
+ {
+ "tileid":50,
+ "wangid":[0, 1, 0, 1, 0, 1, 0, 2]
+ },
+ {
+ "tileid":88,
+ "wangid":[0, 1, 0, 1, 0, 1, 0, 1]
+ },
+ {
+ "tileid":89,
+ "wangid":[0, 1, 0, 1, 0, 1, 0, 1]
+ },
+ {
+ "tileid":110,
+ "wangid":[0, 2, 0, 2, 0, 2, 0, 2]
+ },
+ {
+ "tileid":111,
+ "wangid":[0, 2, 0, 2, 0, 2, 0, 2]
+ },
+ {
+ "tileid":112,
+ "wangid":[0, 2, 0, 2, 0, 2, 0, 2]
+ },
+ {
+ "tileid":113,
+ "wangid":[0, 2, 0, 2, 0, 2, 0, 2]
+ },
+ {
+ "tileid":114,
+ "wangid":[0, 2, 0, 2, 0, 2, 0, 2]
+ }]
+ }]
+}
\ No newline at end of file
diff --git a/ZoFo/GameCore/Client.cs b/ZoFo/GameCore/Client.cs
index 85429f1..f96599a 100644
--- a/ZoFo/GameCore/Client.cs
+++ b/ZoFo/GameCore/Client.cs
@@ -9,6 +9,9 @@ using Microsoft.Xna.Framework.Graphics;
using System;
using ZoFo.GameCore.GameObjects;
using ZoFo.GameCore.GameObjects.MapObjects;
+using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
+using ZoFo.GameCore.GameObjects.MapObjects.Tiles;
+using System.Drawing;
namespace ZoFo.GameCore
{
@@ -45,12 +48,36 @@ namespace ZoFo.GameCore
networkManager.JoinRoom(ip);
}
public void JoinYourself() { networkManager.JoinYourself(); }
+
+
+ List mapObjects = new List();
+ ///
+ /// Клиент должен обнговлять игру анимаций
+ ///
+ ///
internal void Update(GameTime gameTime)
{
}
internal void Draw(SpriteBatch spriteBatch)
{
-
+ for (int i = 0; i < mapObjects.Count; i++)
+ {
+ mapObjects[i].Draw(spriteBatch);
+ }
+ }
+
+ internal void GotData(IUpdateData update)
+ {
+ if (update is UpdateTileCreated)
+ {
+ mapObjects.Add(
+ new MapObject(
+ (update as UpdateTileCreated).Position,
+ (update as UpdateTileCreated).Size.ToVector2(),
+ (update as UpdateTileCreated).sourceRectangle,
+ (update as UpdateTileCreated).tileSetName
+ ));
+ }
}
}
}
\ No newline at end of file
diff --git a/ZoFo/GameCore/GameManagers/AppManager.cs b/ZoFo/GameCore/GameManagers/AppManager.cs
index 1eda28b..83f0382 100644
--- a/ZoFo/GameCore/GameManagers/AppManager.cs
+++ b/ZoFo/GameCore/GameManagers/AppManager.cs
@@ -120,6 +120,7 @@ namespace ZoFo.GameCore.GameManagers
currentGUI.Draw(_spriteBatch);
debugHud.Draw(_spriteBatch);
+ _spriteBatch.Begin();
switch (gamestate)
{
case GameState.ClientPlaying:
@@ -130,6 +131,7 @@ namespace ZoFo.GameCore.GameManagers
default:
break;
}
+ _spriteBatch.End();
base.Draw(gameTime);
}
diff --git a/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs b/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs
index a1c7799..fd67cd1 100644
--- a/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs
+++ b/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs
@@ -17,7 +17,7 @@ namespace ZoFo.GameCore.GameManagers.MapManager
public class MapManager
{
- private static readonly string _templatePath = "TileMaps/{0}.tmj";
+ private static readonly string _templatePath = "Content/MapData/TileMaps/{0}.tmj";
private static readonly float _scale = 1.0f;
private List _tileSets = new List();
@@ -38,7 +38,7 @@ namespace ZoFo.GameCore.GameManagers.MapManager
List tileSets = new List();
foreach (TileSetInfo tileSetInfo in tileMap.TileSets)
{
- TileSet tileSet = LoadTileSet(tileSetInfo.Source);
+ TileSet tileSet = LoadTileSet("Content/MapData/"+tileSetInfo.Source);
tileSet.FirstGid = tileSetInfo.FirstGid;
tileSets.Add(tileSet);
}
@@ -55,18 +55,18 @@ namespace ZoFo.GameCore.GameManagers.MapManager
{
int number = chunk.Data[i] - tileSet.FirstGid;
- int relativeColumn = number % tileSet.Columns * tileSet.TileWidth;
- int relativeRow = number / tileSet.Columns * tileSet.TileHeight;
+ int relativeColumn = (number % tileSet.Columns) * tileSet.TileWidth;
+ int relativeRow = (number / tileSet.Columns) * tileSet.TileHeight;
Rectangle sourceRectangle = new Rectangle(relativeColumn * tileSet.TileWidth, relativeRow * tileSet.TileHeight,
- relativeColumn * tileSet.TileWidth + tileSet.TileWidth, relativeRow * tileSet.TileHeight + tileSet.TileHeight);
+ /* relativeColumn * tileSet.TileWidth +*/ tileSet.TileWidth, /*relativeRow * tileSet.TileHeight +*/ tileSet.TileHeight);
- Vector2 position = new Vector2(i % chunk.Width, i / chunk.Height);
+ Vector2 position = new Vector2((i % chunk.Width) * tileSet.TileWidth + chunk.X * chunk.Width, (i / chunk.Height)*tileSet.TileHeight + chunk.Y * chunk.Height) ;
switch (layer.Class)
{
case "Tile":
- new MapObject(position, new Vector2(tileSet.TileWidth * _scale, tileSet.TileHeight * _scale), sourceRectangle, tileSet.Name);
+ AppManager.Instance.server.RegisterGameObject(new MapObject(position, new Vector2(tileSet.TileWidth * _scale, tileSet.TileHeight * _scale), sourceRectangle, "Textures\\TileSets\\"+tileSet.Name)); //fix naming
break;
case "StopObject":
// new StopObject(position, new Vector2(tileSet.TileWidth * _scale, tileSet.TileHeight * _scale), sourceRectangle, tileSet.Name);
diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs
index b4213e7..bb8717a 100644
--- a/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs
+++ b/ZoFo/GameCore/GameManagers/NetworkManager/ServerNetworkManager.cs
@@ -21,7 +21,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
private IPEndPoint endPoint;
private Socket socket;
private List clients;
- private List updates;
+ public List updates;
public delegate void OnDataSend(string data);
public event OnDataSend GetDataSend; // event
Dictionary managerThread;
@@ -48,6 +48,14 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
///
public void SendData()
{
+ for (int i = 0; i < updates.Count; i++)
+ {
+
+ AppManager.Instance.client.GotData(updates[i]);
+ }
+ updates.Clear();
+ return; //TODO TODO REMOVE TO ADD NETWORK TODO REMOVE TO ADD NETWORK TODO REMOVE TO ADD NETWORK TODO REMOVE TO ADD NETWORK
+
string data = JsonSerializer.Serialize(updates);
var databytes = Encoding.UTF8.GetBytes(data);
foreach (var item in clients)
diff --git a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateTileCreated.cs b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateTileCreated.cs
index 796683d..56f9aed 100644
--- a/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateTileCreated.cs
+++ b/ZoFo/GameCore/GameManagers/NetworkManager/Updates/ServerToClient/UpdateTileCreated.cs
@@ -17,5 +17,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
public string UpdateType { get; set; }
public Texture2D TextureTile { get; set; }
public Vector2 Position { get; set; }
+ public Point Size { get; set; }
+ public Rectangle sourceRectangle { get; set; }
+ public string tileSetName { get; set; }
}
}
diff --git a/ZoFo/GameCore/GameObjects/GameObject.cs b/ZoFo/GameCore/GameObjects/GameObject.cs
index 09c1369..6305674 100644
--- a/ZoFo/GameCore/GameObjects/GameObject.cs
+++ b/ZoFo/GameCore/GameObjects/GameObject.cs
@@ -17,7 +17,8 @@ public abstract class GameObject
public GameObject(Vector2 position)
{
this.position = position;
- AppManager.Instance.server.RegisterGameObject(this);
+
+ graphicsComponent.LoadContent();
}
public virtual void UpdateLogic(GameTime gameTime)
{
diff --git a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs
index d2767d9..ae7b8b1 100644
--- a/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs
+++ b/ZoFo/GameCore/GameObjects/MapObjects/MapObject.cs
@@ -6,21 +6,25 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers;
+using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.ZoFo_graphics;
namespace ZoFo.GameCore.GameObjects.MapObjects
{
public class MapObject : GameObject
{
- public virtual bool IsColliderOn { get; protected set; } = true;
- private Rectangle _sourceRectangle;
- public override GraphicsComponent graphicsComponent => new();
+ public virtual bool IsColliderOn { get; protected set; } = true;//Who added that?
+ public Rectangle _sourceRectangle;
+ public override GraphicsComponent graphicsComponent { get; } = new();
public MapObject(Vector2 position, Vector2 size, Rectangle sourceRectangle, string textureName) : base(position)
{
_sourceRectangle = sourceRectangle;
- graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0, (int)size.X, (int)size.Y);
- graphicsComponent.BuildComponent("Textures\\TileSets\\"+textureName);
+ graphicsComponent.ObjectDrawRectangle = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
+ graphicsComponent.BuildComponent(textureName);
+
+ graphicsComponent.LoadContent();
+
}
public override void Draw(SpriteBatch spriteBatch)
{
diff --git a/ZoFo/GameCore/Server.cs b/ZoFo/GameCore/Server.cs
index 143b07a..0d7fc66 100644
--- a/ZoFo/GameCore/Server.cs
+++ b/ZoFo/GameCore/Server.cs
@@ -11,6 +11,7 @@ using ZoFo.GameCore.GameManagers.NetworkManager.Updates;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameObjects;
using ZoFo.GameCore.GameObjects.Entities;
+using ZoFo.GameCore.GameObjects.MapObjects;
namespace ZoFo.GameCore
{
@@ -29,7 +30,8 @@ namespace ZoFo.GameCore
public void OnDataSend(string data)
{
List updateDatas = JsonSerializer.Deserialize>(data);
- for (int i = 0; i < updateDatas.Count; i++) {
+ for (int i = 0; i < updateDatas.Count; i++)
+ {
ProcessIUpdateData(updateDatas[i]);
}
}
@@ -39,7 +41,7 @@ namespace ZoFo.GameCore
///
public void ProcessIUpdateData(IUpdateData updateData)
{
-
+
//ТУТ Switch case будет честное слово
}
@@ -57,7 +59,7 @@ namespace ZoFo.GameCore
/// Создает комнату и запускает ожидание подключений
///
///
- public void CreateRoom(int players)
+ public void CreateRoom(int players)
{
networkManager.Start(players);
}
@@ -65,7 +67,8 @@ namespace ZoFo.GameCore
///
/// Запуск игры в комнате
///
- public void StartGame() {
+ public void StartGame()
+ {
//TODO начинает рассылку и обмен пакетами игры
//Грузит карту
@@ -73,7 +76,7 @@ namespace ZoFo.GameCore
gameObjects = new List();
entities = new List();
new MapManager().LoadMap();
- }
+ }
///
/// Добавляет UpdateGameEnded и отключает игроков
@@ -87,7 +90,7 @@ namespace ZoFo.GameCore
#endregion
private List gameObjects;
private List entities; //entity
- public void Update(GameTime gameTime)
+ public void Update(GameTime gameTime)
{
if (ticks == 3) //ОБРАБАТЫВАЕТСЯ 20 РАЗ В СЕКУНДУ
{
@@ -101,7 +104,7 @@ namespace ZoFo.GameCore
ticks++;
}
-
+
///
/// Регистрирует игровой объект
@@ -110,7 +113,16 @@ namespace ZoFo.GameCore
public void RegisterGameObject(GameObject gameObject)
{
gameObjects.Add(gameObject);
- AddData(new UpdateTileCreated());//TODO
- }
+ if (gameObject is MapObject)
+ {
+ AddData(new UpdateTileCreated()
+ {
+ Position = (gameObject as MapObject).position,
+ sourceRectangle = (gameObject as MapObject)._sourceRectangle,
+ Size = (gameObject as MapObject).graphicsComponent.ObjectDrawRectangle.Size,
+ tileSetName = (gameObject as MapObject).graphicsComponent.mainTextureName
+ });//TODO
+ }
+ }
}
}
diff --git a/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs b/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs
index bd97d7e..f10b40a 100644
--- a/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs
+++ b/ZoFo/GameCore/ZoFo_grafics/GraphicsComponent.cs
@@ -22,9 +22,9 @@ namespace ZoFo.GameCore.ZoFo_graphics
public event Action actionOfAnimationEnd;
private List animations;
private List textures;
- private List texturesNames;
+ public List texturesNames; //rethink public and following that errors
private AnimationContainer currentAnimation;
- static public int scaling = 4;
+ static public int scaling = 5;
public int parentId;
public AnimationContainer CurrentAnimation
{
@@ -64,6 +64,7 @@ namespace ZoFo.GameCore.ZoFo_graphics
buildSourceRectangle();
}
+ public string mainTextureName;//TODO костыль - пофиксить
public GraphicsComponent(string textureName)
{
BuildComponent(textureName);
@@ -73,7 +74,8 @@ namespace ZoFo.GameCore.ZoFo_graphics
}
public void BuildComponent(string textureName)
{
-
+ mainTextureName = textureName;
+ //texturesNames.Add(textureName);//Added by SD
animations = new List();
textures = new List();
var texture = AppManager.Instance.Content.Load(textureName);
@@ -109,6 +111,11 @@ namespace ZoFo.GameCore.ZoFo_graphics
textures = new List();
texturesNames = new List();
+ if (animations is null)
+ {
+ return;
+ }
+
foreach (var animation in animations)
{
if (!texturesNames.Contains(animation.TextureName))
@@ -293,6 +300,6 @@ namespace ZoFo.GameCore.ZoFo_graphics
AppManager.Instance.DebugHUD.Set("CameraPosition", $"{CameraPosition.X}, {CameraPosition.Y}");
*/
}
- public static Point CameraPosition = new Point(-700, 300);
+ public static Point CameraPosition = new Point(0, 0);
}
}