Some Изменения

This commit is contained in:
Lev 2023-08-17 15:07:59 +03:00
parent ba4466d966
commit 37bb9fbb66
2 changed files with 26 additions and 9 deletions

View file

@ -6,18 +6,21 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using DangerousD.GameCore.GameObjects.PlayerDeath; using DangerousD.GameCore.GameObjects.PlayerDeath;
using Microsoft.Xna.Framework.Input;
namespace DangerousD.GameCore.GameObjects.LivingEntities namespace DangerousD.GameCore.GameObjects.LivingEntities
{ {
public class Player : LivingEntity public class Player : LivingEntity
{ {
bool isAlive = true; bool isAlive = true;
public int health;
public Player(Vector2 position) : base(position) public Player(Vector2 position) : base(position)
{ {
Width = 32; Width = 32;
Height = 64; Height = 64;
AppManager.Instance.InputManager.MovEventJump += AnimationJump; AppManager.Instance.InputManager.MovEventJump += Jump;
AppManager.Instance.InputManager.ShootEvent += Shoot;
} }
public bool IsAlive { get { return isAlive; } } public bool IsAlive { get { return isAlive; } }
@ -43,9 +46,17 @@ namespace DangerousD.GameCore.GameObjects.LivingEntities
} }
isAlive = false; isAlive = false;
} }
public void AnimationJump() public void Jump()
{ {
velocity.Y = -300; if (Keyboard.GetState().IsKeyDown(Keys.Escape))
{
velocity.Y = -300;
}
// здесь будет анимация
}
public void Shoot()
{
} }
} }
} }

View file

@ -19,10 +19,16 @@ namespace DangerousD.GameCore
public void LoadSounds() // метод для загрузки звуков из папки public void LoadSounds() // метод для загрузки звуков из папки
{ {
string[] soundFiles = Directory.GetFiles("../../../Content").Where(x=>x.EndsWith("mp3")).Select(x=>x.Split("\\").Last().Replace(".mp3", "")).ToArray();// папка со звуками там где exe var k = Directory.GetFiles("../../..//Content").Where(x => x.EndsWith("mp3"));
foreach (var soundFile in soundFiles) if (k.Count() > 0)
{ {
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>(soundFile).CreateInstance());
string[] soundFiles = k.Select(x => x.Split("\\").Last().Split("/").Last().Replace(".mp3", "")).ToArray();// папка со звуками там где exe
foreach (var soundFile in soundFiles)
{
Sounds.Add(soundFile, AppManager.Instance.Content.Load<SoundEffect>(soundFile).CreateInstance());
}
} }
} }
@ -33,7 +39,7 @@ namespace DangerousD.GameCore
sound.SoundEffect.IsLooped = false; sound.SoundEffect.IsLooped = false;
sound.SoundEffect.Play(); sound.SoundEffect.Play();
PlayingSounds.Add(sound); PlayingSounds.Add(sound);
if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host) if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Host)
{ {
AppManager.Instance.NetworkManager.SendMsg(new Network.NetworkTask(Vector2.Zero, soundName)); AppManager.Instance.NetworkManager.SendMsg(new Network.NetworkTask(Vector2.Zero, soundName));
} }
@ -45,7 +51,7 @@ namespace DangerousD.GameCore
sound.SoundEffect.Volume = (float)sound.GetDistance(playerPos) / MaxSoundDistance; sound.SoundEffect.Volume = (float)sound.GetDistance(playerPos) / MaxSoundDistance;
sound.SoundEffect.Play(); sound.SoundEffect.Play();
PlayingSounds.Add(sound); PlayingSounds.Add(sound);
if (AppManager.Instance.multiPlayerStatus == MultiPlayerStatus.Host) if (AppManager.Instance.multiPlayerStatus != MultiPlayerStatus.Host)
{ {
AppManager.Instance.NetworkManager.SendMsg(new Network.NetworkTask(soundPos, soundName)); AppManager.Instance.NetworkManager.SendMsg(new Network.NetworkTask(soundPos, soundName));
} }