public void sync() { List <int> folds = RoomMgr.GetInstance().seats [seatindex].folds; ResetInfo(); for (int i = 0; i < folds.Count; i++) { int id = folds [i] % 100; bool ting = folds [i] > 100; GameObject ob = ResourcesMgr.GetInstance().LoadMJ(id); HandCardItem item = new HandCardItem(id, ob); int row = getRow(i); int col = getCol(i); ob.layer = LayerMask.NameToLayer("ZhuoPai"); ob.transform.SetParent(this.transform); ob.transform.localRotation = Quaternion.Euler(new Vector3(-90, 0, 0)); ob.transform.localPosition = new Vector3(offSetX * col, 0, offSetZ * row + 0.0098f); //ob.transform.Translate(offSetX * col, 0, offSetZ * row); if (ting) { item.setTing(true); } _RecyleHandCardList.Add(item); } }
void InitSingleSeat(PlayerInfo player, SeatInfo seat) { RoomMgr rm = RoomMgr.GetInstance(); int si = player.seatindex; int local = rm.getLocalIndex(si); GameObject gs = gseats[local]; bool isIdle = rm.isIdle(); Seat s = seats[local].GetComponent <Seat>(); if (player.userid <= 0) { s.reset(); s.gameObject.SetActive(false); gs.SetActive(false); return; } s.gameObject.SetActive(true); s.setInfo(player.userid, player.name, player.score); s.setOffline(!player.online); s.setButton(rm.state.button == si); s.setReady(rm.state.state == "" ? player.ready : false); s.setTing(seat.tingpai); s.setHu(seat.hued); gs.SetActive(!isIdle); }
void showFlowers() { RoomMgr rm = RoomMgr.GetInstance(); List <int> flowers = rm.seats[seatindex].flowers; int cnt = flowers.Count; int childs = _flowerPlace.childCount; for (int i = 0; i < childs; i++) { Transform tm = _flowerPlace.GetChild(i); tm.localPosition = new Vector3(offSetX * (cnt - i), 0, 0); } for (int i = childs; i < cnt; i++) { int id = flowers[i]; GameObject obj = ResourcesMgr.GetInstance().LoadMJ(id); obj.layer = LayerMask.NameToLayer("ZhuoPai"); obj.gameObject.tag = tagValue; Transform tm = obj.transform; tm.SetParent(_flowerPlace); tm.localRotation = Quaternion.Euler(-90, 0, 0); tm.localPosition = new Vector3(offSetX * (cnt - i), 0, 0); tm.localScale = new Vector3(0.1f, 0.1f, 0.1f); } }
void InitView() { RoomMgr rm = RoomMgr.GetInstance(); // 1. set border Transform bd = transform.Find("border"); bd.GetComponent <UIWidget> ().SetAnchor(GameObject.Find("UI Root")); // 2. set seat index mSeatIndex = rm.seatindex; Debug.LogWarning("我的座位是:" + mSeatIndex); // 3. set player info // 4. set button event handler UIButton btnReady = prepare.Find("actions/btnReady").GetComponent <UIButton> (); btnReady.onClick.Add(new EventDelegate(this, "onBtnReadyClicked")); UIButton btnInvite = prepare.Find("actions/btnInvite").GetComponent <UIButton> (); btnInvite.onClick.Add(new EventDelegate(this, "onBtnInviteClicked")); //AudioManager.Instance.PlayEffectAudio("ui_click"); roomid.text = rm.info.roomid; //gamenum.text = "第" + rm.info.numofgames + "局(" + rm.conf.maxGames + ")"; gamenum.text = "[D82828]" + rm.info.numofgames + "[FFFFFF]/" + rm.conf.maxGames + "局"; demojis = GameObject.Find("demojis").transform; }
public void prev(int step = 1) { int id = current / 3; if (id >= step) { id -= step; } else { id = 0; } NetMgr net = NetMgr.GetInstance(); PomeloClient pc = net.pc; pc.flush(); RoomMgr rm = RoomMgr.GetInstance(); rm.prepareReplay(mRoom, mBaseInfo); mCount = mBaseInfo.mahjongs.Count; gotoAction(id); }
void playVoice() { VoiceMgr vmr = VoiceMgr.GetInstance(); RoomMgr rm = RoomMgr.GetInstance(); if (_playingSeat < 0 && mVoiceQueue.Count > 0) { ChatItem vm = mVoiceQueue.Dequeue(); string msg = vm.voice.msg; string file = vm.path; int si = rm.getSeatIndexByID(vm.sender); int local = rm.getLocalIndex(si); _playingSeat = local; vmr.writeVoice(file, msg); vmr.play(file); if (playing != null) { playing.SetActive(false); playing = null; } playing = vm.vobj; if (playing != null) { playing.SetActive(true); } _lastPlayTime = PUtils.getMilliSeconds() + vm.voice.time; } }
public void onBtnExit() { Debug.Log("onBtnExit"); RoomMgr rm = RoomMgr.GetInstance(); NetMgr nm = NetMgr.GetInstance(); bool isIdle = rm.isIdle(); bool isOwner = rm.isOwner(); if (isIdle) { if (isOwner) { /* * cc.vv.alert.show('牌局还未开始,房主解散房间,房卡退还', function() { * net.send("dispress"); * }, true); */ nm.send("dispress"); } else { nm.send("exit"); } } else { nm.send("dissolve_request"); } hideMenu(); }
void Start() { #if false RoomMgr rm = RoomMgr.GetInstance(); rm.overinfo = new GameOverInfo(); rm.overinfo.info = new GameEndFlags(); GameMaima maima = new GameMaima(); rm.overinfo.info.maima = maima; maima.mas = new List <int> () { 11, 23, 45, 36 }; maima.scores = new List <int> () { 1, 3, 5, 6 }; maima.seatindex = 1; maima.selected = 2; showResult(null); #endif }
public void updatePrompt(int pai) { var arr = RoomMgr.getChiArr(pai); var rm = RoomMgr.GetInstance(); var seat = rm.getSelfSeat(); if (!seat.tingpai) { hidePrompt(); return; } bool found = false; foreach (HuPai hu in seat.hus) { if (hu.pai >= arr [0] && hu.pai <= arr [2]) { found = true; break; } } if (found) { rm.updateHus(); showPrompt(seat.hus); } }
IEnumerator _exit(float delay) { while (syncQueue.Count > 0) { yield return(new WaitForEndOfFrame()); } ReplayMgr rm = ReplayMgr.GetInstance(); GameMgr gm = GameMgr.GetInstance(); RoomMgr room = RoomMgr.GetInstance(); ResourcesMgr.GetInstance().release(); rm.clear(); gm.Reset(); room.reset(); if (delay > 0) { PUtils.setTimeout(() => { LoadingScene.LoadNewScene("02.lobby"); }, delay); } else { LoadingScene.LoadNewScene("02.lobby"); } }
public void ShowAction() { RoomMgr rm = RoomMgr.GetInstance(); GameAction action = rm.action; _options = action; showAction(action); }
void OnEnable() { RoomMgr rm = RoomMgr.GetInstance(); GameOverInfo info = rm.overinfo; List <GameEndInfo> endinfo = info.endinfo; int maxScore = -1; foreach (PlayerInfo p in rm.players) { if (p.score > maxScore) { maxScore = p.score; } } Transform seats = transform.Find("seats"); UIGrid grid = seats.GetComponent <UIGrid>(); int index = 0; for (int i = 0; i < rm.players.Count; i++, index++) { PlayerInfo p = rm.players[i]; Transform seat = seats.GetChild(i); GameEndInfo ei = endinfo[i]; bool bigwin = p.score > 0 && p.score == maxScore; seat.gameObject.SetActive(true); seat.Find("bghead/icon").GetComponent <IconLoader> ().setUserID(p.userid); seat.Find("name").GetComponent <UILabel>().text = p.name; seat.Find("id").GetComponent <UILabel>().text = "ID:" + p.userid; seat.Find("score").GetComponent <UILabel>().text = "" + p.score; seat.Find("winner").gameObject.SetActive(bigwin); seat.Find("owner").gameObject.SetActive(false); Transform stats = seat.Find("stats"); string[] statNames = new string[] { "自摸次数", "接炮次数", "点炮次数" /* , "暗杠次数", "明杠次数" */ }; for (int j = 0; j < statNames.Length; j++) { stats.GetChild(j).GetComponent <UILabel>().text = statNames[j]; } Transform vals = seat.Find("values"); int[] statVals = new int[] { ei.numzimo, ei.numjiepao, ei.numdianpao /*, ei.numangang, ei.numminggang */ }; for (int j = 0; j < statVals.Length; j++) { vals.GetChild(j).GetComponent <UILabel>().text = "" + statVals[j]; } } for (int i = index; i < seats.childCount; i++) { seats.GetChild(i).gameObject.SetActive(false); } grid.Reposition(); }
void showResults(List <GameOverPlayerInfo> results) { Transform seats = transform.Find("seats"); int index = 0; for (int i = 0; i < results.Count; i++, index++) { Transform s = seats.GetChild(i); s.gameObject.SetActive(true); initSeat(s, results[i]); } for (int i = index; i < seats.childCount; i++) { Transform s = seats.GetChild(i); s.gameObject.SetActive(false); } List <int> huSeats = new List <int> (); for (int i = 0; i < results.Count; i++) { HuInfo _hu = results[i].hu; if (_hu != null && _hu.hued) { huSeats.Add(i); } } /* * int id = 0; * if (huSeats.Count == 0) { * id = 2; * } else if (huSeats.FindIndex (x=> x == RoomMgr.GetInstance ().seatindex) >= 0) { * id = 0; * } else { * id = 1; * } * * SpriteMgr title = transform.Find ("title").GetComponent<SpriteMgr> (); * title.setIndex (id); */ int si = RoomMgr.GetInstance().seatindex; bool win = huSeats.Contains(si); GameObject winOb = transform.Find("win").gameObject; GameObject loseOb = transform.Find("lose").gameObject; winOb.SetActive(win); loseOb.SetActive(!win); if (btn_next == null) { string audio = win ? "win" : "loss"; AudioManager.GetInstance().PlayEffectAudio(audio); } }
void chat(int sender, string content) { RoomMgr rm = RoomMgr.GetInstance(); int local = rm.getLocalIndexByID(sender); Seat s = seats [local].GetComponent <Seat>(); s.chat(content); }
void emoji(int sender, int id) { RoomMgr rm = RoomMgr.GetInstance(); int local = rm.getLocalIndexByID(sender); Seat s = seats [local].GetComponent <Seat>(); s.emoji(id); }
void voice(VoiceMsgPush vmp) { RoomMgr rm = RoomMgr.GetInstance(); int local = rm.getLocalIndexByID(vmp.sender); Seat s = seats [local].GetComponent <Seat>(); s.voice((float)vmp.content.time / 1000); }
void InitEventHandlers() { RoomMgr rm = RoomMgr.GetInstance(); GameMgr gm = GameMgr.GetInstance(); /* * gm.AddHandler ("game_action", data => { * GameAction action = rm.action; * _options = action; * * showAction(action); * }); */ gm.AddHandler("guo_result", data => { hideOptions(); }); gm.AddHandler("game_begin", data => { hidePrompt(); showQiaoHelp(false); _options = null; shot = false; }); gm.AddHandler("game_playing", data => { checkChuPai(rm.isMyTurn()); }); gm.AddHandler("game_sync", data => { showPrompt(); shot = false; }); gm.AddHandler("game_chupai_notify", data => { ActionInfo info = (ActionInfo)data; if (info.seatindex == rm.seatindex) { Highlight(info.pai, false); checkChuPai(false); } }); gm.AddHandler("game_turn_change", data => { if (rm.isMyTurn()) { checkChuPai(true); } shot = false; }); gm.AddHandler("hupai", data => { lockHandCards(); }); }
void Start() { RoomMgr rm = RoomMgr.GetInstance(); if (rm.dissolve != null) { showDissolveNotice(rm.dissolve); rm.dissolve = null; } }
public void showAction(int si, string act, int card = 0) { RoomMgr rm = RoomMgr.GetInstance(); int local = rm.getLocalIndex(si); GameSeat gs = gseats[local].GetComponent <GameSeat>(); Debug.Log("showAction si=" + si + " act=" + act); gs.showAction(act, card); }
public void updateFlowers(int si) { RoomMgr rm = RoomMgr.GetInstance(); int cnt = rm.seats[si].flowers.Count; int local = rm.getLocalIndex(si); GameObject gs = gseats[local]; gs.SetActive(true); gs.transform.Find("flower/num").GetComponent <UILabel>().text = "" + cnt; }
void updateBtns() { RoomMgr rm = RoomMgr.GetInstance(); int cnt = rm.histories.Count; btn_next.SetActive(index < cnt - 1); btn_prev.SetActive(index > 0); progress.text = (index + 1) + " / " + rm.conf.maxGames; }
void onBtnInviteClicked() { RoomMgr rm = RoomMgr.GetInstance(); string title = "<雀达麻友圈> - 房间分享"; string content = "房号:" + rm.info.roomid + " 玩法:" + rm.getWanfa(); Dictionary <string, object> args = new Dictionary <string, object>(); args.Add("room", rm.info.roomid); AnysdkMgr.GetInstance().share(title, content, args); }
public void onBtnHistories() { GameObject ob = transform.Find("histories").gameObject; RoomMgr rm = RoomMgr.GetInstance(); int cnt = rm.histories.Count; if (cnt > 0) { ob.SetActive(true); } }
public void showWait() { RoomMgr rm = RoomMgr.GetInstance(); NetMgr nm = NetMgr.GetInstance(); GameMaima maima = rm.state.maima; bool act = maima.seatindex == rm.seatindex; Transform mas = tmaima.Find("mas"); UIGrid grid = mas.GetComponent <UIGrid>(); tmaima.gameObject.SetActive(true); title.text = act ? "请选择飞苍蝇" : "请等待飞苍蝇"; score.text = ""; int count = maima.mas.Count; int i = 0; for (i = 0; i < mas.childCount && i < count; i++) { Transform board = mas.GetChild(i); Transform tile = board.Find("tile"); FrameAnim anim = board.GetComponent <FrameAnim>(); board.gameObject.SetActive(true); tile.gameObject.SetActive(false); anim.reset(); GameObject _fire = board.Find("fire").gameObject; _fire.SetActive(false); int j = i; PUtils.onClick(board, () => { if (!act) { return; } nm.send("maima", "index", j); }); } for (int j = i; j < mas.childCount; j++) { Transform board = mas.GetChild(j); board.gameObject.SetActive(false); } grid.Reposition(); }
public void onBtnMenu() { mMenu.SetActive(true); RoomMgr rm = RoomMgr.GetInstance(); bool isIdle = rm.isIdle(); bool isOwner = rm.isOwner(); UILabel lbl = mMenu.transform.Find("lblExit").GetComponent <UILabel>(); lbl.text = (isIdle && !isOwner) ? "离开房间" : "解散房间"; }
void logout() { ReplayMgr rm = ReplayMgr.GetInstance(); GameMgr gm = GameMgr.GetInstance(); RoomMgr room = RoomMgr.GetInstance(); ResourcesMgr.GetInstance().release(); rm.clear(); gm.Reset(); room.reset(); LoadingScene.LoadNewScene("01.login"); }
void Start() { RoomMgr rm = RoomMgr.GetInstance(); Transform Seats = transform.Find("Seats"); for (int i = 0; i < Seats.childCount; i++) { Transform s = Seats.GetChild(i); seats.Add(s.gameObject); Transform icon = s.Find("bghead"); int j = rm.getSeatIndexByLocal(i); PUtils.onClick(icon, () => { PlayerInfo p = RoomMgr.GetInstance().players[j]; GetComponent <UserPanel>().show(p.userid); }); } Transform gs = transform.Find("Game/seats"); for (int i = 0; i < gs.childCount; i++) { gseats.Add(gs.GetChild(i).gameObject); } InitSeats(); InitEventHandlers(); bool replay = ReplayMgr.GetInstance().isReplay(); GameObject entries = transform.Find("Entries").gameObject; entries.SetActive(!replay); prepare.gameObject.SetActive(!replay); if (replay) { return; } NetMgr nm = NetMgr.GetInstance(); bool isIdle = 0 == rm.info.numofgames; if (!isIdle) { nm.send("ready"); } }
public void showChupai(int si, int card) { RoomMgr rm = RoomMgr.GetInstance(); int local = rm.getLocalIndex(si); if (local == 0) { return; } GameSeat gs = gseats[local].GetComponent <GameSeat>(); gs.showChupai(card); }
void onGameSync() { ResourcesMgr.GetInstance().StopAllHands(); DHM_CardManager[] cms = PlayerManager.GetInstance().getCardManagers(); foreach (DHM_CardManager cm in cms) { cm.sync(); } RoomMgr rm = RoomMgr.GetInstance(); InteractMgr.GetInstance().checkChuPai(rm.isMyTurn()); }
void Awake() { if (focus == null) { focus = GameObject.Find("focus"); } int numofseats = RoomMgr.GetInstance().numOfSeats(); if (2 == numofseats) { transform.Translate(0 - offSetX * 3, 0, 0); } }