feat: add creatures and drops on the map

This commit is contained in:
k0t9i
2023-02-07 22:21:15 +04:00
parent d03f37fbf7
commit 2480563914
13 changed files with 529 additions and 59 deletions

View File

@@ -1,4 +1,5 @@
using Client.Domain.ValueObjects;
using Client.Domain.Enums;
using Client.Domain.ValueObjects;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -15,6 +16,8 @@ namespace Client.Domain.Entities
Transform Transform { get; set; }
string Name { get; }
string BriefInfo { get; }
CreatureTypeEnum Type { get; }
uint AggroRadius { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using Client.Domain.Common;
using Client.Domain.Enums;
using Client.Domain.ValueObjects;
namespace Client.Domain.Entities
@@ -13,11 +14,11 @@ namespace Client.Domain.Entities
private string iconName;
public uint Id { get => id; set => id = value; }
public Transform Transform { get => transform; set { if (value != transform) { transform = value; OnPropertyChanged("Transform"); } } }
public uint ItemId { get => itemId; set { if (value != itemId) { itemId = value; OnPropertyChanged("ItemId"); } } }
public uint Amount { get => amount; set { if (value != amount) { amount = value; OnPropertyChanged("Amount"); } } }
public string Name { get => name; set { if (value != name) { name = value; OnPropertyChanged("Name"); } } }
public string IconName { get => iconName; set { if (value != iconName) { iconName = value; OnPropertyChanged("IconName"); } } }
public Transform Transform { get => transform; set { if (value != transform) { transform = value; OnPropertyChanged(); } } }
public uint ItemId { get => itemId; set { if (value != itemId) { itemId = value; OnPropertyChanged(); } } }
public uint Amount { get => amount; set { if (value != amount) { amount = value; OnPropertyChanged(); } } }
public string Name { get => name; set { if (value != name) { name = value; OnPropertyChanged(); } } }
public string IconName { get => iconName; set { if (value != iconName) { iconName = value; OnPropertyChanged(); } } }
public Drop(uint id, Transform transform, uint itemId, uint amount, string name, string iconName)
{

View File

@@ -1,4 +1,5 @@
using Client.Domain.Common;
using Client.Domain.Enums;
using Client.Domain.ValueObjects;
using System.ComponentModel;
using System.Diagnostics;
@@ -18,6 +19,7 @@ namespace Client.Domain.Entities
public uint TargetId { get => targetId; set { if (value != targetId) { targetId = value; OnPropertyChanged("TargetId"); } } }
public CreatureInterface? Target { get => target; set { if (value != target) { target = value; OnPropertyChanged("Target"); } } }
public bool IsStanding { get; set; }
public CreatureTypeEnum Type { get => CreatureTypeEnum.Hero; }
public FullName FullName
{
get => fullName;
@@ -59,6 +61,7 @@ namespace Client.Domain.Entities
return Phenotype.Race.ToString() + ", " + Phenotype.Class.ToString();
}
}
public uint AggroRadius { get; set; } = 0;
public Hero(uint id, Transform transform, FullName fullName, VitalStats vitalStats, Phenotype phenotype, ExperienceInfo experienceInfo, PermanentStats permanentStats, VariableStats variableStats, Reputation reputation, InventoryInfo inventoryInfo, uint targetId, bool isStanding)
{

View File

@@ -67,17 +67,17 @@ namespace Client.Domain.Entities
}
}
}
public string Name
{
get
{
string result = "";
string result = FullName.Nickname;
if (IsDead())
{
result += "Dead ";
result += " (dead)";
}
result += FullName.Nickname + "[" + NpcId + "]";
return result;
}
@@ -97,11 +97,12 @@ namespace Client.Domain.Entities
result += "*";
}
}
result += "<" + NpcId + ">";
result += " " + Level + "lvl";
return result;
}
}
public CreatureTypeEnum Type { get => CreatureTypeEnum.NPC; }
public NPC(uint id, Transform transform, bool isHostile, uint npcId, SpoilStateEnum spoilState, FullName fullName, VitalStats vitalStats)
{
Id = id;

View File

@@ -60,6 +60,8 @@ namespace Client.Domain.Entities
}
public VitalStats VitalStats { get => vitalStats; set => vitalStats = value; }
public CreatureTypeEnum Type { get => CreatureTypeEnum.Player; }
public uint AggroRadius { get; set; } = 0;
public Player(uint id, Transform transform, FullName fullName, Phenotype phenotype)
{

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Client.Domain.Enums
{
public enum CreatureTypeEnum
{
NPC,
Player,
Hero
}
}

View File

@@ -1,4 +1,5 @@
using Client.Domain.Common;
using System;
namespace Client.Domain.ValueObjects
{
@@ -9,10 +10,40 @@ namespace Client.Domain.ValueObjects
private Vector3 velocity;
private Vector3 acceleration;
public Vector3 Position { get => position; set { if (value != position) { position = value; OnPropertyChanged("Position"); } } }
public Vector3 Rotation { get => rotation; set { if (value != rotation) { rotation = value; OnPropertyChanged("Rotation"); } } }
public Vector3 Velocity { get => velocity; set { if (value != velocity) { velocity = value; OnPropertyChanged("Velocity"); } } }
public Vector3 Acceleration { get => acceleration; set { if (value != acceleration) { acceleration = value; OnPropertyChanged("Acceleration"); } } }
public Vector3 Position { get => position; set { if (value != position) { position = value; OnPropertyChanged(); } } }
public Vector3 Rotation {
get => rotation;
set
{
if (value != rotation)
{
rotation = value;
OnPropertyChanged();
OnPropertyChanged("Direction");
}
}
}
private void Rotation_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "Y")
{
OnPropertyChanged("Direction");
}
}
public Vector3 Velocity { get => velocity; set { if (value != velocity) { velocity = value; OnPropertyChanged(); } } }
public Vector3 Acceleration { get => acceleration; set { if (value != acceleration) { acceleration = value; OnPropertyChanged(); } } }
public Vector3 Direction
{
get
{
float deg = Rotation.Y / 65535 * 2 * MathF.PI;
return new Vector3(MathF.Cos(deg), MathF.Sin(deg), 0);
}
}
public Transform(Vector3 position, Vector3 rotation, Vector3 velocity, Vector3 acceleration)
{
@@ -20,6 +51,7 @@ namespace Client.Domain.ValueObjects
this.rotation = rotation;
this.velocity = velocity;
this.acceleration = acceleration;
rotation.PropertyChanged += Rotation_PropertyChanged;
}
}
}