Merge branch 'DevelopmentX' into NetworkMultiplyPlayers2

This commit is contained in:
SergoDobro 2024-08-20 16:34:21 +03:00 committed by GitHub
commit 4421ceefd8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 507 additions and 131 deletions

View file

@ -29,6 +29,7 @@ public class ItemDisplayButton : Button
private ContentManager content; private ContentManager content;
public string discriptions1; public string discriptions1;
public Dictionary<string, int> resourcesNeededToCraft1; public Dictionary<string, int> resourcesNeededToCraft1;
public TextAligment TextAligment = TextAligment.Left;
public ItemDisplayButton(UIManager manager) : base(manager) public ItemDisplayButton(UIManager manager) : base(manager)
@ -46,7 +47,7 @@ public class ItemDisplayButton : Button
Label itemName = new Label(Manager) Label itemName = new Label(Manager)
{ {
rectangle = new Rectangle(rectangle.X + rectangle.Height / 3 / 2 + rectangle.Height / 3 * 2, rectangle.Y + rectangle.Height / 3 / 2, rectangle.Width / 3, rectangle.Height / 3 * 2), rectangle = new Rectangle(rectangle.X + rectangle.Height / 3 / 2 + rectangle.Height / 3 * 2, rectangle.Y + rectangle.Height / 3 / 2, rectangle.Width / 3, rectangle.Height / 3 * 2),
fontColor = fontColor1, text = text1, scale = scale1, fontName = fontName1, mainColor = Color.Transparent fontColor = fontColor1, text = text1, scale = scale1, fontName = fontName1, mainColor = Color.Transparent, textAligment = TextAligment
}; };
Label itemCount = new Label(Manager) Label itemCount = new Label(Manager)
{ {
@ -87,6 +88,10 @@ public class ItemDisplayButton : Button
{ {
if (presentState != hoverState) if (presentState != hoverState)
{ {
if (resourcesNeededToCraft1 == null)
{
resourcesNeededToCraft1 = new Dictionary<string, int>();
}
hoverWindow = new HoverWindow(Manager) hoverWindow = new HoverWindow(Manager)
{ {
rectangle = new Rectangle(Mouse.GetState().Position.X, Mouse.GetState().Position.Y, rectangle.Width, rectangle.Height * 10), rectangle = new Rectangle(Mouse.GetState().Position.X, Mouse.GetState().Position.Y, rectangle.Width, rectangle.Height * 10),

View file

@ -30,6 +30,7 @@ public class ItemDisplayLabel : DrawableUIElement
public Dictionary<string, int> resourcesNeededToCraft1; public Dictionary<string, int> resourcesNeededToCraft1;
public HoverState hoverState = HoverState.None; public HoverState hoverState = HoverState.None;
private ContentManager content; private ContentManager content;
public TextAligment TextAligment = TextAligment.Left;
public ItemDisplayLabel(UIManager manager) : base(manager) public ItemDisplayLabel(UIManager manager) : base(manager)
@ -47,7 +48,7 @@ public class ItemDisplayLabel : DrawableUIElement
Label itemName = new Label(Manager) Label itemName = new Label(Manager)
{ {
rectangle = new Rectangle(rectangle.X + rectangle.Height / 3 / 2 + rectangle.Height / 3 * 2, rectangle.Y + rectangle.Height / 3 / 2, rectangle.Width / 3, rectangle.Height / 3 * 2), rectangle = new Rectangle(rectangle.X + rectangle.Height / 3 / 2 + rectangle.Height / 3 * 2, rectangle.Y + rectangle.Height / 3 / 2, rectangle.Width / 3, rectangle.Height / 3 * 2),
fontColor = fontColor1, text = text1, scale = scale1, fontName = fontName1, mainColor = Color.Transparent fontColor = fontColor1, text = text1, scale = scale1, fontName = fontName1, mainColor = Color.Transparent, textAligment = TextAligment
}; };
Label itemCount = new Label(Manager) Label itemCount = new Label(Manager)
{ {

View file

@ -44,9 +44,6 @@
#begin MapData/TileMaps/main.tmj #begin MapData/TileMaps/main.tmj
/copy:MapData/TileMaps/main.tmj /copy:MapData/TileMaps/main.tmj
#begin MapData/TileSets/bonfire.tsj
/copy:MapData/TileSets/bonfire.tsj
#begin MapData/TileSets/IconSet.tsj #begin MapData/TileSets/IconSet.tsj
/copy:MapData/TileSets/IconSet.tsj /copy:MapData/TileSets/IconSet.tsj
@ -59,6 +56,30 @@
#begin MapData/TileSets/TilesetNature.tsj #begin MapData/TileSets/TilesetNature.tsj
/copy: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/Loot.wav #begin sounds/Loot.wav
/importer:WavImporter /importer:WavImporter
/processor:SoundEffectProcessor /processor:SoundEffectProcessor
@ -101,8 +122,17 @@
/processorParam:Quality=Best /processorParam:Quality=Best
/build:sounds/Zombi stoit.wav /build:sounds/Zombi stoit.wav
#begin Textures/Animations/explosion_1.animation #begin sounds/zombie sound 2.wav
/copy:Textures/Animations/explosion_1.animation /importer:WavImporter
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:sounds/zombie sound 2.wav
#begin sounds/zombie sound.wav
/importer:WavImporter
/processor:SoundEffectProcessor
/processorParam:Quality=Best
/build:sounds/zombie sound.wav
#begin Textures/Animations/player_down_idle.animation #begin Textures/Animations/player_down_idle.animation
/copy:Textures/Animations/player_down_idle.animation /copy:Textures/Animations/player_down_idle.animation
@ -191,6 +221,33 @@
#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_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_left.animation
/copy:Textures/Animations/player_run_left.animation
#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_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_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

View file

@ -0,0 +1 @@
{"id":"player_run_down","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":528,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"player_run_left","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":792,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"player_run_left_down","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":660,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"player_run_left_up","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":924,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"player_run_right","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":264,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"}

Binary file not shown.

View file

@ -0,0 +1 @@
{"id":"player_run_right_down","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":396,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"player_run_right_up","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":132,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"}

View file

@ -0,0 +1 @@
{"id":"player_run_up","textureName":"Textures/AnimationTextures/Character/hr-level1_running","startSpriteRectangle":{"X":0,"Y":0,"Width":88,"Height":132},"frameSecond":[{"Item1":0,"Item2":2}],"textureFrameInterval":0,"framesCount":22,"isCycle":true,"offset":"0, 0"}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -249,6 +249,16 @@ namespace ZoFo.GameCore
{ {
UpdatePlayerHealth(update as UpdatePlayerParametrs); UpdatePlayerHealth(update as UpdatePlayerParametrs);
} }
else if (update is UpdateLoot)
{
if ((update as UpdateLoot).quantity == 0)
{
return;
}
var ent = FindEntityById(update.IdEntity);
if (ent != null)
(ent as Player).lootData.AddLoot_Client((update as UpdateLoot).lootName, (update as UpdateLoot).quantity);
}
} }
public void UpdatePlayerHealth(UpdatePlayerParametrs update) public void UpdatePlayerHealth(UpdatePlayerParametrs update)

View file

@ -38,7 +38,7 @@ public abstract class AbstractGUI
public virtual void LoadContent() public virtual void LoadContent()
{ {
Manager.LoadContent(AppManager.Instance.Content, "Font"); Manager.LoadContent(AppManager.Instance.Content, "Fonts/Font");
mouse = AppManager.Instance.Content.Load<Texture2D>("Textures/GUI/mouse"); mouse = AppManager.Instance.Content.Load<Texture2D>("Textures/GUI/mouse");
} }

View file

@ -142,6 +142,7 @@ public class BaseGUI : AbstractGUI
ItemDisplayButtonsList.Add(temp); ItemDisplayButtonsList.Add(temp);
temp.LeftButtonPressed += () => temp.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartAmbientSound("Craft sound");
AppManager.Instance.playerData.CraftItem(item.Key); AppManager.Instance.playerData.CraftItem(item.Key);
AppManager.Instance.SetGUI(new BaseGUI()); AppManager.Instance.SetGUI(new BaseGUI());
}; };
@ -163,7 +164,9 @@ public class BaseGUI : AbstractGUI
textureName = "Textures\\GUI\\checkboxs_off" textureName = "Textures\\GUI\\checkboxs_off"
}; };
Elements.Add(bTExit); 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) public override void Update(GameTime gameTime)

View file

@ -17,7 +17,7 @@ public class HUD : AbstractGUI
{ {
private Bar hpBar; private Bar hpBar;
private Bar radBar; private Bar radBar;
private AbstractGUI overlayGUI; public AbstractGUI overlayGUI;
protected override void CreateUI() protected override void CreateUI()
{ {
int width = AppManager.Instance.CurentScreenResolution.X; int width = AppManager.Instance.CurentScreenResolution.X;
@ -28,11 +28,13 @@ public class HUD : AbstractGUI
Elements.Add(pauseButton); Elements.Add(pauseButton);
pauseButton.LoadTexture(AppManager.Instance.Content); pauseButton.LoadTexture(AppManager.Instance.Content);
pauseButton.LeftButtonPressed += () => pauseButton.LeftButtonPressed += () =>
{ {
AppManager.Instance.SetGUI(new FinishingGUI()); AppManager.Instance.SoundManager.StartAmbientSound("Button click");
//overlayGUI = new PauseGUI(); AppManager.Instance.SetGUI(new PauseGUI());
//overlayGUI.Initialize(); //AppManager.Instance.SetGUI(new FinishingGUI());
//overlayGUI.LoadContent(); overlayGUI = new PauseGUI();
overlayGUI.Initialize();
overlayGUI.LoadContent();
}; };
Button invButton = new Button(Manager) 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, 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"};
@ -65,6 +67,7 @@ public class HUD : AbstractGUI
radBar.LoadTexture(AppManager.Instance.Content); radBar.LoadTexture(AppManager.Instance.Content);
} }
public override void Update(GameTime gameTime) public override void Update(GameTime gameTime)
{ {
overlayGUI?.Update(gameTime); overlayGUI?.Update(gameTime);

View file

@ -62,7 +62,7 @@ public class InventoryGUI : AbstractGUI
(height / 20 + height / 80) * (buttonIndex) - height / 10, (height / 20 + height / 80) * (buttonIndex) - height / 10,
(int)(width / 5), (int)(height / 20)), (int)(width / 5), (int)(height / 20)),
text1 = item.Key, text1 = item.Key,
scale1 = 0.4f, scale1 = 0.3f,
count = item.Value, count = item.Value,
itemTextureName = itemInfo.textureName, itemTextureName = itemInfo.textureName,
fontColor1 = Color.White, fontColor1 = Color.White,

View file

@ -40,7 +40,7 @@ public class MainMenuGUI : AbstractGUI
}; };
playButton.LeftButtonPressed += () => playButton.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartAmbientSound("Loot"); AppManager.Instance.SoundManager.StartAmbientSound("Button click");
AppManager.Instance.SetGUI(new SelectModeMenu()); AppManager.Instance.SetGUI(new SelectModeMenu());
}; };
Elements.Add(playButton); Elements.Add(playButton);
@ -55,6 +55,7 @@ public class MainMenuGUI : AbstractGUI
}; };
baseButton.LeftButtonPressed += () => baseButton.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
AppManager.Instance.SetGUI(new BaseGUI()); AppManager.Instance.SetGUI(new BaseGUI());
}; };
Elements.Add(baseButton); Elements.Add(baseButton);
@ -69,7 +70,7 @@ public class MainMenuGUI : AbstractGUI
}; };
optionButton.LeftButtonPressed += () => optionButton.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartAmbientSound("Loot"); AppManager.Instance.SoundManager.StartAmbientSound("Button click");
AppManager.Instance.SetGUI(new OptionsGUI()); AppManager.Instance.SetGUI(new OptionsGUI());
}; };
Elements.Add(optionButton); Elements.Add(optionButton);

