feat: add more info to target panel
This commit is contained in:
@ -67,7 +67,7 @@ namespace Client.Application.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public CreatureListViewModel? Target
|
||||
public TargetSummaryInfoViewModel? Target
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -93,7 +93,7 @@ namespace Client.Application.ViewModels
|
||||
{
|
||||
if (target == null && hero.Target != null)
|
||||
{
|
||||
target = new CreatureListViewModel(hero.Target, hero);
|
||||
target = new TargetSummaryInfoViewModel(hero.Target, hero);
|
||||
OnPropertyChanged("Target");
|
||||
}
|
||||
else if (target != null && hero.Target == null)
|
||||
@ -135,6 +135,6 @@ namespace Client.Application.ViewModels
|
||||
}
|
||||
|
||||
private readonly Hero hero;
|
||||
private CreatureListViewModel? target;
|
||||
private TargetSummaryInfoViewModel? target;
|
||||
}
|
||||
}
|
||||
|
81
Client/Application/ViewModels/TargetSummaryInfoViewModel.cs
Normal file
81
Client/Application/ViewModels/TargetSummaryInfoViewModel.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using Client.Domain.Common;
|
||||
using Client.Domain.Entities;
|
||||
using Client.Domain.ValueObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Client.Application.ViewModels
|
||||
{
|
||||
public class TargetSummaryInfoViewModel : ObservableObject
|
||||
{
|
||||
public uint Id => creature.Id;
|
||||
|
||||
public string Name => creature.Name;
|
||||
|
||||
public Vector3 Position => creature.Transform.Position;
|
||||
|
||||
public string BriefInfo => creature.BriefInfo;
|
||||
|
||||
public float Distance => creature.Distance(hero);
|
||||
|
||||
public float DeltaZ => creature.DeltaZ(hero);
|
||||
|
||||
public uint Hp => creature.VitalStats.Hp;
|
||||
|
||||
public uint MaxHp => creature.VitalStats.MaxHp;
|
||||
|
||||
public TargetSummaryInfoViewModel(CreatureInterface creature, Hero hero)
|
||||
{
|
||||
creature.PropertyChanged += Creature_PropertyChanged;
|
||||
creature.Transform.Position.PropertyChanged += Position_PropertyChanged;
|
||||
creature.VitalStats.PropertyChanged += VitalStats_PropertyChanged;
|
||||
hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged;
|
||||
|
||||
this.creature = creature;
|
||||
this.hero = hero;
|
||||
}
|
||||
|
||||
private void VitalStats_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "Hp")
|
||||
{
|
||||
OnPropertyChanged("Hp");
|
||||
}
|
||||
if (e.PropertyName == "MaxHp")
|
||||
{
|
||||
OnPropertyChanged("MaxHp");
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
OnPropertyChanged("Transform");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user