public void UpdateTutorial(TutorialState state) { curState = state; if (curState == TutorialState.Shape) { tutorialSP.sprite = tutorialImages[1]; tutorialSP.enabled = true; } else if (curState == TutorialState.Move) { tutorialSP.sprite = tutorialImages[0]; tutorialSP.enabled = true; } else if (curState == TutorialState.Rotate) { tutorialSP.sprite = tutorialImages[3]; tutorialSP.enabled = true; } else if (curState == TutorialState.Scale) { tutorialSP.sprite = tutorialImages[2]; tutorialSP.enabled = true; } else { tutorialSP.enabled = false; } }
void Awake() { Instance = this; currentState = initialState; currentState.Initialize(); SkillNodesDisabled = true; }
public void ShowText(string text, string speaker, float showtime, TutorialState state) { displayText = text; speakerName = speaker; end_t = Time.time + showtime; callbackState = state; a.volume = 1; a.Play(); draw = true; }
// Use this for initialization void Start () { if (!LevelManager.GetLoadedLevel().name.Equals("Tutorial")) { label.gameObject.SetActive(false); overlay.enabled = false; this.gameObject.SetActive(false); } currentState = states[0]; overlay.gameObject.SetActive(true); label.text = "Press R2 to boost!"; spaceship = GameplayManager.spaceship; }
public void Init() { bIsTutorial = true; tutorialState = (int)TutorialState.Start; // Deactive all enemy nutrients by default EnemyNutrients = GameObject.FindGameObjectsWithTag ("EnemyMainNutrient"); for (int i = 0; i < 10; i++) EnemyNutrients [i].SetActive (false); }
/** * The update method when we are on FREEZE mode */ private void freeze() { timerFreeze += Time.deltaTime; //Debug.Log (timerFreeze); if (timerFreeze >= maxTimerFreeze) { Destroy(tutoUIInstance); state = TutorialState.NORMAL; Time.timeScale = 1.0f; timerFreeze = 0.0f; } }
void SetState( TutorialState state ) { switch(state) { case TutorialState.INTRO: timer = 5f; break; case TutorialState.SLICE_APPLE: timer = 15f; break; default: break; } }
// Update is called once per frame void Update () { if (currentState == TutorialState.TEACH_BOOST && spaceship.boosting) { overlay.gameObject.SetActive(false); currentState = TutorialState.TEACH_DRIFT; } else if (enteredTeachDriftZone) { overlay.gameObject.SetActive(true); label.text = "Hold L2 when turning to drift!"; currentState = TutorialState.TEACH_DRIFT; enteredTeachDriftZone = false; } if (currentState == TutorialState.TEACH_DRIFT && spaceship.drifting) { overlay.gameObject.SetActive(false); currentState = TutorialState.DONE; } }
void UIToggle() { switch (currentTutorialState) { case TutorialState.jump: LevelManager.manager.DisablePlayer(); jumpText.enabled = true; currentTutorialState=TutorialState.idle; break; case TutorialState.grab: StartCoroutine(Wait(grabText)); break; case TutorialState.drag: StartCoroutine(Wait(dragText)); break; case TutorialState.drag2: StartCoroutine(Wait(dragTextHorizontal)); break; case TutorialState.superJump: StartCoroutine(Wait(superJumpText)); break; case TutorialState.MB: StartCoroutine(Wait(mbText)); break; case TutorialState.teleport: StartCoroutine(Wait(teleportText)); break; case TutorialState.idle: default: break; } }
private void HitBall(int index, Vector velocity) { switch (currentState) { case TutorialState.HITME: if (index == 0) { instructionBlock.Text = "Great!\nHit the block to start!"; bird1.Opacity = 0; bird2.Opacity = 1; currentState = TutorialState.HITMEAGAIN; } break; case TutorialState.HITMEAGAIN: if (index == 1) { startBrickAnimation(); } currentState = TutorialState.END; break; } }
private void TutorialView_Loaded(object sender, RoutedEventArgs e) { RegisterGestures(); currentState = TutorialState.HITME; }
public bool GetStateValue(TutorialState state) { return(states[state].Value); }
public string GetStateText(TutorialState state) { return(states[state].Text); }
/** * Launch the FREEZE mode, adding the tutorial on te screen */ private void launchFreeze(string text, string imagePath) { tutoUIInstance = Instantiate(tutoUIPrefab) as GameObject; TutorialUIManager uiMan = tutoUIInstance.GetComponent<TutorialUIManager> (); uiMan.setText (text); uiMan.setImage (imagePath); state = TutorialState.FREEZE; Time.timeScale = freezeTimeScale; timerNormal = 0.0f; }
public List <XboxButton> GetStateButtons(TutorialState state) { return(states[state].Buttons); }
void Update() { // Update the tutorial state if (tutorialState == TutorialState.Start && playerNutrient != null) { StartCoroutine (PlayerNutrientSpawned ()); tutorialState = TutorialState.PlayerNutrientSpawned; } else if (tutorialState == TutorialState.PlayerNutrientCollected && Time.timeScale != 1f) { Time.timeScale = 1f; StartCoroutine (PlayerNodeTapWaiting ()); } else if (tutorialState == TutorialState.PlayerNodeTapCompleted && Time.timeScale != 1f) { Time.timeScale = 1f; StartCoroutine (PlayerNodeHoldWaiting ()); } else if (tutorialState == TutorialState.PlayerNodeHoldCompleted && Time.timeScale != 1f) { Time.timeScale = 1f; StartCoroutine (PlayerNodeCommandWaiting ()); } else if (tutorialState == TutorialState.PlayerNodeCommandCompleted && Time.timeScale != 1f) { Time.timeScale = 1f; StartCoroutine (SquadCaptainSpawnWaiting ()); } else if (tutorialState == TutorialState.SquadCaptainSpawnCompleted && Time.timeScale != 1f) { Time.timeScale = 1f; StartCoroutine (EnemyMainProductionWaiting ()); } else if (tutorialState == TutorialState.EnemyMainProductionCompleted && Time.timeScale != 1f) { Time.timeScale = 1f; StartCoroutine (EnemyMainDefendWaiting ()); } else if (tutorialState == TutorialState.EnemyMainDefendCompleted && Time.timeScale != 1f) { Time.timeScale = 1f; StartCoroutine (EnemyMainCautiousAttackWaiting ()); } else if (tutorialState == TutorialState.EnemyMainCautiousAttackCompleted && Time.timeScale != 1f) { Time.timeScale = 1f; StartCoroutine (EnemyMainAggressiveAttackWaiting ()); } else if (tutorialState == TutorialState.EnemyMainAggressiveAttackCompleted && Time.timeScale != 1f) { Time.timeScale = 1f; StartCoroutine (EnemyMainLandmineWaiting ()); } }
private void OnApplicationQuit() { instance = null; }
public void ChangeState(TutorialState nextState) { currentState = nextState; currentState.Initialize(); }
public void NextState() { curState = qStates.Dequeue() as TutorialState; curState.Run(); }
void SwitchToToggle1() { state = TutorialState.Toggle1; board.SetBoard(BoardState.FromToggles(new List<int>() { 7 })); scAttack.Hide(); scToggle1.Show(); player.canCharge = true; player.restrictedCharge = board.getSquare(7); arrow = Instantiate(ArrowTemplate) as GameObject; arrow.transform.position = player.restrictedCharge.transform.position; }
/// <summary> /// Called while this is shown /// </summary> /// <param name="overallState">Access to all state</param> /// <param name="delta">Elapsed time</param> public void Process(TutorialState overallState, float delta) { Time += delta; OnProcess(overallState, delta); }
/// <summary> /// Checks (and handles) tutorial events that this tutorial reacts to /// </summary> /// <param name="overallState">State access to all the tutorials</param> /// <param name="eventType">Type of the event that happened</param> /// <param name="args">Event arguments or EventArgs.Empty</param> /// <param name="sender">The object that sent the event</param> /// <returns>True if handled (no other tutorial gets to see it), false if wasn't handled / consumed.</returns> public abstract bool CheckEvent(TutorialState overallState, TutorialEventType eventType, EventArgs args, object sender);
public void SetStateValue(TutorialState state, bool value) { states[state].Value = value; }
// this function sets the next state for our state machine public void SetState(TutorialState newState) { // set the new current state currTutState = newState; // play success sound, we have made progress audioSource.PlayOneShot(correctSFX); // then we enable the next stages of the tutorial based on the current state switch (currTutState) { case TutorialState.Elevate: elevatorScript.enabled = true; break; case TutorialState.Grabbing: Tutorial1_Stage.SetActive(false); Tutorial2_Stage.SetActive(true); player.transform.position = playerStartPos; grabScriptL.enabled = true; grabScriptR.enabled = true; break; case TutorialState.Spawn_MetalPlank: Tutorial2_Stage.SetActive(false); Tutorial3_Stage.SetActive(true); player.transform.position = playerStartPos; menuScript.enabled = true; break; case TutorialState.Spawn_WoodPlank: Tutorial3_Stage.SetActive(false); Tutorial4_Stage.SetActive(true); player.transform.position = playerStartPos; menuScript.objects[1].count = 1; break; case TutorialState.Spawn_Funnel: Tutorial4_Stage.SetActive(false); Tutorial5_Stage.SetActive(true); player.transform.position = playerStartPos; menuScript.objects[2].count = 1; break; case TutorialState.Spawn_Trampoline: Tutorial5_Stage.SetActive(false); Tutorial6_Stage.SetActive(true); player.transform.position = playerStartPos; menuScript.objects[3].count = 1; break; case TutorialState.Spawn_Portal: Tutorial6_Stage.SetActive(false); Tutorial7_Stage.SetActive(true); player.transform.position = playerStartPos; menuScript.objects[4].count = 1; break; case TutorialState.Complete: levelLoader.Trigger(); break; default: break; } }
/// <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) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) this.Exit(); lastKs = ks; ks = Keyboard.GetState(); Keys[] keys = ks.GetPressedKeys(); lastMs = ms; ms = Mouse.GetState(); switch (currentGameState) { //Display all tutorial messages in succession. case GameState.Tutorial: if (ks.IsKeyDown(Keys.Space) && lastKs.IsKeyUp(Keys.Space)) { switch (currentTutorialState) { case TutorialState.Tutorial1: currentTutorialState = TutorialState.Tutorial2; break; case TutorialState.Tutorial2: currentTutorialState = TutorialState.Tutorial3; break; case TutorialState.Tutorial3: currentTutorialState = TutorialState.Tutorial4; break; case TutorialState.Tutorial4: currentTutorialState = TutorialState.Tutorial5; break; case TutorialState.Tutorial5: currentTutorialState = TutorialState.Tutorial6; break; case TutorialState.Tutorial6: currentGameState = GameState.Play; break; } } break; //Main menu state. case GameState.MainMenu: if (btnArray[0].isClicked == true) { currentGameState = GameState.Tutorial; MediaPlayer.Stop(); MediaPlayer.Play(gameMusic); MediaPlayer.IsRepeating = true; } else if (btnArray[1].isClicked == true) { currentGameState = GameState.Controls; if (btnBack.isClicked == true) btnBack.isClicked = false; } else if (btnArray[2].isClicked == true) this.Exit(); btnArray[0].Update(ms); btnArray[1].Update(ms); btnArray[2].Update(ms); break; case GameState.Controls: if (btnBack.isClicked == true) { currentGameState = GameState.MainMenu; btnArray[1].isClicked = false; } btnBack.Update(ms); break; case GameState.Play: //Resets the tanks and map wall data in case of bugs. if (resetTanks) { m1 = new Map(tiles); t1 = new Tank(tankTex, new Vector2(80, 60), 3); ets.Clear(); ets.Add(new EnemyTanks(tankTex, new Vector2(80, 600), 1)); ets.Add(new EnemyTanks(tankTex, new Vector2(1180, 600), 2)); ets[1].ChassisAngle = -90; ets[1].CannonAngle = -90; ets.Add(new EnemyTanks(tankTex, new Vector2(1180, 60), 0)); ets[2].ChassisAngle = -180; ets[2].CannonAngle = -180; resetTanks = false; } //Update particle emitters for enemy tanks (displayed when tanks are defeated). for (int i = 0; i < 3; i++) { explosions[i].Update(); explosions[i].EmitterLocation = ets[i].Position; } //If player tank is defeated, switch to game over. if (t1.livesRemaining <= 0) { currentGameState = GameState.Lose; } //Updated timers for enemy tanks. and update their frames. timer0 += (float)gameTime.ElapsedGameTime.TotalMilliseconds; timer1 += (float)gameTime.ElapsedGameTime.TotalMilliseconds; timer2 += (float)gameTime.ElapsedGameTime.TotalMilliseconds; for (int i = 0; i < 3; i++) { switch (i) { case 0: if (timer0 > interval && ets[i].LivesRemaining > 0) { if (!ets[i].Still) { ets[i].CurrentFrame++; ets[i].updateRectangles(); timer0 = 0f; } } if (ets[i].CurrentFrame == 2 && ets[i].LivesRemaining > 0) { if (!ets[i].Still) { ets[i].CurrentFrame = 0; ets[i].updateRectangles(); } } break; case 1: if (timer1 > interval && ets[i].LivesRemaining > 0) { if (!ets[i].Still) { ets[i].CurrentFrame++; ets[i].updateRectangles(); timer1 = 0f; } } if (ets[i].CurrentFrame == 2 && ets[i].LivesRemaining > 0) { if (!ets[i].Still) { ets[i].CurrentFrame = 0; ets[i].updateRectangles(); } } break; case 2: if (timer2 > interval && ets[i].LivesRemaining > 0) { if (!ets[i].Still) { ets[i].CurrentFrame++; ets[i].updateRectangles(); timer2 = 0f; } } if (ets[i].CurrentFrame == 2 && ets[i].LivesRemaining > 0) { if (!ets[i].Still) { ets[i].CurrentFrame = 0; ets[i].updateRectangles(); } } break; default: break; } //Check if enemy tanks found targets. If one is found, create new bullets to fire. bool willShoot = ets[i].scan(t1, ets); if (willShoot) { switch (i) { case 0: if (canFire0) { bm.createBullet(ets[i].TankColor, ets[i].Position, new Vector2(ets[i].Target.Position.X, ets[i].Target.Position.Y)); canFire0 = false; cdBar1.cd = 0; //Update cooldownt timer. } ets[i].FoundTarget = false; break; case 1: if (canFire1) { bm.createBullet(ets[i].TankColor, ets[i].Position, new Vector2(ets[i].Target.Position.X, ets[i].Target.Position.Y)); canFire1 = false; cdBar2.cd = 0; } ets[i].FoundTarget = false; break; case 2: if (canFire2) { bm.createBullet(ets[i].TankColor, ets[i].Position, new Vector2(ets[i].Target.Position.X, ets[i].Target.Position.Y)); canFire2 = false; cdBar3.cd = 0; } ets[i].FoundTarget = false; break; default: break; } } //If enemy tank found player, seek player. Else, wander. if (ets[i].Target != null && ets[i].Target == t1) { ets[i].Seek(m1, t1, ets); } else { ets[i].Wander(m1, t1, ets); } } //Remove mosue visibility (for targeting reticle display) IsMouseVisible = false; //Mouse input handler. if (lastMs.LeftButton == ButtonState.Released && ms.LeftButton == ButtonState.Pressed) { if (canPlayerFire) { bm.createBullet(t1.TankColor, t1.Position, new Vector2(Mouse.GetState().X, Mouse.GetState().Y)); canPlayerFire = false; cdBar.cd = 0; } } //Update all cooldown bars. if (cdBar.cd == 0) { while (cdBar.cd < playerFireCount) cdBar.cd++; } else if (cdBar.cd >= playerFireCount) { cdBar.cd = playerFireCount; } if (cdBar1.cd == 0) { while (cdBar1.cd < fireCount0) cdBar1.cd++; } else if (cdBar1.cd >= fireCount0) { cdBar1.cd = fireCount0; } if (cdBar2.cd == 0) { while (cdBar2.cd < fireCount1) cdBar2.cd++; } else if (cdBar2.cd >= fireCount1) { cdBar2.cd = fireCount1; } if (cdBar3.cd == 0) { while (cdBar3.cd < fireCount2) cdBar3.cd++; } else if (cdBar3.cd >= fireCount2) { cdBar3.cd = fireCount2; } //Input handler. foreach (Keys key in keys) { switch (key) { //Forward motion. case Keys.W: playerTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (playerTimer > interval) { //Show the next frame t1.CurrentFrame++; t1.updateRectangles(); //Reset the timer playerTimer = 0f; } if (t1.CurrentFrame == 2) { t1.CurrentFrame = 0; t1.updateRectangles(); } t1.Position += new Vector2((float)Math.Cos((t1.ChassisAngle)) * step, (float)Math.Sin((t1.ChassisAngle)) * step); t1.updateSpheres(); //Check for collisions with walls after movement. If collides, undo movement. foreach(BoundingSphere b in m1.Walls) { for (int i = 0; i < t1.Spheres.Count; i++) { int x = (int)Math.Floor(t1.Spheres[i].Center.X / 20); int y = (int)Math.Floor(t1.Spheres[i].Center.Y / 20); if (t1.Spheres[i].Intersects(b)) { t1.Position -= new Vector2((float)Math.Cos((t1.ChassisAngle)) * step, (float)Math.Sin((t1.ChassisAngle)) * step); t1.updateSpheres(); break; } } } //Check for collisions with other tanks after movement. If collides, undo movement. foreach (EnemyTanks et in ets) { if ((t1.Position - et.Position).Length() <= 65) { for (int i = 0; i < t1.Spheres.Count; i++) { for (int j = 0; j < et.Spheres.Count; j++) { if (t1.Spheres[i].Intersects(et.Spheres[j])) { t1.Position -= new Vector2((float)Math.Cos((t1.ChassisAngle)) * step, (float)Math.Sin((t1.ChassisAngle)) * step); t1.updateSpheres(); break; } } } } } break; //Same procedures as forward motion. case Keys.S: playerTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (playerTimer > interval) { //Show the next frame t1.CurrentFrame++; t1.updateRectangles(); //Reset the timer playerTimer = 0f; } if (t1.CurrentFrame == 2) { t1.CurrentFrame = 0; t1.updateRectangles(); } t1.Position -= new Vector2((float)Math.Cos((t1.ChassisAngle)) * step, (float)Math.Sin((t1.ChassisAngle)) * step); t1.updateSpheres(); foreach (BoundingSphere b in m1.Walls) { for (int i = 0; i < t1.Spheres.Count; i++) { if (t1.Spheres[i].Intersects(b)) { t1.Position += new Vector2((float)Math.Cos((t1.ChassisAngle)) * step, (float)Math.Sin((t1.ChassisAngle)) * step); t1.updateSpheres(); break; } } } foreach (EnemyTanks et in ets) { if ((t1.Position - et.Position).Length() <= 65) { for (int i = 0; i < t1.Spheres.Count; i++) { for (int j = 0; j < et.Spheres.Count; j++) { if (t1.Spheres[i].Intersects(et.Spheres[j])) { t1.Position += new Vector2((float)Math.Cos((t1.ChassisAngle)) * step, (float)Math.Sin((t1.ChassisAngle)) * step); t1.updateSpheres(); break; } } } } } break; //A and D keys rotate. case Keys.A: t1.ChassisAngle -= 0.03f; t1.updateRectangles(); t1.updateSpheres(); foreach (BoundingSphere b in m1.Walls) { for (int i = 0; i < t1.Spheres.Count; i++) { if (t1.Spheres[i].Intersects(b)) { t1.ChassisAngle += 0.03f; t1.updateRectangles(); t1.updateSpheres(); break; } } } foreach (EnemyTanks et in ets) { if ((t1.Position - et.Position).Length() <= 65) { for (int i = 0; i < t1.Spheres.Count; i++) { for (int j = 0; j < et.Spheres.Count; j++) { if (t1.Spheres[i].Intersects(et.Spheres[j])) { t1.ChassisAngle += 0.03f; t1.updateSpheres(); break; } } } } } break; case Keys.D: t1.ChassisAngle += 0.03f; t1.updateRectangles(); t1.updateSpheres(); foreach (BoundingSphere b in m1.Walls) { for (int i = 0; i < t1.Spheres.Count; i++) { if (t1.Spheres[i].Intersects(b)) { t1.ChassisAngle -= 0.03f; t1.updateRectangles(); t1.updateSpheres(); break; } } } foreach (EnemyTanks et in ets) { if ((t1.Position - et.Position).Length() <= 65) { for (int i = 0; i < t1.Spheres.Count; i++) { for (int j = 0; j < et.Spheres.Count; j++) { if (t1.Spheres[i].Intersects(et.Spheres[j])) { t1.ChassisAngle -= 0.03f; t1.updateSpheres(); break; } } } } } break; //Debug controls. Space key displays positions of bounding spheres on tank. //U key resets the tanks and map wall data. case Keys.Space: if (lastKs.IsKeyUp(Keys.Space)) { Tank.DrawBSPheres = !Tank.DrawBSPheres; } break; case Keys.U: if (lastKs.IsKeyUp(Keys.U)) { resetTanks = true; } break; } } //Compute player tank's cannon angle based on mouse position. Vector2 playerAim = new Vector2(Mouse.GetState().X, Mouse.GetState().Y) - new Vector2(t1.Position.X, t1.Position.Y); if (Mouse.GetState().X > t1.Position.X && Mouse.GetState().Y > t1.Position.Y) { t1.CannonAngle = (float)Math.Atan2(playerAim.Y, playerAim.X); } else { t1.CannonAngle = (float)Math.Atan2(playerAim.Y, playerAim.X); } //Update cooldown timers tanks. if (playerFireCount > 0 && !canPlayerFire) { playerFireCount--; } else { canPlayerFire = true; playerFireCount = 100; } if (fireCount0 > 0 && !canFire0) { fireCount0--; ets[0].Target = null; } else { canFire0 = true; fireCount0 = 100; } if (fireCount1 > 0 && !canFire1) { fireCount1--; ets[1].Target = null; } else { canFire1 = true; fireCount1 = 100; } if (fireCount2 > 0 && !canFire2) { fireCount2--; ets[2].Target = null; } else { canFire2 = true; fireCount2 = 100; } //Update all active bullets. bm.update(m1, t1, ets); break; } base.Update(gameTime); }
/// <summary> /// This is for subclasses to add custom process behaviour /// </summary> protected virtual void OnProcess(TutorialState overallState, float delta) { }
private GameProperties() { GameWorld = new GameWorld(new WorldGenerationSettings()); TutorialState = new TutorialState(); }
void SwitchToToggle2() { state = TutorialState.Toggle2; board.SetBoard(BoardState.FromToggles(new List<int>() { 17, 22 })); player.restrictedCharge = board.getSquare(17); arrow.transform.position = player.restrictedCharge.transform.position; scToggle1.Hide(); scToggle2.Show(); }
public override void _Process(float delta) { FluidSystem.Process(delta); TimedLifeSystem.Process(delta); ProcessSystem.Process(delta); microbeAISystem.Process(delta); if (gameOver) { guidanceLine.Visible = false; // Player is extinct and has lost the game // Show the game lost popup if not already visible HUD.ShowExtinctionBox(); return; } if (Player != null) { spawner.Process(delta, Player.Translation, Player.Rotation); Clouds.ReportPlayerPosition(Player.Translation); TutorialState.SendEvent(TutorialEventType.MicrobePlayerOrientation, new RotationEventArgs(Player.Transform.basis, Player.RotationDegrees), this); TutorialState.SendEvent(TutorialEventType.MicrobePlayerCompounds, new CompoundBagEventArgs(Player.Compounds), this); TutorialState.SendEvent(TutorialEventType.MicrobePlayerTotalCollected, new CompoundEventArgs(Player.TotalAbsorbedCompounds), this); elapsedSinceCompoundPositionCheck += delta; if (elapsedSinceCompoundPositionCheck > Constants.TUTORIAL_COMPOUND_POSITION_UPDATE_INTERVAL) { elapsedSinceCompoundPositionCheck = 0; if (TutorialState.WantsNearbyCompoundInfo()) { TutorialState.SendEvent(TutorialEventType.MicrobeCompoundsNearPlayer, new CompoundPositionEventArgs(Clouds.FindCompoundNearPoint(Player.Translation, glucose)), this); } guidancePosition = TutorialState.GetPlayerGuidancePosition(); } if (guidancePosition != null) { guidanceLine.Visible = true; guidanceLine.LineStart = Player.Translation; guidanceLine.LineEnd = guidancePosition.Value; } else { guidanceLine.Visible = false; } } else { guidanceLine.Visible = false; if (!spawnedPlayer) { GD.PrintErr("MicrobeStage was entered without spawning the player"); SpawnPlayer(); } else { // Respawn the player once the timer is up playerRespawnTimer -= delta; if (playerRespawnTimer <= 0) { HandlePlayerRespawn(); } } } // Start auto-evo if stage entry finished, don't need to auto save, // settings have auto-evo be started during gameplay and auto-evo is not already started if (TransitionFinished && !wantsToSave && Settings.Instance.RunAutoEvoDuringGamePlay) { GameWorld.IsAutoEvoFinished(true); } // Save if wanted if (TransitionFinished && wantsToSave) { if (!CurrentGame.FreeBuild) { SaveHelper.AutoSave(this); } wantsToSave = false; } }
/// <summary> /// Call this before using the class. /// </summary> public void Initialize() { pTutorialCompleted = false; pCurState = State.NONE; if (CommandLineManager.pInstance["SkipTutorial"] != null) { pTutorialCompleted = true; } mTxtWaitForServe = new GameObject("GameObjects\\UI\\Tutorial\\WaitForServe\\WaitForServe"); mTxtBumpAuto = new GameObject("GameObjects\\UI\\Tutorial\\BumpAuto\\BumpAuto"); mTxtSetAuto = new GameObject("GameObjects\\UI\\Tutorial\\SetAuto\\SetAuto"); mTxtWhenBallHigh = new GameObject("GameObjects\\UI\\Tutorial\\WhenBallHigh\\WhenBallHigh"); mTxtSwipeJump = new GameObject("GameObjects\\UI\\Tutorial\\SwipeJump\\SwipeJump"); mTxtTap = new GameObject("GameObjects\\UI\\Tutorial\\Tap\\Tap"); mTxtPlayerTry = new GameObject("GameObjects\\UI\\Tutorial\\PlayerTry\\PlayerTry"); mTxtTryAgain = new GameObject("GameObjects\\UI\\Tutorial\\TryAgain\\TryAgain"); mTxtWellDone = new GameObject("GameObjects\\UI\\Tutorial\\NiceWork\\NiceWork"); mTxtThatsAll = new GameObject("GameObjects\\UI\\Tutorial\\AllThereIs\\AllThereIs"); mTxtRecap = new GameObject("GameObjects\\UI\\Tutorial\\SwipeTapSmash\\SwipeTapSmash"); mTxtRules = new GameObject("GameObjects\\UI\\Tutorial\\InRow\\InRow"); mTxtTitle = new GameObject("GameObjects\\UI\\Tutorial\\Title\\Title"); mTxtRealThing = new GameObject("GameObjects\\UI\\Tutorial\\RealThing\\RealThing"); mTxtTapContinue = new GameObject("GameObjects\\UI\\Tutorial\\TapToContinue\\TapToContinue"); mImgSwipe = new GameObject("GameObjects\\Items\\Tutorial\\Swipe\\Swipe"); mImgFingerSwipe = new GameObject("GameObjects\\Items\\Tutorial\\FingerSwipe\\FingerSwipe"); mImgBackdrop = new GameObject("GameObjects\\UI\\Tutorial\\Backdrop\\Backdrop"); mInputDelay = StopWatchManager.pInstance.GetNewStopWatch(); mInputDelay.pLifeTime = 15.0f; mHighlightPlayerMsg = new HighlightPlayerMessage(); mHighlightBallMsg = new HighlightBallMessage(); mHighlightPartnerMsg = new HighlightPartnerMessage(); mTutorialStates = new Dictionary<Int32, TutorialState>(); // RECEIVING_TXT TutorialState state = new TutorialState( new List<GameObject> { mTxtWaitForServe, mImgBackdrop, mTxtTapContinue }, new List<HighlightObjectMessage> { mHighlightBallMsg }, mInputDelay, true, true, State.RECEIVING_END); mTutorialStates[(Int32)State.RECEIVING_TXT] = state; // BUMP_TXT state = new TutorialState( new List<GameObject> { mTxtBumpAuto, mImgBackdrop, mTxtTapContinue }, new List<HighlightObjectMessage> { mHighlightBallMsg, mHighlightPlayerMsg }, mInputDelay, true, true, State.SET); mTutorialStates[(Int32)State.BUMP_TXT] = state; // SET_TXT state = new TutorialState( new List<GameObject> { mTxtSetAuto, mImgBackdrop, mTxtTapContinue }, new List<HighlightObjectMessage> { mHighlightBallMsg, mHighlightPartnerMsg }, mInputDelay, true, true, State.SWIPE); mTutorialStates[(Int32)State.SET_TXT] = state; // SWIPE_TXT_BALL_HIGH state = new TutorialState( new List<GameObject> { mTxtWhenBallHigh, mImgBackdrop, mTxtTapContinue }, new List<HighlightObjectMessage> { mHighlightBallMsg }, mInputDelay, true, false, State.SWIPE_TXT_JUMP); mTutorialStates[(Int32)State.SWIPE_TXT_BALL_HIGH] = state; // RECIEVING_END state = new TutorialState( new List<GameObject> { mTxtSwipeJump, mImgBackdrop, mImgSwipe, mImgFingerSwipe }, new List<HighlightObjectMessage> { mHighlightBallMsg, mHighlightPlayerMsg }, mInputDelay, false, true, State.NONE); mTutorialStates[(Int32)State.SWIPE_TXT_JUMP] = state; // TAP_TXT state = new TutorialState( new List<GameObject> { mTxtTap, mImgBackdrop }, new List<HighlightObjectMessage> { mHighlightBallMsg, mHighlightPlayerMsg }, mInputDelay, true, true, State.NONE); mTutorialStates[(Int32)State.TAP_TXT] = state; // PLAYER_TRY state = new TutorialState( new List<GameObject> { mTxtPlayerTry, mImgBackdrop, mTxtTapContinue }, new List<HighlightObjectMessage>( ), mInputDelay, true, true, State.PLAYER_TRYING); mTutorialStates[(Int32)State.PLAYER_TRY] = state; // TRY_AGAIN state = new TutorialState( new List<GameObject> { mTxtTryAgain, mImgBackdrop, mTxtTapContinue }, new List<HighlightObjectMessage>(), mInputDelay, true, true, State.TRYING_AGAIN); mTutorialStates[(Int32)State.TRY_AGAIN] = state; // COMPLETE_WELL_DONE state = new TutorialState( new List<GameObject> { mTxtWellDone, mImgBackdrop, mTxtTapContinue }, new List<HighlightObjectMessage>(), mInputDelay, true, true, State.COMPLETE_THATS_ALL); mTutorialStates[(Int32)State.COMPLETE_WELL_DONE] = state; // COMPLETE_THATS_ALL state = new TutorialState( new List<GameObject> { mTxtThatsAll, mImgBackdrop, mTxtTapContinue }, new List<HighlightObjectMessage>(), mInputDelay, true, true, State.COMPLETE_RECAP); mTutorialStates[(Int32)State.COMPLETE_THATS_ALL] = state; // COMPLETE_RECAP state = new TutorialState( new List<GameObject> { mTxtRecap, mImgBackdrop, mTxtTapContinue }, new List<HighlightObjectMessage>(), mInputDelay, true, true, State.COMPLETE_RULES); mTutorialStates[(Int32)State.COMPLETE_RECAP] = state; // COMPLETE_RULES state = new TutorialState( new List<GameObject> { mTxtRules, mImgBackdrop, mTxtTapContinue }, new List<HighlightObjectMessage>(), mInputDelay, true, true, State.COMPLETE_GET_READY); mTutorialStates[(Int32)State.COMPLETE_RULES] = state; // COMPLETE_GET_READY state = new TutorialState( new List<GameObject> { mTxtRealThing, mImgBackdrop, mTxtTapContinue }, new List<HighlightObjectMessage>(), mInputDelay, true, true, State.COMPLETE); mTutorialStates[(Int32)State.COMPLETE_GET_READY] = state; }
public void OnFinishTransitioning() { TransitionFinished = true; TutorialState.SendEvent(TutorialEventType.EnteredMicrobeStage, EventArgs.Empty, this); }
public static LeaveMeAlone.GameState Update(GameTime gameTime) { lastMouseState = currentMouseState; currentMouseState = Mouse.GetState(); if (BattleManager.boss.level < 2) { HandleTutorial(); } if (lastMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released) { for (int i = 0; i < TowerLevel; i++) { var rectpos = new Rectangle((int)(towerPosition.X + LeaveMeAlone.WindowX / 3), (int)(towerPosition.Y + LeaveMeAlone.WindowY - 100 - 100 * (i + 1)), 400, 100); if (selectedRoomSwapButton.r != null && LairRooms.Contains(selectedRoomSwapButton.r) == false && rectpos.Contains(currentMouseState.X, currentMouseState.Y)) { foreach (UpgradeMenu.ButtonRoom oldroom in boughtRooms) { if (oldroom.r == LairRooms[i]) { oldroom.used = false; } } LairRooms[i] = selectedRoomSwapButton.r; selectedRoomSwapButton.used = true; tutorial_state = TutorialState.SendWave; } } if ((EndOfGame && grindwaveBtn.Intersects(currentMouseState.X, currentMouseState.Y))) { BattleManager.Init(); List <Character> newParty = PartyManager.CreateParty(); BattleManager.heroes = newParty; return(LeaveMeAlone.GameState.Battle); } //next wave if (nextwaveBtn.Intersects(currentMouseState.X, currentMouseState.Y)) { BossBattle = false; if (EndOfGame) { InfoText.changeMessage("PEASANTS!\nOUT OF THE WAY!\nHE'S OURS"); //create the last party if (one_last_party) { for (int i = 0; i <= PartyManager.partyQueue.Count(); i++) { PartyManager.partyQueue.Add(null); PartyManager.popParty(); } List <Character> FinalParty = new List <Character>(); FinalParty.Add(new Character(Character.Type.Knight, 14, new Vector2(sideOffset + sideScaling, topOffset))); FinalParty.Add(new Character(Character.Type.Ranger, 14, new Vector2(sideOffset, topOffset + topScaling * 1))); FinalParty.Add(new Character(Character.Type.Mage, 14, new Vector2(sideOffset + sideScaling, topOffset + topScaling * 2))); FinalParty.Add(new Character(Character.Type.Mage, 14, new Vector2(sideOffset, topOffset + topScaling * 3))); PartyManager.partyQueue.Add(FinalParty); PartyManager.popParty(); one_last_party = false; } //push nothing else else { if (PartyManager.popParty()) { BattleManager.Init(); //Re-Add the party in case the player loses List <Character> FinalParty = new List <Character>(); FinalParty.Add(new Character(Character.Type.Knight, 14, new Vector2(sideOffset + sideScaling, topOffset))); FinalParty.Add(new Character(Character.Type.Ranger, 14, new Vector2(sideOffset, topOffset + topScaling * 1))); FinalParty.Add(new Character(Character.Type.Mage, 14, new Vector2(sideOffset + sideScaling, topOffset + topScaling * 2))); FinalParty.Add(new Character(Character.Type.Mage, 14, new Vector2(sideOffset, topOffset + topScaling * 3))); PartyManager.partyQueue.Add(FinalParty); BossBattle = true; return(LeaveMeAlone.GameState.Battle); } else { PartyManager.partyQueue.Add(null); return(LeaveMeAlone.GameState.Lair); } } } //Normally push a party else { for (int i = 0; i < TowerLevel; i++) { LairAttack(LairRooms[i], PartyManager.partyQueue[i]); } Random random = new Random(); int makeParty = 0;//random.Next(100) % 4; if (makeParty != 1) { List <Character> newParty = PartyManager.CreateParty(); PartyManager.partyQueue.Add(newParty); } else { PartyManager.partyQueue.Add(null); } if (PartyManager.popParty()) { BattleManager.Init(); InfoText.changeMessage(""); return(LeaveMeAlone.GameState.Battle); } else { //Should have some sort of interface on screen InfoText.changeMessage("Here they come\n I can feel them."); return(LeaveMeAlone.GameState.Lair); } } } if (skillsBtn.Intersects(currentMouseState.X, currentMouseState.Y)) { return(LeaveMeAlone.GameState.Upgrade); } if (constructionBtn.Intersects(currentMouseState.X, currentMouseState.Y)) { if (TowerLevel < MaxLevel) { TowerLevel++; LairRooms.Add(UnconstructedRoom); PartyManager.partyQueue.Add(null); for (int j = PartyManager.partyQueue.Count() - 1; j > 0; j--) { PartyManager.partyQueue[j] = PartyManager.partyQueue[j - 1]; } PartyManager.partyQueue[0] = null; } else { InfoText.changeMessage("Max Lair Height"); texttimer = 600; } tutorial_state = TutorialState.Build2; return(LeaveMeAlone.GameState.Lair); } if (mainmenuBtn.Intersects(currentMouseState.X, currentMouseState.Y)) { MainMenu.init(false); LeaveMeAlone.Menu_Song_Instance.Stop(); //UpgradeMenu.boughtRooms.Clear(); return(LeaveMeAlone.GameState.Main); } //checks if a room button was selected selected_flag = false; foreach (UpgradeMenu.ButtonRoom r in boughtRooms) { if (r.b.Intersects(currentMouseState.X, currentMouseState.Y) && !r.used) { Console.WriteLine(r.b.text); //already have a selected thing; if (selectedRoomSwapButton.b != null) { selectedRoomSwapButton.b.selected = false; } selectedRoomSwapButton = r; r.b.selected = true; selected_flag = true; tutorial_state = TutorialState.Build3; } } //otherwise we unselect any previously selected button if (selected_flag == false && selectedRoomSwapButton.b != null) { selectedRoomSwapButton.b.selected = false; selectedRoomSwapButton = new UpgradeMenu.ButtonRoom(); } } return(LeaveMeAlone.GameState.Lair); }
public static LeaveMeAlone.GameState Update(GameTime g) { lastMouseState = currentMouseState; currentMouseState = Mouse.GetState(); int xpos = currentMouseState.X; int ypos = currentMouseState.Y; texts["gold"].changeMessage("Gold: " + Resources.gold); texts["level"].changeMessage("Level: " + BattleManager.boss.level); if (Mouse.GetState().LeftButton == ButtonState.Released) { left_click = false; } if (Mouse.GetState().RightButton == ButtonState.Released) { right_click = false; } if (BattleManager.boss.level < 2) { HandleTutorial(); } foreach (Skill s in BattleManager.boss.skills) { skilltree.SkillButtons[s].text.color = Color.Black; } //gets things that haven't been bought and colors them foreach (Skill s in skilltree.SkillButtons.Keys.Except(BattleManager.boss.skills)) { if (s.cost > Resources.gold || BattleManager.boss.level < s.level) { skilltree.SkillButtons[s].text.color = Color.Red; } else { skilltree.SkillButtons[s].text.color = Color.Blue; } } bool hovered = false; foreach (Skill s in skilltree.SkillButtons.Keys) { if (skilltree.SkillButtons[s].Intersects(currentMouseState.X, currentMouseState.Y)) { hovertext.changeMessage(s.name + ":\n" + s.description); hovered = true; } } //Hover over Stats button if (statsTitleRect.Contains(currentMouseState.X, currentMouseState.Y)) { statsText.changeMessage(BattleManager.boss.StatsToString()); Vector2 statmeasurements = statsText.getMeasurements(300); statsText.position = new Vector2(statsTitle.position.X, statsTitleRect.Y + statsTitleRect.Height + 10); Console.WriteLine("statspos" + statsText.position.ToString()); statsTextRect = new Rectangle((int)statsText.position.X - 10, (int)statsText.position.Y - 10, 300, (int)statmeasurements.Y + 10); } else { statsText.changeMessage(""); } //perfect place for polymophism Chris hovered = false; foreach (Skill s in skilltree.SkillButtons.Keys) { if (skilltree.SkillButtons[s].Intersects(currentMouseState.X, currentMouseState.Y)) { StringBuilder sb = new StringBuilder(); sb.Append(s.name + ":"); if (BattleManager.boss.skills.Contains(s)) { sb.Append(" (bought)"); } else { sb.Append(" (Cost: " + s.cost + ")"); } sb.Append("\nMana Cost: " + s.energy + "\nCooldown: " + s.cooldown + "\n"); sb.Append("\n" + s.description); hovertext.changeMessage(sb.ToString()); hovered = true; } } foreach (ButtonRoom r in AvailableRooms) { if (r.b.Intersects(currentMouseState.X, currentMouseState.Y)) { StringBuilder sb = new StringBuilder(); sb.Append(r.r.name + ":"); if (boughtRooms.Contains(r.r)) { sb.Append(" (bought)"); } else { sb.Append(" (Cost: " + r.r.cost + ")"); } sb.Append("\n" + r.r.description); hovertext.changeMessage(sb.ToString()); hovered = true; } } if (hovered == false) { hovertext.changeMessage(""); } selectedBoss.Update(g); //if (lastMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released) if (leftClicked()) { //check if a room was clicked on for (int x = 0; x < AvailableRooms.Length; x++) { if (BattleManager.boss.selected_rooms.Contains(AvailableRooms[x].r) == false && AvailableRooms[x].b.Intersects(currentMouseState.X, currentMouseState.Y) && AvailableRooms[x].r.level != -1) { if (AvailableRooms[x].r.cost < Resources.gold) { BattleManager.boss.selected_rooms.Add(AvailableRooms[x].r); LairManager.addRoom(AvailableRooms[x]); boughtRooms.Add(AvailableRooms[x].r); Resources.gold -= AvailableRooms[x].r.cost; tutorial_state = TutorialState.Back; buyingSound.Play(); } } } //check the next button if (next.Intersects(currentMouseState.X, currentMouseState.Y)) { BattleManager.bossDefaultPosition(); LairManager.tutorial_state = LairManager.TutorialState.Build1; return(LeaveMeAlone.GameState.Lair); } //check if we clicked on a skill foreach (Skill s in skilltree.SkillButtons.Keys) { if (skilltree.SkillButtons[s].Intersects(currentMouseState.X, currentMouseState.Y)) { Console.WriteLine("Got one!"); if (BattleManager.boss.skills.Contains(s) == false && BattleManager.boss.level >= s.level) { //if you have enough money, buy it if (s.cost < Resources.gold) { BattleManager.boss.addSkill(s); buyingSound.Play(); tutorial_state = TutorialState.BuyRoom; Resources.gold -= s.cost; if (s == SkillTree.final_skill[BattleManager.boss.charType]) { LairManager.EndOfGame = true; LairManager.nextwaveBtn.rectangle.X = LeaveMeAlone.BackgroundRect.X; LairManager.nextwaveBtn.rectangle.Y = LeaveMeAlone.BackgroundRect.Height - 200; } //Console.WriteLine(BattleManager.boss.skills.Count); } } else { //When a skill isn't selected to swap, it should be set to default(Skill) if (selectedSkillSwapButton.s != default(Skill) && BattleManager.boss.skills.Contains(s) == true && BattleManager.boss.selected_skills.Contains(s) == false) { int index = BattleManager.boss.selected_skills.IndexOf(selectedSkillSwapButton.s); BattleManager.boss.selected_skills[index] = s; swappingSound.Play(); Console.WriteLine("swapped"); } } //Console.WriteLine(s+" pressed"); } } updateSelectedSkills(); bool flag = false; for (int x = 0; x < SelectedSkills.Length; x++) { var buttonStuff = SelectedSkills[x]; if (buttonStuff.b.Intersects(currentMouseState.X, currentMouseState.Y) && buttonStuff.s != null) { //already have a selected thing; if (selectedSkillSwapButton.b != null) { selectedSkillSwapButton.b.selected = false; } flag = true; selectedSkillSwapButton = buttonStuff; selectedSkillSwapButton.b.selected = true; //Console.WriteLine("selected " + buttonStuff.s.name); } } if (flag == false) { if (selectedSkillSwapButton.b != null) { selectedSkillSwapButton.b.selected = false; } selectedSkillSwapButton = new ButtonSkill();; } } measurements = hovertext.getMeasurements(hovertextRect.Width - 15); if (xpos + hovertextRect.Width > LeaveMeAlone.WindowX - 20) { hovertextRect.X = LeaveMeAlone.WindowX - hovertextRect.Width - 20; } else { hovertextRect.X = currentMouseState.X + 10; } if (ypos + measurements.Y > LeaveMeAlone.WindowY - 20) { hovertextRect.Y = LeaveMeAlone.WindowY - (int)measurements.Y - 20; } else { hovertextRect.Y = currentMouseState.Y + 10; } return(LeaveMeAlone.GameState.Upgrade); }