View file

@ -43,6 +43,7 @@ public class OptionsGUI : AbstractGUI
label_OverallVolume_Percent.text = Math.Round(slider_OverallVolume.GetSliderValue * 100) + "%"; label_OverallVolume_Percent.text = Math.Round(slider_OverallVolume.GetSliderValue * 100) + "%";
slider_OverallVolume.SliderChanged += (newVal) => slider_OverallVolume.SliderChanged += (newVal) =>
{ {
label_OverallVolume_Percent.text = Math.Round(slider_OverallVolume.GetSliderValue * 100) + "%"; label_OverallVolume_Percent.text = Math.Round(slider_OverallVolume.GetSliderValue * 100) + "%";
AppManager.Instance.SettingsManager.SetMainVolume(newVal); AppManager.Instance.SettingsManager.SetMainVolume(newVal);
}; };
@ -64,6 +65,7 @@ public class OptionsGUI : AbstractGUI
label_MusicVolume_Percent.text = Math.Round(slider_MusicVolume.GetSliderValue * 100) + "%"; label_MusicVolume_Percent.text = Math.Round(slider_MusicVolume.GetSliderValue * 100) + "%";
slider_MusicVolume.SliderChanged += (newVal) => slider_MusicVolume.SliderChanged += (newVal) =>
{ {
label_MusicVolume_Percent.text = Math.Round(slider_MusicVolume.GetSliderValue * 100) + "%"; label_MusicVolume_Percent.text = Math.Round(slider_MusicVolume.GetSliderValue * 100) + "%";
AppManager.Instance.SettingsManager.SetMusicVolume(newVal); AppManager.Instance.SettingsManager.SetMusicVolume(newVal);
}; };
@ -85,6 +87,7 @@ public class OptionsGUI : AbstractGUI
label_EffectsVolume_Percent.text = Math.Round(slider_EffectsVolume.GetSliderValue * 100) + "%"; label_EffectsVolume_Percent.text = Math.Round(slider_EffectsVolume.GetSliderValue * 100) + "%";
slider_EffectsVolume.SliderChanged += (newVal) => slider_EffectsVolume.SliderChanged += (newVal) =>
{ {
label_EffectsVolume_Percent.text = Math.Round(slider_EffectsVolume.GetSliderValue * 100) + "%"; label_EffectsVolume_Percent.text = Math.Round(slider_EffectsVolume.GetSliderValue * 100) + "%";
AppManager.Instance.SettingsManager.SetSoundEffectsVolume(newVal); AppManager.Instance.SettingsManager.SetSoundEffectsVolume(newVal);
}; };
@ -109,6 +112,7 @@ public class OptionsGUI : AbstractGUI
button_FullScreen.SetIsChecked(AppManager.Instance.SettingsManager.IsFullScreen); button_FullScreen.SetIsChecked(AppManager.Instance.SettingsManager.IsFullScreen);
button_FullScreen.Checked += (newCheckState) => button_FullScreen.Checked += (newCheckState) =>
{ {
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
AppManager.Instance.SettingsManager.SetIsFullScreen(newCheckState); AppManager.Instance.SettingsManager.SetIsFullScreen(newCheckState);
}; };
Elements.Add(button_FullScreen); Elements.Add(button_FullScreen);
@ -120,6 +124,7 @@ public class OptionsGUI : AbstractGUI
Elements.Add(bTExit); Elements.Add(bTExit);
bTExit.LeftButtonPressed += () => bTExit.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
AppManager.Instance.SetGUI(new MainMenuGUI()); AppManager.Instance.SetGUI(new MainMenuGUI());
}; };

