Added DoSomething logic, shoot, eat and intialize.
This commit is contained in:
@@ -20,7 +20,7 @@ namespace PeopleVille.Equipment
|
||||
public void Use(Person target)
|
||||
{
|
||||
target.Health -= this.Damage;
|
||||
Console.WriteLine($"{target.Name} has been shot and took {Damage}");
|
||||
Console.WriteLine($"{target.Name} er blevet skudt og mistede {Damage} liv");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using PeopleVille.Equipment;
|
||||
using PeopleVille.WorldBuilder;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace PeopleVille.Persons
|
||||
{
|
||||
@@ -7,7 +9,10 @@ namespace PeopleVille.Persons
|
||||
public AdultCitizen()
|
||||
{
|
||||
Age = RNG.Range(20, 85);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
Manager.TickDone += DoSomething;
|
||||
}
|
||||
|
||||
@@ -39,12 +44,22 @@ namespace PeopleVille.Persons
|
||||
|
||||
private void ShootRandomPerson()
|
||||
{
|
||||
//
|
||||
var targets = World.People.Where(x => x != this && x.CurrentLocation == CurrentLocation).ToList();
|
||||
if (targets.Count == 0)
|
||||
return;
|
||||
|
||||
var target = targets[RNG.ThrowDice(new Die(targets.Count)) - 1];
|
||||
var gun = Inventory.OfType<Gun>().First();
|
||||
gun.Use(target);
|
||||
}
|
||||
|
||||
private void EatFood()
|
||||
{
|
||||
//
|
||||
var food = Inventory.OfType<Food>().First();
|
||||
if (food == null)
|
||||
return;
|
||||
|
||||
food.Use(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using PeopleVille.Equipment;
|
||||
using PeopleVille.Locations;
|
||||
using PeopleVille.WorldBuilder;
|
||||
|
||||
namespace PeopleVille.Persons
|
||||
{
|
||||
@@ -17,6 +18,9 @@ namespace PeopleVille.Persons
|
||||
public Location CurrentLocation { get; set; }
|
||||
|
||||
public GameManager Manager { get; set; }
|
||||
public World World { get; set; }
|
||||
|
||||
public virtual void Initialize() { }
|
||||
|
||||
public void Walk(Location newLocation)
|
||||
{
|
||||
|
||||
@@ -12,3 +12,36 @@ var world = new WorldBuilder()
|
||||
.Build();
|
||||
|
||||
await world.manager.StartClock();
|
||||
|
||||
|
||||
|
||||
/* DoSomething() test
|
||||
using PeopleVille.Equipment;
|
||||
using PeopleVille.Locations;
|
||||
using PeopleVille.Persons;
|
||||
using PeopleVille.WorldBuilder;
|
||||
|
||||
var location = new Bank { Name = "Banken" };
|
||||
|
||||
var thomas = new AdultCitizen { Name = "Thomas", Health = 100 };
|
||||
thomas.Inventory.Add(new Gun { Name = "Glock", Damage = 30 });
|
||||
thomas.CurrentLocation = location;
|
||||
|
||||
var emil = new AdultCitizen { Name = "Emil", Health = 100 };
|
||||
emil.CurrentLocation = location;
|
||||
|
||||
var world = new WorldBuilder()
|
||||
.AddGameManager()
|
||||
.AddEquipment()
|
||||
.AddLocations()
|
||||
.FromRange([location])
|
||||
.AddPersons()
|
||||
.FromRange([thomas, emil])
|
||||
.EndWorldBuilding()
|
||||
.Build();
|
||||
|
||||
thomas.DoSomething();
|
||||
thomas.DoSomething();
|
||||
thomas.DoSomething();
|
||||
|
||||
Console.WriteLine($"Emils liv: {emil.Health}");*/
|
||||
@@ -63,6 +63,8 @@ namespace PeopleVille.WorldBuilder
|
||||
foreach (var person in world.People)
|
||||
{
|
||||
person.Manager = world.manager;
|
||||
person.World = world;
|
||||
person.Initialize();
|
||||
}
|
||||
|
||||
return world;
|
||||
|
||||
Reference in New Issue
Block a user