Merge branch 'DevelopmentX' into GUITextures

This commit is contained in:
SergoDobro 2024-08-20 19:34:15 +03:00 committed by GitHub
commit 4f5270ba9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 3028 additions and 437 deletions

View file

@ -80,6 +80,12 @@
/processorParam:Quality=Best /processorParam:Quality=Best
/build:sounds/Craft sound.wav /build:sounds/Craft sound.wav
#begin sounds/gun-gunshot-01.wav
/importer:WavImporter
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:sounds/gun-gunshot-01.wav
#begin sounds/Loot.wav #begin sounds/Loot.wav
/importer:WavImporter /importer:WavImporter
/processor:SoundEffectProcessor /processor:SoundEffectProcessor
@ -212,57 +218,84 @@
#begin Textures/Animations/player_left_idle.animation #begin Textures/Animations/player_left_idle.animation
/copy:Textures/Animations/player_left_idle.animation /copy:Textures/Animations/player_left_idle.animation
#begin Textures/Animations/player_look_down_weapon.animation
/copy:Textures/Animations/player_look_down_weapon.animation
#begin Textures/Animations/player_look_down.animation #begin Textures/Animations/player_look_down.animation
/copy:Textures/Animations/player_look_down.animation /copy:Textures/Animations/player_look_down.animation
#begin Textures/Animations/player_look_left_down_weapon.animation #begin Textures/Animations/player_look_down_weapon.animation
/copy:Textures/Animations/player_look_left_down_weapon.animation /copy:Textures/Animations/player_look_down_weapon.animation
#begin Textures/Animations/player_look_left_down.animation
/copy:Textures/Animations/player_look_left_down.animation
#begin Textures/Animations/player_look_left_up_weapon.animation
/copy:Textures/Animations/player_look_left_up_weapon.animation
#begin Textures/Animations/player_look_left_up.animation
/copy:Textures/Animations/player_look_left_up.animation
#begin Textures/Animations/player_look_left_weapon.animation
/copy:Textures/Animations/player_look_left_weapon.animation
#begin Textures/Animations/player_look_left.animation #begin Textures/Animations/player_look_left.animation
/copy:Textures/Animations/player_look_left.animation /copy:Textures/Animations/player_look_left.animation
#begin Textures/Animations/player_look_right_down_weapon.animation #begin Textures/Animations/player_look_left_down.animation
/copy:Textures/Animations/player_look_right_down_weapon.animation /copy:Textures/Animations/player_look_left_down.animation
#begin Textures/Animations/player_look_right_down.animation #begin Textures/Animations/player_look_left_down_weapon.animation
/copy:Textures/Animations/player_look_right_down.animation /copy:Textures/Animations/player_look_left_down_weapon.animation
#begin Textures/Animations/player_look_right_up_weapon.animation #begin Textures/Animations/player_look_left_up.animation
/copy:Textures/Animations/player_look_right_up_weapon.animation /copy:Textures/Animations/player_look_left_up.animation
#begin Textures/Animations/player_look_right_up.animation #begin Textures/Animations/player_look_left_up_weapon.animation
/copy:Textures/Animations/player_look_right_up.animation /copy:Textures/Animations/player_look_left_up_weapon.animation
#begin Textures/Animations/player_look_right_weapon.animation #begin Textures/Animations/player_look_left_weapon.animation
/copy:Textures/Animations/player_look_right_weapon.animation /copy:Textures/Animations/player_look_left_weapon.animation
#begin Textures/Animations/player_look_right.animation #begin Textures/Animations/player_look_right.animation
/copy:Textures/Animations/player_look_right.animation /copy:Textures/Animations/player_look_right.animation
#begin Textures/Animations/player_look_up_weapon.animation #begin Textures/Animations/player_look_right_down.animation
/copy:Textures/Animations/player_look_up_weapon.animation /copy:Textures/Animations/player_look_right_down.animation
#begin Textures/Animations/player_look_right_down_weapon.animation
/copy:Textures/Animations/player_look_right_down_weapon.animation
#begin Textures/Animations/player_look_right_up.animation
/copy:Textures/Animations/player_look_right_up.animation
#begin Textures/Animations/player_look_right_up_weapon.animation
/copy:Textures/Animations/player_look_right_up_weapon.animation
#begin Textures/Animations/player_look_right_weapon.animation
/copy:Textures/Animations/player_look_right_weapon.animation
#begin Textures/Animations/player_look_up.animation #begin Textures/Animations/player_look_up.animation
/copy:Textures/Animations/player_look_up.animation /copy:Textures/Animations/player_look_up.animation
#begin Textures/Animations/player_look_up_weapon.animation
/copy:Textures/Animations/player_look_up_weapon.animation
#begin Textures/Animations/player_right_idle.animation #begin Textures/Animations/player_right_idle.animation
/copy:Textures/Animations/player_right_idle.animation /copy:Textures/Animations/player_right_idle.animation
#begin Textures/Animations/player_run_down.animation
/copy:Textures/Animations/player_run_down.animation
#begin Textures/Animations/player_run_left.animation
/copy:Textures/Animations/player_run_left.animation
#begin Textures/Animations/player_run_left_down.animation
/copy:Textures/Animations/player_run_left_down.animation
#begin Textures/Animations/player_run_left_up.animation
/copy:Textures/Animations/player_run_left_up.animation
#begin Textures/Animations/player_run_right.animation
/copy:Textures/Animations/player_run_right.animation
#begin Textures/Animations/player_run_right.zip
/copy:Textures/Animations/player_run_right.zip
#begin Textures/Animations/player_run_right_down.animation
/copy:Textures/Animations/player_run_right_down.animation
#begin Textures/Animations/player_run_right_up.animation
/copy:Textures/Animations/player_run_right_up.animation
#begin Textures/Animations/player_run_up.animation
/copy:Textures/Animations/player_run_up.animation
#begin Textures/Animations/player_running_top_rotate.animation #begin Textures/Animations/player_running_top_rotate.animation
/copy:Textures/Animations/player_running_top_rotate.animation /copy:Textures/Animations/player_running_top_rotate.animation
@ -299,18 +332,6 @@
#begin Textures/Animations/zombie_walk.animation #begin Textures/Animations/zombie_walk.animation
/copy:Textures/Animations/zombie_walk.animation /copy:Textures/Animations/zombie_walk.animation
#begin Textures/AnimationTextures/Character/hr-level1_idle_gun.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_idle_gun.png
#begin Textures/AnimationTextures/Character/hr-level1_idle.png #begin Textures/AnimationTextures/Character/hr-level1_idle.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -323,6 +344,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_idle.png /build:Textures/AnimationTextures/Character/hr-level1_idle.png
#begin Textures/AnimationTextures/Character/hr-level1_idle_gun.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_idle_gun.png
#begin Textures/AnimationTextures/Character/hr-level1_mining_tool-1.png #begin Textures/AnimationTextures/Character/hr-level1_mining_tool-1.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -347,18 +380,6 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_mining_tool-2.png /build:Textures/AnimationTextures/Character/hr-level1_mining_tool-2.png
#begin Textures/AnimationTextures/Character/hr-level1_running_gun.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_running_gun.png
#begin Textures/AnimationTextures/Character/hr-level1_running.png #begin Textures/AnimationTextures/Character/hr-level1_running.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -371,6 +392,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_running.png /build:Textures/AnimationTextures/Character/hr-level1_running.png
#begin Textures/AnimationTextures/Character/hr-level1_running_gun.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_running_gun.png
#begin Textures/AnimationTextures/unicorn.png #begin Textures/AnimationTextures/unicorn.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -407,6 +440,19 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Zombie/zombie_spritesheet_v2.png /build:Textures/AnimationTextures/Zombie/zombie_spritesheet_v2.png
#begin Textures/Effects/explosion.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/Effects/explosion.png
#begin Textures/GUI/back.png #begin Textures/GUI/back.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -539,18 +585,6 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/ButtonI.png /build:Textures/GUI/ButtonI.png
#begin Textures/GUI/checkboxs_off-on.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/GUI/checkboxs_off-on.png
#begin Textures/GUI/checkboxs_off.png #begin Textures/GUI/checkboxs_off.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -563,6 +597,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/checkboxs_off.png /build:Textures/GUI/checkboxs_off.png
#begin Textures/GUI/checkboxs_off-on.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/GUI/checkboxs_off-on.png
#begin Textures/GUI/checkboxs_on.png #begin Textures/GUI/checkboxs_on.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -599,18 +645,6 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/mouse.png /build:Textures/GUI/mouse.png
#begin Textures/GUI/Switch_backgrownd.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/GUI/Switch_backgrownd.png
#begin Textures/GUI/switch.png #begin Textures/GUI/switch.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -623,6 +657,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/GUI/switch.png /build:Textures/GUI/switch.png
#begin Textures/GUI/Switch_backgrownd.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/GUI/Switch_backgrownd.png
#begin Textures/icons/12.png #begin Textures/icons/12.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -827,6 +873,30 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/icons/Collectables/Wood.png /build:Textures/icons/Collectables/Wood.png
#begin Textures/icons/ExitZone.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/icons/ExitZone.png
#begin Textures/icons/ExitZone.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/icons/ExitZone.png
#begin Textures/icons/Material/Fabric.png #begin Textures/icons/Material/Fabric.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor

View file

@ -1,15 +1,24 @@
{ {
"activeFile": "TileMaps/main.tmj",
"expandedProjectPaths": [
"Templates",
"Templates/Zones",
"TileMaps",
".",
"Templates/Enemies"
],
"fileStates": { "fileStates": {
"TileMaps/main.tmj": { "TileMaps/main.tmj": {
"scale": 0.33, "scale": 2,
"selectedLayer": 0, "selectedLayer": 1,
"viewCenter": { "viewCenter": {
"x": -463.63636363636374, "x": -682.5,
"y": 300 "y": 1140.25
} }
}, },
"TileSets/IconSet.tsj": { "TileSets/IconSet.tsj": {
"dynamicWrapping": true "dynamicWrapping": true,
"scaleInDock": 1
}, },
"TileSets/TileSet 1.tsj": { "TileSets/TileSet 1.tsj": {
"dynamicWrapping": false, "dynamicWrapping": false,
@ -18,9 +27,21 @@
"TileSets/TilesetNature.tsj": { "TileSets/TilesetNature.tsj": {
"scaleInDock": 1.5 "scaleInDock": 1.5
}, },
"TileSets/bonfire.tsj": {
"dynamicWrapping": false,
"scaleInDock": 1
},
"TileSets/tileset 1 collision.tsj": { "TileSets/tileset 1 collision.tsj": {
"dynamicWrapping": false, "dynamicWrapping": false,
"scaleInDock": 1 "scaleInDock": 1
} }
} },
"last.objectTemplatePath": "C:/Users/artem/source/repos/ZoFo/ZoFo/Content/MapData/Templates/Zones",
"openFiles": [
"TileMaps/main.tmj"
],
"project": "MapSession.tiled-project",
"recentFiles": [
"TileMaps/main.tmj"
]
} }

View file

@ -0,0 +1,12 @@
{ "object":
{
"height":124,
"id":218,
"name":"Exit",
"rotation":0,
"type":"",
"visible":true,
"width":74
},
"type":"template"
}

File diff suppressed because it is too large Load diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

Binary file not shown.

View file

@ -46,21 +46,25 @@ namespace ZoFo.GameCore
// Подписка на действия инпутменеджера. // Подписка на действия инпутменеджера.
// Отправляются данные апдейтса с обновлением инпута // Отправляются данные апдейтса с обновлением инпута
AppManager.Instance.InputManager.ActionEvent += () => AppManager.Instance.InputManager.ActionEvent += () =>
{
if (AppManager.Instance.client.networkManager.PlayerId > 0)
{ {
networkManager.AddData(new UpdateInput() networkManager.AddData(new UpdateInput()
{ {
InputMovementDirection = AppManager.Instance.InputManager.InputMovementDirection.Serialize(), InputMovementDirection = AppManager.Instance.InputManager.InputMovementDirection.Serialize(),
InputAttackDirection = AppManager.Instance.InputManager.InputAttackDirection.Serialize() InputAttackDirection = AppManager.Instance.InputManager.InputAttackDirection.Serialize(),
PlayerId = AppManager.Instance.client.networkManager.PlayerId
}); });
}
}; };
AppManager.Instance.InputManager.OnInteract += () => AppManager.Instance.InputManager.OnInteract += () =>
{ {
networkManager.AddData(new UpdateInputInteraction() { }); networkManager.AddData(new UpdateInputInteraction() {PlayerId = AppManager.Instance.client.networkManager.PlayerId });
}; };
AppManager.Instance.InputManager.ShootEvent += () => AppManager.Instance.InputManager.ShootEvent += () =>
{ {
networkManager.AddData(new UpdateInputShoot() { }); networkManager.AddData(new UpdateInputShoot() { PlayerId = AppManager.Instance.client.networkManager.PlayerId });
}; };
} }
@ -133,10 +137,10 @@ namespace ZoFo.GameCore
networkManager.SendData();//set to ticks networkManager.SendData();//set to ticks
if (myPlayer != null) if (myPlayer != null)
GraphicsComponent.CameraPosition = GraphicsComponent.CameraPosition =
((GraphicsComponent.CameraPosition.ToVector2() *0.9f + ((GraphicsComponent.CameraPosition.ToVector2() * 0.9f +
(myPlayer.position + myPlayer.graphicsComponent.ObjectDrawRectangle.Size.ToVector2() / 2 - AppManager.Instance.CurentScreenResolution.ToVector2() / (2 * GraphicsComponent.scaling) (myPlayer.position + myPlayer.graphicsComponent.ObjectDrawRectangle.Size.ToVector2() / 2 - AppManager.Instance.CurentScreenResolution.ToVector2() / (2 * GraphicsComponent.scaling)
) * 0.1f ) * 0.1f
) ) ))
.ToPoint(); .ToPoint();
} }
public void SendData() public void SendData()
@ -195,14 +199,14 @@ namespace ZoFo.GameCore
(update as UpdateStopObjectCreated).collisions.Select(x => x.GetRectangle()).ToArray() (update as UpdateStopObjectCreated).collisions.Select(x => x.GetRectangle()).ToArray()
)); ));
} }
else if (update is UpdateGameObjectCreated) else if (update is UpdateGameObjectCreated)
{ {
//TODO
Entity created_gameObject; Entity created_gameObject;
if ((update as UpdateGameObjectCreated).GameObjectType == "Player") if ((update as UpdateGameObjectCreated).GameObjectType == "Player")
{ {
created_gameObject = new Player((update as UpdateGameObjectCreated).position.GetVector2()); created_gameObject = new Player((update as UpdateGameObjectCreated).position.GetVector2());
players.Add(created_gameObject as Player);
myPlayer = players[0];
gameObjects.Add(created_gameObject); gameObjects.Add(created_gameObject);
} }
else else
@ -245,11 +249,15 @@ namespace ZoFo.GameCore
DeleteObject(ent); DeleteObject(ent);
} }
else if (update is UpdatePlayerParametrs) else if (update is UpdateGameEnded)
{
GameEnd();
}
else if (update is UpdatePlayerParametrs && update.IdEntity == myPlayer.Id) //aaa
{ {
UpdatePlayerHealth(update as UpdatePlayerParametrs); UpdatePlayerHealth(update as UpdatePlayerParametrs);
} }
else if (update is UpdateLoot) else if (update is UpdateLoot && update.IdEntity == myPlayer.Id)//aaa
{ {
if ((update as UpdateLoot).quantity == 0) if ((update as UpdateLoot).quantity == 0)
{ {
@ -259,6 +267,15 @@ namespace ZoFo.GameCore
if (ent != null) if (ent != null)
(ent as Player).lootData.AddLoot_Client((update as UpdateLoot).lootName, (update as UpdateLoot).quantity); (ent as Player).lootData.AddLoot_Client((update as UpdateLoot).lootName, (update as UpdateLoot).quantity);
} }
else if (update is UpdateCreatePlayer)
{
UpdateCreatePlayer ucp = (UpdateCreatePlayer)update;
if (networkManager.PlayerId == ucp.PlayerId)
{
myPlayer = (Player)FindEntityById(ucp.IdEntity);
players.Add(myPlayer);
}
}
} }
public void UpdatePlayerHealth(UpdatePlayerParametrs update) public void UpdatePlayerHealth(UpdatePlayerParametrs update)
@ -298,9 +315,12 @@ namespace ZoFo.GameCore
(ent as Player).health = (update as UpdatePlayerParametrs).health; (ent as Player).health = (update as UpdatePlayerParametrs).health;
(ent as Player).rad = (update as UpdatePlayerParametrs).radiatoin; (ent as Player).rad = (update as UpdatePlayerParametrs).radiatoin;
} }
} }
public void GameEnd()
{
AppManager.Instance.SetGUI(new FinishingGUI());
}
public Entity FindEntityById(int id) public Entity FindEntityById(int id)
{ {

View file

@ -54,7 +54,17 @@ public class FinishingGUI : AbstractGUI
fontName = "Fonts\\Font", fontName = "Fonts\\Font",
textureName = "Textures/GUI/Button" textureName = "Textures/GUI/Button"
}; };
ExitButton.LeftButtonPressed += () => { AppManager.Instance.SetGUI(new MainMenuGUI()); }; ExitButton.LeftButtonPressed += () => {
foreach (var item in AppManager.Instance.client.myPlayer.lootData.loots)
{
AppManager.Instance.playerData.AddLoot(item.Key, item.Value);
}
AppManager.Instance.SetGUI(new MainMenuGUI());
};
Elements.Add(ExitButton); Elements.Add(ExitButton);
//player itams //player itams