View file

@ -31,6 +31,7 @@ public class PauseGUI : AbstractGUI
}; };
continueButton.LeftButtonPressed += () => continueButton.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
AppManager.Instance.SetGUI(new HUD()); AppManager.Instance.SetGUI(new HUD());
}; };
Elements.Add(continueButton); Elements.Add(continueButton);
@ -45,6 +46,9 @@ public class PauseGUI : AbstractGUI
}; };
exitButton.LeftButtonPressed += () => exitButton.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StopAllSounds();
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
AppManager.Instance.SoundManager.StartAmbientSound("Background menu music");
AppManager.Instance.SetGUI(new MainMenuGUI()); AppManager.Instance.SetGUI(new MainMenuGUI());
}; };
Elements.Add(exitButton); Elements.Add(exitButton);

View file

@ -38,6 +38,9 @@ public class SelectModeMenu : AbstractGUI
}; };
singleButton.LeftButtonPressed += () => singleButton.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StopAllSounds();
AppManager.Instance.SoundManager.StartAmbientSound("Background music");
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
// single // single
Server server = new Server(); Server server = new Server();
Client client = new Client(); Client client = new Client();
@ -68,6 +71,7 @@ public class SelectModeMenu : AbstractGUI
}; };
optionButton.LeftButtonPressed += () => optionButton.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
AppManager.Instance.SetGUI(new SelectingServerGUI()); AppManager.Instance.SetGUI(new SelectingServerGUI());
// multi // multi
@ -80,6 +84,9 @@ public class SelectModeMenu : AbstractGUI
Elements.Add(bTExit); Elements.Add(bTExit);
bTExit.LeftButtonPressed += () => bTExit.LeftButtonPressed += () =>
{ {
AppManager.Instance.SoundManager.StartAmbientSound("Button click");
AppManager.Instance.SetGUI(new MainMenuGUI()); AppManager.Instance.SetGUI(new MainMenuGUI());
}; };
} }

