private void SelectedReplayChanged(object sender, ListViewItemSelectionChangedEventArgs args) { if (repo == null || listView.SelectedItems.Count == 0) { return; } var lvItem = listView.SelectedItems[0]; var meta = (ReplayMeta)lvItem.Tag; var data = repo.GetData(meta); debugTextArea.Text = meta.ToString() + "\r\n\r\n" + data.Moves.ToDelimitedString("\r\n"); SelectedReplay = new ReplayFullData(meta, data); ReplayChanged?.Invoke(); }
public virtual void RegisterBattleMessageHandlers(IBattlemessageProvider bmp) { bmp.OnMessageIn = (int seqNo, byte[] data) => { if (seqNo > Battle.Replay.Messages.Count) { Battle.Replay.Messages.Add(data); ReplayChanged?.Invoke(); } }; bmp.HandleMsg("ExchangeWarroirsPosition", (player, data) => { var fx = data.ReadInt(); var fy = data.ReadInt(); var tx = data.ReadInt(); var ty = data.ReadInt(); Battle.ExchangeWarroirsPosition(fx, fy, tx, ty); }); bmp.HandleMsg("PlayerPrepared", (player, data) => { Battle.PlayerPrepared(player); }); bmp.HandleMsg("MoveOnPath", (player, data) => { var id = data.ReadInt(); var pathXYArr = data.ReadIntArr(); var warrior = Battle.Map.GetByID <Warrior>(id); warrior.MovingPath.Clear(); warrior.MovingPath.AddRange(pathXYArr); Battle.MoveOnPath(warrior); }); bmp.HandleMsg("Attack", (player, data) => { var attackerID = data.ReadInt(); var targetID = data.ReadInt(); var attacker = Battle.Map.GetByID <Warrior>(attackerID); var target = Battle.Map.GetByID <Warrior>(targetID); if (attacker is Hero) { Battle.Attack(attacker, target); } }); bmp.HandleMsg("MoveOnPathAndAttack", (player, data) => { var attackerID = data.ReadInt(); var pathXYArr = data.ReadIntArr(); var targetID = data.ReadInt(); var attacker = Battle.Map.GetByID <Warrior>(attackerID); attacker.MovingPath.Clear(); attacker.MovingPath.AddRange(pathXYArr); var target = Battle.Map.GetByID <Warrior>(targetID); if (attacker is Hero) { Battle.MoveOnPathAndAttack(attacker, target); } }); bmp.HandleMsg("ActionDone", (player, data) => { Battle.ActionDone(player); }); }