Base entity

This commit is contained in:
femsci 2023-04-27 22:24:25 +02:00
parent 77820294ea
commit d5ff070db6
Signed by: femsci
GPG key ID: 08F7911F0E650C67
7 changed files with 84 additions and 1 deletions

View file

@ -2,5 +2,6 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>Mombae</RootNamespace>
</PropertyGroup>
</Project>
</Project>

View file

@ -1,6 +1,8 @@
using System;
using Godot;
namespace Mombae;
public partial class Bottom : Node
{
// Called when the node enters the scene tree for the first time.

12
src/Entity/IHasArmor.cs Normal file
View file

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Mombae.Entity;
namespace Mombae.Entity;
public interface IHasArmor : IHasHealth
{
public int ArmorPoints { get; }
}

12
src/Entity/IHasHealth.cs Normal file
View file

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Mombae.Entity;
public interface IHasHealth
{
public int Health { get; }
public void ReceiveDamage(int hp);
}

14
src/Entity/Unit.cs Normal file
View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Godot;
namespace Mombae.Entity;
public abstract class Unit
{
public string Name { get; }
public Transform2D Transform { get; set; }
public Vector2 Position => Transform.Origin;
}

View file

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Mombae.Entity;
namespace Mombae.Entity.Vehicle;
public abstract class VehicleBase : Unit, IHasArmor
{
public abstract int ArmorPoints { get; protected set; }
public abstract int Health { get; protected set; }
public void ReceiveDamage(int hp)
{
if (ArmorPoints > 0)
{
ArmorPoints -= hp;
if (ArmorPoints < 0)
{
Health -= Math.Abs(ArmorPoints);
}
}
else
{
Health -= Math.Max(0, Health - hp);
}
}
}

View file

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Mombae.Entity.Vehicle;
public class Vidulg : VehicleBase
{
public override int ArmorPoints { get; protected set; } = 300;
public override int Health { get; protected set; } = 1200;
}