View file

@ -62,12 +62,14 @@ namespace ZoFo.GameCore.GameManagers
ItemManager = new ItemManager.ItemManager(); ItemManager = new ItemManager.ItemManager();
Instance = this; Instance = this;
InputManager = new InputManager(); InputManager = new InputManager();
SoundManager = new SoundManager();
SoundManager.LoadSounds();
SettingsManager = new SettingsManager(); SettingsManager = new SettingsManager();
SettingsManager.LoadSettings(); SettingsManager.LoadSettings();
SoundManager = new SoundManager();
AssetManager = new AssetManager(); AssetManager = new AssetManager();
SoundManager.LoadSounds();
SoundManager.StartAmbientSound("Background menu music");
currentGUI = new MainMenuGUI(); currentGUI = new MainMenuGUI();
debugHud = new DebugHUD(); debugHud = new DebugHUD();

View file

@ -12,7 +12,9 @@ public class AssetManager
public AssetContainer Player = new() public AssetContainer Player = new()
{ {
Animations = [ "player_look_down" ], Animations = [ "player_look_down", "player_run_up", "player_run_down", "player_run_right",
"player_run_left", "player_run_right_up", "player_run_left_up", "player_run_right_down",
"player_run_left_down" ],
IdleAnimation = "player_look_down" IdleAnimation = "player_look_down"
}; };
} }

View file

@ -10,6 +10,7 @@ using Microsoft.Xna.Framework;
using ZoFo.GameCore.GameManagers.MapManager.MapElements; using ZoFo.GameCore.GameManagers.MapManager.MapElements;
using ZoFo.GameCore.GameObjects.Entities; using ZoFo.GameCore.GameObjects.Entities;
using ZoFo.GameCore.GameObjects.Entities.LivingEntities; using ZoFo.GameCore.GameObjects.Entities.LivingEntities;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.Graphics; using ZoFo.GameCore.Graphics;
using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO; using ZoFo.GameCore.GameManagers.NetworkManager.SerializableDTO;
@ -24,8 +25,27 @@ namespace ZoFo.GameCore.GameManagers.CollisionManager
public List<CollisionComponent> ObjectsWithCollisions; public List<CollisionComponent> ObjectsWithCollisions;
public List<CollisionComponent> EntitiesWithMovements; public List<CollisionComponent> EntitiesWithMovements;
public List<CollisionComponent> ObjectsWithTriggers; public List<CollisionComponent> ObjectsWithTriggers;
public List<CollisionComponent> GetEntitiesToUpdate(Player player)
{
float ViewDistance = 500;
List<CollisionComponent> EntitiesInPlayerArea = new List<CollisionComponent>();
Rectangle ViewArea = new Rectangle((int)(player.position.X), (int)(player.position.Y),
(int)(ViewDistance), (int)(ViewDistance));
for (int i = 0; i < ObjectsWithCollisions.Count; i++)
{
if (ViewArea.Contains((float)ObjectsWithCollisions[i].gameObject.position.X, (float)ObjectsWithCollisions[i].gameObject.position.Y));
{
EntitiesInPlayerArea.Add(ObjectsWithCollisions[i]);
}
}
return EntitiesInPlayerArea;
}
//чекаем коллизии в листе //чекаем коллизии в листе
/// <summary> /// <summary>

View file

@ -5,18 +5,11 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Formats.Tar;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GUI; using ZoFo.GameCore.GUI;
namespace ZoFo.GameCore.GameManagers namespace ZoFo.GameCore.GameManagers
{ {
public enum ScopeState { Idle, Left, Right, Top, Down, TopLeft, TopRight, DownLeft, DownRight } public enum ScopeState { Idle, Left, Right, Top, Down, TopLeft, TopRight, DownLeft, DownRight }
public class InputManager public class InputManager
{ {
public event Action ShootEvent; // событие удара(когда нажат X, событие срабатывает) public event Action ShootEvent; // событие удара(когда нажат X, событие срабатывает)
@ -177,7 +170,6 @@ namespace ZoFo.GameCore.GameManagers
#region Обработка взаимодействия с collectable(например лутом). Вызывает событие OnInteract #region Обработка взаимодействия с collectable(например лутом). Вызывает событие OnInteract
if (keyBoardState.IsKeyDown(Keys.E) && !isInteract) if (keyBoardState.IsKeyDown(Keys.E) && !isInteract)
{ {
OnInteract?.Invoke(); OnInteract?.Invoke();
Debug.WriteLine("взаимодействие с Collectable"); Debug.WriteLine("взаимодействие с Collectable");
} }
@ -204,18 +196,33 @@ namespace ZoFo.GameCore.GameManagers
DebugHUD.Instance.Set("controls", currentScopeState.ToString()); DebugHUD.Instance.Set("controls", currentScopeState.ToString());
} }
#region работа с ScopeState и Vector2 #region работа с ScopeState и Vector2
/// <summary>
/// возвращает число от -14 до 16, начиная с
/// </summary>
/// <param name="vector"></param>
/// <returns></returns>
public int ConvertAttackVector2ToState(Vector2 vector){
int currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y,
vector.X) * (180 / Math.PI) / 360 * 32);
return currentSection;
}
public ScopeState ConvertVector2ToState(Vector2 vector) public ScopeState ConvertVector2ToState(Vector2 vector)
{ {
//if() int currentSection = 0;
int currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y, if(vector.X == 0f && vector.Y == 0f){
currentScopeState = ScopeState.Idle;
}
else
{
currentSection = (int)Math.Ceiling(Math.Atan2(vector.Y,
vector.X) * (180 / Math.PI) / 360 * 16); vector.X) * (180 / Math.PI) / 360 * 16);
DebugHUD.DebugSet("current section", currentSection.ToString());
//DebugHUD.DebugSet("y", InputMovementDirection.Y.ToString());
//DebugHUD.DebugSet("x", InputMovementDirection.X.ToString());
switch(currentSection) switch(currentSection)
{ {
case -1:
currentScopeState = ScopeState.Idle;
break;
case 0 or 1: case 0 or 1:
currentScopeState = ScopeState.Right; currentScopeState = ScopeState.Right;
break; break;
@ -243,8 +250,41 @@ namespace ZoFo.GameCore.GameManagers
default: default:
break; break;
} }
DebugHUD.DebugSet("current section", currentSection.ToString());
DebugHUD.DebugSet("y", vector.Y.ToString());
DebugHUD.DebugSet("x", vector.X.ToString());
}
return currentScopeState; 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 #endregion
public bool ButtonClicked(Keys key) => keyBoardState.IsKeyUp(key) && keyBoardState.IsKeyDown(key); public bool ButtonClicked(Keys key) => keyBoardState.IsKeyUp(key) && keyBoardState.IsKeyDown(key);
} }

