Last active
October 24, 2019 02:55
-
-
Save IntegerMan/7275cabe245f946a801c484eb1a9c354 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class ActorViewModel | |
{ | |
private readonly Actors.Actor _actor; | |
public ActorViewModel(Actors.Actor actor) | |
{ | |
_actor = actor; | |
} | |
// Subtract 1 since my data's indexes start at 1 instead of 0 | |
public int PosX => (_actor.Pos.X - 1) * 10; | |
public int PosY => (_actor.Pos.Y - 1) * 10; | |
public string Text => Actors.getChar(_actor).ToString(); | |
public string ImagePath | |
{ | |
get | |
{ | |
if (_actor.ActorKind.Equals(Actors.ActorKind.Acorn)) | |
{ | |
return "Acorn.png"; | |
} | |
if (_actor.ActorKind.Equals(Actors.ActorKind.Doggo)) | |
{ | |
return "Doggo.png"; | |
} | |
if (_actor.ActorKind.Equals(Actors.ActorKind.Rabbit)) | |
{ | |
return "Rabbit.png"; | |
} | |
if (_actor.ActorKind.Equals(Actors.ActorKind.Tree)) | |
{ | |
return "Tree.png"; | |
} | |
if (_actor.ActorKind.Equals(Actors.ActorKind.NewSquirrel(true))) | |
{ | |
return "SquirrelAcorn.png"; | |
} | |
if (_actor.ActorKind.Equals(Actors.ActorKind.NewSquirrel(false))) | |
{ | |
return "Squirrel.png"; | |
} | |
return null; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly ObservableCollection<ActorViewModel> _actors = new ObservableCollection<ActorViewModel>(); | |
public Simulator.GameState State | |
{ | |
get => _state; | |
set | |
{ | |
_state = value; | |
_actors.Clear(); | |
foreach (var actor in _state.World.Actors.Where(a => a.IsActive)) | |
{ | |
_actors.Add(new ActorViewModel(actor)); | |
} | |
OnPropertyChanged(nameof(GameStatusBrush)); | |
OnPropertyChanged(nameof(GameStatusText)); | |
OnPropertyChanged(nameof(TurnsLeftText)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment