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
/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
/importer:WavImporter
/processor:SoundEffectProcessor
@ -91,18 +85,6 @@
/processorParam:Quality=Best
/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
/importer:TextureImporter
/processor:TextureProcessor
@ -115,6 +97,18 @@
/processorParam:TextureFormat=Color
/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
/importer:TextureImporter
/processor:TextureProcessor
@ -139,18 +133,6 @@
/processorParam:TextureFormat=Color
/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
/importer:TextureImporter
/processor:TextureProcessor
@ -163,6 +145,18 @@
/processorParam:TextureFormat=Color
/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
/importer:TextureImporter
/processor:TextureProcessor

Binary file not shown.

View file

@ -52,7 +52,7 @@ public abstract class AbstractGUI
{
Manager.Draw(spriteBatch);
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();
}
}

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using System.Linq;
using DangerousD.GameCore.Graphics;
using Newtonsoft.Json;
using Microsoft.Xna.Framework.Media;
@ -20,23 +20,28 @@ namespace ZoFo.GameCore.GameManagers
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)
{
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)
{
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>("sounds//" + soundFile));
}
}
if (k.Count() > 0)
/*/if (sounds.Count() > 0)
{
foreach (var soundFile in sounds)
{
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>("sounds/" + soundFile));
}
}/*/
}
}
public void StartAmbientSound(string soundName) // запустить звук у которого нет позиции

View file

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

View file

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

View file

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