View file

@ -82,11 +82,7 @@ public class SelectingServerGUI : AbstractGUI
AppManager.Instance.SetGUI(new WaitingForPlayersGUI(false)); AppManager.Instance.SetGUI(new WaitingForPlayersGUI(false));
} }
} }
catch (Exception) catch (Exception) { }
{
// throw;
}
// ваш код здесь // ваш код здесь
}; };

View file

@ -18,6 +18,15 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
LoadPlayerData(); LoadPlayerData();
} }
public Dictionary<string, int> items = new Dictionary<string, int>(); public Dictionary<string, int> items = new Dictionary<string, int>();
public void AddLoot(string loot, int quantity)
{
if (items.ContainsKey(loot))
items[loot] += quantity;
else
items.Add(loot, quantity);
AppManager.Instance.playerData.SavePlayerData();
}
/// <summary> /// <summary>
/// Принимает тэг и крафтит этот объект /// Принимает тэг и крафтит этот объект
/// </summary> /// </summary>

View file

@ -21,7 +21,8 @@ namespace ZoFo.GameCore.GameManagers.MapManager
private static readonly JsonSerializerOptions _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; // Задача настроек для JsonSerialize private static readonly JsonSerializerOptions _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; // Задача настроек для JsonSerialize
private static readonly Dictionary<string, string> _classPath = new Dictionary<string, string>() { private static readonly Dictionary<string, string> _classPath = new Dictionary<string, string>() {
{ "Collectables", "ZoFo.GameCore.GameObjects." }, { "Collectables", "ZoFo.GameCore.GameObjects." },
{ "Enemies", "ZoFo.GameCore.GameObjects." } { "Enemies", "ZoFo.GameCore.GameObjects." },
{ "Zones", "ZoFo.GameCore.GameObjects." }
}; };
//private static readonly float _scale = 1.0f; //private static readonly float _scale = 1.0f;

