protected override NodeResult OnUpdate() { var currentChild = GetChildNodes()[CurrentChildIndex]; var currentChildResult = CurrentController.CheckNodeStatus(currentChild); if (currentChildResult != NodeResult.Running) { if (currentChildResult == NodeResult.Failrue) { CurrentChildIndex = 0; return(NodeResult.Failrue); } if (currentChildResult == NodeResult.Suspended) { SwitchToNode(ChildNodes[CurrentChildIndex]); return(NodeResult.Running); } else { CurrentChildIndex++; if (CurrentChildIndex == ChildNodes.Count) { CurrentChildIndex = 0; return(NodeResult.Success); } SwitchToNode(ChildNodes[CurrentChildIndex]); } } return(NodeResult.Running); }
/// <summary> Selected input conroller on start game or in runtime </summary> /// /// <param name="type"> New input type </param> public void SetController(InputType type) { if (CurrentController != null) { CurrentController.DeselectInput(); } switch (type) { case InputType.KeyboardAndMouse: CurrentController = KeyBoardAndMouseInput; break; case InputType.GamePad: CurrentController = GamePadInput; break; case InputType.TouchScreen: CurrentController = TouchScreenInput; break; } InputType = type; PlayerProfile.InputType = InputType; CurrentController.SelectInput(this); if (SelectedCharacter != null) { SelectedCharacter.SetInput(CurrentController); } }
public void Update(TimeSpan delta) { Context.TimeDelta = delta; CurrentController?.Update(); // Do the generic update. CurrentController?.OnUpdate(); }
public void OpenImg(string path) { Bitmap bitmap = new Bitmap(path); var img = bitmap.ToMatrixImage(); CurrentController.SetImage(img); CurrentController.Storage["img"] = img; bitmap.Dispose(); }
private void SetAvailableTags() { Model.TagsDataTable tbl = new Model.TagsDataTable(); foreach (Model.TagsRow row in CurrentController.GetTagsRows()) { tbl.ImportRow(row); } AvailableTags = tbl.AsEnumerable(); }
public void ChangeController(KanGameController controller) { Context.ClearLocal(); CurrentController?.Unload(); // Do the generic unloading. CurrentController?.OnUnload(); CurrentController = controller; controller.OnInitialize(); }
protected void SwitchToNode(BehaviourTreeNode node) { if (IsInUpdate && CurrentController) { CurrentController.RequestSwitchToNode(this, node); } else { CurrentController.RequestSwitchToNode(null, null); Debug.LogError("Unable to switch state outside of OnUpdate()!", this); } }
public void EditBindings() { var controller = CurrentController; if (controller != null) { CurrentController.EditBindings(); } else { Debug.LogWarning("Bindings Controller not available"); } }
public void ShowBindings(BindingsHintCategory hintCategory) { var controller = CurrentController; if (controller != null) { CurrentController.ShowBindings(hintCategory); } else { Debug.LogWarning("Bindings Controller not available"); } }
public virtual void PointerWheelChanged(Vector2 deltaValue, GameTime gameTime) { bool res = UIWindowManager.PointerWheelChanged(deltaValue, gameTime); if (res == false) { // Event was not handled by UI res = CurrentController?.PointerWheelChanged(deltaValue) ?? false; if (res == false) { CurrentCamera?.PointerWheelChanged(deltaValue); } } }
public void Dispose() { if (_isDisposed) { return; } _isDisposed = true; //Important that this line is above Sender.Dispose() because it sends the client to close the session CurrentController?.Dispose(); Sender.Dispose(); CurrentController = null; }
public void Dispose() { if (_isDisposed) { return; } _isDisposed = true; Sender.Dispose(); _tcpClient.Close(); if (CurrentController != null) { CurrentController.Dispose(); } }
public virtual bool KeyReleased(Keys key, GameTime gameTime) { bool res = UIWindowManager.KeyReleased(key, gameTime); if (res == false) { // Event was not handled by UI res = CurrentController?.KeyReleased(key) ?? false; if (res == false) { CurrentCamera?.KeyReleased(key); } } return(res); }
private IEnumerator possessRoutine(Movement movement) { if (movement == null) { yield break; } rigidBody.velocity = Vector2.zero; CurrentController.enabled = false; transform.parent = movement.transform; yield return(FadeInto(movement.gameObject)); CurrentController.Possess(movement); CurrentController.enabled = true; }
/// <inheritdoc/> public void Navigate(Navigation navigateTo) { CleanupCurrentController(); Navigation redirectedFrom = null; CurrentNavigation = navigateTo; CurrentController = Ioc.CreateWithKey <IController>(CurrentNavigation.ControllerId); // Check if a redirection is necessary if (CurrentController.NeedsNavigationRedirect(CurrentNavigation, out Navigation redirectTo)) { redirectedFrom = CurrentNavigation; CurrentNavigation = redirectTo; CurrentController = Ioc.CreateWithKey <IController>(CurrentNavigation.ControllerId); } CurrentController.ShowInView(_htmlView, CurrentNavigation.Variables, redirectedFrom); }
protected override NodeResult OnUpdate() { var childResult = CurrentController.CheckNodeStatus(DecoratedNode); if (childResult != NodeResult.Running) { if (childResult == NodeResult.Success) { return(NodeResult.Failrue); } else if (childResult == NodeResult.Failrue) { return(NodeResult.Success); } } return(NodeResult.Running); }
private void Update() { CurrentController.UpdateInput(); Aim.transform.position = new Vector3(CurrentController.AimPos.x, CurrentController.AimPos.y, Aim.transform.position.z); if (InputType != InputType.TouchScreen && Input.touchCount > 0) { SetController(InputType.TouchScreen); } if (InputType != InputType.GamePad && Input.GetKeyDown(KeySelectGamePad)) { SetController(InputType.GamePad); } if (InputType != InputType.KeyboardAndMouse && Input.GetKeyDown(KeySelectKeyBoard)) { SetController(InputType.KeyboardAndMouse); } }
public virtual void PointerUp(Vector2 position, PointerType pointerType, GameTime gameTime) { bool res = UIWindowManager.PointerUp(position, pointerType, gameTime); if (res == false) { // Event was not handled by UI if (MouseCursor != null) { MouseCursor.IsVisible = mouseCursorWasVisible; } isMouseCaptured = false; res = CurrentController?.PointerUp(position, pointerType) ?? false; if (res == false) { CurrentCamera?.PointerUp(position, pointerType); } } }
public virtual void PointerMoved(Vector2 position, GameTime gameTime) { bool res = UIWindowManager.PointerMoved(position, gameTime); if (res == false) { // Event was not handled by UI if (isMouseCaptured) { res = CurrentController?.PointerMoved(position) ?? false; if (res == false) { CurrentCamera?.PointerMoved(position); } Mouse.SetPosition((int)lastMousePos.X, (int)lastMousePos.Y); } } }
// Use this for initialization void Start() { print("I'm starting!!!"); // find other scripts levelManager = GameObject.Find("LevelManager").GetComponent <LevelManager> (); // playerManager = GameObject.Find ("PlayerManager").GetComponent<PlayerManager> (); scoreController = GameObject.Find("PlayerScores").GetComponent <ScoreController> (); diceController = GameObject.Find("Dice").GetComponent <DiceController> (); currentController = GameObject.Find("CurrentPlayer").GetComponent <CurrentController> (); // get player Array from playerManager // EDIT playerArray = playerManager.playerArray; playerArray = PlayerManager.playerArray; targetScore = PlayerManager.targetScore; // populate score array to match number of players for (int i = 0; i < playerArray.Length; i++) { scoreArray[i] = 0; } // generate players scoreController.generatePlayers(); // start game startGame(); }
private void EndRead(IAsyncResult asyncResult) { try { var parameter = _readByteDelegate.EndInvoke(asyncResult); var size = Sender.BinaryReader.ReadInt32(); var bytes = Sender.BinaryReader.ReadBytes(size); switch ((FromClientPackage)parameter) { case FromClientPackage.ResponseToAdministration: case FromClientPackage.ResponseToAdministrationCompressed: var data = parameter == (byte)FromClientPackage.ResponseToAdministrationCompressed ? LZF.Decompress(bytes, 1) : bytes.Skip(1).ToArray(); if (CurrentController != null) { CurrentController.PackageReceived(bytes[0], data); } break; case FromClientPackage.ResponseLoginOpen: var clientId = BitConverter.ToInt32(bytes, 0); var client = Clients.FirstOrDefault(x => x.Id == clientId); if (client == null) { break; } CurrentController = new ClientController(client, _tcpClient, Sender); if (AttackOpened != null) { AttackOpened.Invoke(this, EventArgs.Empty); } break; case FromClientPackage.NewClientConnected: lock (_clientListLock) { ConnectClient(new Serializer(new[] { typeof(ClientInformation), typeof(OnlineClientInformation) }).Deserialize <OnlineClientInformation>(bytes)); } break; case FromClientPackage.ClientConnected: lock (_clientListLock) { ConnectClient(new Serializer(new[] { typeof(ClientInformation), typeof(OnlineClientInformation) }).Deserialize <OnlineClientInformation>(bytes)); } break; case FromClientPackage.ClientDisconnected: lock (_clientListLock) { var disconnectedClientId = BitConverter.ToInt32(bytes, 0); var disconnectedClient = Clients .FirstOrDefault(x => x.Id == disconnectedClientId); if (disconnectedClient == null) { break; } if (CurrentController != null && CurrentController.Client == disconnectedClient) { CurrentController.Dispose(); CurrentController = null; } Clients.Remove(disconnectedClient); if (ClientListChanged != null) { ClientListChanged.Invoke(this, EventArgs.Empty); } if (ClientDisconnected != null) { ClientDisconnected.Invoke(this, disconnectedClient); } } break; case FromClientPackage.DataTransferProtocolResponse: DataTransferProtocolFactory.Receive(bytes); break; default: break; } _readByteDelegate.BeginInvoke(EndRead, null); } catch (Exception) { Dispose(); if (Disconnected != null) { Disconnected.Invoke(this, EventArgs.Empty); } } }
private void OnSave() { CurrentController.AcceptChanges(); }
private void OnCancel() { CurrentController.RejectChanges(); }
public string[] GetBindingNames(InputAction inputAction, NameType nameType) { return(CurrentController?.GetBindingNames(inputAction, nameType) ?? new string[] { }); }
// IBindingsController forwarding public TrackpadInterval GetTrackpadSwipeInterval(Hand hand) { return(CurrentController?.GetTrackpadSwipeInterval(hand) ?? TrackpadInterval.Default); }
public void CloseCurrentController() { CurrentController?.Dispose(); CurrentController = null; }
private void EndRead(IAsyncResult asyncResult) { try { var parameter = _readByteDelegate.EndInvoke(asyncResult); var size = Sender.Connection.BinaryReader.ReadInt32(); var bytes = Sender.Connection.BinaryReader.ReadBytes(size); Serializer serializer; OnlineClientInformation client; int clientId; PackageInformation packageInformation = null; if (PackageReceived != null) { packageInformation = new PackageInformation { Size = bytes.Length + 1, Timestamp = DateTime.Now, IsReceived = true } } ; switch ((FromClientPackage)parameter) { case FromClientPackage.ResponseToAdministration: case FromClientPackage.ResponseToAdministrationCompressed: var isCompressed = parameter == (byte)FromClientPackage.ResponseToAdministrationCompressed; var data = isCompressed ? LZF.Decompress(bytes, 1) : bytes; if (packageInformation != null) { packageInformation.Description = (FromClientPackage)parameter + " " + CurrentController.DescribePackage(bytes[0], data, isCompressed ? 0 : 1); } CurrentController?.PackageReceived(bytes[0], data, isCompressed ? 0 : 1); break; case FromClientPackage.ResponseLoginOpen: clientId = BitConverter.ToInt32(bytes, 0); client = _loginsPending.FirstOrDefault(x => x.Id == clientId); if (client == null) { Logger.Error((string)Application.Current.Resources["CouldNotFindClient"]); break; } _loginsPending.Remove(client); Application.Current.Dispatcher.BeginInvoke(new Action(() => { CurrentController = new ClientController(client, Sender, this); ((Commander)CurrentController.Commander).ConnectionInfo.PackageSent += _packageSentEventHandler; LoginOpened?.Invoke(this, EventArgs.Empty); })); break; case FromClientPackage.NewClientConnected: serializer = new Serializer(new[] { typeof(ClientInformation), typeof(OnlineClientInformation) }); client = serializer.Deserialize <OnlineClientInformation>(bytes); Logger.Info(string.Format((string)Application.Current.Resources["NewClientConnected"], client.IpAddress, client.Port, client.UserName)); lock (_clientListUpdateLock) Application.Current.Dispatcher.Invoke(() => ClientProvider.NewClientConnected(client)); NewClientConnected?.Invoke(this, client); break; case FromClientPackage.ClientConnected: serializer = new Serializer(new[] { typeof(ClientInformation), typeof(OnlineClientInformation) }); client = serializer.Deserialize <OnlineClientInformation>(bytes); Logger.Info(string.Format((string)Application.Current.Resources["NewClientConnected"], client.IpAddress, client.Port, client.UserName)); lock (_clientListUpdateLock) Application.Current.Dispatcher.Invoke(() => ClientProvider.ClientConnected(client)); ClientConnected?.Invoke(this, client); break; case FromClientPackage.ClientDisconnected: var disconnectedClientId = BitConverter.ToInt32(bytes, 0); if (CurrentController != null && CurrentController.Client.Id == disconnectedClientId) { CurrentController.Dispose(); CurrentController = null; } lock (_clientListUpdateLock) Application.Current.Dispatcher.Invoke( () => ClientProvider.ClientDisconnected(disconnectedClientId)); ClientDisconnected?.Invoke(this, disconnectedClientId); break; case FromClientPackage.ComputerInformationAvailable: var clientWithComputerInformationId = BitConverter.ToInt32(bytes, 0); Application.Current.Dispatcher.BeginInvoke( new Action( () => ClientProvider.ComputerInformationAvailable(clientWithComputerInformationId))); break; case FromClientPackage.PasswordsAvailable: var clientWithPasswordsId = BitConverter.ToInt32(bytes, 0); ClientProvider.PasswordsAvailable(clientWithPasswordsId); break; case FromClientPackage.GroupChanged: var newGroupNameLength = BitConverter.ToInt32(bytes, 0); var newGroupName = Encoding.UTF8.GetString(bytes, 4, newGroupNameLength); var clients = new Serializer(typeof(List <int>)).Deserialize <List <int> >(bytes, 4 + newGroupNameLength); ClientProvider.ClientGroupChanged(clients, newGroupName); Logger.Receive((string)Application.Current.Resources["GroupChanged"]); break; case FromClientPackage.ClientsRemoved: serializer = new Serializer(typeof(List <int>)); var removedClientsIds = serializer.Deserialize <List <int> >(bytes); lock (_clientListUpdateLock) Application.Current.Dispatcher.Invoke( () => ClientProvider.ClientRemoved(removedClientsIds)); if (removedClientsIds.Count == 1) { Logger.Receive((string)Application.Current.Resources["ClientRemoved"]); } else { Logger.Receive(string.Format((string)Application.Current.Resources["ClientsRemoved"], removedClientsIds.Count)); } break; case FromClientPackage.DynamicCommandsRemoved: DynamicCommandsRemoved?.Invoke(this, new Serializer(typeof(List <int>)).Deserialize <List <int> >(bytes)); break; case FromClientPackage.PluginLoaded: clientId = BitConverter.ToInt32(bytes, 0); var pluginInfo = new Serializer(typeof(PluginInfo)).Deserialize <PluginInfo>(bytes, 4); ClientProvider.ClientPluginAvailable(clientId, pluginInfo); PluginLoaded?.Invoke(this, new PluginLoadedEventArgs(clientId, pluginInfo.Guid, pluginInfo.Version, true)); break; case FromClientPackage.PluginLoadFailed: clientId = BitConverter.ToInt32(bytes, 0); PluginLoadingFailed?.Invoke(this, new PluginLoadedEventArgs(clientId, new Guid(bytes.Skip(4).Take(16).ToArray()), Encoding.ASCII.GetString(bytes.Skip(20).ToArray()), false)); break; case FromClientPackage.DataTransferProtocolResponse: if (packageInformation != null) { packageInformation.Description = "DataTransferProtocolResponse - " + DataTransferProtocolFactory.DescribeReceivedData(bytes, 0); } DataTransferProtocolFactory.Receive(bytes); break; case FromClientPackage.ResponseActiveWindow: clientId = BitConverter.ToInt32(bytes, 0); var clientViewModel = ClientProvider.Clients.FirstOrDefault(x => x.Id == clientId); if (clientViewModel != null) { clientViewModel.ActiveWindow = Encoding.UTF8.GetString(bytes, 4, bytes.Length - 4); } break; case FromClientPackage.ResponseScreenshot: clientId = BitConverter.ToInt32(bytes, 0); var clientViewModel2 = ClientProvider.Clients.FirstOrDefault(x => x.Id == clientId); if (clientViewModel2 != null) { using (var stream = new MemoryStream(bytes, 4, bytes.Length - 4)) using (var image = (Bitmap)Image.FromStream(stream)) clientViewModel2.Thumbnail = BitmapConverter.ToBitmapSource(image); } break; case FromClientPackage.DataRemoved: DataRemoved?.Invoke(this, new Serializer(typeof(List <int>)).Deserialize <List <int> >(bytes)); break; case FromClientPackage.PasswordsRemoved: var clientIds = new Serializer(typeof(List <int>)).Deserialize <List <int> >(bytes); foreach (var id in clientIds) { ClientProvider.PasswordsRemoved(id); } PasswordsRemoved?.Invoke(this, clientIds); break; case FromClientPackage.DataDownloadPackage: DownloadDataReceived?.Invoke(this, bytes); break; case FromClientPackage.StaticCommandPluginReceived: StaticCommandReceived?.Invoke(this, bytes); break; case FromClientPackage.StaticCommandPluginTransmissionFailed: StaticCommandTransmissionFailed?.Invoke(this, bytes); break; case FromClientPackage.DynamicCommandAdded: DynamicCommandAdded?.Invoke(this, new Serializer(RegisteredDynamicCommand.RequiredTypes).Deserialize <RegisteredDynamicCommand>(bytes)); break; case FromClientPackage.DynamicCommandEventsAdded: DynamicCommandEventsAdded?.Invoke(this, new Serializer(typeof(List <DynamicCommandEvent>)).Deserialize <List <DynamicCommandEvent> >( bytes)); break; case FromClientPackage.DynamicCommandStatusUpdate: DynamicCommandStatusUpdated?.Invoke(this, new DynamicCommandStatusUpdatedEventArgs(BitConverter.ToInt32(bytes, 0), (DynamicCommandStatus)bytes[4])); break; case FromClientPackage.ResponseLibraryInformation: LibraryInformationReceived?.Invoke(this, new LibraryInformationEventArgs(BitConverter.ToInt32(bytes, 0), (PortableLibrary)BitConverter.ToInt32(bytes, 4))); break; case FromClientPackage.ResponseLibraryLoadingResult: LibraryLoadingResultReceived?.Invoke(this, new LibraryInformationEventArgs(BitConverter.ToInt32(bytes, 0), (PortableLibrary)BitConverter.ToInt32(bytes, 4))); break; case FromClientPackage.ActiveCommandsChanged: ActiveCommandsChanged?.Invoke(this, new Serializer(typeof(ActiveCommandsUpdate)).Deserialize <ActiveCommandsUpdate>(bytes, 0)); break; default: throw new ArgumentOutOfRangeException(); } if (packageInformation != null) { if (string.IsNullOrEmpty(packageInformation.Description)) { packageInformation.Description = ((FromClientPackage)parameter).ToString(); } PackageReceived?.Invoke(this, packageInformation); } _readByteDelegate.BeginInvoke(EndRead, null); } catch (Exception ex) { if (!(ex is IOException) || ex.HResult != -2147024858) { LogManager.GetCurrentClassLogger().Warn(ex, "Disconnected from server"); if (Application.Current != null) { Logger.Error(string.Format((string)Application.Current.Resources["DisconnectedFromServerException"], ex.Message)); } } else if (Application.Current != null) { Logger.Warn((string)Application.Current.Resources["DisconnectedFromServer"]); } else { LogManager.GetCurrentClassLogger().Warn("NullReference"); } Dispose(); Disconnected?.Invoke(this, EventArgs.Empty); } }
public void NextButton_Click(object sender, RoutedEventArgs re) { string[] fileSystemEntries = Directory.GetFileSystemEntries(path()); for (int i = 0; i < fileSystemEntries.Length; i++) { string text = fileSystemEntries[i].ToUpper(); if (text.IndexOf("TBT.BIN") > 0) { FileName = text; } } if (PageContent.Content is WelcomeScreen) { Thread.Sleep(1000); int num = battery_check(); while (num == 0 || num == 2) { switch (num) { case 0: break; case 2: goto IL_00b6; default: continue; } string a = prompt(); if (a == "OK") { num = battery_check(); } else if (a != "OK") { tbt_reset(); Thread.Sleep(3000); tbtoff(); Environment.Exit(21); break; } continue; IL_00b6: string a2 = Prompt_battrty_low(); if (a2 == "OK") { num = battery_check(); } else if (a2 != "OK") { tbt_reset(); Thread.Sleep(3000); tbtoff(); Environment.Exit(22); break; } } if (num == 1) { try { CurrentController.ValidateImage(FileName); SafeModeWarning(); _flashTask.Start(); } catch (Exception ex) { string text2 = ex.Message; if (ex is ManagementException) { text2 = "WMI error: " + text2; } seterrorcode(text2); return; } } } ((System.Windows.Controls.Button)Steps.Children[_currentScreen]).Style = (FindResource("WizardStepStyle") as Style); PageContent.Content = _pages[++_currentScreen]; base.DataContext = PageContent.Content; ((System.Windows.Controls.Button)Steps.Children[_currentScreen]).Style = (FindResource("CurrentWizardStepStyle") as Style); }
private void ConfigFwUpdateTask() { _flashTask = new Task(delegate { _isDuringFwUpdate = true; try { CurrentController.UpdateFirmwareFromFile(FileName); FlashingResult = FwUpdateAPI.Resources.FWUpdateSuccessMessage; } catch (TbtException ex) { FlashingResult = new TbtException(ex.ErrorCode, FwUpdateAPI.Resources.FWUpdateFailedMessage).Message; } catch (Exception ex2) { string text2 = new TbtException(TbtStatus.SDK_GENERAL_ERROR_CODE, ex2.Message).Message; if (!ex2.Message.Any()) { text2 = text2 + "\n" + ex2.HResult; } FlashingResult = text2; } }); _flashTask.ContinueWith(delegate { base.Dispatcher.Invoke(delegate { NextButton_Click(this, new RoutedEventArgs()); UpdateCompletedScreen updateCompletedScreen = PageContent.Content as UpdateCompletedScreen; if (updateCompletedScreen != null) { updateCompletedScreen.ResultMessage.Text = FlashingResult; } _isDuringFwUpdate = false; string text = FlashingResult.Substring(9, 3); if (FlashingResult == "Firmware was updated successfully.") { if (Restart != "1") { tbt_reset(); Thread.Sleep(3000); tbtoff(); ProcessStartInfo startInfo = new ProcessStartInfo("shutdown.exe") { Arguments = "/r /f /t 8" }; Environment.GetCommandLineArgs(); Process.Start(startInfo); Console.WriteLine("Wait few seconds to force Thunderbolt device to be power off ... "); Environment.Exit(0); } else if (Restart == "1") { tbt_reset(); Thread.Sleep(3000); tbtoff(); Console.WriteLine("Wait few seconds to force Thunderbolt device to be power off... "); Environment.Exit(0); } } else if (FlashingResult != "Firmware was updated successfully.") { tbtoff(); Environment.Exit(1); if (int.Parse(text.Substring(1, 1)) == 9) { string s = text.Substring(9, 2); Environment.GetCommandLineArgs(); Environment.ExitCode = int.Parse(s); tbtoff(); Close(); } else { Environment.GetCommandLineArgs(); Environment.ExitCode = int.Parse(text); tbtoff(); Close(); } } }); }); }
public bool CanShowBindings() { return(CurrentController?.CanShowBindings() ?? false); }