Merge pull request #53 from progtime-net/LootData

Loot data
This commit is contained in:
SergoDobro 2024-08-18 01:07:18 +03:00 committed by GitHub
commit 25cc668576
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 216 additions and 7 deletions

View file

@ -24,9 +24,9 @@ namespace ZoFo.GameCore.GameManagers.ItemManager
}
void Initialize()
{
tagItemPairs.Add("wood", new ItemInfo("wood","wood",false,null));
tagItemPairs.Add("rock", new ItemInfo("rock", "rock", false, null));
tagItemPairs.Add("steel", new ItemInfo("steel", "steel", false, null));
tagItemPairs.Add("Wood", new ItemInfo("Wood","Wood",false,null));
tagItemPairs.Add("Peeble", new ItemInfo("Peeble", "Peeble", false, null));
tagItemPairs.Add("Steel", new ItemInfo("Steel", "Steel", false, null));
}
}

View file

@ -11,6 +11,12 @@ namespace ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient
/// </summary>
public class UpdateLoot : UpdateData
{
public string lootName;
public UpdateLoot() { UpdateType = "UpdateLoot"; }
public UpdateLoot(string lootName)
{
UpdateType = "UpdateLoot";
this.lootName = lootName;
}
}
}

View file

@ -0,0 +1,27 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
{
class Ammo:Collectable
{
public override GraphicsComponent graphicsComponent { get; } = new(new List<string> { "Ammo" }, "Ammo");
public Ammo(Vector2 position) : base(position)
{
}
public override void OnInteraction(object sender, CollisionComponent e)
{
AppManager.Instance.server.AddData(new UpdateLoot("Ammo"));
AppManager.Instance.server.DeleteObject(this);
}
}
}

View file

@ -0,0 +1,27 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
{
class Antiradine:Collectable
{
public override GraphicsComponent graphicsComponent { get; } = new(new List<string> { "Antiradine" }, "Antiradine");
public Antiradine(Vector2 position) : base(position)
{
}
public override void OnInteraction(object sender, CollisionComponent e)
{
AppManager.Instance.server.AddData(new UpdateLoot("Antiradine"));
AppManager.Instance.server.DeleteObject(this);
}
}
}

View file

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.Graphics;
using Microsoft.Xna.Framework;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameManagers;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
{
public class BottleOfWater : Collectable
{
public override GraphicsComponent graphicsComponent { get; } = new(new List<string> { "BottleOfWater" }, "BottleOfWater");
public BottleOfWater(Vector2 position) : base(position)
{
}
public override void OnInteraction(object sender, CollisionComponent e)
{
AppManager.Instance.server.AddData(new UpdateLoot("BottleOfWater"));
AppManager.Instance.server.DeleteObject(this);
}
}
}

View file

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.Graphics;
using Microsoft.Xna.Framework;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameManagers;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
{
public class Peeble:Collectable
{
public override GraphicsComponent graphicsComponent { get; } = new(new List<string> { "Peeble" }, "Peeble");
public Peeble(Vector2 position) : base(position)
{
}
public override void OnInteraction(object sender, CollisionComponent e)
{
AppManager.Instance.server.AddData(new UpdateLoot("Peeble"));
AppManager.Instance.server.DeleteObject(this);
}
}
}

View file

@ -0,0 +1,27 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
{
class PureBottleOfWater:Collectable
{
public override GraphicsComponent graphicsComponent { get; } = new(new List<string> { "PureBottleOfWater" }, "PureBottleOfWater");
public PureBottleOfWater(Vector2 position) : base(position)
{
}
public override void OnInteraction(object sender, CollisionComponent e)
{
AppManager.Instance.server.AddData(new UpdateLoot("PureBottleOfWater"));
AppManager.Instance.server.DeleteObject(this);
}
}
}

View file

@ -0,0 +1,27 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
{
class RottenFlesh:Collectable
{
public override GraphicsComponent graphicsComponent { get; } = new(new List<string> { "RottenFlesh" }, "RottenFlesh");
public RottenFlesh(Vector2 position) : base(position)
{
}
public override void OnInteraction(object sender, CollisionComponent e)
{
AppManager.Instance.server.AddData(new UpdateLoot("RottenFlesh"));
AppManager.Instance.server.DeleteObject(this);
}
}
}

View file

@ -0,0 +1,27 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables
{
class Steel:Collectable
{
public override GraphicsComponent graphicsComponent { get; } = new(new List<string> { "Steel" }, "Steel");
public Steel(Vector2 position) : base(position)
{
}
public override void OnInteraction(object sender, CollisionComponent e)
{
AppManager.Instance.server.AddData(new UpdateLoot("Steel"));
AppManager.Instance.server.DeleteObject(this);
}
}
}

View file

@ -1,5 +1,8 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using ZoFo.GameCore.GameManagers;
using ZoFo.GameCore.GameManagers.CollisionManager;
using ZoFo.GameCore.GameManagers.NetworkManager.Updates.ServerToClient;
using ZoFo.GameCore.Graphics;
namespace ZoFo.GameCore.GameObjects.Entities.Interactables.Collectables;
@ -10,5 +13,11 @@ public class Wood : Collectable
public Wood(Vector2 position) : base(position)
{
}
public override void OnInteraction(object sender, CollisionComponent e)
{
AppManager.Instance.server.AddData(new UpdateLoot("Wood"));
AppManager.Instance.server.DeleteObject(this);
}
}

View file

@ -6,12 +6,13 @@ using System.Threading.Tasks;
namespace ZoFo.GameCore.GameObjects.Entities.LivingEntities.Player
{
internal class LootData
class LootData
{
public Dictionary<string, int> loots;
public void AddLoot(object lootObject, int quantity)
{
public void AddLoot(string lootName, int quantity)
{
loots.Add(lootName, quantity);
}
}
}

View file

@ -21,6 +21,7 @@ public class Player : LivingEntity
public bool IsTryingToShoot { get; set; }
private float speed;
private int health;
private LootData lootData;
public override GraphicsComponent graphicsComponent { get; } = new GraphicsComponent(new List<string> { "player_running_top_rotate" }, "player_running_top_rotate");
public Player(Vector2 position) : base(position)
{