View file

@ -20,7 +20,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
{ {
public class ClientNetworkManager public class ClientNetworkManager
{ {
private int PlayerId; public int PlayerId;
private IPEndPoint endPoint; private IPEndPoint endPoint;
private IPEndPoint sendingEP; private IPEndPoint sendingEP;
private Socket socket; private Socket socket;
@ -138,6 +138,10 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
update = token.ToObject<UpdateGameObjectCreated>(); update = token.ToObject<UpdateGameObjectCreated>();
data.Add(update); data.Add(update);
break; break;
case "UpdateGameObjectWithoutIdCreated":
update = token.ToObject<UpdateGameObjectWithoutIdCreated>();
data.Add(update);
break;
case "UpdateGameObjectDeleted": case "UpdateGameObjectDeleted":
update = token.ToObject<UpdateGameObjectDeleted>(); update = token.ToObject<UpdateGameObjectDeleted>();
data.Add(update); data.Add(update);
@ -170,6 +174,10 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
update = token.ToObject<UpdateTileCreated>(); update = token.ToObject<UpdateTileCreated>();
data.Add(update); data.Add(update);
break; break;
case "UpdateCreatePlayer":
update = token.ToObject<UpdateCreatePlayer>();
data.Add(update);
break;
} }
} }

View file

@ -28,7 +28,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
private IPAddress ip; private IPAddress ip;
private bool isMultiplayer; private bool isMultiplayer;
//Player Id to Player endPoint //Player Id to Player endPoint
private List<IPEndPoint> clientsEP; public List<IPEndPoint> clientsEP;
public IPEndPoint endPoint; public IPEndPoint endPoint;
private List<UpdateData> commonUpdates; private List<UpdateData> commonUpdates;
private List<UpdateData> importantUpdates; private List<UpdateData> importantUpdates;

