Exemple #1
0
 public async Task <List <Room> > GetRoomList(RoomCreateReq searchReq)
 {
     if (main_ch == null || client == null)
     {
         throw new System.Exception("CONNECT_CLIENT_IS_NULL");
     }
     try {
         CancellationTokenSource close_tkn   = new CancellationTokenSource();
         List <Room>             return_list = new List <Room>();
         using (var stream_task = client.GetRoomList(searchReq)) {
             // Debug.Log(stream_task);
             while (await stream_task.ResponseStream.MoveNext(close_tkn.Token))
             {
                 Debug.Log(stream_task.ResponseStream.Current);
                 return_list.Add(stream_task.ResponseStream.Current);
             }
         }
         return(return_list);
     } catch (RpcException) {
         Debug.LogError(client);
         Debug.LogError(config);
         // Debug.LogError()
         throw;
     }
 }
Exemple #2
0
    public async Task <Room> UpdateRoom(RoomCreateReq updateRoom)
    {
        if (main_ch == null || client == null)
        {
            throw new System.Exception("CONNECT_CLIENT_IS_NULL");
        }
        try {
            var task = await client.UpdateRoomAsync(updateRoom);

            return(task);
        } catch (RpcException) {
            throw;
        }
    }
Exemple #3
0
    public async void CreateRoom()
    {
        Debug.Log("nvnOption:" + nvnOption.value);
        var conv_nvnOpt = 1;

        switch (nvnOption.value)
        {
        default:
        case 0:
            conv_nvnOpt = 1;
            break;

        case 1:
            conv_nvnOpt = 3;
            break;
        }
        var create_req = new RoomCreateReq {
            // Password =
            Host = new RmUserInfo {
                Id    = setting.UserInfo.Id,
                Name  = setting.UserInfo.Name,
                Level = setting.UserInfo.Level,
                Rank  = setting.UserInfo.Rank,
            },

            CostLimitMax = Mathf.RoundToInt(TotalCost.HighValue) * 10,
            CostLimitMin = Mathf.RoundToInt(TotalCost.LowValue) * 10,

            CharCardLimitMax = new RmCharCardInfo {
                Cost = Mathf.RoundToInt(CardCost.HighValue)
            },
            CharCardLimitMin = new RmCharCardInfo {
                Cost = Mathf.RoundToInt(CardCost.LowValue),
            },
            CharCardNvn = conv_nvnOpt,
        };
        // Debug.Log(JsonUtility.ToJson(createReq));
        var v = await this.Connecter.CreateRoom(create_req);

        Debug.Log(this.Connecter.CurrentRoom.Key);
        if (this.Connecter.CurrentRoom != null)
        {
            SceneManager.LoadScene("RoomWait", LoadSceneMode.Single);
        }
    }
Exemple #4
0
    public async Task <Room> CreateRoom(RoomCreateReq createReq)
    {
        if (main_ch == null || client == null)
        {
            throw new System.Exception("CONNECT_CLIENT_IS_NULL");
        }
        try {
            var create_task = await client.CreateRoomAsync(createReq);

            Debug.Log(create_task);
            CurrentRoom = create_task;
            IsHost      = true;
            IsWatcher   = false;
            return(create_task);
        } catch (RpcException) {
            throw;
        }
    }
