Beispiel #1
0
        public StateSequencer(IGameStateUseCase gameStateUseCase, ReadyView readyView, DrawView drawView,
                              AttackView attackView, DamageView damageView, ClearView clearView, FailView failView)
        {
            _states = new List <BaseState>
            {
                readyView,
                drawView,
                attackView,
                damageView,
                clearView,
                failView,
            };

            _disposable  = new CompositeDisposable();
            _tokenSource = new CancellationTokenSource();

            foreach (var state in _states)
            {
                state.InitAsync(_tokenSource.Token).Forget();
            }

            _gameStateUseCase = gameStateUseCase;
            _gameStateUseCase.GameState()
            .Subscribe(gameState =>
            {
                Reset(gameState);
                TickAsync(gameState, _tokenSource.Token).Forget();
            })
            .AddTo(_disposable);
        }
Beispiel #2
0
    // TODO: Play currently attack or defense cards from the server
    public void SyncTable(PlayerArea area, PlayerArea targetArea,
                          ref AttackView attackView, AttackView newAttackView,
                          ref DefendView defendView, DefendView newDefendView,
                          ref GameView gameView, GameView newGameView)
    {
        if (newGameView.attackId != gameView.attackId && PLAYER2.Equals(newAttackView.player1))
        {
            // play skill card to table
            for (int i = 0; i < newAttackView.cardsPlayed.Count; i++)
            {
                new RemoveACardCommand(area, newAttackView.handIndexes[i]).AddToQueue();
                new PlaySkillCardCommand(area, FindCardAsset(newAttackView.cardsPlayed[i]), newAttackView.handIndexes[i], newAttackView.user).AddToQueue();
            }
            // highlight attacking monster
            new HighlightCommand(area, newAttackView.user, true).AddToQueue();
            // draw targeting arrows
            for (int i = 0; i < newAttackView.targets.Count; i++)
            {
                new DrawArrowCommand(area, targetArea, newAttackView.user, newAttackView.targets[i]).AddToQueue();
            }
            // sync attack view to local
            gameView.attackId = newGameView.attackId;
            attackView        = newAttackView;
        }

        if (newGameView.defendId != gameView.defendId && PLAYER2.Equals(newDefendView.player1))
        {
            if (newDefendView == null)
            {
                defendView = newDefendView;
                return;
            }
            // play skill card to table
            for (int i = 0; i < newDefendView.cardAndTargets.Count; i++)
            {
                new RemoveACardCommand(area, newDefendView.cardAndTargets[i].handIndex).AddToQueue();
                new PlaySkillCardCommand(area, FindCardAsset(newDefendView.cardAndTargets[i].card),
                                         newDefendView.cardAndTargets[i].handIndex, newDefendView.cardAndTargets[i].user).AddToQueue();
            }

            // play attack animation
            RemoveCardsFromTable();
            new AttackCommand(playerArea, opponentArea, attackRequest.user, attackRequest.targets[0]).AddToQueue();

            // reset attack request
            attackRequest.cardsPlayed = new List <int>();
            attackRequest.targets     = new List <int>();
            attackRequest.damages     = new List <int>();

            // sync defend view to local
            gameView.defendId = newGameView.defendId;
            defendView        = newDefendView;
        }
    }
Beispiel #3
0
        //-------------------------------------------------------------------------------------[]
        private void AddAttackBluePiece(
            DraftScenario draftScenario,
            IStoryAction action,
            AttackView attackView)
        {
            switch (attackView)
            {
            case AttackView.Live: {
                var scenario = GetAttackBlueLiveScenario(action);
                var piece    = ConvertHexesToFly(action, scenario);
                AddAttackPiece(draftScenario, action, piece);
            }
            break;

            case AttackView.Death: {
                var scenario = GetAttackBlueDeathScenario(action);
                var piece    = ConvertHexesToFly(action, scenario);
                AddAttackPiece(draftScenario, action, piece);
            }
            break;

            case AttackView.Block: {
                var scenario = GetAttackBlueMissScenario(action);
                var piece    = ConvertHexesToFly(action, scenario);
                AddAttackPiece(draftScenario, action, piece);
            }
            break;

            case AttackView.Fatality: {
                var scenario = GetAttackBlueFatalityScenario(action);
                var piece    = ConvertHexesToFly(action, scenario);
                AddAttackPiece(draftScenario, action, piece);
            }
            break;
            }
        }
Beispiel #4
0
        //-------------------------------------------------------------------------------------[]
        private void AddAttackChargeBluePiece(
            DraftScenario draftScenario,
            IStoryAction action,
            AttackView attackView)
        {
            switch (attackView)
            {
            case AttackView.Live:
                AddAttackChargePieceForBlue(draftScenario, action, GetAttackChargeBlueLiveScenario(action));
                break;

            case AttackView.Death:
                AddAttackChargePieceForBlue(draftScenario, action, GetAttackChargeBlueDeathScenario(action));
                break;

            case AttackView.Fatality:
                AddAttackChargePieceForBlue(draftScenario, action, GetAttackChargeBlueDeathScenario(action));
                break;

            case AttackView.Block:
                AddAttackChargePieceForBlue(draftScenario, action, GetAttackChargeBlueMissScenario(action));
                break;
            }
        }