View file

@ -14,6 +14,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer
// public int IdEntity { get; set; } // public int IdEntity { get; set; }
public SerializableVector2 InputMovementDirection{get;set;} public SerializableVector2 InputMovementDirection{get;set;}
public SerializableVector2 InputAttackDirection {get;set;} public SerializableVector2 InputAttackDirection {get;set;}
public int PlayerId {get;set;}
public UpdateInput() public UpdateInput()
{ {
UpdateType = "UpdateInput"; UpdateType = "UpdateInput";

View file

@ -9,4 +9,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
public class UpdateInputInteraction : UpdateData public class UpdateInputInteraction : UpdateData
{ {
public UpdateInputInteraction() { UpdateType = "UpdateInputInteraction"; } public UpdateInputInteraction() { UpdateType = "UpdateInputInteraction"; }
public int PlayerId { get; set; }
} }

View file

@ -6,4 +6,5 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
public class UpdateInputShoot : UpdateData public class UpdateInputShoot : UpdateData
{ {
public UpdateInputShoot() { UpdateType = "UpdateInputShoot"; } public UpdateInputShoot() { UpdateType = "UpdateInputShoot"; }
public int PlayerId { get; set; }
} }

View file

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO;
namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
{
public class UpdateCreatePlayer : UpdateData
{
public int PlayerId { get; set; }
public SerializableVector2 position { get; set; }
public UpdateCreatePlayer()
{
isImportant = true;
UpdateType = "UpdateCreatePlayer";
}
}
}

View file

@ -12,6 +12,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
public class UpdateGameObjectDeleted : UpdateData public class UpdateGameObjectDeleted : UpdateData
{ {
public UpdateGameObjectDeleted() { UpdateType = "UpdateGameObjectDeleted"; isImportant = false; } public UpdateGameObjectDeleted() { UpdateType = "UpdateGameObjectDeleted"; isImportant = false; }
public string GameObjectType; public string GameObjectType { get; set; }
} }
} }

