Base entity
This commit is contained in:
parent
77820294ea
commit
d5ff070db6
7 changed files with 84 additions and 1 deletions
|
@ -2,5 +2,6 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<EnableDynamicLoading>true</EnableDynamicLoading>
|
<EnableDynamicLoading>true</EnableDynamicLoading>
|
||||||
|
<RootNamespace>Mombae</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
|
namespace Mombae;
|
||||||
|
|
||||||
public partial class Bottom : Node
|
public partial class Bottom : Node
|
||||||
{
|
{
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
|
|
12
src/Entity/IHasArmor.cs
Normal file
12
src/Entity/IHasArmor.cs
Normal 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
12
src/Entity/IHasHealth.cs
Normal 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
14
src/Entity/Unit.cs
Normal 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;
|
||||||
|
}
|
30
src/Entity/Vehicle/VehicleBase.cs
Normal file
30
src/Entity/Vehicle/VehicleBase.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
12
src/Entity/Vehicle/Vidulg.cs
Normal file
12
src/Entity/Vehicle/Vidulg.cs
Normal 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;
|
||||||
|
}
|
Loading…
Reference in a new issue