View file

@ -25,11 +25,15 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
public void Initialize() public void Initialize()
{ {
tagItemPairs = new Dictionary<string, ItemInfo>(); tagItemPairs = new Dictionary<string, ItemInfo>();
tagItemPairs.Add("Ammo", new ItemInfo("Ammo", "деньги в метро", "Textures\\icons\\Collectables\\Ammo",false,null)); tagItemPairs.Add("rottenflesh", new ItemInfo("rottenflesh", "БУХАТЬ", "Textures/icons/Collectables/RottenFlesh",false,null));
tagItemPairs.Add("wood", new ItemInfo("wood", "бревна кусок", "Textures\\Test\\wood",false,null)); tagItemPairs.Add("purebottleofwater", new ItemInfo("purebottleofwater", "БУХАТЬ 2", "Textures/icons/Collectables/PureBottleOfWater",false,null));
tagItemPairs.Add("rock", new ItemInfo("rock", "пять галек", "Textures\\Test\\rock", false, null)); tagItemPairs.Add("bottleofwater", new ItemInfo("bottleofwater", "БУХАТЬ", "Textures/icons/Collectables/BottleOfWater",false,null));
tagItemPairs.Add("steel", new ItemInfo("steel", "метал, метал, \nжелезо, метал", "Textures\\Test\\steel", false, null)); //tagItemPairs.Add("antiradin", new ItemInfo("antiradin", "радиацию опускает", "Textures/icons/Collectables/Ammo",false,null));
tagItemPairs.Add("pickaxe", new ItemInfo("steel", "прямой путь к \nстановлению каменьщиком", "Textures\\Test\\pickaxe", true, new Dictionary<string, int>() 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("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}, {"wood", 2},
{"steel", 3} {"steel", 3}

View file

@ -54,7 +54,7 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
items = new Dictionary<string, int>(); items = new Dictionary<string, int>();
items.Add("wood", 5); items.Add("wood", 5);
items.Add("steel", 110); items.Add("steel", 110);
items.Add("rock", 6); items.Add("peeble", 6);
} }
} }
} }

View file

@ -11,12 +11,16 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
/// </summary> /// </summary>
public class UpdateLoot : UpdateData public class UpdateLoot : UpdateData
{ {
public string lootName; public string lootName { get; set; }
public UpdateLoot() { UpdateType = "UpdateLoot"; } public int quantity { get; set; }
public UpdateLoot(string lootName) public UpdateLoot() { UpdateType = "UpdateLoot"; isImportant = true; }
public UpdateLoot(string lootName, int quantity, int id)
{ {
UpdateType = "UpdateLoot"; UpdateType = "UpdateLoot";
this.lootName = lootName; this.lootName = lootName;
this.quantity = quantity;
IdEntity = id;
isImportant = true;
} }
} }
} }

View file

@ -11,8 +11,8 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
/// </summary> /// </summary>
public class UpdatePlayerParametrs : UpdateData public class UpdatePlayerParametrs : UpdateData
{ {
public UpdatePlayerParametrs() { UpdateType = "UpdatePlayerParametrs"; } public UpdatePlayerParametrs() { UpdateType = "UpdatePlayerParametrs"; isImportant = true; }
public float radiatoin; public float radiatoin { get; set; }
public float health; public float health { get; set; }
} }
} }

View file

@ -28,18 +28,21 @@ namespace ZoFo.GameCore.GameManagers
public void SetMainVolume(float volume) public void SetMainVolume(float volume)
{ {
settingsContainer.MainVolume = volume; settingsContainer.MainVolume = volume;
//AppManager.Instance.SoundManager.Update(); // AppManager.Instance.SoundManager.Update();
SaveSettings(); SaveSettings();
} }
public void SetMusicVolume(float volume) public void SetMusicVolume(float volume)
{ {
settingsContainer.MusicVolume = volume; settingsContainer.MusicVolume = volume;
//AppManager.Instance.SoundManager.Update();
SaveSettings(); SaveSettings();
} }
public void SetSoundEffectsVolume(float volume) public void SetSoundEffectsVolume(float volume)
{ {
settingsContainer.SoundEffectsVolume = volume; settingsContainer.SoundEffectsVolume = volume;
// AppManager.Instance.SoundManager.Update();
SaveSettings(); SaveSettings();
} }
@ -68,6 +71,7 @@ namespace ZoFo.GameCore.GameManagers
} }
public void SaveSettings() public void SaveSettings()
{ {
AppManager.Instance.SoundManager.Update();
using (StreamWriter streamWriter = new StreamWriter("GameSettings.txt")) using (StreamWriter streamWriter = new StreamWriter("GameSettings.txt"))
{ {
string _str = JsonConvert.SerializeObject(settingsContainer); string _str = JsonConvert.SerializeObject(settingsContainer);

View file

@ -12,6 +12,7 @@ namespace ZoFo.GameCore.GameObjects
{ {
//public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List<string> { "тут пишите название анимации" }, "сдублируйте " + //public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List<string> { "тут пишите название анимации" }, "сдублируйте " +
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_idle" }, "zombie_idle"); public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_idle" }, "zombie_idle");
@ -19,6 +20,7 @@ namespace ZoFo.GameCore.GameObjects
public EntittyForAnimationTests(Vector2 position) : base(position) public EntittyForAnimationTests(Vector2 position) : base(position)
{ {
graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0,16*20, 16 * 20); graphicsComponent.ObjectDrawRectangle = new Rectangle(0,0,16*20, 16 * 20);
position = new Vector2(10, 10); position = new Vector2(10, 10);
} }

View file

@ -1,6 +1,7 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Linq;
using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.CollisionManager; using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
@ -29,9 +30,8 @@ public class Collectable : Interactable
public override void OnInteraction(GameObject sender) public override void OnInteraction(GameObject sender)
{ {
DebugHUD.DebugLog("collected"); DebugHUD.DebugLog("collected");
string lootname = this.GetType().ToString().ToLower(); string lootname = this.GetType().ToString().ToLower().Split('.').Last();
(sender as Player).lootData.AddLoot(lootname, 1); (sender as Player).lootData.AddLoot(lootname, 1, (sender as Player).Id);
AppManager.Instance.server.AddData(new UpdateLoot(lootname));
AppManager.Instance.server.DeleteObject(this); AppManager.Instance.server.DeleteObject(this);
base.OnInteraction(sender); base.OnInteraction(sender);
} }

View file

@ -43,17 +43,38 @@ namespace ZoFo.GameCore.GameObjects
} }
public override void Update() public override void Update()
{ {
if (isDying) return; if (isDying) return;
Vector2 duration = Vector2.Normalize( float m = 10000000;
AppManager.Instance.server.players[0].position - position 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); } if (!isAttacking) { velocity += new Vector2(duration.X * speed, duration.Y * speed); }
} }
public void OnPlayerClose(GameObject sender) public void OnPlayerClose(GameObject sender)
{ {
@ -61,6 +82,8 @@ namespace ZoFo.GameCore.GameObjects
if(!isAttacking) 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"); StartAnimation("zombie_attack");
isAttacking = true; isAttacking = true;
} }
@ -69,18 +92,13 @@ namespace ZoFo.GameCore.GameObjects
} }
public void EndAttack(string a) public void EndAttack(string a)
{ {
if (AppManager.Instance.gamestate == GameState.HostPlaying) if (AppManager.Instance.gamestate != GameState.HostPlaying) return;
{ var damagedPlayers=AppManager.Instance.server.collisionManager.GetPlayersInZone(collisionComponent.triggerRectangle.SetOrigin(position));
var damagedPlayers = AppManager.Instance.server.collisionManager.GetPlayersInZone(collisionComponent.triggerRectangle.SetOrigin(position)); //TODO ДАМАЖИТЬ ИГРОКОВ В ЗОНЕ
//TODO ДАМАЖИТЬ ИГРОКОВ В ЗОНЕ if (damagedPlayers.Length>0) { DebugHUD.DebugLog("End of" + a);
if (damagedPlayers.Length > 0) foreach (var item in damagedPlayers)
{ item.TakeDamage(1);
DebugHUD.DebugLog("End of" + a);
foreach (var item in damagedPlayers)
item.TakeDamage(5);
}
isAttacking = false;
} }
} }

View file

@ -38,15 +38,15 @@ public class LivingEntity : Entity
{ {
base.UpdateAnimations(); base.UpdateAnimations();
} }
Vector2 prevPosition_forClient; protected Vector2 prevPosition_forClient;
public override void Draw(SpriteBatch spriteBatch) public override void Draw(SpriteBatch spriteBatch)
{ {
if ((position - prevPosition_forClient).X < 0) if ((positionDraw - prevPosition_forClient).X < 0)
graphicsComponent.Flip = SpriteEffects.FlipHorizontally; graphicsComponent.Flip = SpriteEffects.FlipHorizontally;
else if ((position - prevPosition_forClient).X > 0) else if ((positionDraw - prevPosition_forClient).X > 0)
graphicsComponent.Flip = SpriteEffects.None; graphicsComponent.Flip = SpriteEffects.None;
base.Draw(spriteBatch); base.Draw(spriteBatch);
prevPosition_forClient = position; prevPosition_forClient = positionDraw;
} }
public virtual void Die() public virtual void Die()

View file

@ -8,6 +8,6 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player
{ {
internal interface IPlayerWeaponAttack internal interface IPlayerWeaponAttack
{ {
} }
} }

View file