View file

@ -27,6 +27,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates
[JsonDerivedType(typeof(UpdatePlayerExit))] [JsonDerivedType(typeof(UpdatePlayerExit))]
[JsonDerivedType(typeof(UpdateInputInteraction))] [JsonDerivedType(typeof(UpdateInputInteraction))]
[JsonDerivedType(typeof(UpdateInputShoot))] [JsonDerivedType(typeof(UpdateInputShoot))]
[JsonDerivedType(typeof(UpdateCreatePlayer))]
public class UpdateData public class UpdateData
{ {

View file

@ -58,9 +58,12 @@ namespace ZoFo.GameCore.GameObjects
} }
public virtual void Delete() public virtual void Delete()
{
if (AppManager.Instance.gamestate == GameState.HostPlaying)
{ {
AppManager.Instance.server.DeleteObject(this); AppManager.Instance.server.DeleteObject(this);
} }
} }
}
} }

View file

@ -111,9 +111,11 @@ namespace ZoFo.GameCore.GameObjects
public override void DeathEnd() public override void DeathEnd()
{ {
Instantiate(new Particle(collisionComponent.stopRectangle.Location.ToVector2() + position + ExtentionClass.RandomVector() * 20)); Instantiate(new Particle(position - collisionComponent.stopRectangle.Size.ToVector2() / 2 + ExtentionClass.RandomVector() * 20));
Instantiate(new Particle(collisionComponent.stopRectangle.Location.ToVector2() + position + ExtentionClass.RandomVector() * 20)); Instantiate(new Particle(position - collisionComponent.stopRectangle.Size.ToVector2() / 2 + ExtentionClass.RandomVector() * 20));
Instantiate(new Particle(collisionComponent.stopRectangle.Location.ToVector2() + position + ExtentionClass.RandomVector() * 20)); Instantiate(new Particle(position - collisionComponent.stopRectangle.Size.ToVector2() / 2 + ExtentionClass.RandomVector() * 20));
Instantiate(new Particle(position - collisionComponent.stopRectangle.Size.ToVector2() / 2 + ExtentionClass.RandomVector() * 20));
Instantiate(new Particle(position - collisionComponent.stopRectangle.Size.ToVector2() / 2 + ExtentionClass.RandomVector() * 20));
base.DeathEnd(); base.DeathEnd();
} }

View file

