Example #1
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;
                    }
                }
            });
        }));
    }