void showHistories() { List <RoomHistory> rooms = mHistory.rooms; onButtonSel(mHistory.statd); for (int i = 0; i < rooms.Count; i++) { Transform item = getItem(i); RoomHistory room = rooms[i]; RoomHistoryInfo info = room.info; item.Find("roomid").GetComponent <UILabel>().text = "房间号:" + room.room_tag; item.Find("club").GetComponent <UILabel>().text = room.club_id == 1 ? room.club_name : "俱乐部:" + room.club_name; item.Find("desc").GetComponent <UILabel>().text = info.huafen + "/" + info.huafen + (info.maima ? "带苍蝇" : "不带苍蝇") + info.maxGames + "局"; item.Find("btn/score").GetComponent <UILabel>().text = "" + room.score; item.Find("date").GetComponent <UILabel>().text = PUtils.formatTime(room.create_time, "MM-dd"); item.Find("time").GetComponent <UILabel>().text = PUtils.formatTime(room.create_time, "HH:mm"); PUtils.onClick(item.Find("btn"), () => { enterDetail(room); }); PUtils.onClick(item, () => { enterDetail(room); }); } shrinkContent(rooms.Count); mGrid.GetComponent <UIGrid> ().Reposition(); mGrid.GetComponentInParent <UIScrollView> ().ResetPosition(); }
private void AddToHistory(RoomHistory history) { var runningTotal = furnituresRunningTotal.ContainsKey(history.RoomId) ? furnituresRunningTotal[history.RoomId] : null; if (runningTotal != null) { foreach (var furniture in history.Furnitures) { var furnitureRunningTotal = runningTotal.FirstOrDefault(x => x.Furniture == furniture.Furniture); if (furnitureRunningTotal != null) { furnitureRunningTotal.Count += furniture.Count; } else { runningTotal.Add(furniture); } } history.Furnitures = runningTotal.ToList(); } else { furnituresRunningTotal[history.RoomId] = history.Furnitures; } history.Furnitures = history.Furnitures.Select(x => new FurnitureCount { Furniture = x.Furniture, RoomId = x.RoomId, Count = x.Count }).ToList(); roomHistories.Add(history); }
public override RoomParameters GetNextParameters(RoomHistory history, System.Random random) { if (!_currentRoom.MoveNext()) { _currentRoom = DemoRoomProgression.GetEnumerator(); _currentRoom.MoveNext(); } var output = new RoomParameters(); output.GroundEnemies = GroundEnemies; output.AirEnemies = AirEnemies; output.Class = RoomClass.Platforming; output.Layout = _currentRoom.Current; output.Theme = typeof(RoomTheme).GetEnumValues() //Absolutely disgusting, but it's for testing so it's ok .Cast <RoomTheme>() .Where(i => i != RoomTheme.Edit) .OrderBy(i => random.Next()) .First(); //output.Effect = RoomEffects.Timer; output.FlipHorizontal = random.Next(2) == 0; output.WeaponEnumerator = WeaponTemplates.OrderBy(i => random.Next()).GetEnumerator(); output.Entrance = output.Layout.GetRandomEntrance(random); do { output.Exit = output.Layout.GetRandomExit(random, EntranceExitSides.None); } while (output.Entrance == output.Exit && output.Layout.EntranceSides != output.Layout.ExitSides); return(output); }
public void enter(RoomHistory room) { mRoom = room; shrinkContent(0); show(() => { refresh(); }); }
public override RoomParameters GetNextParameters(RoomHistory history, Random random) { var original = OriginalBuilder.GetNextParameters(history, random); original.Layout = Room; Room = null; return(original); }
public void Setup(RoomHistory room, GameBaseInfo baseInfo, List <int> records) { actionRecords = records; mRoom = room; mBaseInfo = baseInfo; current = 0; lastAction = null; mCount = baseInfo.mahjongs.Count; foreach (GameSeatInfo seat in baseInfo.game_seats) { mCount -= seat.holds.Count + seat.flowers.Count; } }
private static RoomHistoryClientData Map(RoomHistory data, bool isShort) { var result = new RoomHistoryClientData { Date = Map(data.Date) }; if (!isShort) { result.Name = data.Name; result.Description = Map(data.Furnitures); result.ActionType = data.ActionType; } return(result); }
void showHistories() { for (int i = 0; i < mHistory.Count; i++) { Transform item = getItem(i); RoomHistory room = mHistory[i]; RoomHistoryInfo info = room.info; setText(item, "desc", info.huafen + "/" + info.huafen + (info.maima ? "带苍蝇" : "不带苍蝇") + info.maxGames + "局"); setText(item, "time", PUtils.formatTime(room.create_time, "yyyy/MM/dd HH:mm:ss")); setText(item, "roomid", "房间号: " + room.room_id); setText(item, "gamenum", "局数: " + info.game_num); setBtnEvent(item, "btn_detail", () => { enterDetail(room); }); Transform seats = item.Find("seats"); UITable table = seats.GetComponent <UITable>(); int index = 0; for (int j = 0; j < seats.childCount && j < info.seats.Count; j++, index++) { Transform seat = seats.GetChild(j); seat.gameObject.SetActive(true); setText(seat, "name", info.seats [j].name); setText(seat, "score", "" + info.seats [j].score); setIcon(seat, "bghead/icon", info.seats [j].uid); } for (int j = index; j < seats.childCount; j++) { Transform seat = seats.GetChild(j); seat.gameObject.SetActive(false); } table.Reposition(); } updateItems(mHistory.Count); }
protected override async void Run(Session session, C2G_CreateRoom message, Action <G2C_CreateRoom> reply) { G2C_CreateRoom response = new G2C_CreateRoom(); try { //验证合法性 if (!GateHelper.SignSession(session)) { response.Error = ErrorCode.ERR_SignError; reply(response); return; } DBProxyComponent dbProxy = Game.Scene.GetComponent <DBProxyComponent>(); User user = session.GetUser(); UserInfo userInfo = await dbProxy.Query <UserInfo>(user.UserID, false); if (userInfo.Money < message.Room.GameScore) { response.Error = ErrorCode.ERR_UserMoneyLessError; reply(response); return; } //创建房间 Room room = await RoomFactory.Create(message.Room.PlayerCount, message.Room.GameCount, message.Room.GameScore, session); //创建房间玩家对象 Gamer gamer = GamerFactory.Create(user.Id, user.UserID, room.RoomId, (ushort)room.Count); await gamer.AddComponent <MailBoxComponent>().AddLocation(); gamer.AddComponent <UnitGateComponent, long>(session.Id); //房间添加玩家 room.Add(gamer); //网关服务器和玩家对应 user.ActorID = gamer.Id; //返回房间信息给玩家 response.RoomId = room.RoomId; response.Room = message.Room; response.ChairID = (ushort)(room.Count - 1); Log.Info($"创建房间成功:--- {userInfo.NickName} ,房号:{room.RoomId}"); //返回给客户端 reply(response); //存储该用户房间的创建次数 RoomHistory roomInfo = await dbProxy.Query <RoomHistory>(user.UserID, false); if (roomInfo == null) { RoomHistory roomHistory = ComponentFactory.CreateWithId <RoomHistory>(userInfo.Id); roomHistory.CreateCount = 1; roomHistory.NickName = userInfo.NickName; await dbProxy.Save(roomHistory, false); } else { roomInfo.CreateCount += 1; await dbProxy.Save(roomInfo, false); } //连接游戏服务器 //StartConfigComponent config = Game.Scene.GetComponent<StartConfigComponent>(); //IPEndPoint GameIPEndPoint= config.GameConfig.GetComponent<InnerConfig>().IPEndPoint; //Session GameSession = Game.Scene.GetComponent<NetInnerComponent>().Get(GameIPEndPoint); //GS2G_EnterRoom gs2g_EnterRoom =await GameSession.Call(new G2GS_EnterRoom() //{ // PlayerId = user.Id, // UserID = user.UserID, // GateSessionId = session.Id //}) as GS2G_EnterRoom; } catch (Exception e) { ReplyError(response, e, reply); } }
void enterDetail(RoomHistory room) { GameObject ob = GameObject.Find("PDetailHistory"); ob.GetComponent <DetailHistory> ().enter(room); }
public override RoomParameters GetNextParameters(RoomHistory history, System.Random random) { return(GetInitialParameters(random)); }
public void prepareReplay(RoomHistory room, GameBaseInfo baseInfo) { reset(); info.roomid = room.room_tag; info.numofseats = room.info.seats.Count; info.numofgames = baseInfo.index + 1; int nSeats = room.info.seats.Count; state.state = "playing"; for (int i = 0; i < nSeats; i++) { PlayerInfo p = new PlayerInfo(); p.reset(); HistorySeats hs = room.info.seats[i]; p.name = hs.name; p.score = hs.score; p.userid = hs.uid; p.seatindex = i; p.online = true; p.ip = "127.0.0.1"; p.ready = true; players.Add(p); SeatInfo s = new SeatInfo(); s.reset(); s.holds = new List <int>(baseInfo.game_seats[i].holds); s.flowers = new List <int>(baseInfo.game_seats[i].flowers); seats.Add(s); if (p.userid == GameMgr.GetInstance().userMgr.userid) { seatindex = i; } } if (seatindex < 0) { seatindex = 0; } conf = baseInfo.conf; int button = baseInfo.button; state.button = button; state.turn = button; int count = baseInfo.mahjongs.Count; foreach (GameSeatInfo seat in baseInfo.game_seats) { count -= seat.holds.Count + seat.flowers.Count; } state.numofmj = count; }
/// <summary> /// Gets the next room parameters to use when generating a room /// </summary> /// <param name="history"></param> /// <param name="random"></param> /// <returns></returns> public abstract RoomParameters GetNextParameters(RoomHistory history, SysRandom random);
public HttpResponseMessage PostNotification(NotifyRequest request) { HttpResponseMessage responseMessage; var commandHandler = new CommandHandler(); try { var tempString = Parser.SplitOnFirstWord(request.Item.message.message).Item2; if (string.IsNullOrEmpty(tempString)) { throw new Exception("no email distribution alias provided"); } // parse message var parsedMessage = Parser.SplitOnFirstWord(tempString); //get command var commandString = parsedMessage.Item1.Trim(); Command command; var commandResult = Enum.TryParse(commandString, true, out command); //get message var message = parsedMessage.Item2; var result = ""; if (commandResult) { switch (command) { case Command.Add: commandHandler.Add(message); result = "Added Successfully"; break; case Command.Update: result = commandHandler.Update(message); break; } } else { var isHtml = false; var parsedbody = Parser.SplitOnFirstWord(message); var regex = new Regex(@"^\^(\d)*"); var match = regex.Match(parsedbody.Item1); if (match.Success) { var regexDigits = new Regex(@"(\d)+"); var matchDigits = regexDigits.Match(parsedbody.Item1); if (matchDigits.Success) { var roomHistory = new RoomHistory(request.Item.room.name); isHtml = false; message = roomHistory.GetRoomMessageHistory(int.Parse(matchDigits.Value) + 1).GetEmailMessage(); } } var senderName = request.Item.message.from.name; var senderMention = request.Item.message.from.mention_name; result = commandHandler.Email(senderName, senderMention, commandString, message, isHtml); } if (result == null) { throw new Exception("error"); } // Notify Hipchat var responseBody = new NotifyResponse { color = "green", message = result, message_format = "text", notify = "false" }; responseMessage = this.Request.CreateResponse(HttpStatusCode.OK, responseBody); } catch (Exception ex) { commandHandler.Dispose(); var responseBody = new NotifyResponse { color = "green", message = ex.Message, message_format = "text", notify = "false" }; responseMessage = this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, JsonConvert.SerializeObject(responseBody)); } return(responseMessage); }