示例#1
0
    private void StartTimer()
    {
        SkipButtonUI skip = SkipButtonUI.GetInstance();

        skip.MaxTime = timeToChoose;
        skip.EnableTimerOnly();
    }
示例#2
0
    public override IAction ActionOnEnter(Player obj)
    {
        // Get specific event
        EventAction eventAction = EventListManager.GetInstance().GetAction(obj);

        // Pack UI actions
        ActionList result = new ActionList();

        LambdaCompletableAction action = new LambdaCompletableAction(null);                 // 3

        action.preAction = () => {
            NotifyPlotEnter(obj);

            EventDeck.SetActive(true);                                                      // 1
            // Create Event Card
            GameObject EventCardModel = Instantiate(EventModel);
            // ... with the corresponding event sprite
            SpriteRenderer EventCardRenderer = EventCardModel.GetComponentInChildren <SpriteRenderer>();
            EventCardRenderer.sprite
                = EventListManager.GetInstance().EventSprite[eventAction];
            // When target is reached, show the skip button.
            EventCardRenderer
            .GetComponent <EventCardDraw>()
            .ListenTargetReached(
                new LambdaAction(() =>
            {
                SkipButtonUI skipButtonUI = SkipButtonUI.GetInstance();

                skipButtonUI.MaxTime = 5f;
                skipButtonUI.Enable();
                // When the skip button is clicked, destroy the EventCard
                // and hide the event deck
                // note: skip button UI is disabled on click
                skipButtonUI.ListenClick(
                    new LambdaAction(() =>
                {
                    EventDeck.SetActive(false);                                             // 1
                    Destroy(EventCardModel);
                    // Then FINALLY mark this completable action as complete
                    action.PerformOnComplete();                                             // 3
                }));
            }));
        };

        result.AddBlockingAction(action);
        result.AddNonBlockAction(eventAction);

        /* LOGICAL BUG
         * // TODO
         * result.OnActionComplete = new LambdaAction(() =>
         * {
         *  TurnDirector.Ins.EndOfPhase();
         * });
         * //*/
        NotifyPlotEnter(obj);

        return(result);
    }
示例#3
0
    public void Listen(IPlotChooserAction action, IAction defaultAction,
                       List <PLOT> excludedPlots = null,
                       float timeToChoose        = DEFAULT_TIME_TO_CHOOSE_PLOT)
    {
        ListeningAction    = action;
        this.defaultAction = defaultAction;
        this.timeToChoose  = timeToChoose;

        // Master initiate the skip count down
        if (PhotonNetwork.IsMasterClient)
        {
            StartTimer();
            SkipButtonUI.GetInstance().ListenClick(new LambdaAction(() =>
            {
                photonView.RPC("OnTimeoutEvent", RpcTarget.All);
            }));
        }
        if (!TurnDirector.Ins.IsMyTurn())
        {
            return;
        }
        // Player choose the plot
        CameraTopDown cameraComponent = CameraTopDown.GetInstance();

        cameraComponent.Active = true;
        cameraComponent.ListenTargetReached(new LambdaAction(() =>
        {
            gameObject.SetActive(true);

            if (excludedPlots != null)
            {
                foreach (PLOT plot in excludedPlots)
                {
                    TileChooserButton.buttonDictionary[plot].button.enabled = false;
                }
            }

            postChosenTile = new LambdaAction(() =>
            {
                cameraComponent.Active = true;
                gameObject.SetActive(false);

                if (excludedPlots != null)
                {
                    foreach (PLOT plot in excludedPlots)
                    {
                        TileChooserButton.buttonDictionary[plot].button.enabled = true;
                    }
                }
            });
        }));
    }