This commit is contained in:
MARKPRO44 2024-08-17 12:23:12 +03:00
commit 74ec7f4deb
10 changed files with 97 additions and 79 deletions

View file

@ -73,12 +73,6 @@
/processorParam:Quality=Best /processorParam:Quality=Best
/build:sounds/Tabletki 2.wav /build:sounds/Tabletki 2.wav
#begin sounds/Tabletki.mp3
/importer:Mp3Importer
/processor:SongProcessor
/processorParam:Quality=Best
/build:sounds/Tabletki.mp3
#begin sounds/Zombi napal.wav #begin sounds/Zombi napal.wav
/importer:WavImporter /importer:WavImporter
/processor:SoundEffectProcessor /processor:SoundEffectProcessor
@ -91,18 +85,6 @@
/processorParam:Quality=Best /processorParam:Quality=Best
/build:sounds/Zombi stoit.wav /build:sounds/Zombi stoit.wav
#begin Textures/AnimationTextures/Character/hr-level1_idle_gun.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_idle_gun.png
#begin Textures/AnimationTextures/Character/hr-level1_idle.png #begin Textures/AnimationTextures/Character/hr-level1_idle.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -115,6 +97,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_idle.png /build:Textures/AnimationTextures/Character/hr-level1_idle.png
#begin Textures/AnimationTextures/Character/hr-level1_idle_gun.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_idle_gun.png
#begin Textures/AnimationTextures/Character/hr-level1_mining_tool-1.png #begin Textures/AnimationTextures/Character/hr-level1_mining_tool-1.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -139,18 +133,6 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_mining_tool-2.png /build:Textures/AnimationTextures/Character/hr-level1_mining_tool-2.png
#begin Textures/AnimationTextures/Character/hr-level1_running_gun.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_running_gun.png
#begin Textures/AnimationTextures/Character/hr-level1_running.png #begin Textures/AnimationTextures/Character/hr-level1_running.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor
@ -163,6 +145,18 @@
/processorParam:TextureFormat=Color /processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_running.png /build:Textures/AnimationTextures/Character/hr-level1_running.png
#begin Textures/AnimationTextures/Character/hr-level1_running_gun.png
/importer:TextureImporter
/processor:TextureProcessor
/processorParam:ColorKeyColor=255,0,255,255
/processorParam:ColorKeyEnabled=True
/processorParam:GenerateMipmaps=False
/processorParam:PremultiplyAlpha=True
/processorParam:ResizeToPowerOfTwo=False
/processorParam:MakeSquare=False
/processorParam:TextureFormat=Color
/build:Textures/AnimationTextures/Character/hr-level1_running_gun.png
#begin Textures/AnimationTextures/unicorn.png #begin Textures/AnimationTextures/unicorn.png
/importer:TextureImporter /importer:TextureImporter
/processor:TextureProcessor /processor:TextureProcessor

Binary file not shown.

View file

@ -52,7 +52,7 @@ public abstract class AbstractGUI
{ {
Manager.Draw(spriteBatch); Manager.Draw(spriteBatch);
spriteBatch.Begin(); spriteBatch.Begin();
spriteBatch.Draw(mouse, new Rectangle(mouseState.Position.X, mouseState.Position.Y, 20, 40), Color.Red); spriteBatch.Draw(mouse, new Rectangle(mouseState.Position.X, mouseState.Position.Y, 20, 40), Color.White);
spriteBatch.End(); spriteBatch.End();
} }
} }

View file

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

View file

@ -117,8 +117,7 @@ namespace ZoFo.GameCore.GameManagers
{ {
GraphicsDevice.Clear(Color.CornflowerBlue); GraphicsDevice.Clear(Color.CornflowerBlue);
currentGUI.Draw(_spriteBatch);
debugHud.Draw(_spriteBatch);
// Pointwrap // Pointwrap
_spriteBatch.Begin(samplerState: SamplerState.PointWrap); _spriteBatch.Begin(samplerState: SamplerState.PointWrap);
@ -132,7 +131,10 @@ namespace ZoFo.GameCore.GameManagers
default: default:
break; break;
} }
_spriteBatch.End(); _spriteBatch.End();
currentGUI.Draw(_spriteBatch);
debugHud.Draw(_spriteBatch);
base.Draw(gameTime); base.Draw(gameTime);
} }

View file

