Add AssetManager

This commit is contained in:
Mootfrost777 2024-08-19 11:52:12 +03:00
parent 11d224414f
commit b4c059bd12
6 changed files with 15 additions and 10 deletions

View file

@ -12,6 +12,7 @@ using ZoFo.GameCore.GameManagers.ItemManager;
using ZoFo.GameCore.GUI;
using static System.Collections.Specialized.BitVector32;
using MonogameLibrary.UI.Base;
using ZoFo.GameCore.GameManagers.AssetsManager;
using ZoFo.GameCore.GameObjects;
namespace ZoFo.GameCore.GameManagers
@ -40,6 +41,7 @@ namespace ZoFo.GameCore.GameManagers
public ItemManager.ItemManager ItemManager;
public SettingsManager SettingsManager;
public SoundManager SoundManager;
public AssetManager AssetManager;
public AnimationBuilder animationBuilder { get; set; }
@ -63,6 +65,7 @@ namespace ZoFo.GameCore.GameManagers
SettingsManager = new SettingsManager();
SettingsManager.LoadSettings();
SoundManager = new SoundManager();
AssetManager = new AssetManager();
SoundManager.LoadSounds();

View file

@ -1,16 +1,18 @@
using System.Collections.Generic;
namespace ZoFo.GameCore.GameManagers.AssetsManager;
public static class AssetManager
public class AssetManager
{
public static AssetContainer Zombie = new()
public AssetContainer Zombie = new()
{
Animations = { "zombie_damaged", "zombie_walk", "zombie_idle", "zombie_attack", "zombie_death" },
Animations = ["zombie_damaged", "zombie_walk", "zombie_idle", "zombie_attack", "zombie_death"],
IdleAnimation = "zombie_walk"
};
public static AssetContainer Player = new()
public AssetContainer Player = new()
{
Animations = { "player_look_down" },
Animations = [ "player_look_down" ],
IdleAnimation = "player_look_down"
};
}

View file

@ -117,7 +117,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
while(socket.Connected)
{
byte[] bytes = new byte[65535];
var countAnsw = socket.Receive(bytes, SocketFlags.Partial); //Вылетает если кто то закрыл
var countAnsw = socket.Receive(bytes); //Вылетает если кто то закрыл
string update = Encoding.UTF8.GetString(bytes, 0, countAnsw); // обновление отосланные сервером
GetDataSent(update);
}

View file

@ -86,7 +86,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
var databytes = Encoding.UTF8.GetBytes(data);
foreach (Socket socket in clients)
{
clients[0].SendAsync(databytes, SocketFlags.Partial);
clients[0].SendAsync(databytes);
}
for (int i = 0; i < 200 && i< datasToSend.Count; i++)
updates.RemoveAt(0);
@ -172,7 +172,7 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager
while (client.Connected)
{
var buff = new byte[65535];
var answ = client.Receive(buff, SocketFlags.Partial);
var answ = client.Receive(buff);
string response = Encoding.UTF8.GetString(buff, 0, answ);
GetDataSend(response);
}

View file

@ -12,7 +12,7 @@ namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies
{
class Zombie : Enemy
{
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AssetManager.Zombie);
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Zombie);
public Zombie(Vector2 position) : base(position)
{
health = 5;

View file

@ -22,7 +22,7 @@ public class Player : LivingEntity
public bool IsTryingToShoot { get; set; }
private float speed;
private int health;
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AssetManager.Player);
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AppManager.Instance.AssetManager.Player);
private LootData lootData;
public Player(Vector2 position) : base(position)
{