///-------------------------------------------------------------------------------------------------------- /// static public eCommand ParseCommand(string str) { if (str == null) { return(eCommand.None); } var commands = System.Enum.GetValues(typeof(eCommand)); for (int i = commands.Length - 1; i >= 0; --i) { eCommand command = (eCommand)commands.GetValue(i); if (command == eCommand.None) { continue; } ICommand cmdInst = CreateCommand(command); if (cmdInst == null) { continue; } if (str.StartsWith(((int)command).ToString()) || str.StartsWith(cmdInst.GetCommandName())) { return(command); } } return(eCommand.None); }
// 触发消息 private void ProcessMsg(eCommand cmd, byte[] buffer) { Delegate handler; if (_router.TryGetValue(cmd, out handler)) { var invocationList = handler.GetInvocationList(); for (var i = 0; i < invocationList.Length; i++) { var action = invocationList[i] as Action <byte[]>; if (action == null) { continue; } try { action(buffer); } catch (Exception ex) { Log.Exception(ex); } } } }
static void webClient_OnMessage(object sender, MessageEventArgs e) { JObject receiveData = JObject.Parse(e.Data); JProperty jp = receiveData.Property("payload"); JProperty jpError = receiveData.Property("error"); if (jpError != null) { Log.Error("Auto3D: " + jpError.Value.ToString()); cmd = eCommand.None; pairingKey = ""; return; } else { Log.Info("Auto3D: " + e.Data); } switch (cmd) { case eCommand.None: case eCommand.Pair: JToken jt = jp.Value["client-key"]; if (jt != null) { pairingKey = jt.ToString(); cmd = eCommand.None; if (UpdatePairingKey != null) { UpdatePairingKey(null, pairingKey); } } break; case eCommand.Register: cmd = eCommand.None; ThreadPool.QueueUserWorkItem(ThreadPoolCallback); break; case eCommand.GetInputSocket: String socketPath = jp.Value["socketPath"].ToString(); socketPath = socketPath.Replace("wss:", "ws:").Replace(":3001/", ":3000/"); if (webClientMouse != null) { webClientMouse.Close(); webClientMouse = null; } webClientMouse = new WebSocket(socketPath); webClientMouse.Connect(); cmd = eCommand.None; break; } }
static public void Register(String ipAddress, String pairingKey) { if (webClient == null) { InternalConnect(ipAddress); } JObject sendData = JObject.Parse( @"{ 'type': 'register', 'id': '1', 'payload': { 'client-key': '', 'manifest': { 'manifestVersion' : '1', 'permissions' : [ 'LAUNCH', 'LAUNCH_WEBAPP', 'APP_TO_APP', 'CONTROL_AUDIO', 'CONTROL_INPUT_MEDIA_PLAYBACK', 'CONTROL_POWER', 'READ_INSTALLED_APPS', 'CONTROL_DISPLAY', 'CONTROL_INPUT_JOYSTICK', 'CONTROL_INPUT_MEDIA_RECORDING', 'CONTROL_INPUT_TV', 'READ_INPUT_DEVICE_LIST', 'READ_NETWORK_STATE', 'READ_TV_CHANNEL_LIST', 'WRITE_NOTIFICATION_TOAST', 'CONTROL_INPUT_TEXT', 'CONTROL_MOUSE_AND_KEYBOARD', 'READ_CURRENT_CHANNEL', 'READ_RUNNING_APPS' ] } } }"); JProperty jp = sendData.Property("payload"); jp.Value["client-key"].Replace(pairingKey); String jsonString = sendData.ToString(); webClient.Send(jsonString); cmd = eCommand.Register; }
public long Send <T>(eCommand cmd, T data, Action <byte[]> callback = null) { MemoryStream stream = new MemoryStream(); Serializer.Serialize(stream, data); return(Send((int)cmd, stream.GetBuffer(), (int)stream.Length, callback)); }
public Packet(eCommand Command, int Value, int oText, int oLogger) { mCommand = (byte)Command; mValue = (byte)Value; moText = oText; moLogger = oLogger; }
///-------------------------------------------------------------------------------------------------------- /// static public ICommand CreateCommand(eCommand command) { switch (command) { case eCommand.CheckState: return(new CheckState()); case eCommand.GetAddressList: return(new GetAddressList()); case eCommand.GetTransectionList: return(new GetTransactionList()); case eCommand.CreateAddress: return(new CreateAddress()); case eCommand.StartStaking: return(new StartStaking()); case eCommand.StopStaking: return(new StopStaking()); case eCommand.RestartQtumWallet: return(new RestartQtumWallet()); case eCommand.SendQtum: return(new SendQtum()); case eCommand.RemoteCommandLine: return(new RemoteCommandLine()); case eCommand.BackupWallet: return(new BackupWallet()); case eCommand.RestoreWallet: return(new RestoreWallet()); case eCommand.RestartMachine: return(new RestartMachine()); case eCommand.UpdateChecker: return(new UpdateChecker()); } return(null); }
public void Register(eCommand cmd, Action <byte[]> handler) { if (!_router.ContainsKey(cmd)) { _router.Add(cmd, null); } _router[cmd] = Delegate.Combine(_router[cmd], handler); }
private void buttonLeft_MouseDown(object sender, MouseEventArgs e) { if (currentCommand != eCommand.DOWN && currentCommand != eCommand.UP && currentCommand != eCommand.WAIT) { currentCommand = eCommand.LEFT; cGL.ClawMachine.HandleLeftRightAngle -= 20; cGL.NotifyHandleMoved(); cGL.Draw(); } }
private void buttonBackwards_MouseDown(object sender, MouseEventArgs e) { if (currentCommand != eCommand.DOWN && currentCommand != eCommand.UP && currentCommand != eCommand.WAIT) { currentCommand = eCommand.BACKWARD; cGL.ClawMachine.HandleUpDownAngle += 20; cGL.NotifyHandleMoved(); cGL.Draw(); } }
private void buttonLeft_MouseUp(object sender, MouseEventArgs e) { if (currentCommand != eCommand.DOWN && currentCommand != eCommand.UP && currentCommand != eCommand.WAIT) { currentCommand = eCommand.IDLE; if (cGL.ClawMachine.HandleLeftRightAngle != 0) { cGL.ClawMachine.HandleLeftRightAngle += 20; } cGL.NotifyHandleMoved(); cGL.Draw(); } }
private void buttonBackwards_MouseUp(object sender, MouseEventArgs e) { if (currentCommand != eCommand.DOWN && currentCommand != eCommand.UP && currentCommand != eCommand.WAIT) { currentCommand = eCommand.IDLE; if (cGL.ClawMachine.HandleUpDownAngle != -45) { cGL.ClawMachine.HandleUpDownAngle -= 20; } cGL.NotifyHandleMoved(); cGL.Draw(); } }
/* This function creates a new command buffer and assigns the * command code */ public byte[] MakeCommand(eCommand command) { byte []ret = new byte[7]; // zero out the array to start for (int c = 0; c < ret.Length; c++) { ret[c] = 0; } ret[0] = (byte)PC2MACHINE; // set the direction from the pc to the machine ret[1] = (byte)command; // set the command return ret; }
public void GetDrillDownData(List <long> ids, eCommand cmd, byte[] reqId, int nSplitSize = 0) { // SpliList limits the number of order ids in the SQL query condition. Defaults to 30 (_nSize). foreach (var reqListIds in ids.SplitList(nSplitSize)) { sm(new manifestRequest() { command = cmd, requestId = reqId, valist = reqListIds }); } }
/* * This function creates a new command buffer and assigns the * command code */ public byte[] MakeCommand(eCommand command) { byte [] ret = new byte[7]; // zero out the array to start for (int c = 0; c < ret.Length; c++) { ret[c] = 0; } ret[0] = (byte)PC2MACHINE; // set the direction from the pc to the machine ret[1] = (byte)command; // set the command return(ret); }
/// <summary> /// Standard constructor, used by configuration loader. /// </summary> /// <param name="id">Id of the command.</param> /// <param name="command">Command itself (e.g. SendMail)</param> /// <param name="onFunctionError">True, if command shall be executed in case of an error.</param> /// <param name="onFunctionStart">True, if command shall be executed at function start.</param> /// <param name="onFunctionEnd">True, if command shall be executed at function end.</param> /// <param name="onValidityStart">True, if command shall be executed at validity start.</param> /// <param name="onValidityEnd">True, if command shall be executed at validity end.</param> /// <param name="onUnix">True, if command shall be exceuted on Unix systems. Default=True</param> /// <param name="onWindows">True, if command shall be executed on Windows systems. Default=True</param> public Command(SimpleId id, eCommand command, bool onFunctionError, bool onFunctionStart, bool onFunctionEnd, bool onValidityStart, bool onValidityEnd, bool onUnix, bool onWindows) { _id = id; _command = command; _onFunctionError = onFunctionError; _onFunctionStart = onFunctionStart; _onFunctionEnd = onFunctionEnd; _onValidityStart = onValidityStart; _onValidityEnd = onValidityEnd; _onUnix = onUnix; _onWindows = onWindows; }
static public String Pair(String ipAddress) { pairingKey = null; if (webClient != null) { webClient.Close(); webClient.OnMessage -= webClient_OnMessage; webClient = null; } InternalConnect(ipAddress); cmd = eCommand.Pair; JObject sendData = JObject.Parse( @"{ 'type': 'register', 'id': '1', 'payload': { 'manifest': { 'manifestVersion' : '1', 'permissions' : [ 'LAUNCH', 'LAUNCH_WEBAPP', 'APP_TO_APP', 'CONTROL_AUDIO', 'CONTROL_INPUT_MEDIA_PLAYBACK', 'CONTROL_POWER', 'READ_INSTALLED_APPS', 'CONTROL_DISPLAY', 'CONTROL_INPUT_JOYSTICK', 'CONTROL_INPUT_MEDIA_RECORDING', 'CONTROL_INPUT_TV', 'READ_INPUT_DEVICE_LIST', 'READ_NETWORK_STATE', 'READ_TV_CHANNEL_LIST', 'WRITE_NOTIFICATION_TOAST', 'CONTROL_INPUT_TEXT', 'CONTROL_MOUSE_AND_KEYBOARD', 'READ_CURRENT_CHANNEL', 'READ_RUNNING_APPS' ] } } }"); String jsonString = sendData.ToString(); webClient.Send(jsonString); while (pairingKey == null) { Thread.Sleep(50); } if (pairingKey == "?") { pairingKey = ""; } return(pairingKey); }
public static bool CheckErrorCode(int err, eCommand eCMD) { eErrorCode eErr = (eErrorCode)err; // 调试信息 if (err == 0) { Log.Info("{0} {1}", eCMD.ToString(), "成功"); return(true); } Log.Info("{0} {1} ({2}){3}", eCMD.ToString(), "失败", err, eErr.ToString()); ProcessLoginError(eErr); ProcessCityBuildingError(eErr); ProcessCommonError(eErr); return(false); }
public ManifestDetailsData(ManifestDetailsData dat) { Command = dat.Command; RequestId = dat.RequestId; LINK = dat.LINK; ManId = dat.ManId; DEL_SEQ = dat.DEL_SEQ; DSP_SEQ = dat.DSP_SEQ; EXTRA_STOP = dat.EXTRA_STOP; LOADUNITS = dat.LOADUNITS; //6 bytes UNITSONTRUCK = dat.UNITSONTRUCK; DLR_NO = dat.DLR_NO; SHP_NME = dat.SHP_NME; //30 bytes SHP_ADDR = dat.SHP_ADDR; //30 SHP_ADDR2 = dat.SHP_ADDR2; //30 SHP_CSZ = dat.SHP_CSZ; //30 SHP_TEL = dat.SHP_TEL; //12 DIR_1 = dat.DIR_1; //44 DIR_2 = dat.DIR_2; DIR_3 = dat.DIR_3; DIR_4 = dat.DIR_4; }
public ManifestDetailsData(manifestDetails dat) { Command = dat.command; RequestId = NewGuid(dat.requestId); LINK = BitConverter.ToInt32(dat.LINK, 0); ManId = dat.ManId; DEL_SEQ = dat.DEL_SEQ; DSP_SEQ = dat.DSP_SEQ; EXTRA_STOP = dat.EXTRA_STOP; //LOADUNITS = BitConverter.ToInt64(dat.LOADUNITS, 0); //6 bytes UNITSONTRUCK = dat.UNITSONTRUCK; DLR_NO = dat.DLR_NO; SHP_NME = dat.SHP_NME; //30 bytes SHP_ADDR = dat.SHP_ADDR; //30 SHP_ADDR2 = dat.SHP_ADDR2; //30 SHP_CSZ = dat.SHP_CSZ; //30 SHP_TEL = dat.SHP_TEL; //12 DIR_1 = dat.DIR_1; //44 DIR_2 = dat.DIR_2; DIR_3 = dat.DIR_3; DIR_4 = dat.DIR_4; }
public static void Register(eCommand cmd, Action <byte[]> handler) { NetworkManager.Instance.Register(cmd, handler); }
public static long Send <T>(eCommand cmd, T data, Action <byte[]> handler = null) { return(NetworkManager.Instance.Send <T>(cmd, data, handler)); }
public static void ThreadPoolCallback(Object threadContext) { cmd = eCommand.GetInputSocket; SendCommand("ssap://com.webos.service.networkinput/getPointerInputSocket"); }
public void AddMenuCommand(eCommand aCmd) { mMenuCommandSet |= aCmd; }
public static void SetCommandButton(Button aButton, eCommand aCmd) { aButton.FlatStyle = System.Windows.Forms.FlatStyle.Popup; aButton.Font = new Font("Marlett",8,FontStyle.Bold); switch (aCmd) { case eCommand.Add: aButton.Text = ((char)110).ToString(); aButton.ForeColor = Color.White; break; case eCommand.Edit: aButton.Text = ((char)0x61).ToString(); aButton.ForeColor = Color.Blue; break; case eCommand.Delete: aButton.Text = ((char)0x72).ToString(); aButton.ForeColor = Color.Red; break; case eCommand.Choice: aButton.Text = ((char)0x76).ToString(); aButton.ForeColor = Color.Green; break; case eCommand.Property: aButton.Text = "2"; aButton.ForeColor = Color.Yellow; break; } }
private void moveClaw() { switch (currentCommand) { case eCommand.FORWARD: if (cGL.ClawMachine.ClawPosition[2] > -1.5) { cGL.ClawMachine.ClawPosition[2] -= 0.025; cGL.NotifyHandleMoved(); } break; case eCommand.BACKWARD: if (cGL.ClawMachine.ClawPosition[2] < 1.5) { cGL.ClawMachine.ClawPosition[2] += 0.025; cGL.NotifyHandleMoved(); } break; case eCommand.RIGHT: if (cGL.ClawMachine.ClawPosition[0] < 1.5) { cGL.ClawMachine.ClawPosition[0] += 0.025; cGL.NotifyHandleMoved(); } break; case eCommand.LEFT: if (cGL.ClawMachine.ClawPosition[0] > -1.5) { cGL.ClawMachine.ClawPosition[0] -= 0.025; cGL.NotifyHandleMoved(); } break; case eCommand.DOWN: if (cGL.ClawMachine.Claw.CableLength < 4.8f) { cGL.ClawMachine.Claw.CableLength += 0.025f; cGL.NotifyHandleMoved(); } else { caughtIndex = cGL.ClawMachine.IsCaught(cGL.ClawMachine.ClawPosition[0], cGL.ClawMachine.ClawPosition[2]); currentCommand = eCommand.WAIT; } break; case eCommand.WAIT: if (waitingTime > 0) { waitingTime -= 10; } else { waitingTime = 600; currentCommand = eCommand.UP; } break; case eCommand.UP: if (cGL.ClawMachine.Claw.CableLength > 1.5f) { if (caughtIndex != -1) { cGL.ClawMachine.RaiseTeddyBear(caughtIndex, 0.025); } cGL.ClawMachine.Claw.CableLength -= 0.025f; cGL.NotifyHandleMoved(); } else { if (caughtIndex != -1) { cGL.ClawMachine.RemoveTeddyBear(caughtIndex); caughtIndex = -1; cGL.NotifyHandleMoved(); } currentCommand = eCommand.IDLE; } break; default: break; } }
public long Send(eCommand cmd, Action <byte[]> callback = null) { return(Send((int)cmd, null, 0, callback)); }
static void webClient_OnMessage(object sender, MessageEventArgs e) { JObject receiveData = JObject.Parse(e.Data); JProperty jp = receiveData.Property("payload"); JProperty jpError = receiveData.Property("error"); if (jpError != null) { Log.Error("Auto3D: " + jpError.Value.ToString()); cmd = eCommand.None; pairingKey = ""; return; } else { Log.Info("Auto3D: " + e.Data); } switch (cmd) { case eCommand.None: case eCommand.Pair: JToken jt = jp.Value["client-key"]; if (jt != null) { pairingKey = jt.ToString(); cmd = eCommand.None; if (UpdatePairingKey != null) UpdatePairingKey(null, pairingKey); } break; case eCommand.Register: cmd = eCommand.None; ThreadPool.QueueUserWorkItem(ThreadPoolCallback); break; case eCommand.GetInputSocket: String socketPath = jp.Value["socketPath"].ToString(); socketPath = socketPath.Replace("wss:", "ws:").Replace(":3001/", ":3000/"); if (webClientMouse != null) { webClientMouse.Close(); webClientMouse = null; } webClientMouse = new WebSocket(socketPath); webClientMouse.Connect(); cmd = eCommand.None; break; } }
public void AddMenuItem(eCommand aCmd) { if (ContextMenu == null) return; switch (aCmd) { case eCommand.Choice: mMIChoice = new MenuItem("�������", new EventHandler(OnChoice),Shortcut.CtrlIns); ContextMenu.MenuItems.Add(mMIChoice); break; case eCommand.Delete: mMIDel = new MenuItem("�������", new EventHandler(OnDelete),Shortcut.Del); ContextMenu.MenuItems.Add(mMIDel); break; case eCommand.Edit: mMIRename = new MenuItem("�������������", new EventHandler(OnRename),Shortcut.F2); ContextMenu.MenuItems.Add(mMIRename); break; case eCommand.Property: mMIProp = new MenuItem("��������", new EventHandler(OnProperty),Shortcut.ShiftF2); ContextMenu.MenuItems.Add(mMIProp); break; case eCommand.Find: mMIFind = new MenuItem("�����", new EventHandler(OnFind),Shortcut.CtrlF); ContextMenu.MenuItems.Add(mMIFind); break; } }
public virtual void DoCommand(TreeNode aTn, eCommand aCmd) { if (aCmd == eCommand.Find && !pUseLockFind) //���� ����� ������ { dlgFind dlg = new dlgFind(); dlg.StartPosition = FormStartPosition.CenterScreen; dlg.pFindText = mFindText; dlg.pIsMatchCase = mIsMatchCase; dlg.pIsWordWhole = mIsWordWhole; if (dlg.ShowDialog() == DialogResult.OK) { this.Parent.Refresh(); TreeNode tn = null; if (dlg.pIsDirectionForward) tn = SearchByText(dlg.pFindText, dlg.pIsMatchCase, dlg.pIsWordWhole, true); else tn = SearchByText(dlg.pFindText, dlg.pIsMatchCase, dlg.pIsWordWhole, false); if (tn == null) { MessageBox.Show ("������� ����� ["+mFindText+"] �� ������!"); RestorePrevSelectNode(); } else { SelectedNode = tn; SelectedNode.NodeFont = mFoundItemFont; _prevTreeNodeSelected = tn; } SelectedNode.EnsureVisible(); } } else if (onDoCommand != null) onDoCommand(this, new EvA_CasTVCommand(aTn, aCmd)); }
public void DoCommand(eCommand aCmd) { this.DoCommand(SelectedNode, aCmd); }
// 请求攻打关卡 public void RequestFight(int levelID) { Log.Info("RequestFight: {0}", levelID); MissionConstConfig cfg = MissionConstConfigLoader.GetConfig(levelID); if (cfg == null) { return; } if (UserManager.Instance.SP < cfg.StaminaCost) { UIUtil.ShowErrMsgFormat("UI_NOT_ENOUGTH_SP"); return; } eCommand cmd = eCommand.READY_BT_FUBEN_NORMAL; if (cfg.MissionDegree == (int)ChapterType.NORMAL) { cmd = eCommand.READY_BT_FUBEN_NORMAL; } else if (cfg.MissionDegree == (int)ChapterType.ELITE) { cmd = eCommand.READY_BT_FUBEN_ELITE; } PAttack data = new PAttack(); // foreach (var item in UserManager.Instance.PVEHeroList) { // data.attackerId.Add(item.EntityID); // } // if (UserManager.Instance.HeroList.Count <= 0) { Log.Error("RequestFight error, no hero"); return; } for (int i = 0; i < 3; ++i) { if (i < UserManager.Instance.HeroList.Count) { data.attackerId.Add(UserManager.Instance.HeroList[i].EntityID); } } data.pos = new PVector(); data.pos.x = levelID; NetworkManager.Instance.Send(cmd, data, (buffer) => { PBattlVerify ret = Net.Deserialize <PBattlVerify>(buffer); if (!Net.CheckErrorCode(ret.errorCode, cmd)) { return; } BattleManager.Instance.StartBattle(ret.battleId, LogicBattleType.PVE); }); }
public void RemoveMenuCommand(eCommand aCmd) { mMenuCommandSet &= ~aCmd; }
public static long Send(eCommand cmd, Action <byte[]> handler = null) { return(NetworkManager.Instance.Send((int)cmd, null, 0, handler)); }
public static String Pair(String ipAddress) { pairingKey = null; if (webClient != null) { webClient.Close(); webClient.OnMessage -= webClient_OnMessage; webClient = null; } InternalConnect(ipAddress); cmd = eCommand.Pair; JObject sendData = JObject.Parse( @"{ 'type': 'register', 'id': '1', 'payload': { 'manifest': { 'manifestVersion' : '1', 'permissions' : [ 'LAUNCH', 'LAUNCH_WEBAPP', 'APP_TO_APP', 'CONTROL_AUDIO', 'CONTROL_INPUT_MEDIA_PLAYBACK', 'CONTROL_POWER', 'READ_INSTALLED_APPS', 'CONTROL_DISPLAY', 'CONTROL_INPUT_JOYSTICK', 'CONTROL_INPUT_MEDIA_RECORDING', 'CONTROL_INPUT_TV', 'READ_INPUT_DEVICE_LIST', 'READ_NETWORK_STATE', 'READ_TV_CHANNEL_LIST', 'WRITE_NOTIFICATION_TOAST', 'CONTROL_INPUT_TEXT', 'CONTROL_MOUSE_AND_KEYBOARD', 'READ_CURRENT_CHANNEL', 'READ_RUNNING_APPS' ] } } }"); String jsonString = sendData.ToString(); webClient.Send(jsonString); while (pairingKey == null) Thread.Sleep(50); if (pairingKey == "?") pairingKey = ""; return pairingKey; }
public override void DoCommand(TreeNode aTn, eCommand aCmd) { mLastCommand = aCmd; if (SelectedNode == null && (aCmd&eCommand.Add) != eCommand.Add) return; if (!pIsMayEdit && (aCmd&(eCommand.Add|eCommand.Edit|eCommand.Delete))>0) return; //BeginUpdate(); switch (aCmd) { case eCommand.Add: ItemAdd_TV(); break; case eCommand.Add|eCommand.Edit: ItemAddRemane_TV(); break; case eCommand.Delete: ItemDelete(); break; case eCommand.Edit: ItemRename_TV(); break; case eCommand.Property : ItemProperty(); break; } base.DoCommand (aTn, aCmd); //EndUpdate(); }
public static string GetButtonIcon(eCommand aCmd) { string ret = "9"; switch (aCmd) { case eCommand.Add: ret = ((char)110).ToString(); break; case eCommand.Edit: ret = ((char)0x61).ToString(); break; case eCommand.Delete: ret = ((char)0x72).ToString(); break; case eCommand.Choice: ret = ((char)0x76).ToString(); break; case eCommand.Save: ret = ((char)0x32).ToString(); break; case eCommand.AddLink: ret = ((char)0x37).ToString(); break; case eCommand.Property: ret = "2"; break; } return ret; }
public void ClearMenuCommand() { mMenuCommandSet = eCommand.None; }
private void dropButton_Click(object sender, EventArgs e) { currentCommand = eCommand.DOWN; }
public EvA_CasTVCommand(TreeNode aTn, eCommand aCmd) : base(aTn) { mCommand = aCmd; }
private void ExecuteCommand() { if (commandQueue.Count == 0) { return; } if (mSpriteList.Count <= sceneManager.spriteCountLimit) { bool adv = ((new System.Random()).Next(5) == 0 ? true : false); Transform newFighter = SpawnFighter(adv, (adv ? 7 : 5), "Fighter: Enemy"); if (newFighter != null) { isInAction = false; int x = (new System.Random()).Next(roomList[roomIndex].mX1, roomList[roomIndex].mX2); int y = (new System.Random()).Next(roomList[roomIndex].mY1, roomList[roomIndex].mY2); Vector3 tgt = new Vector3(x, 0, y); if (Utility.Vector3CompareXZ(tgt, new Vector3(roomList[roomIndex].mCenterX, 0, roomList[roomIndex].mCenterY))) { int index = (new System.Random()).Next(roomList.Count - 1) + 1; tgt = new Vector3(roomList[index].mCenterX, 0, roomList[index].mCenterY); } newFighter.gameObject.GetComponent <Sprite>().GeneratePath(tgt); newFighter.gameObject.GetComponent <Sprite>().StartMoving(tgt, Vector3.zero); healthPoints += 3; if (healthPoints > 100) { healthPoints = 100; } } } // print("Money: " + mMoney); eCommand currentCmd = commandQueue.Peek(); switch (currentCmd) { case eCommand.eIdle: { // if (mSpriteList.Count < 1) { // if (tmp != null) { // int index = 1 + (new System.Random()).Next(roomList.Count - 1); // Vector3 tgt = new Vector3(roomList[index].mCenterX, 0, roomList[index].mCenterY); // tmp.gameObject.GetComponent<Sprite>().GeneratePath(tgt); // tmp.gameObject.GetComponent<Sprite>().StartMoving(tgt, Vector3.zero); // } // } for (int i = mSpriteList.Count - 2; i > 2; i--) { if (mSpriteList[i].gameObject.GetComponent <Sprite>().mPath == null) { if (mSpriteList[i] == null) { continue; } int index = (new System.Random()).Next(roomList.Count - 1) + 1; Vector3 tgt = new Vector3(roomList[index].mCenterX, 0, roomList[index].mCenterY); // int x = (new System.Random()).Next(roomList[index].mX1, roomList[index].mX2); // int y = (new System.Random()).Next(roomList[index].mY1, roomList[index].mY2); // Vector3 tgt = new Vector3(x, 0, y); mSpriteList[i].gameObject.GetComponent <Sprite>().GeneratePath(tgt); mSpriteList[i].gameObject.GetComponent <Sprite>().StartMoving(tgt, Vector3.zero); } } } break; case eCommand.eAttack: { // if (!isInAction) { for (int i = mSpriteList.Count - 2; i > 2; i--) { if (mSpriteList[i] == null) { continue; } if (mSpriteList[i].gameObject.GetComponent <Sprite>().mPath == null) { int x = (new System.Random()).Next(roomList[0].mX1, roomList[0].mX2); int y = (new System.Random()).Next(roomList[0].mY1, roomList[0].mY2); Vector3 tgt = new Vector3(x, 0, y); mSpriteList[i].gameObject.GetComponent <Sprite>().GeneratePath(tgt); mSpriteList[i].gameObject.GetComponent <Sprite>().StartMoving(tgt, Vector3.zero); } } isInAction = true; // } } break; case eCommand.eDefend: { // if (!isInAction) { for (int i = mSpriteList.Count - 1; i > mSpriteList.Count / 2; i--) { if (mSpriteList[i] == null) { continue; } if (mSpriteList[i].gameObject.GetComponent <Sprite>().mPath == null) { int x = (new System.Random()).Next(roomList[roomIndex].mX1, roomList[roomIndex].mX2); int y = (new System.Random()).Next(roomList[roomIndex].mY1, roomList[roomIndex].mY2); Vector3 tgt = new Vector3(x, 0, y); mSpriteList[i].gameObject.GetComponent <Sprite>().GeneratePath(tgt); mSpriteList[i].gameObject.GetComponent <Sprite>().StartMoving(tgt, Vector3.zero); } } isInAction = true; // } } break; } }
public static void Register(String ipAddress, String pairingKey) { if (webClient == null) { InternalConnect(ipAddress); } JObject sendData = JObject.Parse( @"{ 'type': 'register', 'id': '1', 'payload': { 'client-key': '', 'manifest': { 'manifestVersion' : '1', 'permissions' : [ 'LAUNCH', 'LAUNCH_WEBAPP', 'APP_TO_APP', 'CONTROL_AUDIO', 'CONTROL_INPUT_MEDIA_PLAYBACK', 'CONTROL_POWER', 'READ_INSTALLED_APPS', 'CONTROL_DISPLAY', 'CONTROL_INPUT_JOYSTICK', 'CONTROL_INPUT_MEDIA_RECORDING', 'CONTROL_INPUT_TV', 'READ_INPUT_DEVICE_LIST', 'READ_NETWORK_STATE', 'READ_TV_CHANNEL_LIST', 'WRITE_NOTIFICATION_TOAST', 'CONTROL_INPUT_TEXT', 'CONTROL_MOUSE_AND_KEYBOARD', 'READ_CURRENT_CHANNEL', 'READ_RUNNING_APPS' ] } } }"); JProperty jp = sendData.Property("payload"); jp.Value["client-key"].Replace(pairingKey); String jsonString = sendData.ToString(); webClient.Send(jsonString); cmd = eCommand.Register; }