Add AssetManager.cs

This commit is contained in:
Mootfrost777 2024-08-18 23:38:49 +03:00
parent d638fa585a
commit 11d224414f
5 changed files with 40 additions and 2 deletions

View file

@ -0,0 +1,9 @@
using System.Collections.Generic;
namespace ZoFo.GameCore.GameManagers.AssetsManager;
public class AssetContainer
{
public List<string> Animations;
public string IdleAnimation;
}

View file

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

View file

@ -5,13 +5,14 @@ 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;
using ZoFo.GameCore.GameManagers.AssetsManager;
using ZoFo.GameCore.Graphics; using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Enemies
{ {
class Zombie : Enemy class Zombie : Enemy
{ {
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "zombie_damaged","zombie_walk","zombie_idle","zombie_attack","zombie_death" }, "zombie_walk"); public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AssetManager.Zombie);
public Zombie(Vector2 position) : base(position) public Zombie(Vector2 position) : base(position)
{ {
health = 5; health = 5;

View file

@ -4,6 +4,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.AssetsManager;
using ZoFo.GameCore.GameManagers.CollisionManager; using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer; using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ClientToServer;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient; using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
@ -21,7 +22,7 @@ public class Player : LivingEntity
public bool IsTryingToShoot { get; set; } public bool IsTryingToShoot { get; set; }
private float speed; private float speed;
private int health; private int health;
public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(new List<string> { "player_look_down" }, "player_look_down"); public override GraphicsComponent graphicsComponent { get; } = new AnimatedGraphicsComponent(AssetManager.Player);
private LootData lootData; private LootData lootData;
public Player(Vector2 position) : base(position) public Player(Vector2 position) : base(position)
{ {

View file

@ -4,6 +4,7 @@ using System.Linq;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using ZoFo.GameCore.GameManagers; using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.AssetsManager;
using ZoFo.GameCore.GUI; using ZoFo.GameCore.GUI;
namespace ZoFo.GameCore.Graphics namespace ZoFo.GameCore.Graphics
@ -60,7 +61,17 @@ namespace ZoFo.GameCore.Graphics
private int interval; private int interval;
private int lastInterval; private int lastInterval;
private Rectangle sourceRectangle; private Rectangle sourceRectangle;
public AnimatedGraphicsComponent(AssetContainer asset)
{
Build(asset.Animations, asset.IdleAnimation);
}
public AnimatedGraphicsComponent(List<string> animationsId, string neitralAnimationId) public AnimatedGraphicsComponent(List<string> animationsId, string neitralAnimationId)
{
Build(animationsId, neitralAnimationId);
}
private void Build(List<string> animationsId, string neitralAnimationId)
{ {
//this._spriteBatch = _spriteBatch; //this._spriteBatch = _spriteBatch;
currentFrame = 0; currentFrame = 0;