Esempio n. 1
0
        private ListBoxItem AddActionRow(UCEActionRow row)
        {
            ListBoxItem item = new ListBoxItem();

            item.Content = row;
            list.Items.Add(item);
            item.PreviewMouseLeftButtonDown += Item_MouseLeftButtonDown;
            return(item);
        }
Esempio n. 2
0
        private void Item_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            e.Handled = true;

            ListBoxItem item = (ListBoxItem)sender;

            UCEActionRow row = (UCEActionRow)item.Content;

            list.SelectedItem = null;
            row.Execute();

            ActionExecuted?.Invoke();
        }
Esempio n. 3
0
        public void Refresh()
        {
            list.Items.Clear();
            list.IsEnabled = true;

            int actionPoints = Game.CurrentPlayer.AvailableActionPoints;

            if (SelectedPosition != null)
            {
                if (Game.CurrentPlayer.Character.CanStepToPosition(SelectedPosition, Game))
                {
                    int movementCost = Game.GetMap().GetMovementCost(SelectedPosition, Game.Config);

                    var          actionPlan = new MoveActionPlan(Game, Game.CurrentPlayer.Character, SelectedPosition);
                    UCEActionRow row        = new UCEActionRow("Move", movementCost, movementCost <= actionPoints, actionPlan);
                    AddActionRow(row);
                }
            }

            if (SelectedObject != null && SelectedObject.AvailableActions.Count > 0)
            {
                var actions = SelectedObject.AvailableActions;

                foreach (var action in actions)
                {
                    int actionCost = SelectedObject.Scheme.GetFunctionByName(action).ActionPoints;

                    var          actionPlan = new ObjectActionPlan(Game, Game.CurrentPlayer.Character, SelectedObject, action);
                    UCEActionRow row        = new UCEActionRow(action, actionCost, actionCost <= actionPoints, actionPlan);
                    AddActionRow(row);
                }
            }

            if (list.Items.Count == 0)
            {
                ListBoxItem item = new ListBoxItem();
                item.Content   = "No other actions available";
                item.IsEnabled = false;
                list.Items.Add(item);
            }

            var          endTurnActionPlan = new EndTurnActionPlan(Game, Game.CurrentPlayer.Character);
            UCEActionRow endTurnRow        = new UCEActionRow("End turn", 0, true, endTurnActionPlan);

            AddActionRow(endTurnRow);
        }