private void AttackMob(int targetId)
        {
            Debug.Assert(SelectedAbilityIndex != null,
                         "_gameInstance.TurnManager.SelectedAbilityIndex != null");

            var abilityIndex = SelectedAbilityIndex.Value;
            var mobId        = _game.CurrentMob;

            Debug.Assert(mobId != null);
            var abilityId = _game.MobManager.MobInfos[mobId.Value].Abilities[abilityIndex];

            var visibilityPath =
                _game.Map.AxialLinedraw(_game.State.MobInstances[mobId.Value].Coord,
                                        _game.State.MobInstances[targetId].Coord);

            bool isVisible = true;

            foreach (var coord in visibilityPath)
            {
                if (_game.Map[coord] == HexType.Wall)
                {
                    isVisible = false;
                }
            }

            if (isVisible)
            {
                bool withinRange = (visibilityPath.Count - 1) <= _game.MobManager.Abilities[abilityId].Range;
                if (withinRange)
                {
                    InputManager.Instance.UserInputEnabled = false;
                    _eventHub.SlowPlayAction(_game, UctAction.AbilityUseAction(abilityId, mobId.Value, targetId))
                    .ContinueWith(t => { InputManager.Instance.UserInputEnabled = true; })
                    .LogContinuation();
                }
                else
                {
                    ShowMessage("Target is outside the range of the currently selected ability.");
                }
            }
            else
            {
                ShowMessage("The target is not visible.");
            }
        }
        public async Task SlowPlayTurn(GameEventHub eventHub)
        {
            var result = await Task.Run(() => new UctAlgorithm(_thinkTime).UctSearch(_gameInstance));

            foreach (var action in result.Actions)
            {
                Debug.Assert(action.Type != UctActionType.EndTurn, "node.Action.Type != UctActionType.EndTurn");

                await eventHub.SlowPlayAction(_gameInstance, action);
            }

            LogActions(result);
        }
Exemple #3
0
        public async Task SlowPlayTurn(GameEventHub eventHub)
        {
            do
            {
                var possibleActions = ActionGenerator.PossibleActions(_gameInstance, null, true, true);
                var chosenAction    = possibleActions[Generator.Random.Next(possibleActions.Count)];

                if (chosenAction.Type == UctActionType.EndTurn)
                {
                    break;
                }

                await eventHub.SlowPlayAction(_gameInstance, chosenAction);
            } while (!_gameInstance.IsFinished);
        }
        public async Task SlowPlayTurn(GameEventHub eventHub)
        {
            do
            {
                var action = ActionGenerator.RuleBasedAction(_gameInstance);

                if (action.Type == UctActionType.EndTurn)
                {
                    break;
                }

                await eventHub.SlowPlayAction(_gameInstance, action);

                if (action.Type == UctActionType.DefensiveMove)
                {
                    break;
                }
            } while (!_gameInstance.IsFinished);
        }