@ -1,16 +1,19 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics.PackedVector;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Formats.Tar; using System.Formats.Tar;
using System.Linq; using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ZoFo.GameCore.GameManagers namespace ZoFo.GameCore.GameManagers
{ {
public enum ScopeState { Left, Right, Straight, Back, StraightLeft, StraightRight, BackLeft, BackRight } public enum ScopeState { Idle, Left, Right, Straight, Back, StraightLeft, StraightRight, BackLeft, BackRight }
public class InputManager public class InputManager
{ {
@ -19,10 +22,11 @@ namespace ZoFo.GameCore.GameManagers
public event Delegat OnInteract; // событие взаимодействия с collectable(например, лутом) public event Delegat OnInteract; // событие взаимодействия с collectable(например, лутом)
//с помощью кнопки E. //с помощью кнопки E.
public Vector2 InputMovementDirection;
public Vector2 InputAttackDirection;
public event Delegat TalkEvent; public event Delegat TalkEvent;
Vector2 vectorMovementDirection;
ScopeState currentScopeState; // Положение оружия. Left, Right, Straight, Back, StraightLeft, StraightRight, BackLeft, BackRight. ScopeState currentScopeState; // Положение оружия. Left, Right, Straight, Back, StraightLeft, StraightRight, BackLeft, BackRight.
private bool _cheatsEnabled = false; private bool _cheatsEnabled = false;
public bool InvincibilityCheat { get; private set; } = false; public bool InvincibilityCheat { get; private set; } = false;
@ -34,18 +38,16 @@ namespace ZoFo.GameCore.GameManagers
private KeyboardState lastKeyboardState; private KeyboardState lastKeyboardState;
private GamePadState lastGamePadState; private GamePadState lastGamePadState;
public Vector2 VectorMovementDirection { get => vectorMovementDirection; }
public ScopeState ScopeState { get => currentScopeState; } public ScopeState ScopeState { get => currentScopeState; }
public string currentControlsState; public string currentControlsState;
public ScopeState CurrentScopeState { get => currentScopeState; } // получить текущее состояние public ScopeState CurrentScopeState { get => currentScopeState; } // получить текущее состояние
public InputManager() public InputManager()
{ {
InputMovementDirection = new Vector2(0, 0);
InputAttackDirection = new Vector2(0, 0);
this.isShoot = false; this.isShoot = false;
currentScopeState = ScopeState.Straight; currentScopeState = ScopeState.Idle;
vectorMovementDirection = new Vector2(0, 0);
} }
public void Update() public void Update()
{ {
@ -59,7 +61,8 @@ namespace ZoFo.GameCore.GameManagers
#region Работа с GamePad #region Работа с GamePad
#region Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика. #region Обработка гейм-пада. Задает Vector2 vectorMovementDirection являющийся вектором отклонения левого стика.
GamePadState gamePadState = GamePad.GetState(0); GamePadState gamePadState = GamePad.GetState(0);
vectorMovementDirection = gamePadState.ThumbSticks.Left; InputMovementDirection = gamePadState.ThumbSticks.Left;
InputAttackDirection = gamePadState.ThumbSticks.Right;
#endregion #endregion
#region читы #region читы
@ -75,39 +78,38 @@ namespace ZoFo.GameCore.GameManagers
} }
#endregion // Cheats #endregion // Cheats
#region Обработка положения оружия. Задает значение полю scopeState. #region set ScopeState
if (vectorMovementDirection.Y >= 0.6) int currentSection = (int)Math.Ceiling(Math.Atan2(InputMovementDirection.Y,
{ InputMovementDirection.X) * 180 / Math.PI * 16 / 360);
currentScopeState = ScopeState.Straight; switch(currentSection){
} case 1 or 0 or 16:
else if(vectorMovementDirection.Y <= 0.6)
{
currentScopeState = ScopeState.Back;
}
else if(vectorMovementDirection.X >= 0.6)
{
currentScopeState = ScopeState.Right; currentScopeState = ScopeState.Right;
} break;
else if(vectorMovementDirection.X <= 0.6) case 2 or 3:
{
currentScopeState = ScopeState.Left;
}
else if(vectorMovementDirection.Y >= 0.6 && vectorMovementDirection.X >= 0.6)
{
currentScopeState = ScopeState.StraightRight; currentScopeState = ScopeState.StraightRight;
} break;
else if(vectorMovementDirection.Y >= 0.6 && vectorMovementDirection.X <= 0.6) case 4 or 5:
{ currentScopeState = ScopeState.Straight;
break;
case 6 or 7:
currentScopeState = ScopeState.StraightLeft; currentScopeState = ScopeState.StraightLeft;
} break;
else if(vectorMovementDirection.Y <= 0.6 && vectorMovementDirection.X >= 0.6) case 8 or 9:
{ currentScopeState = ScopeState.Left;
currentScopeState = ScopeState.BackRight; break;
} case 10 or 11:
else if(vectorMovementDirection.Y <= 0.6 && vectorMovementDirection.X <= 0.6)
{
currentScopeState = ScopeState.BackLeft; currentScopeState = ScopeState.BackLeft;
break;
case 12 or 13:
currentScopeState = ScopeState.Back;
break;
case 14 or 15:
currentScopeState = ScopeState.BackRight;
break;
default:
break;
} }
#endregion #endregion
#region Обработка нажатия выстрела. Вызывает событие ShootEvent #region Обработка нажатия выстрела. Вызывает событие ShootEvent
@ -126,10 +128,20 @@ namespace ZoFo.GameCore.GameManagers
lastGamePadState = gamePadState; lastGamePadState = gamePadState;
#endregion #endregion
#region Работа с KeyBoard #region Работа с KeyBoard
#region InputAttack with mouse
MouseState mouseState = Mouse.GetState();
AppManager.Instance.debugHud.Set("mouse position", $"({mouseState.X}, {mouseState.Y}");
// TODO: CurentScreenResolution
Vector2 a = (AppManager.Instance.CurentScreenResolution / new Point(2, 2)).ToVector2();
InputAttackDirection = Vector2.Normalize(new Vector2(mouseState.X - a.X, mouseState.Y - a.Y));
AppManager.Instance.debugHud.Set("AttackDir(normalize)", $"({a.X}, {a.Y})");
#endregion
#region Состояние клавиатуры #region Состояние клавиатуры
KeyboardState keyBoardState = Keyboard.GetState(); // Состояние клавиатуры KeyboardState keyBoardState = Keyboard.GetState(); // Состояние клавиатуры
#endregion #endregion
#region читы #region читы
if (keyBoardState.IsKeyDown(Keys.LeftShift) && keyBoardState.IsKeyDown(Keys.RightShift)) if (keyBoardState.IsKeyDown(Keys.LeftShift) && keyBoardState.IsKeyDown(Keys.RightShift))
_cheatsEnabled = true; _cheatsEnabled = true;

View file

@ -6,7 +6,7 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Content;
using System.Linq; using System.Linq;
using DangerousD.GameCore.Graphics;
using Newtonsoft.Json; using Newtonsoft.Json;
using Microsoft.Xna.Framework.Media; using Microsoft.Xna.Framework.Media;
@ -20,23 +20,28 @@ namespace ZoFo.GameCore.GameManagers
public void LoadSounds() // метод для загрузки звуков из папки public void LoadSounds() // метод для загрузки звуков из папки
{ {
var k = Directory.GetFiles("Content/sounds").Where(x => x.EndsWith("wav")); //List<string> sounds = AppManager.Instance.Content.Load<List<string>>("sounds/");
var k = Directory.GetFiles(Directory.GetCurrentDirectory() + "//Content//sounds").Where(x => x.EndsWith("xnb"));
if (k.Count() > 0) if (k.Count() > 0)
{ {
string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".wav", "")).ToArray();// папка со звуками там где exe string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".xnb", "")).ToArray();// папка со звуками там где exe
foreach (var soundFile in soundFiles) foreach (var soundFile in soundFiles)
{ {
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>("sounds//" + soundFile)); Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>("sounds//" + soundFile));
} }
} }
/*/if (sounds.Count() > 0)
if (k.Count() > 0)
{ {
foreach (var soundFile in sounds)
{
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>("sounds/" + soundFile));
}
}/*/
}
} }
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции

View file

@ -19,7 +19,6 @@ public abstract class GameObject
public GameObject(Vector2 position) public GameObject(Vector2 position)
{ {
this.position = position; this.position = position;
graphicsComponent.LoadContent(); graphicsComponent.LoadContent();
} }
public virtual void UpdateLogic(GameTime gameTime) public virtual void UpdateLogic(GameTime gameTime)

View file

@ -1,4 +1,5 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using MonogameLibrary.UI.Elements;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -121,6 +122,7 @@ namespace ZoFo.GameCore
/// <param name="gameObject"></param> /// <param name="gameObject"></param>
public void RegisterGameObject(GameObject gameObject) public void RegisterGameObject(GameObject gameObject)
{ {
gameObjects.Add(gameObject); gameObjects.Add(gameObject);
if (gameObject is MapObject) if (gameObject is MapObject)
{ {

View file

@ -11,8 +11,11 @@
<ApplicationIcon>Icon.ico</ApplicationIcon> <ApplicationIcon>Icon.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Content\sounds\Zombie\**" />
<Compile Remove="GameCore\GameObjects\BaseClasses\**" /> <Compile Remove="GameCore\GameObjects\BaseClasses\**" />
<EmbeddedResource Remove="Content\sounds\Zombie\**" />
<EmbeddedResource Remove="GameCore\GameObjects\BaseClasses\**" /> <EmbeddedResource Remove="GameCore\GameObjects\BaseClasses\**" />
<None Remove="Content\sounds\Zombie\**" />
<None Remove="GameCore\GameObjects\BaseClasses\**" /> <None Remove="GameCore\GameObjects\BaseClasses\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -32,7 +35,6 @@
<ProjectReference Include="..\MonogameLibrary\MonogameLibrary.csproj" /> <ProjectReference Include="..\MonogameLibrary\MonogameLibrary.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Content\sounds\Zombie\" />
<Folder Include="Content\Textures\GUI\" /> <Folder Include="Content\Textures\GUI\" />
</ItemGroup> </ItemGroup>
<Target Name="RestoreDotnetTools" BeforeTargets="Restore"> <Target Name="RestoreDotnetTools" BeforeTargets="Restore">