//// Role Buttons Function public void roleButtonFunc(string roleName) { object[] roleInfo = new object[3] { ProtocolLabels.roleSelected, UDPChat.clientNo, roleName }; string msg = MessageMaker.makeMessage(roleInfo); UDPChat.instance.roleName = roleName; if (UDPChat.instance.isServer) { // Server must set roleName to lobby list by itself LobbyList.setRolePref(roleName); UDPChat.instance.Send(msg); } else { UDPChat.instance.connection.Send(msg, new IPEndPoint(UDPChat.instance.serverIp, Globals.port)); } }
private void savKey_Click(object sender, RoutedEventArgs e) { MessageMaker maker = new MessageMaker(); string childrn = childInput.Text.ToString(); List <string> children = extractChildren(childrn); Message msg = maker.makeEditRequest( Utilities.makeUrl(lAddr.Text, lPort.Text), Utilities.makeUrl(rAddr.Text, rPort.Text), keyInput.Text.ToString(), nameInput.Text.ToString(), descInput.Text.ToString(), dataInput.Text.ToString(), children ); if (sndr.sendMessage(msg)) { string content = msg.content; TextBlock item = new TextBlock(); item.Text = trim(content); item.FontSize = 16; sndmsgs.Items.Insert(0, item); } }
public PlayerAction() { player = GameObject.Find("Player").GetComponent <Player>(); itemManager = GameObject.Find("ItemManager").GetComponent <ItemManager>(); gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); messageMaker = GameObject.Find("Logger").GetComponent <MessageMaker>(); Empty = GameObject.Find("ArmorImage").GetComponent <UnityEngine.UI.Image>().sprite; }
void Update() { if (getHP() <= 0) { object[] msgParts = new object[2] { HD.ProtocolLabels.demonDeath, demonId }; string deathMsg = MessageMaker.makeMessage(msgParts); // HD.UDPChat.instance.Send(deathMsg); Destroy(gameObject); } }
private void sendRot() { object[] msgParts = new object[4] { HD.ProtocolLabels.playerRot, HD.UDPChat.clientNo, v3Rotate.x, v3Rotate.y }; string rotMsg = MessageMaker.makeMessage(msgParts); //HD.UDPChat.instance.Send(rotMsg); }
private void sendPos() { object[] msgParts = new object[5] { HD.ProtocolLabels.playerMove, HD.UDPChat.clientNo, transform.position.x, transform.position.y, transform.position.z, }; string posMsg = MessageMaker.makeMessage(msgParts); //HD.UDPChat.instance.Send(posMsg); }
/** * When the door is clicked, this function is called, and if the door can be opened, it moves player and generate monsters by calling functions in gameManager and boardManager. */ private void OnMouseUpAsButton() { Debug.Log(isOpened + " " + gameManager.CurrentSituation); if (isOpened && !gameManager.CurrentSituation) { if (GetComponentsInChildren <UnityEngine.UI.Image>().Length == 1) { switch (tag) { case "EastDoor": direction = BoardManager.Direction.Right; break; case "WestDoor": direction = BoardManager.Direction.Left; break; case "NorthDoor": direction = BoardManager.Direction.UpSide; break; case "SouthDoor": direction = BoardManager.Direction.DownSide; break; default: break; } boardManager.MoveNextFloor(); gameManager.EndPlayerTurn(Unit.Action.Move); gameManager.GenerateItems(boardManager.XPos, boardManager.YPos); gameManager.GenerateMonsters(boardManager.XPos, boardManager.YPos); gameManager.GenerateNPCs(boardManager.XPos, boardManager.YPos); } else { Player player = GameObject.Find("Player").GetComponent <Player>(); if (transform.GetChild(0) == null) { Debug.Log("문짝에서 자물쇠 오브젝트를 못찾았대 ㅋ"); return; } else { if (player.InventoryList.CheckItem(ItemManager.Label.BlackCard)) { player.UseItem(player.InventoryList.Getindex(ItemManager.Label.BlackCard)); Destroy(GetComponentsInChildren <UnityEngine.UI.Image>()[1].gameObject); } else { MessageMaker messageMaker = GameObject.Find("Logger").GetComponent <MessageMaker>(); messageMaker.MakeCannotMessage(ItemManager.Label.BlackCard); } } } } }
internal void clientDisconnected() { if (clientNo != 0) { object[] exitMsgParts = new object[2] { ProtocolLabels.clientLeft, clientNo }; string exitMsg = MessageMaker.makeMessage(exitMsgParts); instance.connection.Send(exitMsg, new IPEndPoint(instance.serverIp, Globals.port)); clientNo = 0; } }
internal static void stopGame() { if (UDPChat.instance.isServer) { instance.startButton.transform.GetChild(0).gameObject.GetComponent <Text>().text = "Start"; object[] gameMsg = new object[2] { ProtocolLabels.gameAction, "stop" }; string msg = MessageMaker.makeMessage(gameMsg); UDPChat.instance.Send(msg); } UDPChat.instance.gameState = "stop"; }
private void sendTyprReq() { MessageMaker maker = new MessageMaker(); Message msg = maker.makeTypeRequest( Utilities.makeUrl(lAddr.Text, lPort.Text), Utilities.makeUrl(rAddr.Text, rPort.Text) ); if (sndr.sendMessage(msg)) { string content = msg.content; TextBlock item = new TextBlock(); item.Text = trim(content); item.FontSize = 16; sndmsgs.Items.Insert(0, item); } }
private void showDB_Click(object sender, RoutedEventArgs e) { MessageMaker maker = new MessageMaker(); Message msg = maker.makeDisplayRequest( Utilities.makeUrl(lAddr.Text, lPort.Text), Utilities.makeUrl(rAddr.Text, rPort.Text) ); if (sndr.sendMessage(msg)) { string content = msg.content; TextBlock item = new TextBlock(); item.Text = trim(content); item.FontSize = 16; sndmsgs.Items.Insert(0, item); } }
} /**< It contains the fixed location of monster in the field. */ // Use this for initialization /** * It initiate the monsterGenLocation and currentTurn to 0 (resp. situtation to false) */ void Start() { playerTurn = true; enemyAttackTurn = false; enemyCheckTurn = false; player = playerObject.GetComponent("Player") as Player; monsterGenLocation = new Vector2 [6]; monsterGenLocation [0] = new Vector2(0, 2); monsterGenLocation [1] = new Vector2(-2, 2); monsterGenLocation [2] = new Vector2(2, 2); monsterGenLocation [3] = new Vector2(-3, 2); monsterGenLocation [4] = new Vector2(3, 2); monsterGenLocation [5] = new Vector2(0, 2); currentTurn = 0; currentSituation = false; boardManager = GameObject.Find("BoardManager").GetComponent <BoardManager>(); itemManager = GameObject.Find("ItemManager").GetComponent <ItemManager> (); messageMaker = GameObject.Find("Logger").GetComponent <MessageMaker>(); }
internal void lockPref() { UDPChat.instance.readyStatement = "R"; // "R" means "Ready" LobbyList.setReadyStatement("R", UDPChat.clientNo); object[] readyInfo = new object[3] { ProtocolLabels.clientReady, UDPChat.clientNo, "R" }; string readyMsg = MessageMaker.makeMessage(readyInfo); UDPChat.instance.Send(readyMsg); roleButtonSection.SetActive(false); lockButton.transform.GetChild(0).gameObject.GetComponent <Text>().text = "Unlock"; }
//----< Get Query Results >------------------------------------------ private void get_query_Click(object sender, RoutedEventArgs e) { MessageMaker maker = new MessageMaker(); Message msg = maker.makeQuery( Utilities.makeUrl(lAddr.Text, lPort.Text), Utilities.makeUrl(rAddr.Text, rPort.Text), querySelectedInt, queryText.Text ); if (sndr.sendMessage(msg)) { string content = msg.content; TextBlock item = new TextBlock(); item.Text = trim(content); item.FontSize = 16; sndmsgs.Items.Insert(0, item); } }
internal static void AddClient( IPEndPoint ipEndpoint) { if (instance.clientList.Contains(ipEndpoint) == false && !instance.connectionFailed) { UnityEngine.MonoBehaviour.print($"Connect to {ipEndpoint}"); instance.clientList.Add(ipEndpoint); // Request Message to Join Lobby if (!instance.isServer) { object[] req = new object[2] { ProtocolLabels.joinRequest, instance.username }; string message = MessageMaker.makeMessage(req); instance.connection.Send(message, ipEndpoint); } } }
private void restore_Click(object sender, RoutedEventArgs e) { string filename = filenameInput.Text; MessageMaker maker = new MessageMaker(); Message msg = maker.makeRestoreRequest( Utilities.makeUrl(lAddr.Text, lPort.Text), Utilities.makeUrl(rAddr.Text, rPort.Text), filename + ".xml" ); if (sndr.sendMessage(msg)) { string content = msg.content; TextBlock item = new TextBlock(); item.Text = trim(content); item.FontSize = 16; sndmsgs.Items.Insert(0, item); } }
//----< send a demonstraton message >-------------------------------- private void send_Click(object sender, RoutedEventArgs e) { try { #region #endregion if (!remoteAddress.Equals(rAddr.Text) || !remotePort.Equals(rPort.Text)) { remoteAddress = rAddr.Text; remotePort = rPort.Text; } // - Make a demo message to send // - You will need to change MessageMaker.makeMessage // to make messages appropriate for your application design // - You might include a message maker tab on the UI // to do this. MessageMaker maker = new MessageMaker(); Message msg = maker.makeMessage( Utilities.makeUrl(lAddr.Text, lPort.Text), Utilities.makeUrl(rAddr.Text, rPort.Text) ); lStat.Text = "sending to" + msg.toUrl; sndr.localUrl = msg.fromUrl; sndr.remoteUrl = msg.toUrl; lStat.Text = "attempting to connect"; if (sndr.sendMessage(msg)) { lStat.Text = "connected"; } else { lStat.Text = "connect failed"; } postSndMsg(msg.content); } catch (Exception ex) { lStat.Text = ex.Message; } }
internal void unlockPref() { const string NOT_READY = "N"; UDPChat.instance.readyStatement = NOT_READY; LobbyList.setReadyStatement(NOT_READY, UDPChat.clientNo); object[] unreadyInfo = new object[3] { ProtocolLabels.clientReady, UDPChat.clientNo, NOT_READY }; string unreadyMsg = MessageMaker.makeMessage(unreadyInfo); UDPChat.instance.Send(unreadyMsg); roleButtonSection.SetActive(true); lockButton.transform.GetChild(0).gameObject.GetComponent <Text>().text = "Lock"; }
//----< send a demonstraton message >-------------------------------- private void send_Click(object sender, RoutedEventArgs e) { try { #region #endregion if (!remoteAddress.Equals(rAddr.Text) || !remotePort.Equals(rPort.Text)) { remoteAddress = rAddr.Text; remotePort = rPort.Text; } MessageMaker maker = new MessageMaker(); Message msg = maker.makeMessage( Utilities.makeUrl(lAddr.Text, lPort.Text), Utilities.makeUrl(rAddr.Text, rPort.Text) ); lStat.Text = "sending to" + msg.toUrl; sndr.localUrl = msg.fromUrl; sndr.remoteUrl = msg.toUrl; lStat.Text = "attempting to connect"; if (sndr.sendMessage(msg)) { lStat.Text = "connected"; } else { lStat.Text = "connect failed"; } postSndMsg(msg.content); } catch (Exception ex) { lStat.Text = ex.Message; } }
public EnemyAction(Enemy enemy) { player = GameObject.Find("Player").GetComponent <Player>(); messageMaker = GameObject.Find("Logger").GetComponent <MessageMaker>(); enemyItself = enemy; }
public void GetMessageTest() { var message = MessageMaker.GetMessage(); Assert.AreEqual(false, string.IsNullOrWhiteSpace(message)); }
//----< Create Message for DB Display Request >---------------------- private Message ProcessShowDB(XElement showDB) { MessageMaker maker = new MessageMaker(); Message msg = maker.makeDisplayRequest( localUrl, remoteUrl ); return msg; }
//----< Create Message for Query Request >--------------------------- private Message ProcessQuery(XElement query) { int type = int.Parse(query.Element("Type").Value.ToString()); string param = query.Element("String").Value.ToString(); MessageMaker maker = new MessageMaker(); Message msg = maker.makeQuery( localUrl, remoteUrl, type, param ); return msg; }
//----< Create Message for Edit Request >---------------------------- private Message ProcessEdit() { MessageMaker maker = new MessageMaker(); Message msg = maker.makeEditRequest( localUrl, remoteUrl, clientCount ); return msg; }
//----< Create Message for Restore Request >------------------------- private Message ProcessRestore(XElement persist) { XElement file = persist.Element("Filename"); string filename = file.Value.ToString(); MessageMaker maker = new MessageMaker(); Message msg = maker.makeRestoreRequest( localUrl, remoteUrl, filename, clientCount ); return msg; }
public static void Handle(string message, IPEndPoint ipEndpoint) { string[] sections = message.Split(';'); string messageType = sections[0]; Debug.Log("Handler: " + message); if (UDPChat.instance.isServer) { switch (messageType) { case ProtocolLabels.joinRequest: if (UDPChat.instance.playerList.ToArray().Length == 4 || UDPChat.instance.gameState == "start") { object[] rejectMsg = new object[2] { ProtocolLabels.joinRequest, "rejected" }; string rejMsg = MessageMaker.makeMessage(rejectMsg); UDPChat.instance.connection.Send(rejMsg, ipEndpoint); } else { // Add player informations to lobby LobbyList.setPlayerName(sections[1]); int newClientNo = UDPChat.instance.playerList.IndexOf(sections[1]); LobbyList.setReadyStatement("N", newClientNo); // give info about itself to client to update it // and set its clientInfo object[] nameMsg = new object[5] { ProtocolLabels.clientInfo, UDPChat.instance.username, newClientNo, UDPChat.instance.roleName, UDPChat.instance.readyStatement }; string infoMsg = MessageMaker.makeMessage(nameMsg); UDPChat.instance.connection.Send(infoMsg, ipEndpoint); } break; case ProtocolLabels.roleSelected: LobbyList.setRolePref(sections[2], System.Int32.Parse(sections[1])); UDPChat.instance.Send(message); break; case ProtocolLabels.clientReady: LobbyList.setReadyStatement(sections[2], System.Int32.Parse(sections[1])); break; case ProtocolLabels.clientLeft: int leftClientNo = System.Int32.Parse(sections[1]); int playerListLength = UDPChat.instance.playerList.ToArray().Length; LobbyList.refreshLobbyList(leftClientNo, playerListLength); UDPChat.RemoveClient(ipEndpoint); MainSceneEventHandler.stopGame(); // send this message to inform other clients object[] exitMsgParts = new object[3] { ProtocolLabels.clientLeft, sections[1], playerListLength }; string exitMsg = MessageMaker.makeMessage(exitMsgParts); UDPChat.instance.Send(exitMsg); break; case ProtocolLabels.playerMove: float[] coordinates = new float[3] { float.Parse(sections[2]), float.Parse(sections[3]), float.Parse(sections[4]) }; GameSceneEventHandler.movePlayerObj(System.Int32.Parse(sections[1]), coordinates); break; case ProtocolLabels.playerRot: GameSceneEventHandler.rotatePlayerObj(System.Int32.Parse(sections[1]), float.Parse(sections[2]), float.Parse(sections[3])); break; default: break; } } else { switch (messageType) { case ProtocolLabels.joinRequest: // means you cannot join lobby, set UI normal MainSceneEventHandler.instance.exitButtonFunc(); break; case ProtocolLabels.clientInfo: if (UDPChat.clientNo == 0) { //add server LobbyList.setPlayerName(sections[1]); LobbyList.setRolePref(sections[3]); LobbyList.setReadyStatement(sections[4]); //client settings UDPChat.clientNo = System.Int32.Parse(sections[2]); LobbyList.setPlayerName(UDPChat.instance.username, UDPChat.clientNo); LobbyList.setReadyStatement("N", UDPChat.clientNo); object[] clientMsg = new object[3] { ProtocolLabels.newClient, UDPChat.instance.username, UDPChat.clientNo }; string othersMsg = MessageMaker.makeMessage(clientMsg); UDPChat.instance.Send(othersMsg); } else { LobbyList.setPlayerName(sections[1], System.Int32.Parse(sections[2])); LobbyList.setRolePref(sections[3], System.Int32.Parse(sections[2])); LobbyList.setReadyStatement(sections[4], System.Int32.Parse(sections[2])); } break; case ProtocolLabels.newClient: LobbyList.setPlayerName(sections[1], System.Int32.Parse(sections[2])); object[] nameMsg = new object[5] { ProtocolLabels.clientInfo, UDPChat.instance.username, UDPChat.clientNo, UDPChat.instance.roleName, UDPChat.instance.readyStatement }; string infoMsg = MessageMaker.makeMessage(nameMsg); UDPChat.instance.connection.Send(infoMsg, ipEndpoint); break; case ProtocolLabels.roleSelected: LobbyList.setRolePref(sections[2], System.Int32.Parse(sections[1])); break; case ProtocolLabels.clientReady: LobbyList.setReadyStatement(sections[2], System.Int32.Parse(sections[1])); break; case ProtocolLabels.clientLeft: int leftClientNo = System.Int32.Parse(sections[1]); LobbyList.refreshLobbyList(leftClientNo, System.Int32.Parse(sections[2])); MainSceneEventHandler.stopGame(); // To stop countdown break; case ProtocolLabels.gameAction: UDPChat.instance.gameState = sections[1]; if (UDPChat.instance.gameState == "start") { MainSceneEventHandler.startGame(); } else { MainSceneEventHandler.stopGame(); } break; case ProtocolLabels.playerMove: float[] coordinates = new float[3] { float.Parse(sections[2]), float.Parse(sections[3]), float.Parse(sections[4]) }; GameSceneEventHandler.movePlayerObj(System.Int32.Parse(sections[1]), coordinates); break; case ProtocolLabels.playerRot: GameSceneEventHandler.rotatePlayerObj(System.Int32.Parse(sections[1]), float.Parse(sections[2]), float.Parse(sections[3])); break; default: break; } } }
private static Radar GetRadarAndSetCommands(string[] cmds) { var radar = new Radar(); radar.Name = GetCommandValue(AirportICAOCommand, cmds); radar.MainAirportICAO = GetCommandValue(AirportICAOCommand, cmds); radar.EndpointUrl = GetCommandValue(ModeSMixerURLCommand, cmds) + "/json"; radar.LongitudeX = GetCommandValueDouble(LongitudeXCommand, cmds); radar.LatitudeX = GetCommandValueDouble(LatitudeXCommand, cmds); radar.LongitudeY = GetCommandValueDouble(LongitudeYCommand, cmds); radar.LatitudeY = GetCommandValueDouble(LatitudeYCommand, cmds); radar.User = GetCommandValue(UserCommand, cmds); radar.Password = GetCommandValue(PasswordCommand, cmds); radar.TwitterConsumerKey = GetCommandValue(TwitterConsumerKeyCommand, cmds); radar.TwitterConsumerSecret = GetCommandValue(TwitterConsumerSecretCommand, cmds); radar.TwitterAccessToken = GetCommandValue(TwitterAccessTokenCommand, cmds); radar.TwitterAccessTokenSecret = GetCommandValue(TwitterAccessTokenSecretCommand, cmds); if (!cmds.Any(a => a.Contains("ShowAll")) && !cmds.Any(a => a.Contains("AvoidAll"))) { radar.ShowEverything = true; } if (cmds.Any(a => a == ShowAllLowWeightAirplanesCommand)) { radar.ShowAllApproximationLowWeightAirplanes = GetCommandValueBool(ShowAllLowWeightAirplanesCommand, cmds); } if (cmds.Any(a => a == ShowAllMediumWeightAirplanesCommand)) { radar.ShowAllApproximationMediumWeightAirplanes = GetCommandValueBool(ShowAllMediumWeightAirplanesCommand, cmds); } if (cmds.Any(a => a == ShowAllHeavyWeightAirplanesCommand)) { radar.ShowAllApproximationHeavyWeightAirplanes = GetCommandValueBool(ShowAllHeavyWeightAirplanesCommand, cmds); } if (cmds.Any(a => a == AvoidAllLowWeightAirplanesCommand)) { radar.AvoidAllApproximationLowWeightAirplanes = GetCommandValueBool(AvoidAllLowWeightAirplanesCommand, cmds); } if (cmds.Any(a => a == AvoidAllMediumWeightAirplanesCommand)) { radar.AvoidAllApproximationMediumWeightAirplanes = GetCommandValueBool(AvoidAllMediumWeightAirplanesCommand, cmds); } if (cmds.Any(a => a == AvoidAllHeavyWeightAirplanesCommand)) { radar.AvoidAllApproximationHeavyWeightAirplanes = GetCommandValueBool(AvoidAllHeavyWeightAirplanesCommand, cmds); } ServerWriter.HTMLServerFolder = GetCommandValue(HTMLServerURLFolderCommand, cmds); if (cmds.Any(a => a == ShowAllCruisesHeavyWeightCommand)) { radar.ShowAllCruisesHeavyWeight = GetCommandValueBool(ShowAllCruisesHeavyWeightCommand, cmds); } if (cmds.Any(a => a == AvoidAllFlightsStartingWithCommand)) { radar.AvoidAllFlightsStartingWith = GetCommandValue(AvoidAllFlightsStartingWithCommand, cmds).Split(',').ToList(); } if (cmds.Any(a => a == ShowAllFlightStartingWithCommand)) { radar.AvoidAllModelsStartingWith = GetCommandValue(ShowAllFlightStartingWithCommand, cmds).Split(',').ToList(); } if (cmds.Any(a => a == AvoidAllModelsStartingWithCommand)) { radar.AvoidAllModelsStartingWith = GetCommandValue(AvoidAllModelsStartingWithCommand, cmds).Split(',').ToList(); } if (cmds.Any(a => a == ShowAllModelsStartingWithCommand)) { radar.ShowAllModelsStartingWith = GetCommandValue(ShowAllModelsStartingWithCommand, cmds).Split(',').ToList(); } if (cmds.Any(a => a == ShowHelicoptersCommand)) { radar.ShowHelicopters = GetCommandValueBool(ShowHelicoptersCommand, cmds); } if (cmds.Any(a => a == MessageLanguageCommand)) { var cultureCode = GetCommandValue(MessageLanguageCommand, cmds); try { var cultureInfo = new CultureInfo(cultureCode); CultureInfo.DefaultThreadCurrentCulture = cultureInfo; } catch { MessageMaker.CustomLanguageCode = cultureCode; MessageMaker.LoadMessages(); } } return(radar); }
//----< send a demonstraton message >-------------------------------- private void send_Click(object sender, RoutedEventArgs e) { try { #region ///////////////////////////////////////////////////// // This commented code was put here to allow // user to change local port and address after // the channel was started. // // It does what is intended, but would throw // if the new port is assigned a slot that // is in use or has been used since the // TCP tables were last updated. // // if (!localPort.Equals(lPort.Text)) // { // localAddress = rcvr.address = lAddr.Text; // localPort = rcvr.port = lPort.Text; // rcvr.shutDown(); // setupChannel(); // } #endregion if (!remoteAddress.Equals(rAddr.Text) || !remotePort.Equals(rPort.Text)) { remoteAddress = rAddr.Text; remotePort = rPort.Text; } // - Make a demo message to send // - You will need to change MessageMaker.makeMessage // to make messages appropriate for your application design // - You might include a message maker tab on the UI // to do this. MessageMaker maker = new MessageMaker(); Message msg = maker.makeMessage( Utilities.makeUrl(lAddr.Text, lPort.Text), Utilities.makeUrl(rAddr.Text, rPort.Text) ); lStat.Text = "sending to" + msg.toUrl; sndr.localUrl = msg.fromUrl; sndr.remoteUrl = msg.toUrl; lStat.Text = "attempting to connect"; if (sndr.sendMessage(msg)) lStat.Text = "connected"; else lStat.Text = "connect failed"; postSndMsg(msg.content); } catch(Exception ex) { lStat.Text = ex.Message; } }
private void savKey_Click(object sender, RoutedEventArgs e) { MessageMaker maker = new MessageMaker(); string childrn = childInput.Text.ToString(); List<string> children = extractChildren(childrn); Message msg = maker.makeEditRequest( Utilities.makeUrl(lAddr.Text, lPort.Text), Utilities.makeUrl(rAddr.Text, rPort.Text), keyInput.Text.ToString(), nameInput.Text.ToString(), descInput.Text.ToString(), dataInput.Text.ToString(), children ); if (sndr.sendMessage(msg)) { string content = msg.content; TextBlock item = new TextBlock(); item.Text = trim(content); item.FontSize = 16; sndmsgs.Items.Insert(0, item); } }