public void JoinRoomFailed(SocketIOEvent e) { Debug.Log("[SocketIO] Join room failed received: " + e.name + " " + e.data); this.m_Room = new CRoom(); this.DisplayLoading(false); this.ShowMessage(e.data.GetField("msg").ToString()); }
/// <summary> /// Receive Join a room complete message. /// Change PlayCaro7x7Scene /// Emit from JoinOrCreateRoom or JoinRoom. /// </summary> public void JoinRoomCompleted(SocketIOEvent e) { #if UNITY_DEBUG Debug.Log("[SocketIO] Join room received: " + e.name + " " + e.data); #endif var room = e.data.GetField("roomInfo"); this.m_Room = new CRoom(); this.m_Room.roomName = room.GetField("roomName").ToString().Replace("\"", ""); var players = room.GetField("players").list; this.m_Room.roomPlayes = new CPlayerData[players.Count]; for (int i = 0; i < players.Count; i++) { var tmpPlayer = players[i]; this.m_Room.roomPlayes[i] = new CPlayerData(); this.m_Room.roomPlayes[i].name = tmpPlayer.GetField("playerName").ToString().Replace("\"", ""); } var matchingMap = e.data.GetField("matchingMap").list; this.m_Room.matchingMap = new int[matchingMap.Count]; for (int i = 0; i < this.m_Room.matchingMap.Length; i++) { var item = int.Parse(matchingMap[i].ToString()); this.m_Room.matchingMap[i] = item; } this.DisplayLoading(players.Count < 2); this.m_SwitchScene.LoadScene("PlayMatching7x8Scene"); }
void SetTilesValuesForRooms() { // Go through all the rooms... for (int i = 0; i < rooms.Length; ++i) { CRoom currentRoom = rooms[i]; // ... and for each room go through it's width. for (int j = 0; j < currentRoom.roomWidth; ++j) { int xCoord = currentRoom.xPos + j; // For each horizontal tile, go up vertically through the room's height. for (int k = 0; k < currentRoom.roomHeight; k++) { int yCoord = currentRoom.yPos + k; if (yCoord < 0) { yCoord = 0; } // The coordinates in the jagged array are based on the room's position and it's width and height. // Debug.Log("x " + xCoord + " : " + " || " + " y " + yCoord + " : "); tiles[xCoord][yCoord] = TileType.Floor; } } } }
/// <summary> /// Receive leave message. /// Emit from LeaveRoom. /// </summary> public void ReceiveClearRoom(SocketIOEvent e) { #if UNITY_DEBUG Debug.Log("[SocketIO] Received clear room: " + e.name + " " + e.data); #endif this.m_Room = new CRoom(); this.SwithSceneTo <CDisplayRoomTask> (); this.ShowMessage(e.data.GetField("msg").ToString()); }
public static string SetInitRole(string playerHash, string roomHash) { CRoom r = CRoom.GetRoom(roomHash); if (r == null) { return(null); } r.UpdatePlayerRoles(playerHash); return("OK"); }
public static string GetGameEndStatus(string roomHash) { CRoom r = CRoom.GetRoom(roomHash); if (r == null) { return(null); } string answer = r.GetGameResponses(); return(answer); }
public void SetupCorridor(CRoom room, IntRange length, IntRange roomWidth, IntRange roomHeight, int columns, int rows, int _direction) { // Set a random direction (a random index from 0 to 3, cast to Direction). if (_direction >= 4) { _direction = _direction % 4; } direction = (Direction)_direction; // Set a random length. corridorLength = length.Random; // Create a cap for how long the length can be (this will be changed based on the direction and position). int maxLength = length.m_Max; switch (direction) { // If the choosen direction is NORTH (up)... case Direction.NORTH: // ... the starting position in the x axis can be random but within the width of the room. startXPos = Random.Range(room.xPos, room.xPos + room.roomWidth - 1); // The starting position in the y axis must be the top of the room. startYPos = room.yPos + room.roomHeight; // The maximum length the corridor can be is the height of the board (rows) but from the top of the room (y pos + height). maxLength = rows - startYPos - roomHeight.m_Min; break; case Direction.EAST: startXPos = room.xPos + room.roomWidth; startYPos = Random.Range(room.yPos, room.yPos + room.roomHeight - 1); maxLength = columns - startXPos - roomWidth.m_Min; break; case Direction.SOUTH: startXPos = Random.Range(room.xPos, room.xPos + room.roomWidth); startYPos = room.yPos; maxLength = startYPos - roomHeight.m_Min; break; case Direction.WEST: startXPos = room.xPos; startYPos = Random.Range(room.yPos, room.yPos + room.roomHeight); maxLength = startXPos - roomWidth.m_Min; break; } // We clamp the length of the corridor to make sure it doesn't go off the board. corridorLength = Mathf.Clamp(corridorLength, 1, maxLength); }
public static string GetGameSettings(string roomHash) { CRoom r = CRoom.GetRoom(roomHash); if (r == null) { return(null); } var json = new JavaScriptSerializer().Serialize(r.GetGameSettings()); return(json); }
public static string GetActiveGameUsers(string playerhash, string roomHash) { CRoom r = CRoom.GetRoom(roomHash); if (r == null) { return(null); } InGamePlayer[] allPlayers = r.GetAllGamesPlayers(playerhash).ToArray(); var json = new JavaScriptSerializer().Serialize(allPlayers); return(json); }
/// <summary> /// Receive leave message. /// Emit from LeaveRoom. /// </summary> public void LeaveRoomCompleted(SocketIOEvent e) { #if UNITY_DEBUG Debug.Log("[SocketIO] Leave received: " + e.name + " " + e.data); #endif var room = e.data.GetField("roomInfo"); this.m_Room = new CRoom(); this.m_Room.roomName = room.GetField("roomName").ToString().Replace("\"", ""); this.m_Room.roomMaximumMember = int.Parse(room.GetField("maxPlayer").ToString().Replace("\"", "")); // ROOM PLAYERS var players = room.GetField("players").list; this.UpdateRoomPlayers(players); this.CallbackEvent("NewLeaveRoom", this.m_Room.roomPlayes); this.CallbackEvent("UpdateRoomInGame", this.m_Room.roomPlayes); }
public static string SetResponse(string playerHash, string roomHash, string response) { CRoom r = CRoom.GetRoom(roomHash); if (r == null) { return(null); } if (r.UpdatePlayerResponse(roomHash, playerHash, response)) { return("OK"); } else { return("NotOK"); } }
public void JoinRoomCompleted(SocketIOEvent e) { Debug.Log("[SocketIO] Join room received: " + e.name + " " + e.data); var room = e.data.GetField("roomInfo"); this.m_Room = new CRoom(); this.m_Room.roomName = room.GetField("roomName").ToString().Replace("\"", ""); var players = room.GetField("players").list; this.m_Room.roomPlayes = new CPlayerData[players.Count]; for (int i = 0; i < players.Count; i++) { var tmpPlayer = players[i]; this.m_Room.roomPlayes[i] = new CPlayerData(); this.m_Room.roomPlayes[i].name = tmpPlayer.GetField("playerName").ToString().Replace("\"", ""); } this.DisplayLoading(players.Count < 2); this.m_SwitchScene.LoadScene("PlayCaro7x7Scene"); }
protected virtual IEnumerator DeadStateFunc() { mScene.AddScore(mDeadScore); mScene.AddGold(mDeadGold); float tAlpha = 1; Color tColor = mSpriteRenderer.color; while (tAlpha > 0) { tColor.a = tAlpha; mSpriteRenderer.color = tColor; tAlpha -= 0.1f; yield return(null); } CRoom room = GetComponentInParent <CRoom>(); if (room != null) { room.DeadEnemy(); } Destroy(this.gameObject); }
private int _portalMomCount; //포탈맘 사용할때 태그를 이용해서 오브젝트를 받아오는데, 이 때 사라져야할 전방 포탈들도 가져와서 전 방 포탈들을 따로 하드코딩으로 제외하기 위한 변수 #endregion private void Start() { startRoom = Resources.Load("Room/StartRoom0") as GameObject; bossRoom = Resources.Load("Room/BossRoom0") as GameObject; shopRoom = Resources.Load("Room/ShopRoom0") as GameObject; _portals = new List <CPortal>(); if (instance == null) { instance = this; } _stageNumber = 0; _skillEliteCount = 0; _eventCount = 0; _shopCount = 0; _noRoomFlag = true; _roomTypeFlag = CGlobal.ERoomType._empty; _roomCount = 0; //방의 개수가 12개가 넘어가면 멈춰줄 변수 _portalMomCount = 0; _roomArr = new CRoom[CConstants.ROOM_PER_STAGE, CConstants.MAX_ROAD]; for (int i = 0; i < CConstants.ROOM_PER_STAGE; i++) { for (int j = 0; j < CConstants.MAX_ROAD; j++) { _roomArr[i, j] = new CRoom(); } } _rooms = new LinkedList <GameObject>(); RandomRoomEnqueue(); CreateStage(); }
/// <summary> /// Receive Join a room complete message. /// Change PlaySpaceshipScene /// Emit from JoinOrCreateRoom or JoinRoom. /// </summary> public void JoinRoomCompleted(SocketIOEvent e) { #if UNITY_DEBUG Debug.Log("[SocketIO] Join room received: " + e.name + " " + e.data); #endif var room = e.data.GetField("roomInfo"); this.m_Room = new CRoom(); this.m_Room.roomName = room.GetField("roomName").ToString().Replace("\"", ""); var players = room.GetField("players").list; this.m_Room.roomPlayes = new CPlayerData[players.Count]; for (int i = 0; i < players.Count; i++) { var tmpPlayer = players[i]; this.m_Room.roomPlayes[i] = new CPlayerData(); this.m_Room.roomPlayes[i].name = tmpPlayer.GetField("playerName").ToString().Replace("\"", ""); this.m_Room.roomPlayes[i].formation = tmpPlayer.GetField("formation").ToString().Replace("\"", ""); } if (players.Count >= 2) { this.CallbackEvent("PlayerInRoomComplete"); this.CallbackEvent("PlayerInRoomUI"); this.DisplayLoading(false); } }
private void ParseInput(string cmd) { Variables.cmdCount++; // if any BeforeCommand present, then use it HandleResult res = (CArea != null) ? CArea.BeforeCommand(CArea, Variables, cmd) : HandleResult.Continue; if (res != HandleResult.Continue) { return; } res = CRoom.BeforeCommand(CRoom, Variables, cmd); if (res != HandleResult.Continue) { return; } // as direction ... Direction?dir = null; if (cmd == "上" || cmd == "上去" || cmd == "上楼") { dir = Direction.Up; } else if (cmd == "下" || cmd == "下去" || cmd == "下楼") { dir = Direction.Down; } else { string[] dirs = new[] { "东", "南", "西", "北", "东北", "西北", "东南", "西南" }; for (int i = 0; i < 8; i++) { if (dirs[i] == cmd) { dir = (Direction)i; } } } if (dir != null) { if (!GoDirection((Direction)dir)) { return; } // only look at PostCommand if succeeded res = (CArea != null) ? CArea.PostCommand(CArea, Variables, cmd) : HandleResult.Continue; if (res != HandleResult.Continue) { return; } CRoom.PostCommand(CRoom, Variables, cmd); return; } // as command ... foreach (var x in SingleObjVerbs) { // FIXME: what System.StringComparison should be used? if (cmd.StartsWith(x.Key, System.StringComparison.Ordinal)) { x.Value.Invoke(cmd.Substring(x.Key.Length)); res = (CArea != null) ? CArea.PostCommand(CArea, Variables, cmd) : HandleResult.Continue; if (res != HandleResult.Continue) { return; } res = CRoom.PostCommand(CRoom, Variables, cmd); if (res != HandleResult.Continue) { return; } return; } } Print("我不理解这个,请尝试不同的表达方法。\n\n"); }
public ActionResult GiaHangphong() { List <RoomModel> list = new CRoom().GetAllRoomHotel(); return(View(list)); }
public static string OpenNewRoom(int RoomSize, string random, string AI) { Player[] players = Player.GetAllPlayers(); List <Player> joiningPlayers = new List <Player>(); IList <Player> sortedPlayers = players.OrderBy(si => si.EntranceTime).ToList(); if (random == "True") { sortedPlayers = Shuffle(sortedPlayers); } int i = 0; try { retPlayers.WaitOne(); } catch (AbandonedMutexException) { retPlayers.ReleaseMutex(); retPlayers.WaitOne(); } foreach (var player in sortedPlayers) { if (player.conStat == Player.Connection.Connected && player.status == Player.Status.WaitingRoom && player.futureStatus == player.status) { joiningPlayers.Add(player); i++; if (i == RoomSize) { break; } } } retPlayers.ReleaseMutex(); if (i < RoomSize) { return("Not enough players to open such room"); } else { List <string> playersHash = new List <string>(); foreach (var item in joiningPlayers) { playersHash.Add(item.HashPlayer); } //Room newRoom = new Room(RoomSize, playersHash.ToArray()); CRoom cRoom; if (AI == "false") { cRoom = new CRoom(playersHash.ToArray(), false); } else { cRoom = new CRoom(playersHash.ToArray(), true); } foreach (var item in joiningPlayers) { //item.AddPlayerToRoom(newRoom._hashRoom); item.AddPlayerToRoom(cRoom.roomHash); item.SetFutureStatus(Player.Status.WaitingForJoinResponse, false); } return("Join request sent to all players."); } }
public static string RoomsUpdate() { CRoom.UpdateRooms(); return("OK"); }
protected virtual void ResetRoom() { this.m_Room = new CRoom(); }
public int SetupCorridor(CRoom room, IntRange length, IntRange roomWidth, IntRange roomHeight, int columns, int rows, bool firstCorridor) { // Set a random direction (a random index from 0 to 3, cast to Direction). direction = (Direction)Random.Range(0, 4); // Find the direction opposite to the one entering the room this corridor is leaving from. // Cast the previous corridor's direction to an int between 0 and 3 and add 2 (a number between 2 and 5). // Find the remainder when dividing by 4 (if 2 then 2, if 3 then 3, if 4 then 0, if 5 then 1). // Cast this number back to a direction. // Overall effect is if the direction was SOUTH then that is 2, becomes 4, remainder is 0, which is NORTH. Direction oppositeDirection = (Direction)(((int)room.Corridors + 2) % 4); // If this is not the first corridor and the randomly selected direction is opposite to the previous corridor's direction... if (!firstCorridor && direction == oppositeDirection) { // Rotate the direction 90 degrees clockwise (NORTH becomes EAST, EAST becomes SOUTH, etc). // This is a more broken down version of the opposite direction operation above but instead of adding 2 we're adding 1. // This means instead of rotating 180 (the opposite direction) we're rotating 90. int directionInt = (int)direction; directionInt++; directionInt = directionInt % 4; direction = (Direction)directionInt; } // Set a random length. corridorLength = length.Random; // Create a cap for how long the length can be (this will be changed based on the direction and position). int maxLength = length.m_Max; switch (direction) { // If the choosen direction is NORTH (up)... case Direction.NORTH: // ... the starting position in the x axis can be random but within the width of the room. startXPos = Random.Range(room.xPos, room.xPos + room.roomWidth - 1); // The starting position in the y axis must be the top of the room. startYPos = room.yPos + room.roomHeight; // The maximum length the corridor can be is the height of the board (rows) but from the top of the room (y pos + height). maxLength = rows - startYPos - roomHeight.m_Min; break; case Direction.EAST: startXPos = room.xPos + room.roomWidth; startYPos = Random.Range(room.yPos, room.yPos + room.roomHeight - 1); maxLength = columns - startXPos - roomWidth.m_Min; break; case Direction.SOUTH: startXPos = Random.Range(room.xPos, room.xPos + room.roomWidth); startYPos = room.yPos; maxLength = startYPos - roomHeight.m_Min; break; case Direction.WEST: startXPos = room.xPos; startYPos = Random.Range(room.yPos, room.yPos + room.roomHeight); maxLength = startXPos - roomWidth.m_Min; break; } // We clamp the length of the corridor to make sure it doesn't go off the board. corridorLength = Mathf.Clamp(corridorLength, 1, maxLength); return((int)direction); }
void CreateRoomsAndCorridors(IntRange _numRooms, IntRange _numCorridors, IntRange _roomWidth, IntRange _roomHeight, IntRange _corridorLength) { // Create the rooms array with a random size. rooms = new CRoom[_numRooms.Random]; // There should be one less corridor than there is rooms. int rand = _numCorridors.Random; corridors = new List <CCorridor>(rand); //Debug.Log(rand + " " + corridors.Count); // Create the first room and corridor. rooms[0] = new CRoom(); // Setup the first room, there is no previous corridor so we do not use one. rooms[0].SetupRoom(_roomWidth, _roomHeight, columns, rows); for (int startingCorr = 0; startingCorr < 4; ++startingCorr) { // ... create a corridor. CCorridor firstCorridor = new CCorridor(); // Setup the first corridor using the first room. firstCorridor.SetupCorridor(rooms[0], _corridorLength, _roomWidth, _roomHeight, columns, rows, startingCorr); corridors.Add(firstCorridor); } for (int i = 1; i < rooms.Length; i++) { // Create a room. rooms[i] = new CRoom(); List <int> notConnectedCorrsIndex = new List <int>(); // Setup the room base on a unConnectedTo corridor for (int corIndex = 0; corIndex < corridors.Count; ++corIndex) { if (corridors[corIndex].connectedTo == false) { notConnectedCorrsIndex.Add(corIndex); } } //choose randomly from the list of unconnected corridors if (notConnectedCorrsIndex.Count > 0) { int randomChoice = Random.Range(0, notConnectedCorrsIndex.Count); rooms[i].SetupRoom(_roomWidth, _roomHeight, columns, rows, corridors[notConnectedCorrsIndex[randomChoice]]); } else { rooms[i].SetupRoom(_roomWidth, _roomHeight, columns, rows, corridors[i - 1]); } notConnectedCorrsIndex.Clear(); // If we haven't reached the end of the corridors array... if (corridors.Count < corridors.Capacity) { CCorridor tempCorridor = new CCorridor(); int firstDir = tempCorridor.SetupCorridor(rooms[i], _corridorLength, _roomWidth, _roomHeight, columns, rows, false); corridors.Add(tempCorridor); } } }
private JRoom(CRoom value) : this() { ID = JID.Value(value.ID); }
public static bool TryParse(JRoom j, out CRoom room) => CRoom.TryParse(j, out room);
public static JRoom Value(CRoom room) => new JRoom(room);
public static bool AnswerJoinRequest(string hash, bool answer) { Dictionary <string, Player> OnlinePlayers = (Dictionary <string, Player>)HttpContext.Current.Application["OnlinePlayers"]; if (OnlinePlayers != null) { if (!answer) { // if this player is not ready, return all players to the queue foreach (var item in OnlinePlayers) { if (item.Value.HashPlayer == hash) { foreach (var otherPlayers in OnlinePlayers) { if (item.Key == otherPlayers.Key) { CRoom.CloseRoom(item.Value.roomHash); continue; } if (otherPlayers.Value.roomHash == item.Value.roomHash) { otherPlayers.Value.SetFutureStatus(Player.Status.WaitingRoom, false); } } item.Value.SetFutureStatus(Player.Status.WaitingRoom, true); } } } else { foreach (var item in OnlinePlayers) { if (item.Value.HashPlayer != hash) { continue; } item.Value.SetFutureStatus(Player.Status.Ready, false); bool allready = true; foreach (var otherPlayer in OnlinePlayers) { // bugfix: if the any of the players from the room has state different from ready if (otherPlayer.Key != item.Key && otherPlayer.Value.roomHash == item.Value.roomHash && otherPlayer.Value.status != Player.Status.Ready && otherPlayer.Value.futureStatus != Player.Status.Ready) { allready = false; break; } } if (allready) { foreach (var otherPlayer in OnlinePlayers) { if (otherPlayer.Value.roomHash == item.Value.roomHash) { otherPlayer.Value.futureStatus = Player.Status.EnteringRoom; } } } } } } return(true); }
public void ConnectToRoom(CRoom room) => m_Room = room; //确定该敌人属于哪个房间,以确定开门的时机