コード例 #1
0
    void Start()
    {
        this.OnMouseDownAsObservable()
        .Subscribe(_ => {
            //  カードプレイ&補充
            var canNotPlay = !onePlayArea.CanPlay(hands[0].GetSelectedCards());
            if (canNotPlay)
            {
                return;
            }
            onePlayArea.Play(hands[0].RemoveSelectedCards());
            hands[0].Deal(decks[0]);
            foreach (var onehand in oneHands)
            {
                onehand.DeselectFrame();
            }

            var drawPlay     = onePlayArea.DrawPlay();
            var drawHandDeal = hands[0].DrawDeal();
            var drawFrame    = oneHands.Select(onehand => onehand.DrawFrame()).Merge();
            drawable.SyncCommand.Execute(drawPlay.Merge(drawHandDeal).Merge(drawFrame));

            // 次プレイできなければ、再配置処理
            var canNextPlay = hands                     // hands × onePlayAreas で CanNextPlay
                              .Any(hand => onePlayAreas
                                   .Any(onePlayArea => onePlayArea.CanNextPlay(hand)));
            if (canNextPlay)
            {
                return;
            }
            Debug.Log("cannotPlay!");
            foreach (var onePlayArea in onePlayAreas)
            {
                discardBox.Store(onePlayArea.RemoveAll());
            }

            foreach (var onePlayArea in onePlayAreas)
            {
                onePlayArea.Deal(decks[0].TopDraw());
            }

            var drawRemoveForPlayArea = Observable.TimerFrame(120).AsUnitObservable()
                                        .Concat(discardBox.DrawRemoveForPlayArea());
            var drawPlayAreaDeal = onePlayAreas.Select(onePlayArea => onePlayArea.DrawDeal()).Merge();
            //drawable.SyncCommand.Execute (Observable.ReturnUnit ().ForEachAsync (a => Debug.Log ("ok")));
            drawable.SyncCommand.Execute(drawRemoveForPlayArea.Concat(drawPlayAreaDeal));
        });
    }
コード例 #2
0
    public void PlayForHand(Hand playHand, OnePlayArea targetArea)
    {
        if (!targetArea.CanPlay(playHand.GetSelectedCards()))
        {
            return;
        }
        // カードプレイ
        targetArea.Play(playHand.RemoveSelectedCards());
        var drawPlay = targetArea.DrawPlay();

        // ハンド補充
        playHand.Deal(decks[0]);
        var drawHandDeal = playHand.DrawDeal();

        drawable.SyncCommand.Execute(drawPlay.Merge(drawHandDeal));

        // 次のカードがプレイできるように再配置する処理
        var canNextPlay = hands.Any(hand =>
                                    playAreas.Any(onePlayArea =>
                                                  onePlayArea.CanNextPlay(hand)));

        // 次プレイできれば、再配置処理は必要ない
        if (canNextPlay)
        {
            return;
        }

        Debug.Log("CannotPlay!");
        // プレイ済みのカードの廃棄処理
        foreach (var playArea in playAreas)
        {
            discardsBox.Store(playArea.RemoveAll());
        }
        var drawRemoveForPlayArea = Observable.TimerFrame(120).AsUnitObservable()
                                    .Concat(discardsBox.DrawRemoveForPlayArea());

        // プレイエリアへの再配置
        foreach (var onePlayArea in playAreas)
        {
            onePlayArea.Deal(decks[0].TopDraw());
        }
        var drawPlayAreaDeal = playAreas.Select(playArea => playArea.DrawDeal()).Merge();

        drawable.SyncCommand.Execute(drawRemoveForPlayArea.Concat(drawPlayAreaDeal));
        return;
    }