@ -3,6 +3,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GUI;
namespace ZoFo.GameCore.GameObjects namespace ZoFo.GameCore.GameObjects
{ {
@ -10,7 +13,23 @@ namespace ZoFo.GameCore.GameObjects
{ {
public Dictionary<string, int> loots; public Dictionary<string, int> loots;
public void AddLoot(string lootName, int quantity) public void AddLoot(string lootName, int quantity, int id)
{
if (lootName == null)
{
DebugHUD.DebugLog("PROBLEM, loot is null");
DebugHUD.DebugLog("PROBLEM, loot is null");
DebugHUD.DebugLog("PROBLEM, loot is null");
return;
}
AppManager.Instance.server.AddData(new UpdateLoot(lootName, quantity, id));
if (loots.ContainsKey(lootName))
loots[lootName] +=quantity;
else
loots.Add(lootName, quantity);
}
public void AddLoot_Client(string lootName, int quantity)
{ {
if (loots.ContainsKey(lootName)) if (loots.ContainsKey(lootName))
loots[lootName] +=quantity; loots[lootName] +=quantity;

View file

@ -11,6 +11,7 @@ using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.Graphics; using ZoFo.GameCore.Graphics;
using System.Diagnostics; using System.Diagnostics;
using ZoFo.GameCore.GUI; using ZoFo.GameCore.GUI;
using System.Runtime.InteropServices;
namespace ZoFo.GameCore.GameObjects; namespace ZoFo.GameCore.GameObjects;
@ -18,18 +19,21 @@ public class Player : LivingEntity
{ {
public Vector2 InputWeaponRotation { get; set; } public Vector2 InputWeaponRotation { get; set; }
public Vector2 InputPlayerRotation { get; set; } public Vector2 InputPlayerRotation { get; set; }
private float speed; private float speed;
public int reloading; public int reloading;
public float health= 100; public float health = 100;
public float MaxHealth = 100; public float MaxHealth = 100;
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Player.Animations, AppManager.Instance.AssetManager.Player.IdleAnimation);
public AnimatedGraphicsComponent animatedGraphicsComponent => graphicsComponent as AnimatedGraphicsComponent;
public float rad = 0; public float rad = 0;
public float MaxRad = 100; public float MaxRad = 100;
public LootData lootData; public LootData lootData;
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Player);
public bool IsTryingToInteract { get; set; } public bool IsTryingToInteract { get; set; }
@ -37,58 +41,176 @@ public class Player : LivingEntity
/// Факт того, что плеер в этом апдейте пытается стрелять /// Факт того, что плеер в этом апдейте пытается стрелять
/// </summary> /// </summary>
public bool IsTryingToShoot { get; set; } public bool IsTryingToShoot { get; set; }
ScopeState prevScopeState;
public Player(Vector2 position) : base(position) public Player(Vector2 position) : base(position)
{ {
lootData = new LootData(); lootData = new LootData();
lootData.loots = new Dictionary<string, int>(); lootData.loots = new Dictionary<string, int>();
graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30); graphicsComponent.ObjectDrawRectangle = new Rectangle(0, 0, 30, 30);
collisionComponent.stopRectangle = new Rectangle(0, 20, 30, 10); collisionComponent.stopRectangle = new Rectangle(10, 15, 10, 15);
speed = 5; speed = 5;
StartAnimation("player_look_down"); StartAnimation("player_look_down");
} }
public override void Update() public override void Update()
{ {
if (reloading>0) #region название current текстуры
var idName = animatedGraphicsComponent.CurrentAnimation.Id;
#endregion
#region анимация управления подбора лута
DebugHUD.DebugSet("texture name", idName);
if (reloading > 0)
{ {
reloading--; reloading--;
} }
#region анимация управления, стрельбы switch (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation))
switch(AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation))
{ {
case ScopeState.Top: case ScopeState.Top:
if (idName != "player_run_up")
StartAnimation("player_run_up");
break; break;
case ScopeState.Down: case ScopeState.Down:
if (idName != "player_run_down")
break; StartAnimation("player_run_down");
break;
case ScopeState.Right: case ScopeState.Right:
//StartAnimation("player_running_top_rotate");
break;
case ScopeState.Left: case ScopeState.Left:
if (idName != "player_run_right")
break; StartAnimation("player_run_right");
break;
case ScopeState.TopRight: case ScopeState.TopRight:
break;
case ScopeState.TopLeft: case ScopeState.TopLeft:
if (idName != "player_run_right_up")
break; StartAnimation("player_run_right_up");
break;
case ScopeState.DownRight: case ScopeState.DownRight:
break;
case ScopeState.DownLeft: case ScopeState.DownLeft:
if (idName != "player_run_right_down")
break; StartAnimation("player_run_right_down");
break;
case ScopeState.Idle:
break;
}
if (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation) != ScopeState.Idle)
{
prevScopeState = AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation);
}
else if (AppManager.Instance.InputManager.ConvertVector2ToState(InputPlayerRotation) == ScopeState.Idle)
{
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")
StartAnimation("player_look_right");
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
break;
case 2 or 3:
//down_right_right
break;
case 4 or 5:
//down_right
break;
case 6 or 7:
//down_right_left
break;
case 8 or 9:
//down
break;
case 10 or 11:
//down_left_right
break;
case 12 or 13:
//down_left
break;
case 14 or 15:
//down_left_left
break;
case 16 or -14:
//left
break;
case -13 or -12:
//top_left_left
break;
case -11 or -10:
//top_left
break;
case -9 or -8:
//top_left_right
break;
case -7 or -6:
//top
break;
case -5 or -4:
//top_right_left
break;
case -3 or -2:
//top_right
break;
case -1 or 0:
//top_right_right
break;
} }
#endregion #endregion
MovementLogic(); MovementLogic();
} }
public void MovementLogic() public void WeaponAttack()
{
}
public void MovementLogic()
{ {
velocity += InputPlayerRotation * speed; velocity += InputPlayerRotation * speed;
DebugHUD.DebugSet("player pos server", position.ToString()); DebugHUD.DebugSet("player pos server", position.ToString());
@ -120,7 +242,7 @@ public class Player : LivingEntity
base.Die(); base.Die();
} }
#endregion #endregion
public void HandleShoot(UpdateInputShoot updateInputShoot) public void HandleShoot(UpdateInputShoot updateInputShoot)
{ {
if (reloading > 0) if (reloading > 0)
@ -128,24 +250,34 @@ public class Player : LivingEntity
reloading = 5; reloading = 5;
IsTryingToShoot = true; IsTryingToShoot = true;
var rect = collisionComponent.stopRectangle.SetOrigin(position); Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(GetDamageArea(InputManager.ConvertStateToVector2(prevScopeState)), this);
rect.Width += 100; if (entities != null)
rect.Height += 100;
Entity[] entities = AppManager.Instance.server.collisionManager.GetEntities(rect, this);
AppManager.Instance.server.RegisterGameObject(new Particle(rect.Location.ToVector2()));
if (entities.Length>0)
{ {
DebugHUD.DebugSet("ent[0]", entities[0].ToString()); foreach (Entity entity in entities)
if (entities != null)
{ {
foreach (Entity entity in entities) if (entity is Enemy)
{ {
if (entity is Enemy) (entity as Enemy).TakeDamage(1);
{
(entity as Enemy).TakeDamage(1);
}
} }
} }
} }
} }
public override void Draw(SpriteBatch spriteBatch)
{
DrawDebugRectangle(spriteBatch, GetDamageArea((position - prevPosition_forClient)), Color.Green);
base.Draw(spriteBatch);
}
public Rectangle GetDamageArea(Vector2 direction)
{
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*15);
return rect;
}
} }

