// Code to execute when the application is activated (brought to foreground) // This code will not execute when the application is first launched private void Application_Activated(object sender, ActivatedEventArgs e) { _isAppLaunched = false; // this means app is activated, could be tombstone or dormant state _isTombstoneLaunch = !e.IsApplicationInstancePreserved; //e.IsApplicationInstancePreserved --> if this is true its dormant else tombstoned try { _appLaunchState = (LaunchState)PhoneApplicationService.Current.State[LAUNCH_STATE]; } catch { } if (_isTombstoneLaunch) { if (appSettings.TryGetValue <PageState>(App.PAGE_STATE, out ps)) { isNewInstall = false; } instantiateClasses(); } else { if (ps == PageState.CONVLIST_SCREEN) { MqttManagerInstance.connect(); } } NetworkManager.turnOffNetworkManager = false; }
protected override async Task <Process> LaunchImpl(IGameLauncherFactory factory, ILaunchContentAction <IContent> action) { var launcher = factory.Create <IRealVirtualityLauncher>(this); var launchAction = _shouldLaunchAsDedicatedServer.Value ? LaunchAction.LaunchAsDedicatedServer : action.Action; var ls = new LaunchState(GetLaunchExecutable(launchAction), GetExecutable(launchAction), await GetStartupParameters(launcher, action, launchAction).ConfigureAwait(false), launchAction); if (launchAction.IsAsServer()) { Tools.FileUtil.Ops.CreateDirectoryAndSetACLWithFallbackAndRetry(KeysPath); } var launchables = action.GetLaunchables() .OfType <IModContent>() .Select(c => new RvMod(this, c)); foreach (var mod in launchables) { await mod.PreLaunch(action.Action).ConfigureAwait(false); } return(await InitiateLaunch(launcher, ls).ConfigureAwait(false)); }
protected override bool ShouldLaunchWithSteam(LaunchState ls) { var casted = Settings as ILaunchAsDedicatedServer; var launchAsDedicated = (casted?.LaunchAsDedicatedServer).GetValueOrDefault(); return(!launchAsDedicated && base.ShouldLaunchWithSteam(ls)); }
//private bool HasSteamApiDlls() // => _launchState.LaunchExecutable.ParentDirectoryPath.DirectoryInfo.EnumerateFiles("steam_api*.dll") //.Any(); protected virtual Task <LaunchGameInfo> GetDefaultLaunchInfo(LaunchState launchState) => Task.FromResult(new LaunchGameInfo(launchState.LaunchExecutable, launchState.Executable, launchState.LaunchExecutable.ParentDirectoryPath, launchState.StartupParameters) { LaunchAsAdministrator = ShouldLaunchAsAdministrator() });
public void ShowLaunchInfo(LaunchState state, string LaunchIcon, byte LaunchType) { m_State = state; m_LaunchType = LaunchType; m_LauncherIcon.spriteName = LaunchIcon; m_LauncherName.spriteName = string.Format("Launch_Name{0}", LaunchType); if (state == LaunchState.AlreadyEquip) { m_UIButton.isEnabled = false; m_ButtonBg.spriteName = "Change_Launch_Btn2"; ChangeButtonBg("Btn_Bg_2"); m_Locked.SetActive(false); } else if (state == LaunchState.AlreadyGet) { m_Locked.SetActive(false); m_UIButton.isEnabled = true; m_ButtonBg.spriteName = "Change_Launch_Btn1"; ChangeButtonBg("Btn_Bg_0"); } else { m_UIButton.isEnabled = true; m_Locked.SetActive(true); m_ButtonBg.spriteName = "Change_Launch_Btn0"; ChangeButtonBg("Btn_Bg_1"); } }
public void OnPointerDown() { if (slimeBehaviour.isAttached) { currentLaunchState = LaunchState.Holding; UpdateGizmoState(); } }
void OnDestroy() { if (this.state != null) { this.state.Exit(); this.state = null; } }
private LaunchState() { if (_instance != null) { return; } _instance = this; }
protected virtual Task <LaunchGameWithSteamInfo> GetSteamLaunchInfo(LaunchState launchState) => Task.FromResult(new LaunchGameWithSteamInfo(launchState.LaunchExecutable, launchState.Executable, launchState.LaunchExecutable.ParentDirectoryPath, launchState.StartupParameters) { SteamAppId = SteamInfo.AppId, SteamDRM = SteamInfo.DRM, LaunchAsAdministrator = ShouldLaunchAsAdministrator() });
void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e) { RootFrame.Navigating -= RootFrame_Navigating; if (appSettings.TryGetValue <PageState>(App.PAGE_STATE, out ps)) { isNewInstall = false; } instantiateClasses(); string targetPage = e.Uri.ToString(); if (targetPage != null && targetPage.Contains("ConversationsList") && targetPage.Contains("msisdn")) // PUSH NOTIFICATION CASE { _appLaunchState = LaunchState.PUSH_NOTIFICATION_LAUNCH; PhoneApplicationService.Current.State[LAUNCH_STATE] = _appLaunchState; // this will be used in tombstone and dormant state string param = GetParamFromUri(targetPage); e.Cancel = true; RootFrame.Dispatcher.BeginInvoke(delegate { RootFrame.Navigate(new Uri("/View/NewChatThread.xaml?" + param, UriKind.Relative)); }); } else if (targetPage != null && targetPage.Contains("sharePicker.xaml") && targetPage.Contains("FileId")) // SHARE PICKER CASE { if (ps != PageState.CONVLIST_SCREEN) { RootFrame.Dispatcher.BeginInvoke(delegate { loadPage(); return; }); } _appLaunchState = LaunchState.SHARE_PICKER_LAUNCH; PhoneApplicationService.Current.State[LAUNCH_STATE] = _appLaunchState; // this will be used in tombstone and dormant state e.Cancel = true; int idx = targetPage.IndexOf("?") + 1; string param = targetPage.Substring(idx); RootFrame.Dispatcher.BeginInvoke(delegate { RootFrame.Navigate(new Uri("/View/NewSelectUserPage.xaml?" + param, UriKind.Relative)); }); } else { _appLaunchState = LaunchState.NORMAL_LAUNCH; PhoneApplicationService.Current.State[LAUNCH_STATE] = _appLaunchState; // this will be used in tombstone and dormant state e.Cancel = true; RootFrame.Dispatcher.BeginInvoke(delegate { loadPage(); }); } }
public void OnPuckReset(IEventPayload genericPayload) { if (genericPayload.GetType() == typeof(PuckResetPayload)) { launchState = LaunchState.LAUNCH_READY; puckBody.bodyType = RigidbodyType2D.Kinematic; LaunchAimStart = Vector2.zero; LaunchAimEnd = Vector2.zero; transform.position = new Vector2(startLaunchXPos, launchYPos); } }
protected override void Init() { ShowInQuestState showInQuest = new ShowInQuestState(); AddState(showInQuest); PrepareLandingState prepareLanding = new PrepareLandingState(); AddState(prepareLanding); PrepareLaunchState prepareLaunch = new PrepareLaunchState(); AddState(prepareLaunch); LaunchState launch = new LaunchState(); AddState(launch); LaunchPauseState launchPause = new LaunchPauseState(); AddState(launchPause); DecelerateLaunchState decelerate = new DecelerateLaunchState(); AddState(decelerate); LandedState landed = new LandedState(); AddState(landed); BlockedOffState blocked = new BlockedOffState(); AddState(blocked); defaultState = showInQuest; AddTransition <ShowInQuestState, LandedState>("StartExploring"); AddTransition <PrepareLandingState, LandedState>("Landing"); AddTransition <LandedState, PrepareLaunchState>("TakingOff"); AddTransition <PrepareLaunchState, LaunchState>("Pushing"); AddTransition <LaunchState, DecelerateLaunchState>("Decelerate"); AddTransition <DecelerateLaunchState, LaunchState>("Pushing"); AddTransition <DecelerateLaunchState, LaunchPauseState>("PauseLaunch"); AddTransition <DecelerateLaunchState, PrepareLandingState>("OnEnterCollider"); AddTransition <LaunchPauseState, LaunchState>("Pushing"); AddTransition <LaunchPauseState, PrepareLandingState>("OnEnterCollider"); AddTransition <LaunchState, PrepareLandingState>("OnEnterCollider"); AddTransition <LaunchState, BlockedOffState>("Blocked"); AddTransition <LaunchPauseState, BlockedOffState>("Blocked"); AddTransition <LaunchState, BlockedOffState>("Blocked"); AddTransition <BlockedOffState, LaunchPauseState>("BlockedFinished"); AddTransition <PrepareLaunchState, LandedState>("Reland"); }
public void OnPointerUp() { var mousePosition = (Vector2)Camera.main.ScreenToWorldPoint(Input.mousePosition); if (CanLaunch(slimeBehaviour.currentWall, mousePosition)) { slimeBehaviour.LaunchSlime(force * (mousePosition - (Vector2)slimeBehaviour.transform.position).normalized); } currentLaunchState = LaunchState.NotClicked; UpdateGizmoState(); }
private void LaunchPuck() { // Enable physics launchState = LaunchState.LAUNCHED; puckBody.bodyType = RigidbodyType2D.Dynamic; // Calculate launch vector and apply it to the Puck Vector2 launchVector = LaunchAimEnd - LaunchAimStart; float launchPower = launchVector.magnitude > maxLaunchPower ? maxLaunchPower : launchVector.magnitude; Vector2 launchDir = launchVector / launchPower; puckBody.AddForce(launchDir * launchPower, ForceMode2D.Impulse); }
private void StateChangedHandler(object sender, EventArgs e) { LaunchState currentState = ((DfoLauncher)sender).State; Logging.Log.DebugFormat("Handling state change to {0}.", currentState); switch (currentState) { case LaunchState.None: ctlStatusStrip.BeginInvoke(() => ctlStatusLabel.Text = m_stateNoneText); ctlResizeButton.BeginInvoke(() => ctlResizeButton.Visible = false); lock ( m_syncHandle ) { if (!m_closeWhenDone) { this.BeginInvoke(() => this.WindowState = m_stateToRestoreTo); } } m_stateBecameNoneEvent.Set(); break; case LaunchState.Login: ctlStatusStrip.BeginInvoke(() => ctlStatusLabel.Text = "Logging in..."); break; case LaunchState.Launching: ctlStatusStrip.BeginInvoke(() => ctlStatusLabel.Text = "Launching..."); this.BeginInvoke(() => this.WindowState = FormWindowState.Minimized); break; case LaunchState.GameInProgress: ctlStatusStrip.BeginInvoke(() => ctlStatusLabel.Text = "Game in progress"); ctlResizeButton.BeginInvoke(() => ctlResizeButton.Visible = true); lock ( m_syncHandle ) { m_closeWhenDone = true; } break; } if (currentState == LaunchState.Login) { ShowProgressBar(); } else { HideProgressBar(); } }
public void Init(LaunchState state, InitialiseSettings settings) { LaunchState = state; Settings = settings; ActiveWorld = new World(); Settings.Context.MakeCurrent(null); SystemManager.LoadSystems(new CoreSystemLoader()); EntityManager.RegisterSystem(Renderer); SystemManager.InitialiseSystems(EntityManager, EventManager, ResourceManager, ActiveWorld); UpdateThread.Start(); RenderThread.Start(); }
/// <summary> /// 开始 /// </summary> public static void Run() { //注册游戏状态 IState launch = new LaunchState(); IState reg = new RegisterState(); IState update = new UpdateState(); IState luavm = new LuaVmState(); // StateService.GetInstance().RegisteState("Launch", launch); StateService.GetInstance().RegisteState("Update", update); StateService.GetInstance().RegisteState("Register", reg); StateService.GetInstance().RegisteState("LuaVM", luavm); //启动 StateService.GetInstance().ChangeState("Launch"); }
/// <summary> /// 刷新启动器状态 /// </summary> /// <param name="state">启动器状态</param> /// <param name="value">启动进度百分比,保留小数点后2位.格式{0:N2}</param> public void SetLaunchState(LaunchState state, float value) { string name = ""; if (!_launcher.TryGetValue(state, out name)) { Debug.LogErrorFormat("_launcher[{0}] = null ~", state); return; } //--设置状态标题 //--设置百分比 //Debug.LogFormat("[{0}]{1}\t{2}", state, name, value); _title = name; _progress = value; }
void Awake() { if (launchYPos == 0f) { throw new InvalidOperationException("Must set valid Launch Height."); } if (maxLaunchPower == 0f) { maxLaunchPower = DEFAULT_MAX_LAUNCH_PWR; } Vector3 screenCenter = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width / 2, Screen.height / 2, Camera.main.nearClipPlane)); startLaunchXPos = screenCenter.x; puckBody = GetComponent <Rigidbody2D>(); puckBody.bodyType = RigidbodyType2D.Kinematic; launchState = LaunchState.LAUNCH_READY; }
private void Launch() { if (state != LaunchState.PreLaunch) { LogLine($"ERROR: Got duplicate launch command, ignoring it"); return; } LogLine($"Launching to '{finalTarget.Name}'\nOrigin coords: {launchPos}\nDestination coords: {finalTarget.Coords}"); if (separator != null) { separator.Enabled = false; } foreach (var thrust in allThrusters) { thrust.Enabled = true; thrust.ThrustOverridePercentage = 0; } foreach (var thrust in downThrusters) { thrust.ThrustOverridePercentage = 0.1f; } foreach (var ant in antennas) { ant.Enabled = true; } foreach (var gyro in gyros) { gyro.Enabled = true; gyro.GyroOverride = false; } this.remote.DampenersOverride = true; this.enginesActive = true; this.state = LaunchState.Separation; this.launchPos = this.Position; this.launchForwardVec = this.remote.WorldMatrix.Forward; this.launchDownVec = this.remote.WorldMatrix.Down; this.launchTime = DateTime.Now; Runtime.UpdateFrequency = UpdateFrequency.Update10; }
void Update() { if (this.state == null) { return; } if (this.state.pause) { return; } var s = this.state.CheckTransition(); if (s != null) { this.state.Exit(); s.Enter(); this.state = s; return; } this.state.Update(); }
public Board(LaunchState launchState = LaunchState.Empty) { gameSpace = new Piece[8, 8]; switch (launchState) { case LaunchState.Empty: for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { gameSpace[x, y] = new EmptyPiece(x, y); } } break; case LaunchState.NoPawns: for (int y = 0; y < 8; y++) { if (y == 7) { for (int x = 0; x < 8; x++) { if (x == 0 | x == 7) { gameSpace[x, y] = new Rook("White", x, y); } else if (x == 1 | x == 6) { gameSpace[x, y] = new Knight("White", x, y); } else if (x == 2 | x == 5) { gameSpace[x, y] = new Bishop("White", x, y); } else if (x == 3) { gameSpace[x, y] = new Queen("White", x, y); } else if (x == 4) { gameSpace[x, y] = new King("White", x, y); } } } else if (y == 0) { for (int x = 0; x < 8; x++) { if (x == 0 | x == 7) { gameSpace[x, y] = new Rook("Black", x, y); } else if (x == 1 | x == 6) { gameSpace[x, y] = new Knight("Black", x, y); } else if (x == 2 | x == 5) { gameSpace[x, y] = new Bishop("Black", x, y); } else if (x == 3) { gameSpace[x, y] = new Queen("Black", x, y); } else if (x == 4) { gameSpace[x, y] = new King("Black", x, y); } } } else { for (int x = 0; x < 8; x++) { gameSpace[x, y] = new EmptyPiece(x, y); } } } break; case LaunchState.FullStart: for (int y = 0; y < 8; y++) { if (y == 7) { for (int x = 0; x < 8; x++) { if (x == 0 | x == 7) { gameSpace[x, y] = new Rook("White", x, y); } else if (x == 1 | x == 6) { gameSpace[x, y] = new Knight("White", x, y); } else if (x == 2 | x == 5) { gameSpace[x, y] = new Bishop("White", x, y); } else if (x == 3) { gameSpace[x, y] = new Queen("White", x, y); } else if (x == 4) { gameSpace[x, y] = new King("White", x, y); } } } else if (y == 6) { for (int x = 0; x < 8; x++) { gameSpace[x, y] = new Pawn("White", x, y); } } else if (y == 1) { for (int x = 0; x < 8; x++) { gameSpace[x, y] = new Pawn("Black", x, y); } } else if (y == 0) { for (int x = 0; x < 8; x++) { if (x == 0 | x == 7) { gameSpace[x, y] = new Rook("Black", x, y); } else if (x == 1 | x == 6) { gameSpace[x, y] = new Knight("Black", x, y); } else if (x == 2 | x == 5) { gameSpace[x, y] = new Bishop("Black", x, y); } else if (x == 3) { gameSpace[x, y] = new Queen("Black", x, y); } else if (x == 4) { gameSpace[x, y] = new King("Black", x, y); } } } else { for (int x = 0; x < 8; x++) { gameSpace[x, y] = new EmptyPiece(x, y); } } } break; default: break; } }
private void InitMachine() { Log.Info("InitMachine"); // if (saveLoadWinPos == null) // saveLoadWinPos = new SaveLoadWinPos(); // Create the states initial = new InitialState("Init", _machine); settings = new SettingState("Settings", _machine); sequence = new SequenceState("Sequence", _machine); launch = new LaunchState("Launch", _machine); launched = new LaunchedState("Launched", _machine); finish = new KFSMState("Finish"); // Add events to the states var go2Finish = new KFSMEvent("Finish") { GoToStateOnEvent = finish, updateMode = KFSMUpdateMode.MANUAL_TRIGGER }; var go2Settings = new KFSMEvent("Settings") { GoToStateOnEvent = settings, updateMode = KFSMUpdateMode.MANUAL_TRIGGER }; initial.AddEvent(go2Settings); var go2Init = new KFSMEvent("Init") { GoToStateOnEvent = initial, updateMode = KFSMUpdateMode.MANUAL_TRIGGER }; settings.AddEvent(go2Init); sequence.AddEvent(go2Init); finish.AddEvent(go2Init); var go2Sequence = new KFSMEvent("Sequence") { GoToStateOnEvent = sequence, updateMode = KFSMUpdateMode.MANUAL_TRIGGER }; initial.AddEvent(go2Sequence); var go2Launch = new KFSMEvent("Launch") { GoToStateOnEvent = launch, updateMode = KFSMUpdateMode.MANUAL_TRIGGER }; initial.AddEvent(go2Launch); launch.AddEvent(go2Init); launch.AddEvent(go2Finish); var go2Launched = new KFSMEvent("Launched") { GoToStateOnEvent = launched, updateMode = KFSMUpdateMode.MANUAL_TRIGGER }; launch.AddEvent(go2Launched); initial.AddEvent(go2Finish); launched.AddEvent(go2Finish); // Add states to the state machine _machine.AddState(initial); _machine.AddState(settings); _machine.AddState(sequence); _machine.AddState(launch); _machine.AddState(finish); }
void StartLaunche() { this.state = LaunchState.Create(this); this.state.Enter(); }
protected async Task <Process> LaunchWithSteam(ILaunchWithSteam launcher, LaunchState ls) => await launcher.Launch(await GetSteamLaunchInfo(ls).ConfigureAwait(false)) .ConfigureAwait(false);
void switchState(LaunchState newState) { switch(newState) { case LaunchState.Idle: rigidbody.isKinematic = false; disableGravity(); engine.Disable(); asteroidSpawner.Stop(); switchMode(ControlMode.Tactical); break; case LaunchState.Launching: disableGravity(); engine.Disable(); asteroidSpawner.Stop(); switchMode(ControlMode.Flight); break; case LaunchState.Orbit: disableGravity(); engine.Disable(); asteroidSpawner.Stop(); rigidbody.isKinematic = false; break; case LaunchState.Transit: enableGravity(); engine.Enable(); asteroidSpawner.Go(); rigidbody.isKinematic = false; break; } state = newState; }
protected virtual bool ShouldLaunchWithSteam(LaunchState ls) => IsSteamEdition();
protected Task <Process> InitiateLaunch <T>(T launcher, LaunchState ls) where T : ILaunch, ILaunchWithSteam => ShouldLaunchWithSteam(ls) ? LaunchWithSteam(launcher, ls) : LaunchNormal(launcher, ls);
private void SetToDefaultState() { lightSpeedEffect.Stop(); engine.Disable(); lineRendererToLauncher.enabled = false; state = LaunchState.Idle; mode = ControlMode.Tactical; allowMouseDragMovement = false; disableGravity(); }
protected async Task <Process> LaunchNormal(ILaunch launcher, LaunchState ls) => await launcher.Launch(await GetDefaultLaunchInfo(ls).ConfigureAwait(false)) .ConfigureAwait(false);