/// <summary> /// 是否可以下注 /// </summary> /// <param name="gold"></param> /// <returns></returns> public bool IsBet(int gold) { if (!BetManager.GetInstance().IsBeginBet) { return(false); } var gameMgr = App.GetGameManager <CschGameManager>(); var self = App.GameData.GetPlayerInfo(); if (gameMgr.BankerMgr.IsBanker(self.Seat)) { YxMessageTip.Show("您是店主,不能跟自己玩哦!"); return(false); } if (self.CoinA < gold) { YxMessageTip.Show("金币不足,请充值或换更小的筹码!"); return(false); } if (gold > CanBet) { YxMessageTip.Show("不能下注,店家金币不足!"); return(false); } return(true); }
public void EndBet() { Facade.Instance <MusicManager>().Play("Zero"); _isCountNum = false; CountNum.gameObject.SetActive(false); InGameLogo.SetActive(true); BetManager.GetInstance().IsBeginBet = false; }
public static BetManager GetInstance() { if (_instance == null) { _instance = new BetManager(); } return(_instance); }
/// <summary> /// 重复上轮 /// </summary> public void OnClickLastTime() { var self = App.GameData.GetPlayerInfo(); if (App.GetGameManager <CschGameManager>().BankerMgr.IsBanker(self.Seat))// || CurNum == LastTimeNum) { return; } if (!BetManager.GetInstance().IsBeginBet) { return; } if (App.GetGameManager <CschGameManager>().BankerMgr.IsBanker(self.Seat)) { YxMessageTip.Show("您是店主,不能跟自己玩哦!"); return; } var golds = UpValue.ToArray(); var gold = 0; var regions = App.GetGameManager <CschGameManager>().Regions; for (int i = 0; i < golds.Length; i++) { if (golds[i] > regions[i].CanBet) { //golds[i] = 0; LastTime.isEnabled = false; YxMessageTip.Show("不能下注,店家金币不足!"); return; } gold += golds[i]; } if (self.CoinA < gold) { YxMessageTip.Show("金币不足,请充值或换更小的筹码!"); return; } IDictionary bet = new Dictionary <string, object>(); bet.Add("golds", golds); CschGameServer.GetInstance().SendRequest(RequestType.Bet, bet); //LastTime.isEnabled = false; }
/// <summary> /// 点击下注区 /// </summary> public void OnClick() { var gold = App.GetGameData <CschGameData>().AnteRate[BetManager.GetInstance().CurBetIndex]; if (!IsBet(gold)) { return; } YxDebug.Log("下注!!"); //AddBet(BetManager.GetInstance().Bets[BetManager.GetInstance().CurBetIndex]);//直接加注 IDictionary bet = new Dictionary <string, object>(); bet.Add("p", (int)CurBetType); bet.Add("gold", gold); CschGameServer.GetInstance().SendRequest(RequestType.Bet, bet); }
/// <summary> /// 检测是否可以下注 /// </summary> public void CheckBeginBet(ISFSObject gi) { long st = gi.GetLong("st"); long ct = gi.GetLong("ct"); BetManager.GetInstance().IsBeginBet = false; if (st != 0) { if (ct - st < 14) { //BetManager.GetInstance().IsBeginBet = true;. } CountNum.gameObject.SetActive(false); InGameLogo.gameObject.SetActive(true); //todo 画筹码 } }
public override void OnGetGameInfo(ISFSObject gameInfo) { YxDebug.Log(">>>>> 加入房间成功 <<<<< OnGetGameInfo"); Screen.sleepTimeout = SleepTimeout.NeverSleep; CheckBeginBet(gameInfo); BetManager.GetInstance().CheckBets(); CdTime = gameInfo.ContainsKey("cd") ? gameInfo.GetInt("cd") : 10; if (BankerMgr.IsBanker(-1)) { BankerMgr.SetBankerInfo(null); } BankerMgr.RefreshBankerList(gameInfo.GetSFSArray("bankers"), gameInfo.GetInt("banker")); BankerMgr.RefreshPlayerList(gameInfo.GetSFSArray("users")); // UserManager.GetInstance().RefreshUserInfo(gameInfo.GetSFSObject("user")); RightBottomMgr.BankerLimit = gameInfo.GetInt("bankLimit"); RightBottomMgr.RefreshLastTimeBtn(); //历史记录面板初始化 HistoryRecord.GetInstance().InitHistory(gameInfo.GetIntArray("history"), gameInfo.GetInt("hisIdx"), gameInfo.GetIntArray("winTimes")); }
/// <summary> /// 添加筹码 /// </summary> /// <param name="bet">筹码</param> /// <param name="seat">下注人的座位号 </param> public void AddBet(GameObject bet, int seat, int gold, bool isSelf = false) { _curBetCount++; var gob = Instantiate(bet); var betManager = BetManager.GetInstance(); gob.transform.parent = betManager.transform; if (isSelf) { gob.transform.localPosition = bet.transform.localPosition; } else { gob.transform.localPosition = betManager.AllPlayerPos.localPosition; } gob.transform.parent = BetPos.transform; //gob.transform.localPosition = Vector3.zero; gob.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f); //gob.GetComponent<UISprite>().depth = _curBetCount + MinDepth; gob.transform.FindChild("Title").gameObject.SetActive(true); gob.transform.FindChild("Selected").gameObject.SetActive(false); gob.GetComponent <BoxCollider>().enabled = false; var w = Random.Range(-BetW, BetW); var h = Random.Range(-BetH, BetH); var v3 = new Vector3(w, h, 0); var target = Vector3.zero + v3; //gob.transform.transform.localPosition += v3; _bets.Add(gob); TotalGold += gold; if (seat == App.GameData.SelfSeat) { SelfGold += gold; } TotalLabel.text = TotalGold > 0 ? YxUtiles.GetShowNumberForm(TotalGold) : ""; SelfLabel.text = SelfGold > 0 ? YxUtiles.GetShowNumberForm(SelfGold) : ""; SetChipTween(gob.transform, target, betManager.TweenInfo); }
/// <summary> /// 下注 /// </summary> /// <param name="gold"></param> /// <param name="p"></param> /// <param name="seat"></param> public void AddBet(int gold, int p, int seat, bool isLastTime = false) { if (gold <= 0 || p >= Regions.Length) { return; } var bet = BetManager.GetInstance().GetBet(-1, gold); var self = App.GameData.GetPlayerInfo(); if (seat == self.Seat) { var gdata = App.GetGameData <CschGameData>(); CanQuit = false; gdata.GetPlayer().Coin -= gold; RegionsDic[(BetType)p].AddBet(bet, seat, gold, true); //UserManager.GetInstance().RefreshUserInfo(); //App.GameData.GetPlayer().UpdateView(); } else { RegionsDic[(BetType)p].AddBet(bet, seat, gold); } Facade.Instance <MusicManager>().Play("Bet"); GetUpBetValue(seat, isLastTime, p, gold); //重复上轮相关 --将函数封装起来了... /*if (seat == self.Seat && !isLastTime) * { * //重复上轮的数据更新 * if (RightBottomMgr.UpValue.Count == 0) * { * RightBottomMgr.LastTimeNum = RightBottomMgr.CurNum; * RightBottomMgr.UpValue = new List<int>(); * for (var i = 0; i < Regions.Length; i++) * { * RightBottomMgr.UpValue.Add(0); * } * } * //刷新重复上轮数据 * if (RightBottomMgr.LastTimeNum != RightBottomMgr.CurNum) * { * RightBottomMgr.LastTimeNum = RightBottomMgr.CurNum; * for (int i = 0; i < Regions.Length; i++) * { * RightBottomMgr.UpValue[i] = 0; * } * } * * RightBottomMgr.UpValue[p] += gold; * * }*/ var bestUp = 0; var bestIUp = 0; var bestDown = 0; var bestIDown = 0; for (var i = 0; i < RegionsDic.Count - 2; i++) { if (i < 4) { if (bestUp <= RegionsDic[(BetType)i].TotalGold * RegionsDic[(BetType)i].Rate) { bestUp = RegionsDic[(BetType)i].TotalGold * RegionsDic[(BetType)i].Rate; bestIUp = i; } } else { if (bestDown <= RegionsDic[(BetType)i].TotalGold * RegionsDic[(BetType)i].Rate) { bestDown = RegionsDic[(BetType)i].TotalGold * RegionsDic[(BetType)i].Rate; bestIDown = i; } } } for (var i = 0; i < RegionsDic.Count; i++) { var best = i < 4 ? bestUp : bestDown; var bestI = i < 4 ? bestIUp : bestIDown; var all = 0; all += (int)BankerMgr.Banker.Coin; var can = 0; if (i > 7) { for (var j = 0; j < RegionsDic.Count; j++) { if (i == j || i == bestI) { continue; } all += RegionsDic[(BetType)j].TotalGold; } var len = i == 7 ? 4 : 8; var betV = RegionsDic[(BetType)i].TotalGold * RegionsDic[(BetType)i].Rate + best; can = (int)((all - betV) / RegionsDic[(BetType)i].Rate); } else { for (var j = 0; j < RegionsDic.Count; j++) { if (i == j || (i < 4 && j == 8) || (i > 4 && j == 9)) { continue; } all += RegionsDic[(BetType)j].TotalGold; } var doubleIndex = i < 4 ? 8 : 9; var betV = RegionsDic[(BetType)i].TotalGold * RegionsDic[(BetType)i].Rate + RegionsDic[(BetType)doubleIndex].TotalGold * RegionsDic[(BetType)doubleIndex].Rate; can = (int)((all - betV) / RegionsDic[(BetType)i].Rate); } RegionsDic[(BetType)i].CanBet = can <= 0 ? 0 : can; RegionsDic[(BetType)i].SetCanBetLabel(RegionsDic[(BetType)i].CanBet); } }
public override void GameResponseStatus(int type, ISFSObject response) { YxDebug.Log("Request == " + (RequestType)type); if (response.ContainsKey("playerlist")) { BankerMgr.RefreshPlayerList(response.GetUtfStringArray("playerlist")); } switch ((RequestType)type) { case RequestType.Bet: if (response.ContainsKey("golds")) // -- 统一走else逻辑 { YxDebug.Log("收到重复上轮"); var golds = response.GetIntArray("golds"); var seat = response.GetInt("seat"); if (seat == App.GameData.SelfSeat) { RightBottomMgr.LastTime.isEnabled = true; } for (int i = 0; i < golds.Length; i++) { AddBet(golds[i], i, seat, true); } } else { int p = response.GetInt("p"); int gold = response.GetInt("gold"); int seat = response.GetInt("seat"); AddBet(gold, p, seat); } break; case RequestType.Reward: break; case RequestType.ApplyBanker: break; case RequestType.ApplyQuit: break; case RequestType.BeginBet: CanQuit = true; Loading.SetActive(false); RightBottomMgr.CurNum++; ResultManager.GetInstance().CloseResult(); ClearAllBet(); BetManager.GetInstance().IsBeginBet = true; StartCountNum(); Wheel.GetInstance().Selected.GetComponent <TweenAlpha>().enabled = false; Wheel.GetInstance().Selected.GetComponent <TweenAlpha>().value = Wheel.GetInstance().Selected.GetComponent <TweenAlpha>().from; break; case RequestType.EndBet: Loading.SetActive(false); BetManager.GetInstance().IsBeginBet = false; //开始摇奖 Wheel.GetInstance().StartTrun(); RefreshRepeatData(RightBottomMgr.UpBetValue.ToArray()); break; case RequestType.GiveCards: int carIndex = response.GetInt("carInx"); //针对超过20的服务器反馈进行处理 if (carIndex >= 20 && Wheel.GetInstance().Items.Length <= 20) //=>条件2考虑兼容问题 { carIndex = carIndex % 8; } LuckIndex = carIndex; Wheel.GetInstance().StopTrun(carIndex, OnDrawFinish); break; case RequestType.Result: CanQuit = true; Loading.SetActive(false); RightBottomMgr.RefreshLastTimeBtn(); if (!BankerMgr.IsBanker(-1)) { BankerMgr.Banker.WinTotalCoin += response.GetInt("bankWin"); var bankerCoin = "¥" + YxUtiles.ReduceNumber(BankerMgr.Banker.WinTotalCoin); BankerMgr.Banker.WinTotalCoinLabel.Text(bankerCoin); } var self = App.GameData.GetPlayer(); self.Coin = response.GetLong("total"); self.WinTotalCoin += response.GetInt("win"); YxDebug.Log("---------结算-----------"); ResultManager.GetInstance().OpenResult(response); HistoryRecord.GetInstance().RefreshData(response.GetInt("carInx"), 1); //YxDebug.Log("result"); break; case RequestType.BankerList: //UserManager.GetInstance().BankerSeat = response.GetInt("banker"); if (response.GetInt("banker") == -1) { BankerMgr.SetBankerInfo(null); } BankerMgr.RefreshBankerList(response.GetSFSArray("bankers"), response.GetInt("banker")); break; default: YxDebug.Log("不存在的服务器交互!"); break; } }
void Awake() { _instance = this; }