Example #1
0
    public Future <bool> InitShopData()
    {
        FutureTask <bool> initTask = new FutureTask <bool>();

        initShopTask = initTask;

        int totalPlayer = TurnDirector.Ins.ListPlayer.Count;
        int countPlayer = 0;

        foreach (var player in TurnDirector.Ins.ListPlayer)
        {
            var future = FetchShopItems(player.Id);
            future.then((x) =>
            {
                countPlayer++;

                if (countPlayer == totalPlayer)
                {
                    initTask.Complete(true);
                }
            });
        }

        return(initTask.GetFuture());
    }
Example #2
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="idItem">id Item to get</param>
    /// <param name="itemCount">Number of item get, 0 to get all item left</param>
    /// <returns></returns>
    public Future <bool> GetRandomSunnariItem(int idPlayer)
    {
        FutureTask <bool> futureItems = new FutureTask <bool>();

        getRandomSunnariItemCallback = futureItems;

        photonView.RPC("GetRandomtSunnariItemServer", RpcTarget.MasterClient, idPlayer);

        return(futureItems.GetFuture());
    }
Example #3
0
    public Future <bool> RequestBuyItem(int idPlayer, int idItem)
    {
        FutureTask <bool> requestBuy = new FutureTask <bool>();

        requestBuyCallback = requestBuy;

        photonView.RPC("RequestBuyItemServer", RpcTarget.MasterClient, idPlayer, idItem);

        return(requestBuy.GetFuture());
    }
Example #4
0
    private Future <List <BaseItem> > FetchShopItems(int idPlayer)
    {
        FutureTask <List <BaseItem> > fetchTask = new FutureTask <List <BaseItem> >();

        futureTasks.Add(fetchTask);

        photonView.RPC("FetchShopItemsServer", RpcTarget.MasterClient, idPlayer, PhotonNetwork.LocalPlayer.UserId, futureTasks.Count - 1);

        return(fetchTask.GetFuture());
    }
Example #5
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="idPlayer">Shop's owner's id</param>
    /// <param name="itemCount"></param>
    /// <returns></returns>
    public Future <List <BaseItem> > RequestNewShop(int idPlayer, int itemCount, int numberMoney)
    {
        FutureTask <List <BaseItem> > futureItems = new FutureTask <List <BaseItem> >();

        requestNewShopCallback = futureItems;

        photonView.RPC("RequestNewShopServer", RpcTarget.MasterClient, idPlayer, itemCount, numberMoney);

        return(futureItems.GetFuture());
    }
Example #6
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="idItem">id Item to get</param>
    /// <param name="itemCount">Number of item get, 0 to get all item left</param>
    /// <returns></returns>
    public Future <List <BaseItem> > RequestItem(int idItem, int itemCount)
    {
        FutureTask <List <BaseItem> > futureItems = new FutureTask <List <BaseItem> >();

        requestItemCallback = futureItems;

        photonView.RPC("RequestItemServer", RpcTarget.MasterClient, idItem, itemCount);

        return(futureItems.GetFuture());
    }
Example #7
0
    private Future <bool> ConnectToLobby()
    {
        FutureTask <bool> connectTask = new FutureTask <bool>();

        _connectToLobbyTask = connectTask;

        if (!PhotonNetwork.IsConnectedAndReady)
        {
            PhotonNetwork.SendRate               = 60;
            PhotonNetwork.SerializationRate      = 60;
            PhotonNetwork.AutomaticallySyncScene = true;
            PhotonNetwork.ConnectUsingSettings();
        }
        else
        {
            connectTask.Complete(true);
        }

        return(connectTask.GetFuture());
    }
Example #8
0
 public Future <bool> Init(float duration)
 {
     this.duration  = duration;
     taskOnComplete = new FutureTask <bool>();
     return(taskOnComplete.GetFuture());
 }