Exemple #5
0
    // Updated Panel related
    void updatePanel_init(Room roomInfo)
    {
        Debug.Log("in update-panel-init");
        this.UP_updateReq     = new RoomCreateReq();
        this.UP_updateReq.Key = this.Connecter.CurrentRoom.Key;
        switch (roomInfo.CharCardNvn)
        {
        case 3:
            this.UP_deckType.value = 1;
            break;

        default:
        case 1:
            this.UP_deckType.value = 0;
            break;
        }
        this.UP_deckType.onValueChanged.AddListener((int v) => {
            switch (v)
            {
            default:
            case 0:
                this.UP_updateReq.CharCardNvn = 1;
                break;

            case 1:
                this.UP_updateReq.CharCardNvn = 3;
                break;
            }
        });

        Debug.Log("CostMin::" + roomInfo.CostLimitMin.ToString());
        Debug.Log("CostMax::" + roomInfo.CostLimitMax.ToString());
        // TotalCardDeckCost Slider
        var totalCardDeckCost = this.UP_totalCardDeckCost.transform.Find("Range Slider").GetComponent <RangeSlider>();

        totalCardDeckCost.LowValue = roomInfo.CostLimitMin / 10;
        if (roomInfo.CharCardLimitMax != null)
        {
            totalCardDeckCost.HighValue = roomInfo.CostLimitMax / 10;
        }

        totalCardDeckCost.OnValueChanged.AddListener((float min, float max) => {
            this.UP_totalCardDeckCost.transform.Find("MaxVal").GetComponent <Text>().text =
                "(Current:" + (Mathf.RoundToInt(max) * 10).ToString() + ")";
            this.UP_totalCardDeckCost.transform.Find("MinVal").GetComponent <Text>().text =
                "(Current:" + (Mathf.RoundToInt(min) * 10).ToString() + ")";

            this.UP_updateReq.CostLimitMax = Mathf.RoundToInt(max) * 10;
            this.UP_updateReq.CostLimitMin = Mathf.RoundToInt(min) * 10;
        });

        Debug.Log("CC-CostMin::" + roomInfo.CharCardLimitMin.Cost.ToString());
        Debug.Log("CC-CostMax::" + roomInfo.CharCardLimitMax.Cost.ToString());
        // CharacterCard Slider
        var CharCardCost = this.UP_CharecterCardLimit.transform.Find("Range Slider").GetComponent <RangeSlider>();

        if (roomInfo.CharCardLimitMin != null)
        {
            CharCardCost.LowValue = roomInfo.CharCardLimitMin.Cost;
        }
        if (roomInfo.CharCardLimitMax != null)
        {
            CharCardCost.HighValue = roomInfo.CharCardLimitMax.Cost;
        }
        CharCardCost.OnValueChanged.AddListener((float min, float max) => {
            this.UP_CharecterCardLimit.transform.Find("MaxVal").GetComponent <Text>().text =
                "(Current:" + (Mathf.RoundToInt(max)).ToString() + ")";
            this.UP_CharecterCardLimit.transform.Find("MinVal").GetComponent <Text>().text =
                "(Current:" + (Mathf.RoundToInt(min)).ToString() + ")";
            this.UP_updateReq.CharCardLimitMax = new RmCharCardInfo {
                Cost = Mathf.RoundToInt(max)
            };
            this.UP_updateReq.CharCardLimitMin = new RmCharCardInfo {
                Cost = Mathf.RoundToInt(min)
            };
        });
        on_requirement_update();
    }
Exemple #6
0
    public async void RefetchRoomList()
    {
        clearRoomList();
        if (createReq == null)
        {
            createReq = new RoomCreateReq();
        }

        rmInSort = await this.Connecter.GetRoomList(createReq);

        foreach (Room rm in rmInSort)
        {
            Debug.Log(rm.Key);
            if (rm.Status != RoomStatus.OnDestroy)
            {
                GameObject rmobj = (GameObject)Instantiate(
                    this.RoomPrefab, this.ScrollcContent.transform);
                rmobj.transform.Find("ID").GetComponent <Text>().text        = "ID:" + rm.Id;
                rmobj.transform.Find("Host/name").GetComponent <Text>().text = "Host:" + rm.Host.Name;
                rmobj.transform.Find("Host/lv").GetComponent <Text>().text   = "Lv:" + rm.Host.Level.ToString();
                if (rm.Dueler != null)
                {
                    rmobj.transform.Find("Dueler/name").GetComponent <Text>().text = "Dueler:" + rm.Dueler.Name;
                    rmobj.transform.Find("Dueler/lv").GetComponent <Text>().text   = "Lv:" + rm.Dueler.ToString();
                }
                else
                {
                    rmobj.transform.Find("Dueler/name").GetComponent <Text>().text = "Dueler:";
                    rmobj.transform.Find("Dueler/lv").GetComponent <Text>().text   = "";
                }
                rmobj.transform.Find("nvn/Text").GetComponent <Text>().text = rm.CharCardNvn + "VS" + rm.CharCardNvn;
                string status_str = "";
                switch (rm.Status)
                {
                case RoomStatus.OnWait:
                    status_str = "Available";
                    break;

                case RoomStatus.OnStart:
                case RoomStatus.OnEnd:
                    status_str = "On Running";
                    break;
                }
                rmobj.transform.Find("status/Value").GetComponent <Text>().text = status_str;
                rmobj.GetComponent <Button>().onClick.AddListener(
                    () => {
                    this.reflect_room = rm;
                    if (rm.Status == RoomStatus.OnWait)
                    {
                        GoToRoom(rm);
                    }
                    else
                    {
                        this.WatchOnlyPanel.SetActive(true);
                    }
                }
                    );
            }
        }
        return;
    }