public PlayerInputMessage(SEND_TYPE t, PLAYER_ID id, int hInput, int vInput) : base(DATAMESSAGE_TYPE.PLAYER_INPUT, t) { horzInput = hInput; vertInput = vInput; ID = id; }
public static long Frequency_convert(SEND_TYPE _type) { long _out; if (_type == MainForm.SEND_TYPE.FREQ_TYPE) { _out = Frequency; } else if (_type == MainForm.SEND_TYPE.CHAN_TYPE) { if ((Frequency >= 520000) && (Frequency <= 2500000)) { _out = (Frequency - 520000) / 250 + 1; } else { _out = 0; } } else { _out = 0; } return(_out); }
public PlayerUpdateMessage(SEND_TYPE t, PLAYER_ID id, float xPos, float yPos, float angle) : base(DATAMESSAGE_TYPE.PLAYER_UPDATE, t) { x = xPos; y = yPos; pAngle = angle; ID = id; }
public PlayerInputMessage(SEND_TYPE _sendType, int _playerID, int _horzInput, int _vertInput, bool _fireMissile, bool _layMine) : base(DataMessage_Type.PLAYER_INPUT, _sendType) { playerID = _playerID; horzInput = _horzInput; vertInput = _vertInput; fireMissile = _fireMissile; layMine = _layMine; }
public MissileUpdateMessage(SEND_TYPE t, PLAYER_ID id, int networkID, float xPos, float yPos, int last) : base(DATAMESSAGE_TYPE.MISSILE_UPDATE, t) { ID = id; missileNetworkID = networkID; x = xPos; y = yPos; lastID = last; }
/// <summary> /// Send a request to Theta <br /> /// Actual network operations are done here. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sendType">POST/GET</param> /// <param name="command"></param> /// <param name="commandPath"></param> /// <returns></returns> /// <exception cref="ThetaWifiConnectException" /> async private Task <HttpResponseMessage> SendRequestAsync <T>(SEND_TYPE sendType, T command, String commandPath, int?timeout = null) { var httpClient = _httpClient; //httpClient.Timeout = new TimeSpan(0, 0, 5); var headers = httpClient.DefaultRequestHeaders; headers.Clear(); headers.Add("Accept", "application/json"); StringContent content = null; if (command != null) { var jsonString = JsonUtil.ToSring <T>(command).Replace(":999", ":0"); content = new StringContent(jsonString, Encoding.UTF8, "application/json"); } try { var commandUri = Path.Combine(THETA_URL, commandPath); if (sendType == SEND_TYPE.POST) { return(await httpClient.PostAsync(commandUri, content)); } else { return(await httpClient.GetAsync(commandUri)); } } catch (HttpRequestException wex) { throw new ThetaWifiConnectException(WifiStrings.Err_ConnectionFailed, wex); } catch (TaskCanceledException wex) { throw new ThetaWifiConnectException(WifiStrings.Err_ConnectionFailed, wex); } }
void CallMessage(Packet msg)//클라이언트 수신부 { PROTOCOL protocolType = msg.Protocol; //Debug.Log("콜메세지 " + protocolType); switch (protocolType) { case PROTOCOL.ChatAck: { SEND_TYPE sendType = (SEND_TYPE)msg.PopInt16(); string text = msg.PopString(); } break; case PROTOCOL.LoginAck: { SceneManager.LoadScene(3); Packet sendmsg = PacketBufferManager.Instance.Pop(PROTOCOL.JoinRoom); sendmsg.Push(0); Send(sendmsg); } break; case PROTOCOL.LoginRej: { //다시입력하라고 } break; case PROTOCOL.SignUpAck: { SceneManager.LoadScene(1); } break; case PROTOCOL.SignUpRej: { SceneManager.LoadScene(1); } break; case PROTOCOL.JoinRoomRes: { int current_user_count = msg.PopInt32(); GameObject waitdisplay = GameObject.Find("Wait"); game_wait_click wait_script = waitdisplay.GetComponent <game_wait_click>(); wait_script.user_count = current_user_count; if (current_user_count == connectUserMax) { SceneManager.LoadScene(4); } } break; case PROTOCOL.GameStart: { CreateChracter(1, connectUserMax / 2, msg); CreateChracter(2, connectUserMax / 2, msg); for (int i = 0; i < 3; i++) { int item_position = msg.PopInt32(); GameObject itemSpawner = GameObject.Find("Item_Spawn"); Item_Spawn componentSpawner = itemSpawner.GetComponent <Item_Spawn>(); componentSpawner.item_create(item_position); } for (int i = 0; i < 20; i++) { GameObject npcSpawner = GameObject.Find("NPC_Spawn"); NPC_Spawn componentSpawner = npcSpawner.GetComponent <NPC_Spawn>(); numberingNPC[i] = componentSpawner.create_npc(i); } } break; case PROTOCOL.NPCPosition: { for (int i = 0; i < 20; i++) { int position = msg.PopInt32(); numberingNPC[i].GetComponent <NPC>().way = position; } } break; case PROTOCOL.PositionAck: { string remoteID = msg.PopString(); lock (networkObj) //thread 안정적으로 사용하려고 { if (networkObj.ContainsKey(remoteID)) { Player5 userPlayer = networkObj[remoteID].GetComponent <Player5>(); userPlayer.transform.position = msg.PopVector().Vector; //Quaternion rot = Quaternion.identity; //rot. = msg.PopVector().Vector; Quaternion rotation = userPlayer.transform.rotation; rotation.eulerAngles = msg.PopVector().Vector; userPlayer.transform.rotation = rotation; //userPlayer.transform.Rotate(msg.PopVector().Vector); int count = msg.PopInt32(); for (int i = 0; i < count; i++) { KeyCode key = (KeyCode)msg.PopInt16(); bool press = msg.PopInt16() == 1; userPlayer.inputEventKey[key] = press; } //userPlayer.mouseAxis = msg.PopFloat(); } } } break; case PROTOCOL.DestroyObjAck: { string type = msg.PopString(); string destroyDest = msg.PopString(); if (string.Compare(type, "item") == 0) { Destroy(networkObj[destroyDest], 3f); } else if (string.Compare(type, "thief") == 0) { Destroy(networkObj[destroyDest], 3f); } } break; case PROTOCOL.DestroyObjRej: { } break; case PROTOCOL.PlayerExit: { string remoteID = msg.PopString(); lock (csNetworkObj) { Destroy(networkObj[remoteID]); networkObj.Remove(remoteID); } } break; //case PROTOCOL.CreateObjAck: // { // int objNumbering = msg.PopInt32(); // string objTag = msg.PopString(); // Vector3 position; position.x = msg.PopFloat(); position.y = msg.PopFloat(); position.z = msg.PopFloat(); // lock (csNumberingWaitObj) // { // print(numberingWaitObj.Count); // GameObject createObj = numberingWaitObj.Peek(); // numberingWaitObj.Clear(); // NetworkObj netInfoObj = createObj.GetComponent<NetworkObj>(); // netInfoObj.remoteId = networkID; // lock (networkObj) // { // networkObj.Add(networkID, createObj); // createObj.SetActive(true); // } // } // } // break; default: { string text = msg.PopString(); Debug.Log("그외 " + text); } break; } }
public DataMessage(DataMessage_Type t, SEND_TYPE _sendType) { type = t; sendType = _sendType; }
public GameStateMessage(SEND_TYPE _sendType, GAME_STATE _state) : base(DataMessage_Type.GAME_STATE, _sendType) { state = _state; }
public DataMessage(DATAMESSAGE_TYPE dt, SEND_TYPE t) { dataType = dt; sendType = t; }
public RemoveMissileMessage(SEND_TYPE t, PLAYER_ID id, int uniqueMissileID) : base(DATAMESSAGE_TYPE.MISSILE_REMOVE, t) { ID = id; missileNetworkID = uniqueMissileID; }
public CreateMissileMessage(SEND_TYPE t, PLAYER_ID id, int uniqueMissileID) : base(DATAMESSAGE_TYPE.MISSILE_CREATE, t) { ID = id; missileNetworkID = uniqueMissileID; }