@ -12,6 +12,7 @@ using ZoFo.GameCore.Graphics;
using System.Diagnostics; using System.Diagnostics;
using ZoFo.GameCore.GUI; using ZoFo.GameCore.GUI;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Linq;
namespace ZoFo.GameCore.GameObjects; namespace ZoFo.GameCore.GameObjects;
@ -221,7 +222,12 @@ public class Player : LivingEntity
{ {
InputPlayerRotation = updateInput.InputMovementDirection.GetVector2(); InputPlayerRotation = updateInput.InputMovementDirection.GetVector2();
InputWeaponRotation = updateInput.InputAttackDirection.GetVector2(); InputWeaponRotation = updateInput.InputAttackDirection.GetVector2();
DebugHUD.DebugSet("dir", InputWeaponRotation.ToString()); if (InputPlayerRotation.X != 0f || InputPlayerRotation.Y != 0f)
{
InputPlayerRotation /= (InputPlayerRotation.Length());
}
DebugHUD.DebugSet("dir", InputPlayerRotation.ToString());
DebugHUD.DebugSet("dir2", InputWeaponRotation.ToString());
} }
public void HandleInteract(UpdateInputInteraction updateInputInteraction) public void HandleInteract(UpdateInputInteraction updateInputInteraction)
{ {
@ -252,18 +258,21 @@ public class Player : LivingEntity
reloading = 5; reloading = 5;
IsTryingToShoot = true; IsTryingToShoot = true;
Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(GetDamageArea(InputWeaponRotation), this); List<Entity> entities = AppManager.Instance.server.collisionManager.GetEntities(GetDamageArea(InputWeaponRotation), this).ToList();
entities.AddRange(AppManager.Instance.server.collisionManager.GetEntities(GetDamageArea(InputWeaponRotation, 2), this).ToList());
entities.AddRange(AppManager.Instance.server.collisionManager.GetEntities(GetDamageArea(InputWeaponRotation, 3), this).ToList());
if (entities != null) if (entities != null)
{ {
foreach (Entity entity in entities) foreach (Entity entity in entities)
{ {
if (entity is Enemy) if (entity is Enemy)
{ {
for (int i = 0; i < 3; i++) for (int i = 3; i <= 3; i++)
{ {
Instantiate(new Particle( Instantiate(new Particle(
(collisionComponent.stopRectangle.Location.ToVector2() * i / 3f) + ((position - graphicsComponent.ObjectDrawRectangle.Size.ToVector2() / 2) * (3 - i) / 3f) +
(collisionComponent.stopRectangle.Location.ToVector2() * (3 - i) / 3f) ((entity.position - graphicsComponent.ObjectDrawRectangle.Size.ToVector2() / 2) * i / 3f) + ExtentionClass.RandomVector() * 3
)); ));
} }
@ -276,9 +285,11 @@ public class Player : LivingEntity
{ {
DrawDebugRectangle(spriteBatch, GetDamageArea(AppManager.Instance.InputManager.InputAttackDirection), Color.Green); DrawDebugRectangle(spriteBatch, GetDamageArea(AppManager.Instance.InputManager.InputAttackDirection), Color.Green);
DrawDebugRectangle(spriteBatch, GetDamageArea(AppManager.Instance.InputManager.InputAttackDirection, 2), Color.Green);
DrawDebugRectangle(spriteBatch, GetDamageArea(AppManager.Instance.InputManager.InputAttackDirection, 3), Color.Green);
base.Draw(spriteBatch); base.Draw(spriteBatch);
} }
public Rectangle GetDamageArea(Vector2 direction) public Rectangle GetDamageArea(Vector2 direction, float mult = 1)
{ {
direction.Normalize(); direction.Normalize();
var rect = collisionComponent.stopRectangle.SetOrigin(position); var rect = collisionComponent.stopRectangle.SetOrigin(position);
@ -287,7 +298,7 @@ public class Player : LivingEntity
rect.Y -= size; rect.Y -= size;
rect.Width += 2 * size; rect.Width += 2 * size;
rect.Height += 2 * size; rect.Height += 2 * size;
rect = rect.SetOrigin(direction * 40); rect = rect.SetOrigin(direction * 40 * mult);
return rect; return rect;
} }
} }

View file

@ -16,11 +16,16 @@ namespace ZoFo.GameCore.GameObjects
public Particle(Vector2 position) : base(position) public Particle(Vector2 position) : base(position)
{ {
graphicsComponent.ObjectDrawRectangle = new Rectangle(-30, -30,60,60).SetOrigin(position); graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0,60,60).SetOrigin(position);
AppManager.Instance.SoundManager.StartSound("gun-gunshot-01", Vector2.Zero, Vector2.Zero, 0.5f, (float)(Random.Shared.NextDouble()*2-1));
(graphicsComponent as AnimatedGraphicsComponent).actionOfAnimationEnd += _ => { (graphicsComponent as AnimatedGraphicsComponent).actionOfAnimationEnd += _ => {
if (AppManager.Instance.client!=null)
{
AppManager.Instance.client.DeleteObject(this); AppManager.Instance.client.DeleteObject(this);
}
}; };
} }
} }

View file

@ -0,0 +1,42 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects
{
public class ExitZone : Entity
{
public override GraphicsComponent graphicsComponent { get; } = new StaticGraphicsComponent("Content/Textures/icons/ExitZone");
public ExitZone(Vector2 position) : base(position)
{
collisionComponent.OnTriggerZone += Exit;
graphicsComponent.ObjectDrawRectangle.Width = 100;
graphicsComponent.ObjectDrawRectangle.Height = 100;
position = new Vector2(500f, 500f);
collisionComponent.isTrigger = true;
collisionComponent.triggerRectangle = new Rectangle(0, 0, 100, 100);
}
public void Exit(GameObject sender)
{
if (sender is Player &&
AppManager.Instance.server.collisionManager.GetPlayersInZone(collisionComponent.triggerRectangle.SetOrigin(position)).Length == AppManager.Instance.server.players.Count)
{
sender.position = new Vector2(0f, 0f);
AppManager.Instance.server.EndGame();
AppManager.Instance.debugHud.Set("Exit", sender.position.ToString());
}
}
}
}

View file

@ -24,6 +24,7 @@ public abstract class GameObject
graphicsComponent.ObjectDrawRectangle.X = (int)position.X; graphicsComponent.ObjectDrawRectangle.X = (int)position.X;
graphicsComponent.ObjectDrawRectangle.Y = (int)position.Y; graphicsComponent.ObjectDrawRectangle.Y = (int)position.Y;
positionDraw = position;
} }
public virtual void UpdateLogic() public virtual void UpdateLogic()
{ {
@ -42,9 +43,12 @@ public abstract class GameObject
} }
public void Instantiate(GameObject gameObject) public void Instantiate(GameObject gameObject)
{
if (AppManager.Instance.gamestate == GameState.HostPlaying)
{ {
AppManager.Instance.server.RegisterGameObject(gameObject); AppManager.Instance.server.RegisterGameObject(gameObject);
} }
}
#endregion #endregion

View file

@ -69,20 +69,32 @@ namespace ZoFo.GameCore
{ {
case "UpdateInput": case "UpdateInput":
if (players.Count > 0) if (players.Count > 0)
players[0].HandleNewInput(updateData as UpdateInput);//TODO id instead of 0 {
UpdateInput data = updateData as UpdateInput;
players[data.PlayerId - 1].HandleNewInput(data);
}
//TODO id instead of 0
else else
DebugHUD.DebugLog("NO PLAYER ON MAP"); DebugHUD.DebugLog("NO PLAYER ON MAP");
break; break;
case "UpdateTileCreated": case "UpdateTileCreated":
break; break;
case "UpdateInputInteraction": case "UpdateInputInteraction":
players[0].HandleInteract(updateData as UpdateInputInteraction); if (players.Count > 0)
{
UpdateInputInteraction data = updateData as UpdateInputInteraction;
players[data.PlayerId - 1].HandleInteract(data);
}
break; break;
case "UpdateInputShoot": case "UpdateInputShoot":
players[0].HandleShoot(updateData as UpdateInputShoot); if (players.Count > 0)
{
UpdateInputShoot data = updateData as UpdateInputShoot;
players[data.PlayerId - 1].HandleShoot(data);
}
break; break;
} }
} }//Поспать
/// <summary> /// <summary>
@ -124,7 +136,12 @@ namespace ZoFo.GameCore
new MapManager().LoadMap(); new MapManager().LoadMap();
//AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0))); //AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0)));
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(760, 140))); for (int i = 0; i < networkManager.clientsEP.Count; i++)
{
Player player = new Player(new Vector2(760 - 30 * i, 140));
RegisterGameObject(player);
networkManager.AddData(new UpdateCreatePlayer() { PlayerId = i+1, IdEntity=player.Id});
}
//for (int i = 0; i < 20; i++) //for (int i = 0; i < 20; i++)
// for (int j = 0; j < 20; j++) // for (int j = 0; j < 20; j++)
// AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1300 + i*70, 1000+j*70))); // AppManager.Instance.server.RegisterGameObject(new Zombie(new Vector2(1300 + i*70, 1000+j*70)));
@ -138,6 +155,7 @@ namespace ZoFo.GameCore
{ {
UpdateGameEnded gameEnded = new UpdateGameEnded(); UpdateGameEnded gameEnded = new UpdateGameEnded();
networkManager.AddData(gameEnded); networkManager.AddData(gameEnded);
// networkManager.CloseConnection();
} }
public List<GameObject> gameObjects = new List<GameObject>(); public List<GameObject> gameObjects = new List<GameObject>();
@ -208,7 +226,6 @@ namespace ZoFo.GameCore
}); });
return; return;
} }
if (gameObject is Entity entity) if (gameObject is Entity entity)
{ {
AddData(new UpdateGameObjectCreated() AddData(new UpdateGameObjectCreated()