View file

@ -1,13 +1,25 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Numerics;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameObjects.MapObjects.StopObjects;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player.PlayerAttacks namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player.PlayerAttacks
{ {
internal class SwordAttack : IPlayerWeaponAttack internal class SwordAttack : IPlayerWeaponAttack
{ {
Rectangle rectangle;
public SwordAttack(){
}
public Rectangle Attack(Vector2 position){
rectangle = new Rectangle((int)position.X, (int)position.Y, 30, 10);
return rectangle;
}
} }
} }

View file

@ -58,6 +58,7 @@ public abstract class GameObject
public void PlayAnimation_OnClient() public void PlayAnimation_OnClient()
{ {
graphicsComponent.Update(); graphicsComponent.Update();
} }
/// <summary> /// <summary>
@ -69,14 +70,19 @@ public abstract class GameObject
graphicsComponent.LoadContent(); graphicsComponent.LoadContent();
} }
/// <summary>
/// for smooth client draw
/// </summary>
public Vector2 positionDraw;
/// <summary> /// <summary>
/// Для клиента /// Для клиента
/// Обновление, которое вызывается у клиента, для просмотра анимаций /// Обновление, которое вызывается у клиента, для просмотра анимаций
/// </summary> /// </summary>
public virtual void UpdateAnimations() public virtual void UpdateAnimations()
{ {
graphicsComponent.ObjectDrawRectangle.X = (int)position.X; //Move To place where Updates Sets your position positionDraw = (position * 0.15f + positionDraw*0.85f);
graphicsComponent.ObjectDrawRectangle.Y = (int)position.Y; graphicsComponent.ObjectDrawRectangle.X = (int)positionDraw.X; //Move To place where Updates Sets your position
graphicsComponent.ObjectDrawRectangle.Y = (int)positionDraw.Y;
PlayAnimation_OnClient(); PlayAnimation_OnClient();
} }

View file

@ -136,7 +136,16 @@ namespace ZoFo.GameCore.Graphics
buildSourceRectangle(); buildSourceRectangle();
SetInterval(); SetInterval();
}
public void StartCyclingAnimation(string startedanimationId)
{
currentFrame = 0;
currentAnimation = animations.Find(x => x.Id == startedanimationId);
currentAnimation.IsCycle = true;
buildSourceRectangle();
SetInterval();
} }
public void StopAnimation() public void StopAnimation()

View file

@ -124,13 +124,11 @@ 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(740, 140))); AppManager.Instance.server.RegisterGameObject(new Player(new Vector2(760, 140)));
//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)));
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(140, 440)));
AppManager.Instance.server.RegisterGameObject(new Ammo(new Vector2(240, 440)));
} }
/// <summary> /// <summary>

View file

@ -1 +1 @@
{"IsFullScreen":false,"MainVolume":1.0,"MusicVolume":1.0,"SoundEffectsVolume":1.0,"Resolution":{"X":1440,"Y":900}} {"IsFullScreen":false,"MainVolume":1.0,"MusicVolume":0.0,"SoundEffectsVolume":1.0,"Resolution":{"X":1440,"Y":900}}

View file

@ -35,8 +35,8 @@
<ProjectReference Include="..\MonogameLibrary\MonogameLibrary.csproj" /> <ProjectReference Include="..\MonogameLibrary\MonogameLibrary.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Content\sounds\Zombie\" /> <Folder Include="Content\sounds\Zombie\" />
<Folder Include="Content\Textures\Animations\PlayerAFK\" /> <Folder Include="Content\Textures\Animations\PlayerAFK\" />
<Folder Include="Content\Textures\GUI\" /> <Folder Include="Content\Textures\GUI\" />
</ItemGroup> </ItemGroup>
<Target Name="RestoreDotnetTools" BeforeTargets="Restore"> <Target Name="RestoreDotnetTools" BeforeTargets="Restore">