|
@ -18,6 +18,7 @@ namespace MonogameLibrary.UI.Base
|
|||
public string textureName = "";
|
||||
public Rectangle rectangle = new Rectangle(0, 0, 10, 10);
|
||||
public Color mainColor = Color.White;
|
||||
public bool sus = true;
|
||||
|
||||
public DrawableUIElement(UIManager manager, int layerIndex = 0, string textureName = "")
|
||||
{
|
||||
|
@ -29,6 +30,7 @@ namespace MonogameLibrary.UI.Base
|
|||
{
|
||||
if (textureName == "")
|
||||
{
|
||||
sus = false;
|
||||
texture = new Texture2D(Manager.GraphicsDevice, 1, 1);
|
||||
texture.SetData<Color>(new Color[] { mainColor });
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public class Bar : DrawableUIElement
|
|||
public float percent = 0.5f;
|
||||
private DrawableUIElement barInside;
|
||||
public Color inColor;
|
||||
public string inTextureName;
|
||||
public string inTextureName = "";
|
||||
|
||||
public Bar(UIManager manager, int layerIndex = 0, string textureName = "") : base(manager, layerIndex, textureName)
|
||||
{
|
||||
|
@ -30,8 +30,7 @@ public class Bar : DrawableUIElement
|
|||
{
|
||||
rectangle = new Rectangle(rectangle.X + rectangle.Height / 8, rectangle.Y + rectangle.Height / 8,
|
||||
(int)((rectangle.Width - rectangle.Height / 4) * percent), rectangle.Height / 8 * 7),
|
||||
mainColor = inColor,
|
||||
textureName = inTextureName
|
||||
mainColor = inColor
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,8 @@ public class ItemDisplayButton : Button
|
|||
fontColor2 = fontColor1,
|
||||
fontName2 = fontName1,
|
||||
scale2 = scale1,
|
||||
itemTextureName1 = itemTextureName
|
||||
itemTextureName1 = itemTextureName,
|
||||
textureName = "Textures/GUI/Back"
|
||||
};
|
||||
hoverWindow.Initialize(content);
|
||||
hoverWindow.LoadTexture(content);
|
||||
|
|
|
@ -111,7 +111,8 @@ public class ItemDisplayLabel : DrawableUIElement
|
|||
fontColor2 = fontColor1,
|
||||
fontName2 = fontName1,
|
||||
scale2 = scale1,
|
||||
itemTextureName1 = itemTextureName
|
||||
itemTextureName1 = itemTextureName,
|
||||
textureName = "Textures/GUI/Back"
|
||||
};
|
||||
hoverWindow.Initialize(content);
|
||||
hoverWindow.LoadTexture(content);
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
#begin MapData/TileMaps/main.tmj
|
||||
/copy:MapData/TileMaps/main.tmj
|
||||
|
||||
#begin MapData/TileSets/bonfire.tsj
|
||||
/copy:MapData/TileSets/bonfire.tsj
|
||||
|
||||
#begin MapData/TileSets/IconSet.tsj
|
||||
/copy:MapData/TileSets/IconSet.tsj
|
||||
|
||||
|
@ -56,6 +59,36 @@
|
|||
#begin MapData/TileSets/TilesetNature.tsj
|
||||
/copy:MapData/TileSets/TilesetNature.tsj
|
||||
|
||||
#begin sounds/Background menu music.wav
|
||||
/importer:WavImporter
|
||||
/processor:SoundEffectProcessor
|
||||
/processorParam:Quality=Best
|
||||
/build:sounds/Background menu music.wav
|
||||
|
||||
#begin sounds/Background music.wav
|
||||
/importer:WavImporter
|
||||
/processor:SoundEffectProcessor
|
||||
/processorParam:Quality=Best
|
||||
/build:sounds/Background music.wav
|
||||
|
||||
#begin sounds/Button click.wav
|
||||
/importer:WavImporter
|
||||
/processor:SoundEffectProcessor
|
||||
/processorParam:Quality=Best
|
||||
/build:sounds/Button click.wav
|
||||
|
||||
#begin sounds/Craft sound.wav
|
||||
/importer:WavImporter
|
||||
/processor:SoundEffectProcessor
|
||||
/processorParam:Quality=Best
|
||||
/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
|
||||
/importer:WavImporter
|
||||
/processor:SoundEffectProcessor
|
||||
|
@ -98,14 +131,20 @@
|
|||
/processorParam:Quality=Best
|
||||
/build:sounds/Zombi stoit.wav
|
||||
|
||||
#begin Textures/Animations/player_down_idle.animation
|
||||
/copy:Textures/Animations/player_down_idle.animation
|
||||
#begin sounds/zombie sound 2.wav
|
||||
/importer:WavImporter
|
||||
/processor:SoundEffectProcessor
|
||||
/processorParam:Quality=Best
|
||||
/build:sounds/zombie sound 2.wav
|
||||
|
||||
#begin Textures/Animations/player_down-left_idle.animation
|
||||
/copy:Textures/Animations/player_down-left_idle.animation
|
||||
#begin sounds/zombie sound.wav
|
||||
/importer:WavImporter
|
||||
/processor:SoundEffectProcessor
|
||||
/processorParam:Quality=Best
|
||||
/build:sounds/zombie sound.wav
|
||||
|
||||
#begin Textures/Animations/player_down-right_idle.animation
|
||||
/copy:Textures/Animations/player_down-right_idle.animation
|
||||
#begin Textures/Animations/explosion_1.animation
|
||||
/copy:Textures/Animations/explosion_1.animation
|
||||
|
||||
#begin Textures/Animations/player_idle_down_mining.animation
|
||||
/copy:Textures/Animations/player_idle_down_mining.animation
|
||||
|
@ -131,9 +170,6 @@
|
|||
#begin Textures/Animations/player_idle_top-rights_mining.animation
|
||||
/copy:Textures/Animations/player_idle_top-rights_mining.animation
|
||||
|
||||
#begin 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
|
||||
|
||||
|
@ -182,9 +218,6 @@
|
|||
#begin Textures/Animations/player_look_up.animation
|
||||
/copy:Textures/Animations/player_look_up.animation
|
||||
|
||||
#begin 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
|
||||
|
||||
|
@ -218,15 +251,30 @@
|
|||
#begin Textures/Animations/player_top_mining.animation
|
||||
/copy:Textures/Animations/player_top_mining.animation
|
||||
|
||||
#begin Textures/Animations/player_top-left_idle.animation
|
||||
/copy:Textures/Animations/player_top-left_idle.animation
|
||||
|
||||
#begin Textures/Animations/player_top-right_idle.animation
|
||||
/copy:Textures/Animations/player_top-right_idle.animation
|
||||
|
||||
#begin Textures/Animations/running_top.animation
|
||||
/copy:Textures/Animations/running_top.animation
|
||||
|
||||
#begin Textures/Animations/Simple Idles/player_down_idle.animation
|
||||
/copy:Textures/Animations/Simple Idles/player_down_idle.animation
|
||||
|
||||
#begin Textures/Animations/Simple Idles/player_down-left_idle.animation
|
||||
/copy:Textures/Animations/Simple Idles/player_down-left_idle.animation
|
||||
|
||||
#begin Textures/Animations/Simple Idles/player_down-right_idle.animation
|
||||
/copy:Textures/Animations/Simple Idles/player_down-right_idle.animation
|
||||
|
||||
#begin Textures/Animations/Simple Idles/player_left_idle.animation
|
||||
/copy:Textures/Animations/Simple Idles/player_left_idle.animation
|
||||
|
||||
#begin Textures/Animations/Simple Idles/player_right_idle.animation
|
||||
/copy:Textures/Animations/Simple Idles/player_right_idle.animation
|
||||
|
||||
#begin Textures/Animations/Simple Idles/player_top-left_idle.animation
|
||||
/copy:Textures/Animations/Simple Idles/player_top-left_idle.animation
|
||||
|
||||
#begin Textures/Animations/Simple Idles/player_top-right_idle.animation
|
||||
/copy:Textures/Animations/Simple Idles/player_top-right_idle.animation
|
||||
|
||||
#begin Textures/Animations/testAnimation.animation
|
||||
/copy:Textures/Animations/testAnimation.animation
|
||||
|
||||
|
@ -368,6 +416,18 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/Effects/explosion.png
|
||||
|
||||
#begin Textures/GUI/back.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/back.png
|
||||
|
||||
#begin Textures/GUI/background/base.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -452,6 +512,42 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/GUI/background/waiting.png
|
||||
|
||||
#begin Textures/GUI/Button.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/Button.png
|
||||
|
||||
#begin Textures/GUI/Button2.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/Button2.png
|
||||
|
||||
#begin Textures/GUI/ButtonI.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/ButtonI.png
|
||||
|
||||
#begin Textures/GUI/checkboxs_off-on.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
@ -680,7 +776,7 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/icons/Collectables/BottleOfWater.png
|
||||
|
||||
#begin Textures/icons/Collectables/Peeble.png
|
||||
#begin Textures/icons/Collectables/Pebble.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
/processorParam:ColorKeyColor=255,0,255,255
|
||||
|
@ -690,7 +786,7 @@
|
|||
/processorParam:ResizeToPowerOfTwo=False
|
||||
/processorParam:MakeSquare=False
|
||||
/processorParam:TextureFormat=Color
|
||||
/build:Textures/icons/Collectables/Peeble.png
|
||||
/build:Textures/icons/Collectables/Pebble.png
|
||||
|
||||
#begin Textures/icons/Collectables/PureBottleOfWater.png
|
||||
/importer:TextureImporter
|
||||
|
@ -740,6 +836,18 @@
|
|||
/processorParam:TextureFormat=Color
|
||||
/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/Material/Fabric.png
|
||||
/importer:TextureImporter
|
||||
/processor:TextureProcessor
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
{
|
||||
"activeFile": "TileMaps/main.tmj",
|
||||
"expandedProjectPaths": [
|
||||
"Templates",
|
||||
"Templates/Zones",
|
||||
"TileMaps",
|
||||
".",
|
||||
"Templates/Enemies"
|
||||
],
|
||||
"fileStates": {
|
||||
"TileMaps/main.tmj": {
|
||||
"scale": 0.33,
|
||||
"selectedLayer": 0,
|
||||
"scale": 2,
|
||||
"selectedLayer": 1,
|
||||
"viewCenter": {
|
||||
"x": -463.63636363636374,
|
||||
"y": 300
|
||||
"x": -682.5,
|
||||
"y": 1140.25
|
||||
}
|
||||
},
|
||||
"TileSets/IconSet.tsj": {
|
||||
"dynamicWrapping": true
|
||||
"dynamicWrapping": true,
|
||||
"scaleInDock": 1
|
||||
},
|
||||
"TileSets/TileSet 1.tsj": {
|
||||
"dynamicWrapping": false,
|
||||
|
@ -18,9 +27,21 @@
|
|||
"TileSets/TilesetNature.tsj": {
|
||||
"scaleInDock": 1.5
|
||||
},
|
||||
"TileSets/bonfire.tsj": {
|
||||
"dynamicWrapping": false,
|
||||
"scaleInDock": 1
|
||||
},
|
||||
"TileSets/tileset 1 collision.tsj": {
|
||||
"dynamicWrapping": false,
|
||||
"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"
|
||||
]
|
||||
}
|
||||
|
|
12
ZoFo/Content/MapData/Templates/Zones/ExitZone.tj
Normal file
|
@ -0,0 +1,12 @@
|
|||
{ "object":
|
||||
{
|
||||
"height":124,
|
||||
"id":218,
|
||||
"name":"Exit",
|
||||
"rotation":0,
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":74
|
||||
},
|
||||
"type":"template"
|
||||
}
|
BIN
ZoFo/Content/Textures/GUI/Button.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
ZoFo/Content/Textures/GUI/Button2.png
Normal file
After Width: | Height: | Size: 885 B |
BIN
ZoFo/Content/Textures/GUI/ButtonI.png
Normal file
After Width: | Height: | Size: 931 B |
BIN
ZoFo/Content/Textures/GUI/back.png
Normal file
After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
BIN
ZoFo/Content/Textures/icons/ExitZone.png
Normal file
After Width: | Height: | Size: 179 KiB |
BIN
ZoFo/Content/sounds/Background menu music.wav
Normal file
BIN
ZoFo/Content/sounds/Background music.wav
Normal file
BIN
ZoFo/Content/sounds/Button click.wav
Normal file
BIN
ZoFo/Content/sounds/Craft sound.wav
Normal file
BIN
ZoFo/Content/sounds/gun-gunshot-01.wav
Normal file
BIN
ZoFo/Content/sounds/zombie sound 2.wav
Normal file
BIN
ZoFo/Content/sounds/zombie sound.wav
Normal file
|
@ -47,20 +47,30 @@ namespace ZoFo.GameCore
|
|||
// Отправляются данные апдейтса с обновлением инпута
|
||||
AppManager.Instance.InputManager.ActionEvent += () =>
|
||||
{
|
||||
networkManager.AddData(new UpdateInput()
|
||||
if (AppManager.Instance.client.networkManager.PlayerId > 0)
|
||||
{
|
||||
InputMovementDirection = AppManager.Instance.InputManager.InputMovementDirection.Serialize(),
|
||||
InputAttackDirection = AppManager.Instance.InputManager.InputAttackDirection.Serialize()
|
||||
});
|
||||
networkManager.AddData(new UpdateInput()
|
||||
{
|
||||
InputMovementDirection = AppManager.Instance.InputManager.InputMovementDirection.Serialize(),
|
||||
InputAttackDirection = AppManager.Instance.InputManager.InputAttackDirection.Serialize(),
|
||||
PlayerId = AppManager.Instance.client.networkManager.PlayerId
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
AppManager.Instance.InputManager.OnInteract += () =>
|
||||
{
|
||||
networkManager.AddData(new UpdateInputInteraction() { });
|
||||
if (AppManager.Instance.client.networkManager.PlayerId > 0)
|
||||
{
|
||||
networkManager.AddData(new UpdateInputInteraction() { PlayerId = AppManager.Instance.client.networkManager.PlayerId });
|
||||
}
|
||||
};
|
||||
AppManager.Instance.InputManager.ShootEvent += () =>
|
||||
{
|
||||
networkManager.AddData(new UpdateInputShoot() { });
|
||||
if (AppManager.Instance.client.networkManager.PlayerId > 0)
|
||||
{
|
||||
networkManager.AddData(new UpdateInputShoot() { PlayerId = AppManager.Instance.client.networkManager.PlayerId });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -103,7 +113,7 @@ namespace ZoFo.GameCore
|
|||
float shakeEffect = 0;
|
||||
public void AddShaking(float power)
|
||||
{
|
||||
shakeEffect += power;
|
||||
shakeEffect += power*3;
|
||||
}
|
||||
public void UpdateShaking()
|
||||
{
|
||||
|
@ -133,10 +143,10 @@ namespace ZoFo.GameCore
|
|||
networkManager.SendData();//set to ticks
|
||||
if (myPlayer != null)
|
||||
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)
|
||||
) * 0.1f
|
||||
) )
|
||||
))
|
||||
.ToPoint();
|
||||
}
|
||||
public void SendData()
|
||||
|
@ -195,14 +205,14 @@ namespace ZoFo.GameCore
|
|||
(update as UpdateStopObjectCreated).collisions.Select(x => x.GetRectangle()).ToArray()
|
||||
));
|
||||
}
|
||||
|
||||
else if (update is UpdateGameObjectCreated)
|
||||
{
|
||||
//TODO
|
||||
Entity created_gameObject;
|
||||
if ((update as UpdateGameObjectCreated).GameObjectType == "Player")
|
||||
{
|
||||
created_gameObject = new Player((update as UpdateGameObjectCreated).position.GetVector2());
|
||||
players.Add(created_gameObject as Player);
|
||||
myPlayer = players[0];
|
||||
gameObjects.Add(created_gameObject);
|
||||
}
|
||||
else
|
||||
|
@ -245,11 +255,15 @@ namespace ZoFo.GameCore
|
|||
DeleteObject(ent);
|
||||
|
||||
}
|
||||
else if (update is UpdatePlayerParametrs)
|
||||
else if (update is UpdateGameEnded)
|
||||
{
|
||||
GameEnd();
|
||||
}
|
||||
else if (update is UpdatePlayerParametrs && myPlayer !=null && update.IdEntity == myPlayer.Id) //aaa
|
||||
{
|
||||
UpdatePlayerHealth(update as UpdatePlayerParametrs);
|
||||
}
|
||||
else if (update is UpdateLoot)
|
||||
else if (update is UpdateLoot && myPlayer != null && update.IdEntity == myPlayer.Id)//aaa
|
||||
{
|
||||
if ((update as UpdateLoot).quantity == 0)
|
||||
{
|
||||
|
@ -259,6 +273,15 @@ namespace ZoFo.GameCore
|
|||
if (ent != null)
|
||||
(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)
|
||||
|
@ -298,9 +321,13 @@ namespace ZoFo.GameCore
|
|||
(ent as Player).health = (update as UpdatePlayerParametrs).health;
|
||||
(ent as Player).rad = (update as UpdatePlayerParametrs).radiatoin;
|
||||
}
|
||||
|
||||
}
|
||||
public bool changeGUI = false;
|
||||
public void GameEnd()
|
||||
{
|
||||
|
||||
changeGUI = true;
|
||||
}
|
||||
|
||||
public Entity FindEntityById(int id)
|
||||
{
|
||||
|
|
|
@ -54,14 +54,14 @@ public class BaseGUI : AbstractGUI
|
|||
rectangle = new Rectangle(width / 2 - (height / 16 + (int)(width / 2.5)) / 2,
|
||||
height / 2 - (int)(height / 1.5) / 2,
|
||||
height / 40 + width / 5, (int)(height / 1.5)),
|
||||
mainColor = Color.LightGray
|
||||
textureName = "Textures/GUI/Back"
|
||||
};
|
||||
Elements.Add(baseItemBack);
|
||||
DrawableUIElement baseCraftBack = new DrawableUIElement(Manager)
|
||||
{
|
||||
rectangle = new Rectangle(width / 2 + height / 160, height / 2 - (int)(height / 1.5) / 2,
|
||||
height / 40 + width / 5, (int)(height / 1.5)),
|
||||
mainColor = Color.LightGray
|
||||
textureName = "Textures/GUI/Back"
|
||||
};
|
||||
Elements.Add(baseCraftBack);
|
||||
|
||||
|
@ -85,7 +85,8 @@ public class BaseGUI : AbstractGUI
|
|||
mainColor = Color.Gray,
|
||||
fontName1 = "Fonts\\Font4",
|
||||
discriptions1 = itemInfo.description,
|
||||
resourcesNeededToCraft1 = itemInfo.resourcesNeededToCraft
|
||||
resourcesNeededToCraft1 = itemInfo.resourcesNeededToCraft,
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
Elements.Add(temp);
|
||||
temp.Initialize();
|
||||
|
@ -134,7 +135,8 @@ public class BaseGUI : AbstractGUI
|
|||
mainColor = Color.Gray,
|
||||
fontName1 = "Fonts\\Font4",
|
||||
discriptions1 = itemInfo.description,
|
||||
resourcesNeededToCraft1 = itemInfo.resourcesNeededToCraft
|
||||
resourcesNeededToCraft1 = itemInfo.resourcesNeededToCraft,
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
Elements.Add(temp);
|
||||
temp.Initialize();
|
||||
|
@ -142,6 +144,7 @@ public class BaseGUI : AbstractGUI
|
|||
ItemDisplayButtonsList.Add(temp);
|
||||
temp.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Craft sound");
|
||||
AppManager.Instance.playerData.CraftItem(item.Key);
|
||||
AppManager.Instance.SetGUI(new BaseGUI());
|
||||
};
|
||||
|
@ -160,10 +163,12 @@ public class BaseGUI : AbstractGUI
|
|||
{
|
||||
fontName = "Fonts\\Font3", scale = 0.4f, text = "<-", fontColor = Color.Black,
|
||||
mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40),
|
||||
textureName = "Textures\\GUI\\checkboxs_off"
|
||||
textureName = "Textures/GUI/Button2"
|
||||
};
|
||||
Elements.Add(bTExit);
|
||||
bTExit.LeftButtonPressed += () => { AppManager.Instance.SetGUI(new MainMenuGUI()); };
|
||||
bTExit.LeftButtonPressed += () => { AppManager.Instance.SetGUI(new MainMenuGUI());
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
};
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
|
|
|
@ -31,6 +31,7 @@ public class DebugHUD
|
|||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
//return;//TODO delete
|
||||
var keysString = Join("\n", _text.Select(el => el.Key + ": " + el.Value).ToList());
|
||||
spriteBatch.Begin();
|
||||
spriteBatch.DrawString(
|
||||
|
|
|
@ -36,7 +36,8 @@ public class ExitGameGUI : AbstractGUI
|
|||
scale = 0.3f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
endButton.LeftButtonPressed += () =>
|
||||
{
|
||||
|
|
|
@ -38,7 +38,8 @@ public class FinishingGUI : AbstractGUI
|
|||
rectangle = new Rectangle(width / 2 - height / 80 - width / 5 / 2,
|
||||
height / 2 - (int)(height / 1.5) / 2,
|
||||
height / 40 + width / 5, (int)(height / 1.5)),
|
||||
mainColor = Color.LightGray
|
||||
mainColor = Color.LightGray,
|
||||
textureName = "Textures/GUI/Back"
|
||||
};
|
||||
Elements.Add(inventoryBack);
|
||||
|
||||
|
@ -50,9 +51,20 @@ public class FinishingGUI : AbstractGUI
|
|||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
fontName = "Fonts\\Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
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());
|
||||
|
||||
};
|
||||
ExitButton.LeftButtonPressed += () => { AppManager.Instance.SetGUI(new MainMenuGUI()); };
|
||||
Elements.Add(ExitButton);
|
||||
|
||||
//player itams
|
||||
|
|
|
@ -36,7 +36,8 @@ public class GameEndedGUI : AbstractGUI
|
|||
scale = 0.3f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
endButton.LeftButtonPressed += () =>
|
||||
{
|
||||
|
|
|
@ -24,17 +24,27 @@ public class HUD : AbstractGUI
|
|||
int height = AppManager.Instance.CurentScreenResolution.Y;
|
||||
|
||||
Button pauseButton = new Button(Manager)
|
||||
{ fontName = "Fonts\\Font3", scale = 0.4f, text = "| |", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width - width / 30 - width / 40, height / 30, width / 40, width / 40), textureName = "Textures\\GUI\\checkboxs_off"};
|
||||
{
|
||||
fontName = "Fonts\\Font3", scale = 0.4f, text = "| |", fontColor = Color.Black,
|
||||
mainColor = Color.Transparent, rectangle = new Rectangle(width - width / 30 - width / 40, height / 30, width / 40, width / 40),
|
||||
textureName = "Textures/GUI/Button2"
|
||||
};
|
||||
Elements.Add(pauseButton);
|
||||
pauseButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
AppManager.Instance.SetGUI(new PauseGUI());
|
||||
//AppManager.Instance.SetGUI(new FinishingGUI());
|
||||
overlayGUI = new PauseGUI();
|
||||
overlayGUI.Initialize();
|
||||
overlayGUI.LoadContent();
|
||||
};
|
||||
Button invButton = new Button(Manager)
|
||||
{ fontName = "Fonts\\Font3", scale = 0.4f, text = "inv", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width - width / 30 - width / 40, height / 15 + width / 40, width / 40, width / 40), textureName = "Textures\\GUI\\checkboxs_off"};
|
||||
{
|
||||
fontName = "Fonts\\Font3", scale = 0.4f, fontColor = Color.Black,
|
||||
mainColor = Color.Transparent, rectangle = new Rectangle(width - width / 30 - width / 40, height / 15 + width / 40, width / 40, width / 40),
|
||||
textureName = "Textures/GUI/ButtonI"
|
||||
};
|
||||
Elements.Add(invButton);
|
||||
invButton.LeftButtonPressed += () =>
|
||||
{
|
||||
|
|
|
@ -31,7 +31,8 @@ public class InventoryGUI : AbstractGUI
|
|||
rectangle = new Rectangle(width / 2 - height / 80 - width / 5 / 2,
|
||||
height / 2 - (int)(height / 1.5) / 2 - height / 10,
|
||||
height / 40 + width / 5, (int)(height / 1.5)),
|
||||
mainColor = Color.LightGray
|
||||
mainColor = Color.LightGray,
|
||||
textureName = "Textures/GUI/Back"
|
||||
};
|
||||
Elements.Add(inventoryBack);
|
||||
|
||||
|
@ -43,7 +44,8 @@ public class InventoryGUI : AbstractGUI
|
|||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
fontName = "Fonts\\Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
continueButton.LeftButtonPressed += () => { AppManager.Instance.SetGUI(new HUD()); };
|
||||
Elements.Add(continueButton);
|
||||
|
@ -69,7 +71,8 @@ public class InventoryGUI : AbstractGUI
|
|||
mainColor = Color.Gray,
|
||||
fontName1 = "Fonts\\Font4",
|
||||
discriptions1 = itemInfo.description,
|
||||
resourcesNeededToCraft1 = itemInfo.resourcesNeededToCraft
|
||||
resourcesNeededToCraft1 = itemInfo.resourcesNeededToCraft,
|
||||
textureName = "Texturs/GUI/Button"
|
||||
};
|
||||
Elements.Add(temp);
|
||||
temp.Initialize();
|
||||
|
|
|
@ -36,11 +36,12 @@ public class MainMenuGUI : AbstractGUI
|
|||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
playButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Loot");
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
AppManager.Instance.SetGUI(new SelectModeMenu());
|
||||
};
|
||||
Elements.Add(playButton);
|
||||
|
@ -51,10 +52,12 @@ public class MainMenuGUI : AbstractGUI
|
|||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
fontName = "Fonts\\Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
baseButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
AppManager.Instance.SetGUI(new BaseGUI());
|
||||
};
|
||||
Elements.Add(baseButton);
|
||||
|
@ -65,11 +68,12 @@ public class MainMenuGUI : AbstractGUI
|
|||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
optionButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Loot");
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
AppManager.Instance.SetGUI(new OptionsGUI());
|
||||
};
|
||||
Elements.Add(optionButton);
|
||||
|
@ -80,7 +84,8 @@ public class MainMenuGUI : AbstractGUI
|
|||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
exitButton.LeftButtonPressed += () =>
|
||||
{
|
||||
|
|
|
@ -43,6 +43,7 @@ public class OptionsGUI : AbstractGUI
|
|||
label_OverallVolume_Percent.text = Math.Round(slider_OverallVolume.GetSliderValue * 100) + "%";
|
||||
slider_OverallVolume.SliderChanged += (newVal) =>
|
||||
{
|
||||
|
||||
label_OverallVolume_Percent.text = Math.Round(slider_OverallVolume.GetSliderValue * 100) + "%";
|
||||
AppManager.Instance.SettingsManager.SetMainVolume(newVal);
|
||||
};
|
||||
|
@ -64,6 +65,7 @@ public class OptionsGUI : AbstractGUI
|
|||
label_MusicVolume_Percent.text = Math.Round(slider_MusicVolume.GetSliderValue * 100) + "%";
|
||||
slider_MusicVolume.SliderChanged += (newVal) =>
|
||||
{
|
||||
|
||||
label_MusicVolume_Percent.text = Math.Round(slider_MusicVolume.GetSliderValue * 100) + "%";
|
||||
AppManager.Instance.SettingsManager.SetMusicVolume(newVal);
|
||||
};
|
||||
|
@ -85,6 +87,7 @@ public class OptionsGUI : AbstractGUI
|
|||
label_EffectsVolume_Percent.text = Math.Round(slider_EffectsVolume.GetSliderValue * 100) + "%";
|
||||
slider_EffectsVolume.SliderChanged += (newVal) =>
|
||||
{
|
||||
|
||||
label_EffectsVolume_Percent.text = Math.Round(slider_EffectsVolume.GetSliderValue * 100) + "%";
|
||||
AppManager.Instance.SettingsManager.SetSoundEffectsVolume(newVal);
|
||||
};
|
||||
|
@ -109,6 +112,7 @@ public class OptionsGUI : AbstractGUI
|
|||
button_FullScreen.SetIsChecked(AppManager.Instance.SettingsManager.IsFullScreen);
|
||||
button_FullScreen.Checked += (newCheckState) =>
|
||||
{
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
AppManager.Instance.SettingsManager.SetIsFullScreen(newCheckState);
|
||||
};
|
||||
Elements.Add(button_FullScreen);
|
||||
|
@ -116,10 +120,15 @@ public class OptionsGUI : AbstractGUI
|
|||
//--------------------------------------
|
||||
|
||||
Button bTExit = new Button(Manager)
|
||||
{ fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures/GUI/checkboxs_off"};
|
||||
{
|
||||
fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent,
|
||||
rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40),
|
||||
textureName = "Textures/GUI/Button2"
|
||||
};
|
||||
Elements.Add(bTExit);
|
||||
bTExit.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
AppManager.Instance.SetGUI(new MainMenuGUI());
|
||||
};
|
||||
|
||||
|
|
|
@ -27,10 +27,12 @@ public class PauseGUI : AbstractGUI
|
|||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
fontName = "Fonts\\Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
continueButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
AppManager.Instance.SetGUI(new HUD());
|
||||
};
|
||||
Elements.Add(continueButton);
|
||||
|
@ -41,10 +43,14 @@ public class PauseGUI : AbstractGUI
|
|||
scale = 0.2f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts\\Font"
|
||||
fontName = "Fonts\\Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
exitButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SoundManager.StopAllSounds();
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Background menu music");
|
||||
AppManager.Instance.SetGUI(new MainMenuGUI());
|
||||
};
|
||||
Elements.Add(exitButton);
|
||||
|
|
|
@ -34,10 +34,14 @@ public class SelectModeMenu : AbstractGUI
|
|||
scale = 0.3f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
singleButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SoundManager.StopAllSounds();
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Background music");
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
// single
|
||||
Server server = new Server();
|
||||
Client client = new Client();
|
||||
|
@ -64,10 +68,12 @@ public class SelectModeMenu : AbstractGUI
|
|||
scale = 0.3f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
optionButton.LeftButtonPressed += () =>
|
||||
{
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
AppManager.Instance.SetGUI(new SelectingServerGUI());
|
||||
// multi
|
||||
|
||||
|
@ -76,10 +82,17 @@ public class SelectModeMenu : AbstractGUI
|
|||
Elements.Add(optionButton);
|
||||
|
||||
Button bTExit = new Button(Manager)
|
||||
{ fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures/GUI/checkboxs_off"};
|
||||
{
|
||||
fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent,
|
||||
rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40),
|
||||
textureName = "Textures/GUI/Button2"
|
||||
};
|
||||
Elements.Add(bTExit);
|
||||
bTExit.LeftButtonPressed += () =>
|
||||
{
|
||||
|
||||
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
|
||||
|
||||
AppManager.Instance.SetGUI(new MainMenuGUI());
|
||||
};
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ public class SelectingServerGUI : AbstractGUI
|
|||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
textAligment = MonogameLibrary.UI.Enums.TextAligment.Left,
|
||||
fontName = "Fonts/Font3"
|
||||
fontName = "Fonts/Font3",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
ipBox.TextChanged += input =>
|
||||
{
|
||||
|
@ -61,7 +62,8 @@ public class SelectingServerGUI : AbstractGUI
|
|||
scale = 0.3f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
joinButton.LeftButtonPressed += () =>
|
||||
{
|
||||
|
@ -80,11 +82,7 @@ public class SelectingServerGUI : AbstractGUI
|
|||
AppManager.Instance.SetGUI(new WaitingForPlayersGUI(false));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
// throw;
|
||||
}
|
||||
catch (Exception) { }
|
||||
|
||||
// ваш код здесь
|
||||
};
|
||||
|
@ -96,7 +94,8 @@ public class SelectingServerGUI : AbstractGUI
|
|||
scale = 0.3f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
hostButton.LeftButtonPressed += () =>
|
||||
{
|
||||
|
@ -116,7 +115,11 @@ public class SelectingServerGUI : AbstractGUI
|
|||
Elements.Add(hostButton);
|
||||
|
||||
Button bTExit = new Button(Manager)
|
||||
{ fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures/GUI/checkboxs_off" };
|
||||
{
|
||||
fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent,
|
||||
rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40),
|
||||
textureName = "Textures/GUI/Button2"
|
||||
};
|
||||
Elements.Add(bTExit);
|
||||
bTExit.LeftButtonPressed += () =>
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ public class WaitingForPlayersGUI : AbstractGUI
|
|||
int width = AppManager.Instance.CurentScreenResolution.X;
|
||||
int height = AppManager.Instance.CurentScreenResolution.Y;
|
||||
|
||||
menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures/GUI/background/Waiting" };
|
||||
menuBackground = new DrawableUIElement(Manager) { rectangle = new Rectangle(0, 0, width, height), mainColor = Color.White, textureName = "Textures/GUI/background/waiting" };
|
||||
Elements.Add(menuBackground);
|
||||
menuBackground.LoadTexture(AppManager.Instance.Content);
|
||||
// string pcIp =
|
||||
|
@ -47,7 +47,8 @@ public class WaitingForPlayersGUI : AbstractGUI
|
|||
scale = 0.3f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
startButton.LeftButtonPressed += () =>
|
||||
{
|
||||
|
@ -67,18 +68,24 @@ public class WaitingForPlayersGUI : AbstractGUI
|
|||
scale = 0.3f,
|
||||
fontColor = Color.White,
|
||||
mainColor = Color.Gray,
|
||||
fontName = "Fonts/Font"
|
||||
fontName = "Fonts/Font",
|
||||
textureName = "Textures/GUI/Button"
|
||||
};
|
||||
waitButton.LeftButtonPressed += () =>
|
||||
{
|
||||
// start
|
||||
AppManager.Instance.SetGUI(new HUD());
|
||||
// ваш код здесь
|
||||
};
|
||||
Elements.Add(waitButton);
|
||||
}
|
||||
|
||||
Button bTExit = new Button(Manager)
|
||||
{ fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent, rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40), textureName = "Textures/GUI/checkboxs_off"};
|
||||
{
|
||||
fontName = "Fonts/Font3", scale = 0.4f, text = "<-", fontColor = Color.Black, mainColor = Color.Transparent,
|
||||
rectangle = new Rectangle(width / 30, height / 30, width / 40, width / 40),
|
||||
textureName = "Textures/GUI/Button2"
|
||||
};
|
||||
Elements.Add(bTExit);
|
||||
bTExit.LeftButtonPressed += () =>
|
||||
{
|
||||
|
|
|
@ -62,12 +62,14 @@ namespace ZoFo.GameCore.GameManagers
|
|||
ItemManager = new ItemManager.ItemManager();
|
||||
Instance = this;
|
||||
InputManager = new InputManager();
|
||||
SoundManager = new SoundManager();
|
||||
SoundManager.LoadSounds();
|
||||
SettingsManager = new SettingsManager();
|
||||
SettingsManager.LoadSettings();
|
||||
SoundManager = new SoundManager();
|
||||
AssetManager = new AssetManager();
|
||||
SoundManager.LoadSounds();
|
||||
|
||||
AssetManager = new AssetManager();
|
||||
|
||||
SoundManager.StartAmbientSound("Background menu music");
|
||||
|
||||
currentGUI = new MainMenuGUI();
|
||||
debugHud = new DebugHUD();
|
||||
|
@ -125,13 +127,20 @@ namespace ZoFo.GameCore.GameManagers
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (client != null)
|
||||
{
|
||||
if (client.changeGUI)
|
||||
{
|
||||
SetGUI(new FinishingGUI());
|
||||
client.changeGUI = false;
|
||||
}
|
||||
}
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
protected override void Draw(GameTime gameTime)
|
||||
{
|
||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||
GraphicsDevice.Clear(Color.Black);
|
||||
|
||||
|
||||
// Pointwrap
|
||||
|
@ -139,6 +148,8 @@ namespace ZoFo.GameCore.GameManagers
|
|||
switch (gamestate)
|
||||
{
|
||||
case GameState.ClientPlaying:
|
||||
client.Draw(_spriteBatch);
|
||||
break;
|
||||
case GameState.HostPlaying:
|
||||
client.Draw(_spriteBatch);
|
||||
break;
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace ZoFo.GameCore.GameManagers
|
|||
#endregion
|
||||
|
||||
#region Обработка взаимодействия с collectable(например лутом). Вызывает событие OnInteract
|
||||
if (keyBoardState.IsKeyDown(Keys.E) && !isInteract)
|
||||
if ((keyBoardState.IsKeyDown(Keys.E) || mouseState.LeftButton == ButtonState.Pressed) && !isInteract)
|
||||
{
|
||||
OnInteract?.Invoke();
|
||||
Debug.WriteLine("взаимодействие с Collectable");
|
||||
|
@ -256,7 +256,35 @@ namespace ZoFo.GameCore.GameManagers
|
|||
DebugHUD.DebugSet("x", vector.X.ToString());
|
||||
}
|
||||
return currentScopeState;
|
||||
}
|
||||
public static Vector2 ConvertStateToVector2(ScopeState scopeState)
|
||||
{
|
||||
switch (scopeState)
|
||||
{
|
||||
case ScopeState.Idle:
|
||||
return new Vector2(0, 0);
|
||||
case ScopeState.Left:
|
||||
return new Vector2(-1, 0);
|
||||
case ScopeState.Right:
|
||||
return new Vector2(1, 0);
|
||||
case ScopeState.Top:
|
||||
return new Vector2(0, -1);
|
||||
case ScopeState.Down:
|
||||
return new Vector2(0, 1);
|
||||
case ScopeState.TopLeft:
|
||||
return new Vector2(-1, -1);
|
||||
case ScopeState.TopRight:
|
||||
return new Vector2(-1, 1);
|
||||
case ScopeState.DownLeft:
|
||||
return new Vector2(1, -1);
|
||||
case ScopeState.DownRight:
|
||||
return new Vector2(1, 1);
|
||||
default:
|
||||
return new Vector2(0, 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
public bool ButtonClicked(Keys key) => keyBoardState.IsKeyUp(key) && keyBoardState.IsKeyDown(key);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
|||
//методы
|
||||
public ItemInfo GetItemInfo(string tag)
|
||||
{
|
||||
if (tag == "peeble")
|
||||
return tagItemPairs["pebble"];
|
||||
return tagItemPairs[tag];
|
||||
}
|
||||
public void LoadItemTextures()
|
||||
|
@ -25,19 +27,47 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
|||
public void Initialize()
|
||||
{
|
||||
tagItemPairs = new Dictionary<string, ItemInfo>();
|
||||
tagItemPairs.Add("rottenflesh", new ItemInfo("rottenflesh", "БУХАТЬ", "Textures/icons/Collectables/RottenFlesh",false,null));
|
||||
tagItemPairs.Add("purebottleofwater", new ItemInfo("purebottleofwater", "БУХАТЬ 2", "Textures/icons/Collectables/PureBottleOfWater",false,null));
|
||||
tagItemPairs.Add("bottleofwater", new ItemInfo("bottleofwater", "БУХАТЬ", "Textures/icons/Collectables/BottleOfWater",false,null));
|
||||
tagItemPairs.Add("rottenflesh", new ItemInfo("rottenflesh", "гниль", "Textures/icons/Collectables/RottenFlesh",false,null));
|
||||
tagItemPairs.Add("bottleofwater", new ItemInfo("bottleofwater", "грязная водка", "Textures/icons/Collectables/BottleOfWater",false,null));
|
||||
//tagItemPairs.Add("antiradin", new ItemInfo("antiradin", "радиацию опускает", "Textures/icons/Collectables/Ammo",false,null));
|
||||
tagItemPairs.Add("ammo", new ItemInfo("ammo", "деньги в метро", "Textures/icons/Collectables/Ammo",false,null));
|
||||
tagItemPairs.Add("wood", new ItemInfo("wood", "бревна кусок", "Textures/icons/Collectables/Wood",false,null));
|
||||
tagItemPairs.Add("peeble", new ItemInfo("peeble", "пять галек", "Textures/icons/Collectables/Peeble", false, null));
|
||||
tagItemPairs.Add("fabric", new ItemInfo("fabric", "смотя какой fabric", "Textures/icons/Material/Fabric",false,null));
|
||||
tagItemPairs.Add("paper", new ItemInfo("paper", "бумага", "Textures/icons/Material/Paper",false,null));
|
||||
tagItemPairs.Add("pebble", new ItemInfo("pebble", "пять галек", "Textures/icons/Collectables/Pebble", false, null));
|
||||
tagItemPairs.Add("steel", new ItemInfo("steel", "метал, метал, \nжелезо, метал", "Textures/icons/Collectables/Steel", false, null));
|
||||
tagItemPairs.Add("pickaxe", new ItemInfo("pickaxe", "прямой путь к \nстановлению каменьщиком", "Textures/Test/pickaxe", true, new Dictionary<string, int>()
|
||||
{
|
||||
{"wood", 2},
|
||||
{"steel", 3}
|
||||
}));
|
||||
tagItemPairs.Add("plank", new ItemInfo("plank", "проосто доска", "Textures/icons/Material/Wooden Plank", true, new Dictionary<string, int>()
|
||||
{
|
||||
{"wood", 1}
|
||||
}));
|
||||
tagItemPairs.Add("gear", new ItemInfo("gear", "настройки", "Textures/icons/Misc/Gear", true, new Dictionary<string, int>()
|
||||
{
|
||||
{"steel", 3}
|
||||
}));
|
||||
tagItemPairs.Add("purebottleofwater", new ItemInfo("purebottleofwater", "чистая водка", "Textures/icons/Collectables/PureBottleOfWater", true, new Dictionary<string, int>()
|
||||
{
|
||||
{"bottleofwater", 1},
|
||||
{"wood", 2}
|
||||
}));
|
||||
tagItemPairs.Add("leather", new ItemInfo("leather", "кожа", "Textures/icons/Material/Leather", true, new Dictionary<string, int>()
|
||||
{
|
||||
{"rottenflash", 1},
|
||||
{"wood", 2}
|
||||
}));
|
||||
tagItemPairs.Add("crate", new ItemInfo("crate", "коробка", "Textures/icons/Misc/Crate", true, new Dictionary<string, int>()
|
||||
{
|
||||
{"plank", 5}
|
||||
}));
|
||||
tagItemPairs.Add("book", new ItemInfo("book", "книга", "Textures/icons/Misc/Book", true, new Dictionary<string, int>()
|
||||
{
|
||||
{"leather", 2},
|
||||
{"paper", 5}
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers.ItemManager
|
||||
|
@ -15,7 +17,16 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
|||
{
|
||||
LoadPlayerData();
|
||||
}
|
||||
public Dictionary<string, int> items;
|
||||
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>
|
||||
|
@ -50,11 +61,52 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
|
|||
|
||||
public void LoadPlayerData()
|
||||
{
|
||||
//TODO
|
||||
items = new Dictionary<string, int>();
|
||||
items.Add("wood", 5);
|
||||
items.Add("steel", 110);
|
||||
items.Add("peeble", 6);
|
||||
/*items.Add("wood", 100);
|
||||
items.Add("steel", 100);
|
||||
items.Add("bottleofwater", 100);
|
||||
items.Add("rottenflesh", 100);
|
||||
items.Add("pebble", 100);
|
||||
items.Add("ammo", 100);
|
||||
items.Add("fabric", 100);
|
||||
items.Add("paper", 100);*/
|
||||
if (File.Exists("Items.txt"))
|
||||
{
|
||||
string data;
|
||||
using (StreamReader reader = new StreamReader("Items.txt"))
|
||||
{
|
||||
data = reader.ReadToEnd();
|
||||
}
|
||||
|
||||
List<PlayerItemsData> itemsDatas = JsonSerializer.Deserialize<List<PlayerItemsData>>(data);
|
||||
foreach (var item in itemsDatas)
|
||||
{
|
||||
items.Add(item.Name, item.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SavePlayerData()
|
||||
{
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
|
||||
List<PlayerItemsData> playerItemsDatas = new List<PlayerItemsData>();
|
||||
foreach (var item in items)
|
||||
{
|
||||
playerItemsDatas.Add(new PlayerItemsData { Name = item.Key, Count = item.Value });
|
||||
}
|
||||
|
||||
string data = JsonSerializer.Serialize<List<PlayerItemsData>>(playerItemsDatas);
|
||||
|
||||
using (StreamWriter outputFile = new StreamWriter("Items.txt", new FileStreamOptions() { Mode = FileMode.Create, Access = FileAccess.Write } ))
|
||||
{
|
||||
outputFile.WriteLine(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PlayerItemsData
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,8 @@ namespace ZoFo.GameCore.GameManagers.MapManager
|
|||
private static readonly JsonSerializerOptions _options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; // Задача настроек для JsonSerialize
|
||||
private static readonly Dictionary<string, string> _classPath = new Dictionary<string, string>() {
|
||||
{ "Collectables", "ZoFo.GameCore.GameObjects." },
|
||||
{ "Enemies", "ZoFo.GameCore.GameObjects." }
|
||||
{ "Enemies", "ZoFo.GameCore.GameObjects." },
|
||||
{ "Zones", "ZoFo.GameCore.GameObjects." }
|
||||
};
|
||||
|
||||
//private static readonly float _scale = 1.0f;
|
||||
|
|
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||
using System.Data.SqlTypes;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
|
@ -20,7 +21,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
{
|
||||
public class ClientNetworkManager
|
||||
{
|
||||
private int PlayerId;
|
||||
public int PlayerId = 0;
|
||||
private IPEndPoint endPoint;
|
||||
private IPEndPoint sendingEP;
|
||||
private Socket socket;
|
||||
|
@ -83,7 +84,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
if (AppManager.Instance.gamestate != GameState.HostPlaying)
|
||||
{
|
||||
AppManager.Instance.ChangeState(GameState.ClientPlaying);
|
||||
AppManager.Instance.SetGUI(new HUD());
|
||||
}
|
||||
SendAcknowledgement(Dgramm.DatagrammId);
|
||||
}
|
||||
|
@ -139,6 +139,10 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
update = token.ToObject<UpdateGameObjectCreated>();
|
||||
data.Add(update);
|
||||
break;
|
||||
case "UpdateGameObjectWithoutIdCreated":
|
||||
update = token.ToObject<UpdateGameObjectWithoutIdCreated>();
|
||||
data.Add(update);
|
||||
break;
|
||||
case "UpdateGameObjectDeleted":
|
||||
update = token.ToObject<UpdateGameObjectDeleted>();
|
||||
data.Add(update);
|
||||
|
@ -171,6 +175,10 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
update = token.ToObject<UpdateTileCreated>();
|
||||
data.Add(update);
|
||||
break;
|
||||
case "UpdateCreatePlayer":
|
||||
update = token.ToObject<UpdateCreatePlayer>();
|
||||
data.Add(update);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +223,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
public void JoinRoom(string ip, int port) // multyplayer
|
||||
{
|
||||
sendingEP = new IPEndPoint(IPAddress.Parse(ip), port);
|
||||
AppManager.Instance.ChangeState(GameState.ClientPlaying);
|
||||
SendData();
|
||||
Thread listen = new Thread(StartListening);
|
||||
listen.IsBackground = true;
|
||||
|
@ -236,19 +243,18 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
#endregion
|
||||
public static IPAddress GetIp()
|
||||
{
|
||||
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
|
||||
var ipList = Dns.GetHostEntry(hostName).AddressList;
|
||||
var ipV4List = new List<IPAddress>();
|
||||
foreach (var ip in ipList)
|
||||
var ips = NetworkInterface.GetAllNetworkInterfaces()
|
||||
.Where(x => x.OperationalStatus == OperationalStatus.Up)
|
||||
.Where(x => x.NetworkInterfaceType is NetworkInterfaceType.Wireless80211
|
||||
or NetworkInterfaceType.Ethernet)
|
||||
.SelectMany(x => x.GetIPProperties().UnicastAddresses)
|
||||
.Where(x => x.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||
.Select(x => x.Address)
|
||||
.ToList();
|
||||
|
||||
if (ips.Count > 0)
|
||||
{
|
||||
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
|
||||
{
|
||||
ipV4List.Add(ip);
|
||||
}
|
||||
}
|
||||
if (ipV4List.Count>0)
|
||||
{
|
||||
return ipV4List[ipV4List.Count - 1];
|
||||
return ips[^1];
|
||||
}
|
||||
return IPAddress.Loopback;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
@ -28,7 +29,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
private IPAddress ip;
|
||||
private bool isMultiplayer;
|
||||
//Player Id to Player endPoint
|
||||
private List<IPEndPoint> clientsEP;
|
||||
public List<IPEndPoint> clientsEP;
|
||||
public IPEndPoint endPoint;
|
||||
private List<UpdateData> commonUpdates;
|
||||
private List<UpdateData> importantUpdates;
|
||||
|
@ -66,20 +67,18 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
/// <returns></returns>
|
||||
public static IPAddress GetIp()
|
||||
{
|
||||
string hostName = Dns.GetHostName(); // Retrive the Name of HOST
|
||||
var ipList = Dns.GetHostEntry(hostName).AddressList;
|
||||
var ips = NetworkInterface.GetAllNetworkInterfaces()
|
||||
.Where(x => x.OperationalStatus == OperationalStatus.Up)
|
||||
.Where(x => x.NetworkInterfaceType is NetworkInterfaceType.Wireless80211
|
||||
or NetworkInterfaceType.Ethernet)
|
||||
.SelectMany(x => x.GetIPProperties().UnicastAddresses)
|
||||
.Where(x => x.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||
.Select(x => x.Address)
|
||||
.ToList();
|
||||
|
||||
var ipV4List = new List<IPAddress>();
|
||||
foreach (var ip in ipList)
|
||||
if (ips.Count > 0)
|
||||
{
|
||||
if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
|
||||
{
|
||||
ipV4List.Add(ip);
|
||||
}
|
||||
}
|
||||
if (ipV4List.Count > 0)
|
||||
{
|
||||
return ipV4List[ipV4List.Count - 1];
|
||||
return ips[^1];
|
||||
}
|
||||
return IPAddress.Loopback;
|
||||
}
|
||||
|
@ -117,27 +116,25 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
|
|||
List<UpdateData> dataToSend;
|
||||
if (importantUpdates.Count > 0)
|
||||
{
|
||||
dataToSend = new List<UpdateData>();
|
||||
for (int j = 0; j < datapackSize && j < importantUpdates.Count; j++)
|
||||
dataToSend.Add(importantUpdates[j]);
|
||||
for (int i = 0; i < clientsEP.Count; i++)
|
||||
{
|
||||
dataToSend = new List<UpdateData>();
|
||||
for (int j = 0; j < datapackSize && j < importantUpdates.Count; j++)
|
||||
dataToSend.Add(importantUpdates[j]);
|
||||
Datagramm impDgramm = new Datagramm();
|
||||
impDgramm.DatagrammId = currentDatagrammId;
|
||||
impDgramm.updateDatas = dataToSend;
|
||||
impDgramm.isImportant = true;
|
||||
impDgramm.PlayerId = i + 1;
|
||||
sendedData.Add(impDgramm);
|
||||
for (int j = 0; j < datapackSize && j < dataToSend.Count; j++)
|
||||
importantUpdates.RemoveAt(0);
|
||||
}
|
||||
for (int j = 0; j < datapackSize && j < dataToSend.Count; j++)
|
||||
importantUpdates.RemoveAt(0);
|
||||
currentDatagrammId++;
|
||||
}
|
||||
|
||||
if (sendedData.Count != 0)
|
||||
{
|
||||
|
||||
|
||||
for (int i = 0; i < clientsEP.Count; i++)
|
||||
{
|
||||
foreach (Datagramm Dgramm in sendedData.Where(x => x.PlayerId == i+1))
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer
|
|||
// public int IdEntity { get; set; }
|
||||
public SerializableVector2 InputMovementDirection{get;set;}
|
||||
public SerializableVector2 InputAttackDirection {get;set;}
|
||||
|
||||
public int PlayerId {get;set;}
|
||||
public UpdateInput()
|
||||
{
|
||||
UpdateType = "UpdateInput";
|
||||
|
|
|
@ -9,4 +9,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
|
|||
public class UpdateInputInteraction : UpdateData
|
||||
{
|
||||
public UpdateInputInteraction() { UpdateType = "UpdateInputInteraction"; }
|
||||
public int PlayerId { get; set; }
|
||||
|
||||
}
|
||||
|
|
|
@ -6,4 +6,5 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
|
|||
public class UpdateInputShoot : UpdateData
|
||||
{
|
||||
public UpdateInputShoot() { UpdateType = "UpdateInputShoot"; }
|
||||
public int PlayerId { get; set; }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
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 UpdateCreatePlayer()
|
||||
{
|
||||
isImportant = true;
|
||||
UpdateType = "UpdateCreatePlayer";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
|||
/// </summary>
|
||||
public class UpdateGameObjectWithoutIdCreated : UpdateData
|
||||
{
|
||||
public UpdateGameObjectWithoutIdCreated() { UpdateType = "UpdateGameObjectWithoutIdCreated"; }
|
||||
public UpdateGameObjectWithoutIdCreated() { UpdateType = "UpdateGameObjectWithoutIdCreated"; isImportant = true; }
|
||||
public string GameObjectClassName { get; set; }
|
||||
public SerializableVector2 position { get; set; }
|
||||
}
|
||||
|
|
|
@ -12,6 +12,6 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
|||
public class UpdateGameObjectDeleted : UpdateData
|
||||
{
|
||||
public UpdateGameObjectDeleted() { UpdateType = "UpdateGameObjectDeleted"; isImportant = false; }
|
||||
public string GameObjectType;
|
||||
public string GameObjectType { get; set; }
|
||||
}
|
||||
}
|
|
@ -11,8 +11,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
|
|||
/// </summary>
|
||||
public class UpdatePlayerParametrs : UpdateData
|
||||
{
|
||||
public UpdatePlayerParametrs() { UpdateType = "UpdatePlayerParametrs"; }
|
||||
public float radiatoin;
|
||||
public float health;
|
||||
public UpdatePlayerParametrs() { UpdateType = "UpdatePlayerParametrs"; isImportant = true; }
|
||||
public float radiatoin { get; set; }
|
||||
public float health { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates
|
|||
[JsonDerivedType(typeof(UpdatePlayerExit))]
|
||||
[JsonDerivedType(typeof(UpdateInputInteraction))]
|
||||
[JsonDerivedType(typeof(UpdateInputShoot))]
|
||||
[JsonDerivedType(typeof(UpdateCreatePlayer))]
|
||||
|
||||
public class UpdateData
|
||||
{
|
||||
|
|
|
@ -28,18 +28,21 @@ namespace ZoFo.GameCore.GameManagers
|
|||
public void SetMainVolume(float volume)
|
||||
{
|
||||
settingsContainer.MainVolume = volume;
|
||||
//AppManager.Instance.SoundManager.Update();
|
||||
// AppManager.Instance.SoundManager.Update();
|
||||
SaveSettings();
|
||||
}
|
||||
public void SetMusicVolume(float volume)
|
||||
{
|
||||
settingsContainer.MusicVolume = volume;
|
||||
//AppManager.Instance.SoundManager.Update();
|
||||
|
||||
SaveSettings();
|
||||
|
||||
}
|
||||
public void SetSoundEffectsVolume(float volume)
|
||||
{
|
||||
settingsContainer.SoundEffectsVolume = volume;
|
||||
// AppManager.Instance.SoundManager.Update();
|
||||
SaveSettings();
|
||||
|
||||
}
|
||||
|
@ -68,6 +71,7 @@ namespace ZoFo.GameCore.GameManagers
|
|||
}
|
||||
public void SaveSettings()
|
||||
{
|
||||
AppManager.Instance.SoundManager.Update();
|
||||
using (StreamWriter streamWriter = new StreamWriter("GameSettings.txt"))
|
||||
{
|
||||
string _str = JsonConvert.SerializeObject(settingsContainer);
|
||||
|
|
|
@ -40,12 +40,15 @@ namespace ZoFo.GameCore.GameObjects
|
|||
|
||||
public void StartAnimation(string animationId)
|
||||
{
|
||||
(graphicsComponent as Graphics.AnimatedGraphicsComponent).StartAnimation(animationId);
|
||||
AppManager.Instance.server.AddData(new GameManagers.NetworkManager.Updates.ServerToClient.UpdateAnimation()
|
||||
if (AppManager.Instance.gamestate == GameState.HostPlaying)
|
||||
{
|
||||
animationId = animationId,
|
||||
IdEntity = Id
|
||||
});
|
||||
(graphicsComponent as Graphics.AnimatedGraphicsComponent).StartAnimation(animationId);
|
||||
AppManager.Instance.server.AddData(new GameManagers.NetworkManager.Updates.ServerToClient.UpdateAnimation()
|
||||
{
|
||||
animationId = animationId,
|
||||
IdEntity = Id
|
||||
});
|
||||
}
|
||||
}
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
|
@ -56,7 +59,10 @@ namespace ZoFo.GameCore.GameObjects
|
|||
|
||||
public virtual void Delete()
|
||||
{
|
||||
AppManager.Instance.server.DeleteObject(this);
|
||||
if (AppManager.Instance.gamestate == GameState.HostPlaying)
|
||||
{
|
||||
AppManager.Instance.server.DeleteObject(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace ZoFo.GameCore.GameObjects
|
|||
{
|
||||
public class Peeble:Collectable
|
||||
{
|
||||
public override StaticGraphicsComponent graphicsComponent { get; } = new(_path + "Peeble");
|
||||
public override StaticGraphicsComponent graphicsComponent { get; } = new(_path + "Pebble");
|
||||
|
||||
public Peeble(Vector2 position) : base(position) { }
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace ZoFo.GameCore.GameObjects
|
|||
public Zombie(Vector2 position) : base(position)
|
||||
{
|
||||
health = 5;
|
||||
speed = 0.5f;
|
||||
speed = 7.5f;
|
||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30);
|
||||
collisionComponent.stopRectangle = new Rectangle(10, 20, 10, 10);
|
||||
isAttacking = false;
|
||||
|
@ -45,15 +45,36 @@ namespace ZoFo.GameCore.GameObjects
|
|||
public override void Update()
|
||||
{
|
||||
if (isDying) return;
|
||||
Vector2 duration = Vector2.Normalize(
|
||||
AppManager.Instance.server.players[0].position - position
|
||||
float m = 10000000;
|
||||
int j = -1;
|
||||
for (int i = 0; i < AppManager.Instance.server.players.Count; i++)
|
||||
{
|
||||
var player = AppManager.Instance.server.players[i];
|
||||
if (m > (player.position.X - position.X) * (player.position.X - position.X) + (player.position.Y - position.Y) * (player.position.Y - position.Y))
|
||||
{
|
||||
m = (player.position.X - position.X) * (player.position.X - position.X) + (player.position.Y - position.Y) * (player.position.Y - position.Y);
|
||||
j = i;
|
||||
}
|
||||
}
|
||||
Vector2 duration = Vector2.Zero;
|
||||
if (m<= 130000)
|
||||
{
|
||||
duration = Vector2.Normalize(
|
||||
AppManager.Instance.server.players[j].position - position
|
||||
);
|
||||
|
||||
|
||||
if (Random.Shared.NextDouble() > 0.999)
|
||||
{
|
||||
AppManager.Instance.SoundManager.StartSound("zombie sound", position, AppManager.Instance.server.players[0].position, pitch: new Random().Next(-1, 2) * (float)new Random().NextDouble());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!isAttacking) { velocity += new Vector2(duration.X * speed, duration.Y * speed); }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void OnPlayerClose(GameObject sender)
|
||||
{
|
||||
|
@ -61,6 +82,8 @@ namespace ZoFo.GameCore.GameObjects
|
|||
|
||||
if(!isAttacking)
|
||||
{
|
||||
|
||||
AppManager.Instance.SoundManager.StartSound("Zombi napal", position, AppManager.Instance.server.players[0].position,pitch:new Random().Next(-1,2)*(float)new Random().NextDouble());
|
||||
StartAnimation("zombie_attack");
|
||||
isAttacking = true;
|
||||
}
|
||||
|
@ -70,13 +93,14 @@ namespace ZoFo.GameCore.GameObjects
|
|||
}
|
||||
public void EndAttack(string a)
|
||||
{
|
||||
if (AppManager.Instance.server is null) return;
|
||||
var damagedPlayers=AppManager.Instance.server.collisionManager.GetPlayersInZone(collisionComponent.triggerRectangle.SetOrigin(position));
|
||||
//TODO ДАМАЖИТЬ ИГРОКОВ В ЗОНЕ
|
||||
if (damagedPlayers.Length>0) { DebugHUD.DebugLog("End of" + a);
|
||||
foreach (var item in damagedPlayers)
|
||||
item.TakeDamage(5);
|
||||
item.TakeDamage(20);
|
||||
}
|
||||
isAttacking = false;
|
||||
|
||||
}
|
||||
|
||||
public override void Die()
|
||||
|
@ -87,9 +111,11 @@ namespace ZoFo.GameCore.GameObjects
|
|||
public override void DeathEnd()
|
||||
{
|
||||
|
||||
Instantiate(new Particle(collisionComponent.stopRectangle.Location.ToVector2() + position + ExtentionClass.RandomVector() * 20));
|
||||
Instantiate(new Particle(collisionComponent.stopRectangle.Location.ToVector2() + position + 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));
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -38,15 +38,15 @@ public class LivingEntity : Entity
|
|||
{
|
||||
base.UpdateAnimations();
|
||||
}
|
||||
Vector2 prevPosition_forClient;
|
||||
protected Vector2 prevPosition_forClient;
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if ((position - prevPosition_forClient).X < 0)
|
||||
if ((positionDraw - prevPosition_forClient).X < 0)
|
||||
graphicsComponent.Flip = SpriteEffects.FlipHorizontally;
|
||||
else if ((position - prevPosition_forClient).X > 0)
|
||||
else if ((positionDraw - prevPosition_forClient).X > 0)
|
||||
graphicsComponent.Flip = SpriteEffects.None;
|
||||
base.Draw(spriteBatch);
|
||||
prevPosition_forClient = position;
|
||||
prevPosition_forClient = positionDraw;
|
||||
}
|
||||
|
||||
public virtual void Die()
|
||||
|
|
|
@ -12,6 +12,7 @@ using ZoFo.GameCore.Graphics;
|
|||
using System.Diagnostics;
|
||||
using ZoFo.GameCore.GUI;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Linq;
|
||||
|
||||
namespace ZoFo.GameCore.GameObjects;
|
||||
|
||||
|
@ -22,7 +23,7 @@ public class Player : LivingEntity
|
|||
|
||||
private float speed;
|
||||
public int reloading;
|
||||
public float health= 100;
|
||||
public float health = 100;
|
||||
public float MaxHealth = 100;
|
||||
|
||||
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Player.Animations, AppManager.Instance.AssetManager.Player.IdleAnimation);
|
||||
|
@ -32,7 +33,7 @@ public class Player : LivingEntity
|
|||
public float rad = 0;
|
||||
public float MaxRad = 100;
|
||||
public LootData lootData;
|
||||
|
||||
Vector2 prevPosition;
|
||||
|
||||
|
||||
public bool IsTryingToInteract { get; set; }
|
||||
|
@ -41,122 +42,175 @@ public class Player : LivingEntity
|
|||
/// Факт того, что плеер в этом апдейте пытается стрелять
|
||||
/// </summary>
|
||||
public bool IsTryingToShoot { get; set; }
|
||||
|
||||
ScopeState prevScopeState;
|
||||
public Player(Vector2 position) : base(position)
|
||||
{
|
||||
lootData = new LootData();
|
||||
lootData.loots = new Dictionary<string, int>();
|
||||
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30);
|
||||
collisionComponent.stopRectangle = new Rectangle(0, 15, 30, 15);
|
||||
speed = 2.5f;
|
||||
collisionComponent.stopRectangle = new Rectangle(10, 15, 10, 15);
|
||||
speed = 7;
|
||||
|
||||
StartAnimation("player_look_down");
|
||||
}
|
||||
|
||||
|
||||
public override void Update()
|
||||
public override void Update()
|
||||
{
|
||||
#region название current текстуры
|
||||
var idName = animatedGraphicsComponent.CurrentAnimation.Id;
|
||||
var idName = animatedGraphicsComponent.CurrentAnimation.Id;
|
||||
#endregion
|
||||
|
||||
#region анимация управления подбора лута
|
||||
DebugHUD.DebugSet("texture name", idName);
|
||||
if (reloading>0)
|
||||
if (reloading > 0)
|
||||
{
|
||||
reloading--;
|
||||
|
||||
}
|
||||
|
||||
switch(AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation))
|
||||
switch (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation))
|
||||
{
|
||||
case ScopeState.Top:
|
||||
if (idName!="player_run_up")
|
||||
if (idName != "player_run_up")
|
||||
StartAnimation("player_run_up");
|
||||
break;
|
||||
case ScopeState.Down:
|
||||
if (idName!="player_run_down")
|
||||
if (idName != "player_run_down")
|
||||
StartAnimation("player_run_down");
|
||||
break;
|
||||
case ScopeState.Right:
|
||||
case ScopeState.Left:
|
||||
if (idName!="player_run_right")
|
||||
if (idName != "player_run_right")
|
||||
StartAnimation("player_run_right");
|
||||
break;
|
||||
case ScopeState.TopRight:
|
||||
case ScopeState.TopLeft:
|
||||
if (idName!="player_run_right_up")
|
||||
if (idName != "player_run_right_up")
|
||||
StartAnimation("player_run_right_up");
|
||||
break;
|
||||
break;
|
||||
case ScopeState.DownRight:
|
||||
case ScopeState.DownLeft:
|
||||
if (idName!="player_run_right_down")
|
||||
if (idName != "player_run_right_down")
|
||||
StartAnimation("player_run_right_down");
|
||||
break;
|
||||
break;
|
||||
case ScopeState.Idle:
|
||||
if (idName!="player_look_down")
|
||||
if (idName != "player_look_down")
|
||||
StartAnimation("player_look_down");
|
||||
break;
|
||||
break;
|
||||
}
|
||||
if (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation) != ScopeState.Idle)
|
||||
{
|
||||
prevScopeState = AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation);
|
||||
}
|
||||
else if (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation) == ScopeState.Idle && false)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
switch (prevScopeState)
|
||||
{
|
||||
case ScopeState.Top:
|
||||
if (idName != "player_look_up_weapon")
|
||||
StartAnimation("player_look_up_weapon");
|
||||
break;
|
||||
case ScopeState.Down:
|
||||
if (idName != "player_look_down_weapon")
|
||||
StartAnimation("player_look_down_weapon");
|
||||
break;
|
||||
case ScopeState.Right:
|
||||
case ScopeState.Left:
|
||||
if (idName != "player_look_right_down_weapon")
|
||||
StartAnimation("player_look_right_down_weapon");
|
||||
break;
|
||||
case ScopeState.TopRight:
|
||||
case ScopeState.TopLeft:
|
||||
if (idName != "player_look_right_up_weapon")
|
||||
StartAnimation("player_look_right_up_weapon");
|
||||
break;
|
||||
case ScopeState.DownRight:
|
||||
case ScopeState.DownLeft:
|
||||
if (idName != "player_look_right_down_weapon")
|
||||
StartAnimation("player_look_right_down_weapon");
|
||||
break;
|
||||
case ScopeState.Idle:
|
||||
if (idName != "player_look_down")
|
||||
StartAnimation("player_look_down");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region анимация поворота оружия
|
||||
int currentAttackSection = AppManager.Instance.InputManager.ConvertAttackVector2ToState(InputWeaponRotation);
|
||||
switch(currentAttackSection)
|
||||
{
|
||||
case 0 or 1:
|
||||
//right
|
||||
int currentAttackSection = AppManager.Instance.InputManager.ConvertAttackVector2ToState(InputWeaponRotation);
|
||||
switch (currentAttackSection)
|
||||
{
|
||||
case 0 or 1:
|
||||
//right
|
||||
break;
|
||||
case 2 or 3:
|
||||
//down_right_right
|
||||
case 2 or 3:
|
||||
//down_right_right
|
||||
break;
|
||||
case 4 or 5:
|
||||
//down_right
|
||||
case 4 or 5:
|
||||
//down_right
|
||||
break;
|
||||
case 6 or 7:
|
||||
//down_right_left
|
||||
case 6 or 7:
|
||||
//down_right_left
|
||||
break;
|
||||
case 8 or 9:
|
||||
//down
|
||||
case 8 or 9:
|
||||
//down
|
||||
break;
|
||||
case 10 or 11:
|
||||
//down_left_right
|
||||
case 10 or 11:
|
||||
//down_left_right
|
||||
break;
|
||||
case 12 or 13:
|
||||
//down_left
|
||||
case 12 or 13:
|
||||
//down_left
|
||||
break;
|
||||
case 14 or 15:
|
||||
//down_left_left
|
||||
case 14 or 15:
|
||||
//down_left_left
|
||||
break;
|
||||
case 16 or -14:
|
||||
//left
|
||||
case 16 or -14:
|
||||
//left
|
||||
break;
|
||||
case -13 or -12:
|
||||
//top_left_left
|
||||
case -13 or -12:
|
||||
//top_left_left
|
||||
break;
|
||||
case -11 or -10:
|
||||
//top_left
|
||||
case -11 or -10:
|
||||
//top_left
|
||||
break;
|
||||
case -9 or -8:
|
||||
//top_left_right
|
||||
case -9 or -8:
|
||||
//top_left_right
|
||||
break;
|
||||
case -7 or -6:
|
||||
//top
|
||||
case -7 or -6:
|
||||
//top
|
||||
break;
|
||||
case -5 or -4:
|
||||
//top_right_left
|
||||
case -5 or -4:
|
||||
//top_right_left
|
||||
break;
|
||||
case -3 or -2:
|
||||
//top_right
|
||||
case -3 or -2:
|
||||
//top_right
|
||||
break;
|
||||
case -1 or 0:
|
||||
//top_right_right
|
||||
case -1 or 0:
|
||||
//top_right_right
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
MovementLogic();
|
||||
}
|
||||
public void WeaponAttack(){
|
||||
public void WeaponAttack()
|
||||
{
|
||||
|
||||
}
|
||||
public void MovementLogic()
|
||||
|
@ -168,7 +222,12 @@ public class Player : LivingEntity
|
|||
{
|
||||
InputPlayerRotation = updateInput.InputMovementDirection.GetVector2();
|
||||
InputWeaponRotation = updateInput.InputAttackDirection.GetVector2();
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -191,7 +250,7 @@ public class Player : LivingEntity
|
|||
base.Die();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
public void HandleShoot(UpdateInputShoot updateInputShoot)
|
||||
{
|
||||
if (reloading > 0)
|
||||
|
@ -199,24 +258,47 @@ public class Player : LivingEntity
|
|||
reloading = 5;
|
||||
IsTryingToShoot = true;
|
||||
|
||||
var rect = collisionComponent.stopRectangle.SetOrigin(position);
|
||||
rect.Width += 100;
|
||||
rect.Height += 100;
|
||||
Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(rect, 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)
|
||||
{
|
||||
foreach (Entity entity in entities)
|
||||
{
|
||||
if (entity is Enemy)
|
||||
if (entity is Enemy)
|
||||
{
|
||||
for (int i = 3; i <= 3; i++)
|
||||
{
|
||||
(entity as Enemy).TakeDamage(1);
|
||||
Instantiate(new Particle(
|
||||
((position - graphicsComponent.ObjectDrawRectangle.Size.ToVector2() / 2) * (3 - i) / 3f) +
|
||||
((entity.position - graphicsComponent.ObjectDrawRectangle.Size.ToVector2() / 2) * i / 3f) + ExtentionClass.RandomVector() * 3
|
||||
));
|
||||
|
||||
}
|
||||
(entity as Enemy).TakeDamage(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
//DrawDebugRectangle(spriteBatch, collisionComponent.stopRectangle.SetOrigin(position + new Vector2(10,10)), 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);
|
||||
}
|
||||
public Rectangle GetDamageArea(Vector2 direction, float mult = 1)
|
||||
{
|
||||
direction.Normalize();
|
||||
var rect = collisionComponent.stopRectangle.SetOrigin(position);
|
||||
int size = 10;
|
||||
rect.X -= size;
|
||||
rect.Y -= size;
|
||||
rect.Width += 2 * size;
|
||||
rect.Height += 2 * size;
|
||||
rect = rect.SetOrigin(direction * 40 * mult);
|
||||
return rect;
|
||||
}
|
||||
}
|
|
@ -16,11 +16,16 @@ namespace ZoFo.GameCore.GameObjects
|
|||
|
||||
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 += _ => {
|
||||
|
||||
if (AppManager.Instance.client!=null)
|
||||
{
|
||||
AppManager.Instance.client.DeleteObject(this);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
42
ZoFo/GameCore/GameObjects/ExitZone.cs
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ public abstract class GameObject
|
|||
graphicsComponent.ObjectDrawRectangle.X = (int)position.X;
|
||||
graphicsComponent.ObjectDrawRectangle.Y = (int)position.Y;
|
||||
|
||||
positionDraw = position;
|
||||
}
|
||||
public virtual void UpdateLogic()
|
||||
{
|
||||
|
@ -43,7 +44,10 @@ public abstract class GameObject
|
|||
|
||||
public void Instantiate(GameObject gameObject)
|
||||
{
|
||||
AppManager.Instance.server.RegisterGameObject(gameObject);
|
||||
if (AppManager.Instance.gamestate == GameState.HostPlaying)
|
||||
{
|
||||
AppManager.Instance.server.RegisterGameObject(gameObject);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -58,6 +62,7 @@ public abstract class GameObject
|
|||
public void PlayAnimation_OnClient()
|
||||
{
|
||||
graphicsComponent.Update();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -69,14 +74,19 @@ public abstract class GameObject
|
|||
graphicsComponent.LoadContent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// for smooth client draw
|
||||
/// </summary>
|
||||
public Vector2 positionDraw;
|
||||
/// <summary>
|
||||
/// Для клиента
|
||||
/// Обновление, которое вызывается у клиента, для просмотра анимаций
|
||||
/// </summary>
|
||||
public virtual void UpdateAnimations()
|
||||
{
|
||||
graphicsComponent.ObjectDrawRectangle.X = (int)position.X; //Move To place where Updates Sets your position
|
||||
graphicsComponent.ObjectDrawRectangle.Y = (int)position.Y;
|
||||
positionDraw = (position * 0.15f + positionDraw*0.85f);
|
||||
graphicsComponent.ObjectDrawRectangle.X = (int)positionDraw.X; //Move To place where Updates Sets your position
|
||||
graphicsComponent.ObjectDrawRectangle.Y = (int)positionDraw.Y;
|
||||
PlayAnimation_OnClient();
|
||||
}
|
||||
|
||||
|
@ -93,6 +103,7 @@ public abstract class GameObject
|
|||
}
|
||||
public void DrawDebugRectangle(SpriteBatch spriteBatch, Rectangle _rectangle, Nullable<Color> color = null)
|
||||
{
|
||||
return;
|
||||
if (color is null) color = new Color(1, 0, 0, 0.1f);
|
||||
if (color.Value.A == 255) color = new Color(color.Value, 0.25f);
|
||||
spriteBatch.Draw(debugTexture,
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace ZoFo.GameCore
|
|||
{
|
||||
networkManager = new ServerNetworkManager();
|
||||
collisionManager = new CollisionManager();
|
||||
|
||||
players = new List<Player>();
|
||||
}
|
||||
#region server logic as App
|
||||
|
||||
|
@ -69,20 +69,35 @@ namespace ZoFo.GameCore
|
|||
{
|
||||
case "UpdateInput":
|
||||
if (players.Count > 0)
|
||||
players[0].HandleNewInput(updateData as UpdateInput);//TODO id instead of 0
|
||||
{
|
||||
UpdateInput data = updateData as UpdateInput;
|
||||
if (data.PlayerId > 0)
|
||||
{
|
||||
players[data.PlayerId - 1].HandleNewInput(data);
|
||||
}
|
||||
}
|
||||
//TODO id instead of 0
|
||||
else
|
||||
DebugHUD.DebugLog("NO PLAYER ON MAP");
|
||||
break;
|
||||
case "UpdateTileCreated":
|
||||
break;
|
||||
case "UpdateInputInteraction":
|
||||
players[0].HandleInteract(updateData as UpdateInputInteraction);
|
||||
if (players.Count > 0)
|
||||
{
|
||||
UpdateInputInteraction data = updateData as UpdateInputInteraction;
|
||||
players[data.PlayerId - 1].HandleInteract(data);
|
||||
}
|
||||
break;
|
||||
case "UpdateInputShoot":
|
||||
players[0].HandleShoot(updateData as UpdateInputShoot);
|
||||
if (players.Count > 0)
|
||||
{
|
||||
UpdateInputShoot data = updateData as UpdateInputShoot;
|
||||
players[data.PlayerId - 1].HandleShoot(data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//Поспать
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -120,18 +135,20 @@ namespace ZoFo.GameCore
|
|||
collisionManager = new CollisionManager();
|
||||
gameObjects = new List<GameObject>();
|
||||
entities = new List<Entity>();
|
||||
players = new List<Player>();
|
||||
networkManager.StartGame();
|
||||
new MapManager().LoadMap();
|
||||
|
||||
//AppManager.Instance.server.RegisterGameObject(new EntittyForAnimationTests(new Vector2(0, 0)));
|
||||
AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(740, 140)));
|
||||
for (int i = 0; i < networkManager.clientsEP.Count; i++)
|
||||
{
|
||||
Player player = new Player(new Vector2(-800 - 30 * i, 750));
|
||||
RegisterGameObject(player);
|
||||
networkManager.AddData(new UpdateCreatePlayer() { PlayerId = i+1, IdEntity=player.Id});
|
||||
}
|
||||
//for (int i = 0; i < 20; i++)
|
||||
// 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 Ammo(new Vector2(140, 440)));
|
||||
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(240, 440)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -141,6 +158,7 @@ namespace ZoFo.GameCore
|
|||
{
|
||||
UpdateGameEnded gameEnded = new UpdateGameEnded();
|
||||
networkManager.AddData(gameEnded);
|
||||
// networkManager.CloseConnection();
|
||||
}
|
||||
|
||||
public List<GameObject> gameObjects = new List<GameObject>();
|
||||
|
@ -211,7 +229,6 @@ namespace ZoFo.GameCore
|
|||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameObject is Entity entity)
|
||||
{
|
||||
AddData(new UpdateGameObjectCreated()
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="MonoGame.Framework.DesktopGL" Version="3.8.1.303" />
|
||||
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
|
||||
<PackageReference Include="MonoGame.Templates.CSharp" Version="3.8.1.1-kniEngine" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|