feat: create creature interface

This commit is contained in:
k0t9i
2023-01-31 15:14:19 +04:00
parent b8b92b7cf8
commit 31febdd341
16 changed files with 279 additions and 275 deletions

View File

@@ -0,0 +1,61 @@
using Client.Domain.Common;
using Client.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace Client.Application.ViewModels
{
public class CreatureListViewModel : NotifyPropertyChanged
{
public uint Id => creature.Id;
public string Name => creature.Name;
public string BriefInfo => creature.BriefInfo;
public float Distance => creature.Transform.Position.HorizontalDistance(hero.Transform.Position) / 100;
public float DeltaZ => (creature.Transform.Position.Z - hero.Transform.Position.Z) / 100;
public CreatureListViewModel(CreatureInterface creature, Hero hero)
{
creature.PropertyChanged += Creature_PropertyChanged;
creature.Transform.Position.PropertyChanged += Position_PropertyChanged;
hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged;
this.creature = creature;
this.hero = hero;
}
private void HeroPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
OnPropertyChanged("Distance");
OnPropertyChanged("DeltaZ");
}
private void Position_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
OnPropertyChanged("Distance");
OnPropertyChanged("DeltaZ");
}
private void Creature_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == "Name")
{
OnPropertyChanged("Name");
}
if (e.PropertyName == "BriefInfo")
{
OnPropertyChanged("BriefInfo");
}
}
private readonly CreatureInterface creature;
private readonly Hero hero;
}
}