private void EditRoom() { roomId = GetComponentInParent <RootJoinRoomView>().GetComponentInChildren <ListView>().selectRoomId; RestFulProxy.IsEditRoom(int.Parse (roomId), (result) => { if (result.Equals("0")) { transform.localScale = Vector3.one; ShowHideList(false); Room room = ListData.FindRoomByKey(roomId); if (room != null) { roomName.text = room.name.Trim(); gamePasswordInput.text = ""; roomCreatePasswordInput.text = room.checkCode.Trim(); } SetGrounpName(); SetTitle("编辑战队"); } else { GetComponentInParent <RootJoinRoomView>().errorMessage.ShowMessage("非法操作", SoundType.Error); } }); }
void Start() { if (isEdit) { GetComponent <Button>().onClick.AddListener(() => { if (!isPlay) { MessageBox.Show("信息提示", "确定启动游戏吗?", MessageBoxButtonState.OK, (ok) => { RestFulProxy.SaveState(grounpId, (result) => { result = result.Trim('"'); if (result.Equals("0")) { GetComponentInParent <RootEditGameView>().errorMessage.ShowMessage("游戏已成功启动", SoundType.None, 5.0f); SwitchState(); } else { GetComponentInParent <RootEditGameView>().errorMessage.ShowMessage(result, SoundType.Error, 5.0f); } }); }, true); } else { GetComponentInParent <RootEditGameView>().errorMessage.ShowMessage(grounpName + ",游戏已处于运行状态", SoundType.Error); } }); } // GetComponent<Button>().interactable = isEdit; }
public void AddLifeClick() { string lifeValue = playerCurrentLifeName.text.Trim(); if (string.IsNullOrEmpty(lifeValue)) { GetComponentInParent <RootEditGameView>().errorMessage.ShowMessage("设定的命值不能为空!", SoundType.Error); return; } string bulletCountValue = playerBulletCountInput.text.Trim(); if (string.IsNullOrEmpty(bulletCountValue)) { GetComponentInParent <RootEditGameView>().errorMessage.ShowMessage("设定的弹量不能为空!", SoundType.Error); return; } RestFulProxy.AddLife(lifeValue, bulletCountValue, userId.ToString(), (result) => { }); GetComponentInParent <RootEditGameView>().errorMessage.ShowMessage("操作成功", SoundType.Success); ShowOrHide(false); }
private void SetFence() { string grounpId = root.GetComponentInChildren <ListView>().selectGameId; Grounp grounp = ListData.FindGrounpByKey(root.GetComponentInChildren <ListView>().selectGameId); RestFulProxy.SearchState(grounpId, (result) => { result = result.Trim('"'); if (result.Equals("1")) { PlayerPrefs.SetString("grounpId", grounpId); if (grounp != null) { PlayerPrefs.SetFloat("fenceLon", grounp.fenceLon); PlayerPrefs.SetFloat("fenceLat", grounp.fenceLat); PlayerPrefs.SetInt("fenceRadius", grounp.fenceRadius); } SceneTools.instance.LoadScene("Fence"); } else { root.GetComponent <RootEditGameView>().errorMessage.ShowMessage( grounp.name + "游戏已启动,无法再次进行编辑器电子围栏", SoundType.Error); } }); }
public void RequstData(int currentPlayer) { RestFulProxy.SearchScore(currentPlayer, (result) => { List <Score> list = Utils.CollectionsConvert.ToObject <List <Score> >(result); Create(list); }); }
public void AddLifeValue(Toggle toogle) { string userId = toogle.name; string _url = "http://" + Config.parse("ServerIP") + ":8899/"; if (!string.IsNullOrEmpty(userId)) { RestFulProxy.CheckEnterButton((checkResult) => { checkResult = checkResult.Trim('"'); if (!checkResult.Equals("0")) { string url = _url + "GetPlayerLifeInfoByUser/" + userId; ResourceUtility.Instance.GetHttpText(url, (result) => { Life life = Utils.CollectionsConvert.ToObject <Life>(result); if (life != null) { AddLife.instance.ShowOrHide(true); AddLife.instance.ShowFormData(life); } }); } else { GetComponentInParent <RootBaseRoomView>().errorMessage.ShowMessage("操作错误,游戏已处于运行状态。" , SoundType.Error); } }); } }
public void UpdateButonState() { RestFulProxy.GetLeaderAuthority((result) => { if (result.Equals("0")) { SetButtonState(true); } else { SetButtonState(false); } }); }
public void DeleteRoom(UnityAction <string> action) { DeleteButton.onClick.AddListener(() => { //检查是否有权限 string roomId = GetComponentInParent <RootJoinRoomView>().GetComponentInChildren <ListView>().selectRoomId; RestFulProxy.IsEditRoom(int.Parse(roomId), (result) => { if (result.Equals("0")) { action.Invoke(roomId); } else { GetComponentInParent <RootJoinRoomView>().errorMessage.ShowMessage("非法操作", SoundType.Error); } }); }); }
private IEnumerator CheckEnterState() { while (true) { RestFulProxy.CheckEnterButton((result) => { result = result.Trim('"'); if (result.Equals("0")) { GetComponent <Button>().interactable = true; SoundUtilty.PlayResouceSound("Sound/GameStart"); //SetAddLifeButton(); StopAllCoroutines(); } }); yield return(new WaitForSeconds(4.0f)); } }
/// <summary> /// 玩家准备操作 /// </summary> /// <param name="toggle"></param> public void Ready(Toggle toggle) { MessageBox.Show("信息提示", "确定游戏准备就绪操作吗?", MessageBoxButtonState.OK, (ok) => { RestFulProxy.SetUserState(LoginInfo.Userinfo.id, (result) => { //NGUIDebug.Log(result); result = result.Trim('"'); if (result.Equals("0")) { GetComponentInParent <RootBaseRoomView>().errorMessage.ShowMessage("操作成功!", SoundType.Success); } else if (result.Equals("-2")) { GetComponentInParent <RootBaseRoomView>().errorMessage.ShowMessage("操作错误,该战队不能只有一个玩家。" , SoundType.Error); } else { GetComponentInParent <RootBaseRoomView>().errorMessage.ShowMessage("操作错误,其他玩家尚未准备就绪。", SoundType.Error); } }, null); }, true); }
private void CreateList() { RestFulProxy.GetRoomListByAdmin(LoginInfo.Userinfo.id, (result) => { List <Room> roomList = Utils.CollectionsConvert.ToObject <List <Room> >(result); if (dropList == null || dropList.options == null) { return; } ClearData(); this.roomList = roomList; DropDownDataItem optiondata = new DropDownDataItem(); optiondata.id = -1; optiondata.text = "请选择战队"; dropList.options.Add(optiondata); roomList.ForEach((room) => { optiondata = new DropDownDataItem(); optiondata.id = room.id; optiondata.text = room.name; dropList.options.Add(optiondata); }); dropList.value = -1; }); }