public void OnLoginSuccess() { if (LoginManager.Instance.IsLoggedIn) { state = IntroState.ReadyToPlay; LoginManager.Instance.loginType = LoginManager.LoginType.ActiveFacebook; } }
public Intro(Engine engine) : base(engine) { this.engine = engine; screens = new List <SpriteSheet>(); state = IntroState.Counting; isDone = false; }
private void showNextFrame(GameTime time) { startTime = (int)time.TotalGameTime.TotalMilliseconds; ++slideIndex; state = IntroState.Counting; if (slideIndex == screens.Count) { isDone = true; } }
public void ContinueButtonEvent() { if (state == IntroState.INTRO1) { state = IntroState.INTRO2; } else { Game.Instance.ShowTutorial(); } }
// Use this for initialization void Start() { fadeScript.StartFadingToClear(1f); rsc.audioMng.FadeInMusic(AudioManager.MusicType.INTRO, 1f); state = IntroState.FadingIn; async = SceneManager.LoadSceneAsync("Level01"); async.allowSceneActivation = false; movie.Play(); startFadingTime = movie.duration - 1f; elapsedTime = 0f; }
void SetState(IntroState s) { state = s; time = 0; if (s == IntroState.Studio) { background.renderer.material = whiteMaterial; } if (s == IntroState.Video) { renderer.enabled = true; Play(); } }
public void Update(GameTime gameTime) { if (timer > 500) { foreach (Player player in GameServices.GetService <List <Player> >()) { if (Keyboard.GetState().IsKeyDown(player.PlayerControls.MenuSelect)) { StateProvider.Instance.State = GameState.MENU; } } } timer += gameTime.ElapsedGameTime.TotalMilliseconds; switch (State) { case IntroState.FADING_IN: Opacity += (1f / (float)FadeInTime) * (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (timer > FadeInTime) { timer = 0; State = IntroState.VISIBLE; } break; case IntroState.VISIBLE: Opacity = 1; if (timer > VisibleTime) { timer = 0; State = IntroState.FADING_OUT; } break; case IntroState.FADING_OUT: Opacity -= (1f / (float)FadeOutTime) * (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (timer > FadeOutTime) { StateProvider.Instance.State = GameState.MENU; } break; } }
public void GoToNextState() { _currentState = _currentState + 1; if (_currentState == IntroState.End) { GameStateManager.SetGameState <SurvivalGameState>(); } else { if (IntroStateSwitchedEvent != null) { IntroStateSwitchedEvent(_currentState); } } }
IEnumerator AnimateMove(GameObject obj, Vector3 origin, Vector3 target, float duration) { cameraPanning = true; float journey = 0f; while (journey <= duration) { journey = journey + Time.deltaTime; float percent = Mathf.Clamp01(journey / duration); float curvePercent = animCurve.Evaluate(percent); obj.transform.position = Vector3.LerpUnclamped(origin, target, curvePercent); yield return(null); } cameraPanning = false; state = IntroState.Applause; StartTimer(timer); textPanel.SetActive(true); if (camTarget >= 0) { var charTemp = players[camTarget].GetComponent <Character>().character; string s1 = charTemp.name; string s2 = " the "; string s3 = adjectives[Random.Range(0, adjectives.Length)]; string s4 = "!"; string s5 = string.Concat(new string[] { s1, s2, s3, s4 }); text.text = s5; if (!canGoToNextScene) { canGoToNextScene = true; } } else { textPanel.SetActive(false); if (canGoToNextScene) { GoToMinigame(); } } }
public void NextScene() { switch (state) { case IntroState.START: state = IntroState.MAIN; StartCoroutine(MainScene()); break; case IntroState.MAIN: state = IntroState.END; StartCoroutine(EndScene()); break; case IntroState.END: SceneManager.LoadScene("GameScene"); break; } }
public StateManager() { stateStack = new List <GameState>(); IntroState intro = new IntroState(this); stateStack.add(intro); MenuState menu = new MenuState(this); stateStack.add(menu); PlayingState playing = new PlayingState(this); stateStack.add(playing); GameOverState gameOver = new GameOverState(this); stateStack.add(gameOver); OutroState outro = new OutroState(this); stateStack.add(outro); activeState = 0; }
void OnGameStart() { IEnumerator stateMachine(IState state) { do { Debug.Log($"Entering state {state.GetType()}"); state.OnEnter(); yield return(state.OnUpdate()); Debug.Log($"Exiting state {state.GetType()}"); state.OnExit(); state = state.NextState; } while (state != null); } var initialState = new IntroState(); StartCoroutine(stateMachine(initialState)); }
public static void Update(int gameTime) { if (state == IntroState.FadeIn || state == IntroState.SpaceBar) { Engine.player.state = State.Dialog; } if (state != IntroState.SpaceBar) { if(introTime < moveHelpTime || Hud.hidden == false) introTime += gameTime; } if (state == IntroState.FadeIn && introTime > fadeTime) { state = IntroState.SpaceBar; DialogBox.SetDialog("pressspacebar"); } if (state == IntroState.SpaceBar && (Keyboard.GetState().IsKeyDown(Keys.Space) || GamePad.GetState(Game1.activePlayer).IsButtonDown(Buttons.A))) { state = IntroState.MoveHelp; Game1.controller.JumpInvalidate(); Engine.player.state = State.Normal; DialogBox.state = BoxState.Close; DialogBox.animationTime = 0; SoundFX.DialogExtend(); } if (state == IntroState.MoveHelp && introTime > moveHelpTime) { state = IntroState.LookHelp; DialogBox.SetDialog("intromovehelp"); } if (state == IntroState.LookHelp && introTime > lookHelpTime) { state = IntroState.LoadHelp; DialogBox.SetDialog("introlookhelp"); } if (state == IntroState.LoadHelp && introTime > useHelpTime) { state = IntroState.Play; DialogBox.SetDialog("introusehelp"); } }
IEnumerator EvilGloating() { waitCoroutineStarted = true; yield return(new WaitForSeconds(5)); bossAnim.SetTrigger("IntroBossRoarIdle"); yield return(new WaitForSeconds(1)); string endMessage1 = "Je woorden zijn zwak,\nniets wat je zegt\nkan mij raken!"; messageObject.GetComponent <TextMesh>().text = endMessage1; StartCoroutine(PlaySound(endMessage1)); yield return(new WaitForSeconds(4)); messageObject.GetComponent <TextMesh>().text = ""; bossAnim.SetTrigger("IntroBossRoarIdle"); yield return(new WaitForSeconds(1)); string endMessage2 = "Niemand hier kan je helpen,\nhahaha!"; messageObject.GetComponent <TextMesh>().text = endMessage2; StartCoroutine(PlaySound(endMessage2)); yield return(new WaitForSeconds(5)); messageObject.GetComponent <TextMesh>().text = ""; Vector3 theScale = boss.transform.localScale; theScale.x *= -1; boss.transform.localScale = theScale; yield return(new WaitForSeconds(1)); bossMoveOut = true; _state = IntroState.bossMoveOut; StartCoroutine(FadeToBlack()); yield return(new WaitForSeconds(10)); // Load the tutorial level Application.LoadLevel("Tutorial"); waitCoroutineStarted = false; }
public override void Update(GameTime gameTime) { int now = (int)gameTime.TotalGameTime.TotalMilliseconds; if (!keyPress) { if (Input.isGamepadBtnDown(Buttons.A) || Input.isGamepadBtnDown(Buttons.B)) { keyPress = true; } } else if (keyPress && !(Input.isGamepadBtnDown(Buttons.A) || Input.isGamepadBtnDown(Buttons.B))) { keyPress = false; isDone = true; } if (state == IntroState.Starting) { Debug.WriteLine("Starting " + slideIndex); startTime = now; state = IntroState.Counting; } if (state == IntroState.Transitioning) { Debug.WriteLine("Tranitioning " + slideIndex); if (now - startTime > TRANSITION_TIME) { showNextFrame(gameTime); } } else if (state == IntroState.Counting) { Debug.WriteLine("Counting " + slideIndex); if (now - startTime > SLIDE_TIMEOUT) { transitionToNextFrame(gameTime); } } }
public LevelLifeCycleTransitionManager(IntroState introState, IncomingWaveState incomingWaveState, WaitingState waitingState, DivingWaveState divingWaveState, LevelEndState levelEndState) { AddState(introState) .AllowTransition(waitingState, _ => true) .Build(); AddState(incomingWaveState) .AllowTransition(waitingState, _ => true) .Build(); AddState(divingWaveState) .AllowTransition(waitingState, _ => true) .Build(); AddState(waitingState) .AllowTransition(levelEndState, context => context.LevelEndAchieved) .AllowTransition(incomingWaveState, context => context.HasWavesToIncome) .AllowTransition(divingWaveState, context => true) .Build(); }
private void Start() { _introState = IntroState.Loading; _starTime = Time.realtimeSinceStartup; _rotSpeed = 10; _lastDataCheck = -1; _storyPlaneId = 1; _webcamTex = new Texture2D(1920, 1080, TextureFormat.RGBA32, false); //_webcamTex = new Texture2D(1024, 768, TextureFormat.RGBA32, false); Planes.SetActive(false); _audioSource = GetComponent<AudioSource>(); _audioSource.clip = Resources.Load<AudioClip>("Audio/intro2"); _planeRenderer = Plane.GetComponent<Renderer>(); StoryPlane.transform.localScale = new Vector3(0.0001f, 0, 0.0001f); _tempTargetPos = new Vector3(Random.Range(-0.01f, 0.01f), Random.Range(-0.01f, 0.01f), _planeStartPos.z); var nextTex = Resources.Load<Texture2D>("Textures/Story/Story1"); StoryPlane.GetComponent<Renderer>().material.mainTexture = nextTex; _cccScriptLeft = leftCam.GetComponent<ColorCorrectionCurves>(); _cccScriptRight = rightCam.GetComponent<ColorCorrectionCurves>(); _grayScriptLeft = leftCam.GetComponent<Grayscale>(); _grayScriptRight = rightCam.GetComponent<Grayscale>(); _grayScriptLeft.enabled = false; _grayScriptRight.enabled = false; _twirlScriptLeft = leftCam.GetComponent<Twirl>(); _twirlScriptRight = rightCam.GetComponent<Twirl>(); _twirlScriptLeft.enabled = false; _twirlScriptRight.enabled = false; }
// Update is called once per frame void Update() { elapsedTime += Time.deltaTime; switch (state) { case IntroState.FadingIn: if (!fadeScript.FadingToClear) { skipHint.SetActive(true); state = IntroState.Playing; } break; case IntroState.Playing: if (InputManager.GetAnyControllerButtonWasPressed(InputControlType.Action2) || elapsedTime >= startFadingTime) { skipHint.SetActive(false); fadeScript.StartFadingToColor(1f); rsc.audioMng.FadeOutMusic(1f); state = IntroState.FadingOut; } break; case IntroState.FadingOut: if (!fadeScript.FadingToColor) { //SceneManager.LoadScene("Level01"); async.allowSceneActivation = true; } break; default: break; } }
// Start is called before the first frame update void Awake() { DontDestroyOnLoad(this); if (Instance != null) { GameObject obj = GameObject.Find("ServerManager"); DestroyImmediate(obj); } else { Instance = this; gameObject.name = "ServerManager_Orizin"; Begin(); m_Intro = new IntroState(); m_Login = new LoginState(); m_Chat = new ChatState(); m_Lobby = new LobbyState(); m_Player = new PlayerState(); m_Intro.Intro_Message(); } }
void Update() { switch (state) { case IntroState.Applause: if (timerEnd) { state = IntroState.CameraPan; NextCameraTarget(); textPanel.SetActive(false); timerEnd = false; } break; case IntroState.CameraPan: // we do not want to execute the coroutine while in a coroutine if (!cameraPanning) { // pan the camera to the next target if (camTarget >= 0) { MoveTo(cam.gameObject, players[camTarget].transform.position + camOffset, duration); } else { MoveTo(cam.gameObject, spawnPointCamera, duration); } } break; } if (Input.GetKeyDown(KeyCode.R)) { SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); } }
// Use this for initialization void Start() { scenario = new Scenario(); objectif = scenario.getObjectif(); Time.timeScale = 1; scriptIntroControl = this.GetComponent <IntroControl> (); scriptIntroControl.enabled = true; scriptIntroState = plane.GetComponent <IntroState> (); scriptIntroState.enabled = true; //intro script activation state = State.INTRO; scriptPlanePhysics = plane.GetComponent <PlanePhysics> (); scriptPlanePhysics.enabled = false; scriptSlidingBackground = backgrounds.GetComponent <SlidingBackground>(); scriptRandomObject = this.GetComponent <RandomObject> (); scriptRandomObject.enabled = false; scriptFuelControl = GetComponent <FuelControl>(); scriptFuelControl.enabled = true; prevY = scriptPlanePhysics.transform.position.y; isPause = false; guiBestScore.value = PlayerPrefs.GetInt(Constants.MAIN_GAME_HIGH_SCORE); tutoScript = tutoPref.GetComponent <GenericTutoScript>(); if (PlayerPrefs.GetInt(Constants.MAIN_GAME_ALREADY_PLAYED) == 0) { bouttonPause.GetComponent <Image> ().enabled = false; firstPlayTuto(); PlayerPrefs.SetInt(Constants.MAIN_GAME_ALREADY_PLAYED, 1); } else if (!scenario.isFinished()) { displayObjectif(); } }
public virtual IEnumerator<ITask> ReplaceHandler(Replace replace) { _state = replace.Body; replace.ResponsePort.Post(DefaultReplaceResponseType.Instance); yield break; }
void Update() { currentTimer += Time.deltaTime; switch (introState) { case IntroState.FadeIn: IntroScreens[currentScreen].color = new Color(1, 1, 1, currentTimer / FadeTimer); if (currentTimer >= FadeTimer) { currentTimer = 0; introState = IntroState.Show; IntroScreens[currentScreen].color = new Color(1, 1, 1, 1); } break; case IntroState.Show: if (currentTimer >= ShowTimer) { currentTimer = 0; introState = IntroState.FadeOut; } break; case IntroState.FadeOut: if (currentTimer >= FadeTimer) { ++currentScreen; currentTimer = 0; if (currentScreen < IntroScreens.Count) { IntroScreens[currentScreen - 1].color = new Color(1, 1, 1, 0); introState = IntroState.FadeIn; break; } else { Debug.Log("switching to " + NextSceneName); SceneManager.LoadScene(NextSceneName); break; } } IntroScreens[currentScreen].color = new Color(1, 1, 1, 1 - (currentTimer / FadeTimer)); break; } if (Input.anyKey) { ++currentScreen; if (currentScreen < IntroScreens.Count) { IntroScreens[currentScreen - 1].color = new Color(1, 1, 1, 0); // hide last screen currentTimer = 0; introState = IntroState.FadeIn; } else { SceneManager.LoadScene(NextSceneName); } } }
void Reset() { currentFade = Color.White * 0f; fadeIn = 1f; particleManager = new ParticleManager(); particleManager.LoadContent(Content); enemyManager = new EnemyManager(); enemyManager.LoadContent(Content, GraphicsDevice); enemyManager.Spawn(gameMap, planeFloorHight); itemManager = new ItemManager(); itemManager.LoadContent(Content, GraphicsDevice); itemManager.SpawnWorld(ItemType.Chute, ItemName.Chute, new Vector2((gameMap.Width * gameMap.TileWidth) - 650f, planeFloorHight-100f)); itemManager.SpawnRandom(10, planeFloorHight); //pilot = new Dude(new Vector2(100,100), true); pilot = new Dude(new Vector2((gameMap.Width * gameMap.TileWidth) - 400f, planeFloorHight), true); pilot.Scale = 2f; pilot.LoadContent(Content, GraphicsDevice); gameCamera.Position = pilot.Position; //sfxEngine.Stop(); sfxPanic.Stop(); sfxWind.Stop(); sfxPanic.Volume = 0.4f; sfxEngine.Volume = 1f; sfxWind.Volume = 0f; sfxEngine.Play(); sfxRattle.Play(); sfxRattle.Pause(); gameState = GameState.Intro; introState = IntroState.FadeIn; introTimer = 0; planeRot = 0f; planeRotTarget = 0f; planeAltitude = 35000; gradHeight = 0f; outroCameraOffset = 0f; tutorialTime = 15000; doorOpen = false; doorFrame = 0; parachuteOpenAmount = 0f; }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { KeyboardState cks = Keyboard.GetState(); // Allows the game to exit if (cks.IsKeyDown(Keys.Escape)) this.Exit(); if (this.IsActive) { switch (gameState) { case GameState.InGame: tutorialTime -= gameTime.ElapsedGameTime.TotalMilliseconds; speechBubble.Visible = false; if (cks.IsKeyDown(Keys.Left)) pilot.MoveLeftRight(-1); if (cks.IsKeyDown(Keys.Right)) pilot.MoveLeftRight(1); pilot.Attack(cks.IsKeyDown(Keys.Z)); if(cks.IsKeyDown(Keys.X) && !lks.IsKeyDown(Keys.X)) pilot.Pickup(); if (Helper.Random.Next(200) == 0 && pilot.IsInPlane) { rattleTime = Helper.Random.NextDouble() * 1000; gameCamera.Shake(rattleTime, Helper.RandomFloat(10f)); rattleTime += 1000; } if (rattleTime > 0) { if(sfxRattle.State== SoundState.Paused) sfxRattle.Resume(); rattleTime -= gameTime.ElapsedGameTime.TotalMilliseconds; if (rattleTime <= 0) sfxRattle.Pause(); } if (Helper.Random.Next(200) == 0) if (planeRotTarget >= -0.1f) planeRotTarget = Helper.RandomFloat(-0.3f, -0.1f); if (Helper.Random.Next(200) == 0) if (planeRotTarget < -0.1f) planeRotTarget = -0.1f; planeAltitude -= 1 + (int)(-50f * planeRot); gradHeight = ((texGradient.Height - GraphicsDevice.Viewport.Height) / 35000f) * (35000f - (float)planeAltitude); planeRot = (float)MathHelper.Lerp(planeRot, planeRotTarget, 0.01f); pilot.Update(gameTime, gameMap, pilot, planeRot, (doorOpen && doorFrame == 3)); enemyManager.Update(gameTime, gameCamera, gameMap, pilot, planeRot, (doorOpen && doorFrame==3)); CheckDoor(); if (doorOpen) { if (doorFrame < 3) { doorAnimTime += gameTime.ElapsedGameTime.TotalMilliseconds; if (doorAnimTime >= 200) { doorAnimTime = 0; doorFrame++; } } } if (planeAltitude <= 0 && pilot.IsInPlane) { planeAltitude = 0; gameState = GameState.Outro; fadingWhite = true; currentFade = Color.White * 0f; AudioController.PlaySFX("explode"); sfxPanic.Stop(); sfxEngine.Stop(); sfxRattle.Pause(); } if (!pilot.IsInPlane) { if (pilot.Position.Y < -400) { if (pilot.HasParachute && parachuteOpenAmount < 1f) parachuteOpenAmount += 0.1f; outroCameraRot = MathHelper.Lerp(outroCameraRot, 0f, 0.1f); } else outroCameraRot = planeRot; sfxWind.Play(); if (sfxPanic.Volume > 0f) sfxPanic.Volume = MathHelper.Clamp(sfxPanic.Volume - 0.01f, 0f, 1f); if (sfxEngine.Volume > 0f) sfxEngine.Volume = MathHelper.Clamp(sfxEngine.Volume - 0.01f, 0f, 1f); if (sfxWind.Volume < 1f) sfxWind.Volume = MathHelper.Clamp(sfxWind.Volume + 0.01f, 0f, 1f); //if (sfxWind.Volume == 1f) gameState = GameState.Outro; planeRotTarget = -0.5f; //planeRot = (float)MathHelper.Lerp(planeRot, planeRotTarget, 0.01f); //planeAltitude -= 1 + (int)(-50f * planeRot); //gradHeight = ((texGradient.Height - GraphicsDevice.Viewport.Height) / 35000f) * (35000f - (float)planeAltitude); if (planeAltitude <= 0) { if (outroCameraOffset > -100f) { outroCameraOffset -= (pilot.HasParachute?5f:20f); } else { if (!pilot.HasParachute) { fadingWhite = true; AudioController.PlaySFX("splat"); } else currentFade = Color.Black * 0f; introTimer = 0; gameState = GameState.Outro; if(pilot.HasParachute) speechBubble.Show(pilot.Position + new Vector2(0f, -280f), endingQuips[Helper.Random.Next(endingQuips.Length)]); sfxWind.Stop(); } } } break; #region Intro case GameState.Intro: //planeAltitude -= (int)(-300f * planeRot); if (fadeIn > 0f) fadeIn -= 0.01f; if ((cks.IsKeyDown(Keys.Space) && !lks.IsKeyDown(Keys.Space)) || (cks.IsKeyDown(Keys.Z)) && !lks.IsKeyDown(Keys.Z)) introTimer += 5000f; introTimer += gameTime.ElapsedGameTime.TotalMilliseconds; switch (introState) { case IntroState.FadeIn: if (introTimer > 5000) { introTimer = 0; gameCamera.Shake(1000, 20f); AudioController.PlaySFX("explode"); sfxPanic.Play(); introState = IntroState.PostExplosion; } break; case IntroState.PostExplosion: if (planeRot > -0.05f) planeRot -= 0.0001f; if (introTimer > 2000) { introTimer = 0; speechBubble.Show(pilot.Position + new Vector2(50f, -250f), "Mayday! Mayday! We're going down!"); introState = IntroState.Speech2; } break; case IntroState.Speech2: if (introTimer > 3000) { introTimer = 0; speechBubble.Show(pilot.Position + new Vector2(90f, -260f), "...And we've only got one parachute!"); introState = IntroState.Speech3; } break; case IntroState.Speech3: if (introTimer > 3000) { introTimer = 0; speechBubble.Show(pilot.Position + new Vector2(50f, -250f), "That parachute is mine, ensign."); introState = IntroState.Speech4; } break; case IntroState.Speech4: if (introTimer > 3000) { introTimer = 0; speechBubble.Show(pilot.Position + new Vector2(90f, -260f), "Haha, nope. See ya!"); introState = IntroState.IntoGame; } break; case IntroState.IntoGame: if (introTimer > 3000) { introTimer = 0; speechBubble.Visible = false; gameState = GameState.InGame; planeRotTarget = -0.1f; } break; } break; #endregion case GameState.Outro: if (planeAltitude <= 0) { if (pilot.HasParachute && !pilot.IsInPlane) { introTimer += gameTime.ElapsedGameTime.TotalMilliseconds; if (introTimer > 3000) { speechBubble.Visible = false; currentFade = Color.Lerp(currentFade, Color.Black * 1f, 0.05f); if (currentFade.R < 30 && currentFade.A > 230) { currentFade = Color.Black * 1f; introTimer += gameTime.ElapsedGameTime.TotalMilliseconds; if (introTimer >= 3000) Reset(); } } } else { if (fadingWhite) { currentFade = Color.Lerp(currentFade, Color.White * 1f, 0.1f); if (currentFade.A > 230) fadingWhite = false; } else { currentFade = Color.Lerp(currentFade, Color.Black * 1f, 0.05f); if (currentFade.R < 30 && currentFade.A > 230) { currentFade = Color.Black * 1f; introTimer += gameTime.ElapsedGameTime.TotalMilliseconds; if (introTimer >= 5000) Reset(); } } } } break; } if (Helper.Random.Next(10) == 0) { float zindex = Helper.RandomFloat(0f, 1f); if (planeAltitude > 1000) { if (pilot.IsInPlane) { particleManager.Add(ParticleType.Cloud, new Vector2((gameMap.Width * gameMap.TileWidth) + (GraphicsDevice.Viewport.Width / 2), Helper.RandomFloat(700f, (gameMap.Height * gameMap.TileHeight))), new Vector2(-zindex * (20f), -0.1f + planeRot), 30000f * (1f - zindex), false, new Rectangle(0, 0, 400, 200), 0f, Color.White, zindex); } else { if(planeAltitude>3000) particleManager.Add(ParticleType.Cloud, new Vector2(Helper.RandomFloat(pilot.Position.X - (GraphicsDevice.Viewport.Width / 2), pilot.Position.X + (GraphicsDevice.Viewport.Width / 2)), pilot.Position.Y + 400f), new Vector2(0f, (pilot.HasParachute?-40f:-40f) - zindex * (20f)), 30000f * (1f - zindex), false, new Rectangle(0, 0, 400, 200), 0f, Color.White, zindex); } } } gradHeight = MathHelper.Clamp(gradHeight, 0f, (texGradient.Height - GraphicsDevice.Viewport.Height)); gameCamera.Rotation = pilot.IsInPlane ? planeRot : outroCameraRot; gameCamera.Target = pilot.Position + new Vector2(0f,outroCameraOffset);// -new Vector2(GraphicsDevice.Viewport.Width / 2, 550f); gameCamera.Update(gameTime); particleManager.Update(gameTime, gameMap, pilot.IsInPlane?planeRot:0f); itemManager.Update(gameTime, gameCamera, gameMap, pilot, planeRot); sfxEngine.Pitch = MathHelper.Clamp(-0.5f + ((-planeRot) * 8f), -1f, 1f); } lks = cks; base.Update(gameTime); }
/// <summary> /// Service Start /// </summary> protected override void Start() { // TT Dec-2006 - Setup for initial state // The state might already have been created using // the Initial State Partner above. If so, then we // don't want to create a new one! if (_state == null) { _state = new IntroState(); // Do any other initialization here for the default // settings that you might want ... } // There should be some code in here to validate the settings // from the config file just in case the user entered some // invalid values ... // Now save the State // This creates a new file the first time it is run. // Later, it re-reads the existing file, but by then // the file has been populated with the default values. SaveState(_state); // Listen on the main port for requests and call the appropriate handler. ActivateDsspOperationHandlers(); // Robotics Tutorial Step 3 -- Service Startup Initialization // Start() is a required method that was created by // dssnewservice. We need to modify it. // Start listening for bumpers // See the method code below SubscribeToBumpers(); // Publish the service to the local Node Directory DirectoryInsert(); // display HTTP service Uri LogInfo(LogGroups.Console, "Service uri: "); }
private void transitionToNextFrame(GameTime time) { startTime = (int)time.TotalGameTime.TotalMilliseconds; state = IntroState.Transitioning; }
public void OnInitSuccess() { if (!LoginManager.Instance.IsLoggedIn) { state = IntroState.LoginType; } }
protected override void OnSetupState() { _currentState = IntroState.None; }
public void OnNoLoginClick() { LoginManager.Instance.loginType = LoginManager.LoginType.ActiveNoLogin; state = IntroState.ReadyToPlay; }
public override void OnVisible() { base.OnVisible(); if (LoginManager.Instance.loginType == LoginManager.LoginType.NotLoggedIn) { if (!LoginManager.Instance.IsInitialized) { LoginManager.Instance.Initialize(); } else { Debug.LogFormat("[{0}]: Login Manager is already Initialized", name); } if (!LoginManager.Instance.IsLoggedIn) { // Display Login Options } else { Debug.LogFormat("[{0}]: User in not logged in", name); // Display Tap to Play Message } } else { state = IntroState.ReadyToPlay; } }
private void Update() { switch (_introState) { case IntroState.Loading: if (Time.realtimeSinceStartup - _starTime > 1) if (!Config.InitializedOCV) Config.InitOpenCV(); if (Config.InitializedOCV && Config.CamDataUpdate > 0 && Config.CamDataUpdate > _lastDataCheck) { _introState = IntroState.Calibration; LoadingRect.SetActive(false); CalibRect.SetActive(true); Application.LoadLevel("Game"); } break; case IntroState.Calibration: if (Config.CamDataUpdate > 0 && Config.CamDataUpdate > _lastDataCheck) { _lastDataCheck = Config.CamDataUpdate; if (Config.CamData.Length > 0) { _webcamTex.LoadRawTextureData(Config.CamData); _webcamTex.Apply(); WebcamTex.texture = _webcamTex; _planeRenderer.material.mainTexture = _webcamTex; } } var timeLeft = 5f; if (Config.LastShape == SHAPETYPE.Star) { timeLeft = 5 - (Time.realtimeSinceStartup - _starTime); if (timeLeft <= 0) { _introState = IntroState.Transport; _starTime = Time.realtimeSinceStartup; _twirlScriptLeft.enabled = true; _twirlScriptRight.enabled = true; CalibRect.SetActive(false); Planes.SetActive(true); Config.PauseOpenCV(); Config.PauseCam(); } } else _starTime = Time.realtimeSinceStartup; var timeLeftClamped = (int) Mathf.Clamp(timeLeft, 0, 5); TimeText.text = timeLeftClamped + ((timeLeftClamped == 1) ? " Sekunde" : " Sekunden"); break; case IntroState.Transport: Plane.transform.position = Vector3.Lerp(Plane.transform.position, _bgPlaneTargetPos, Time.deltaTime); _rotSpeed *= SpeedIncrease; if (_rotSpeed < MaxRotSpeed) _rotSpeed *= SpeedIncrease; Plane.transform.Rotate(new Vector3(0, 1, 0), _rotSpeed*Time.deltaTime); _twirlScriptLeft.angle += AngleIncrease*Time.deltaTime; _twirlScriptRight.angle += AngleIncrease * Time.deltaTime; if (_cccScriptLeft.saturation >= 0) { _cccScriptLeft.saturation -= SaturationDecrease*Time.deltaTime; _cccScriptRight.saturation -= SaturationDecrease*Time.deltaTime; } else { if (!_grayScriptLeft.enabled) { _grayScriptLeft.enabled = true; _grayScriptRight.enabled = true; } _grayScriptLeft.rampOffset += RampIncrease*Time.deltaTime; _grayScriptRight.rampOffset += RampIncrease * Time.deltaTime; } if (_grayScriptLeft.rampOffset > 1.0f) { _planeRenderer.material.mainTexture = WormholeTex; _introState = IntroState.Wormhole; _rotSpeed = 3; } break; case IntroState.Wormhole: Plane.transform.Rotate(new Vector3(0, 1, 0), _rotSpeed*Time.deltaTime); if (_grayScriptLeft.rampOffset >= 0) { _grayScriptLeft.rampOffset -= RampIncrease * Time.deltaTime; _grayScriptRight.rampOffset -= RampIncrease * Time.deltaTime; } else { if (_grayScriptLeft.enabled) { _grayScriptLeft.enabled = false; _grayScriptRight.enabled = false; } if (_cccScriptLeft.saturation < 0.4f) { _cccScriptLeft.saturation += SaturationDecrease*Time.deltaTime; _cccScriptRight.saturation += SaturationDecrease*Time.deltaTime; } else { _cccScriptLeft.saturation = 0.45f; _cccScriptRight.saturation = 0.45f; } if (_twirlScriptLeft.angle - AngleIncrease*Time.deltaTime > 0) { _twirlScriptLeft.angle -= AngleIncrease*Time.deltaTime; _twirlScriptRight.angle -= AngleIncrease * Time.deltaTime; } else { _twirlScriptLeft.enabled = false; _twirlScriptRight.enabled = false; } } if (_cccScriptLeft.saturation > 0.4f && !_twirlScriptLeft.enabled) { _introState = IntroState.Story; _audioSource.Play(); } break; case IntroState.Story: Plane.transform.Rotate(new Vector3(0, 1, 0), _rotSpeed * Time.deltaTime); StoryPlane.transform.localScale = Vector3.Lerp(StoryPlane.transform.localScale, _planeTargetSize, Time.deltaTime); if (StoryPlane.transform.localScale.x >= 0.14f) { _starTime = Time.realtimeSinceStartup; _introState = IntroState.StoryStay; } break; case IntroState.StoryStay: Plane.transform.Rotate(new Vector3(0, 1, 0), _rotSpeed * Time.deltaTime); if (Time.realtimeSinceStartup - _starTime >= ClipLength[_storyPlaneId-1]) { StoryPlane.transform.localScale = Vector3.Lerp(StoryPlane.transform.localScale, _planeTargetSizeMax, Time.deltaTime); StoryPlane.transform.position = Vector3.Lerp(StoryPlane.transform.position, _storyPlaneId%2 == 0 ? _planeOddPos : _planeEvenPos, Time.deltaTime); if (StoryPlane.transform.localScale.x >= 0.34f) { if (_storyPlaneId < 6) { _storyPlaneId++; StoryPlane.transform.position = _planeStartPos; StoryPlane.transform.localScale = new Vector3(0.0001f, 0, 0.0001f); var nextTex = Resources.Load<Texture2D>("Textures/Story/Story" + _storyPlaneId); StoryPlane.GetComponent<Renderer>().material.mainTexture = nextTex; _introState = IntroState.Story; } else _introState = IntroState.Start; } } else { StoryPlane.transform.localPosition = Vector3.Lerp(StoryPlane.transform.localPosition, _tempTargetPos, Time.deltaTime * 2); var dist = Vector3.Distance(StoryPlane.transform.localPosition, _tempTargetPos); if (dist < 0.001f) _tempTargetPos = new Vector3(Random.Range(-0.01f, 0.01f), Random.Range(-0.01f, 0.01f), _planeStartPos.z); } break; case IntroState.Start: Config.ResumeOpenCV(); Application.LoadLevel("Game"); break; } }
public void Update(GameTime gameTime) { if (timer > 500) { foreach (Player player in GameServices.GetService<List<Player>>()) { if (Keyboard.GetState().IsKeyDown(player.PlayerControls.MenuSelect)) { StateProvider.Instance.State = GameState.MENU; } } } timer += gameTime.ElapsedGameTime.TotalMilliseconds; switch (State) { case IntroState.FADING_IN: Opacity += (1f / (float) FadeInTime) * (float) gameTime.ElapsedGameTime.TotalMilliseconds; if (timer > FadeInTime) { timer = 0; State = IntroState.VISIBLE; } break; case IntroState.VISIBLE: Opacity = 1; if (timer > VisibleTime) { timer = 0; State = IntroState.FADING_OUT; } break; case IntroState.FADING_OUT: Opacity -= (1f / (float) FadeOutTime) * (float) gameTime.ElapsedGameTime.TotalMilliseconds; if(timer > FadeOutTime) { StateProvider.Instance.State = GameState.MENU; } break; } }
// Use this for initialization void Start() { scenario = new Scenario (); objectif = scenario.getObjectif(); Time.timeScale = 1; scriptIntroControl = this.GetComponent<IntroControl> (); scriptIntroControl.enabled = true; scriptIntroState = plane.GetComponent<IntroState> (); scriptIntroState.enabled = true; //intro script activation state = State.INTRO; scriptPlanePhysics = plane.GetComponent<PlanePhysics> (); scriptPlanePhysics.enabled = false; scriptSlidingBackground = backgrounds.GetComponent<SlidingBackground>(); scriptRandomObject = this.GetComponent<RandomObject> (); scriptRandomObject.enabled = false; scriptFuelControl = GetComponent<FuelControl>(); scriptFuelControl.enabled = true; prevY = scriptPlanePhysics.transform.position.y; isPause = false; guiBestScore.value = PlayerPrefs.GetInt (Constants.MAIN_GAME_HIGH_SCORE); tutoScript = tutoPref.GetComponent<GenericTutoScript>(); if (PlayerPrefs.GetInt (Constants.MAIN_GAME_ALREADY_PLAYED) == 0) { bouttonPause.GetComponent<Image> ().enabled = false; firstPlayTuto (); PlayerPrefs.SetInt (Constants.MAIN_GAME_ALREADY_PLAYED, 1); } else if (! scenario.isFinished()){ displayObjectif(); } }