private void MusicManagement() { if (MediaPlayer.State == MediaState.Stopped) { if (musicBool == false) { counters["musicCounter"] = 3000.0f; musicBool = true; } if (counters.Check("musicCounter") == false) { MediaPlayer.Play(backgroundSong); musicBool = false; } } }
private void GravityInput() { if (gravityItem == null) { return; } if (gravityItem.Done == true) { gravitySetMode = false; } if (counters.Check("gravitySet") == true) { return; } if (keyboardMode == true) { if (PolyInput.Keyboard.Pressed(Keys.C)) { if (gravityItem.Distance <= distanceToUse && gravitySetMode == false && (isOnObject || isOnGround)) { gravitySetMode = true; openGravEffect.Play(); } else if (gravitySetMode == true && (isOnObject || isOnGround)) { gravitySetMode = false; } if (gravityItem.GravitySet == false) { gravityItem.GravitySwitch = gravitySetMode; } } } else if (controllerMode == true) { if (PolyInput.GamePads[0].Pressed(Buttons.X) || PolyInput.GamePads[0].LeftTriggerPressed(0.5f)) { if (gravityItem.Distance <= distanceToUse && gravitySetMode == false && (isOnObject || isOnGround)) { gravitySetMode = true; openGravEffect.Play(); } else if (gravitySetMode == true && (isOnObject || isOnGround)) { gravitySetMode = false; } if (gravityItem.GravitySet == false) { gravityItem.GravitySwitch = gravitySetMode; } } } if (gravitySetMode == true) { if (keyboardMode == true) { if (PolyInput.Keyboard.Pressed(Keys.Down) == true || PolyInput.Keyboard.Pressed(Keys.S) == true) { if (gravityItem.GetType() == typeof(GravityBoxSmallUpDown) || gravityItem.GetType() == typeof(GravityBoxSmallCombo) || gravityItem.GetType() == typeof(GravityBoxMediumCombo) || gravityItem.GetType() == typeof(GravityBoxMediumUpDown) || gravityItem.GetType() == typeof(EnemyCombo) || gravityItem.GetType() == typeof(EnemyUpDown)) { counters["gravitySet"] = gravitySetTime; gravityItem.Direction = GravityDirection.Down; gravityItem.GravitySet = true; fireGravEffect.Play(); } } else if (PolyInput.Keyboard.Pressed(Keys.Up) == true || PolyInput.Keyboard.Pressed(Keys.W) == true) { if (gravityItem.GetType() == typeof(GravityBoxSmallUpDown) || gravityItem.GetType() == typeof(GravityBoxSmallCombo) || gravityItem.GetType() == typeof(GravityBoxMediumCombo) || gravityItem.GetType() == typeof(GravityBoxMediumUpDown) || gravityItem.GetType() == typeof(EnemyCombo) || gravityItem.GetType() == typeof(EnemyUpDown)) { counters["gravitySet"] = gravitySetTime; gravityItem.Direction = GravityDirection.Up; gravityItem.GravitySet = true; fireGravEffect.Play(); } } else if (PolyInput.Keyboard.Pressed(Keys.Right) == true || PolyInput.Keyboard.Pressed(Keys.D) == true) { if (gravityItem.GetType() == typeof(GravityBoxSmallLeftRight) || gravityItem.GetType() == typeof(GravityBoxSmallCombo) || gravityItem.GetType() == typeof(GravityBoxMediumCombo) || gravityItem.GetType() == typeof(GravityBoxMediumLeftRight) || gravityItem.GetType() == typeof(EnemyCombo) || gravityItem.GetType() == typeof(EnemyLeftRight)) { counters["gravitySet"] = gravitySetTime; gravityItem.Direction = GravityDirection.Right; gravityItem.GravitySet = true; fireGravEffect.Play(); } } else if (PolyInput.Keyboard.Pressed(Keys.Left) == true || PolyInput.Keyboard.Pressed(Keys.A) == true) { if (gravityItem.GetType() == typeof(GravityBoxSmallLeftRight) || gravityItem.GetType() == typeof(GravityBoxSmallCombo) || gravityItem.GetType() == typeof(GravityBoxMediumLeftRight) || gravityItem.GetType() == typeof(GravityBoxMediumCombo) || gravityItem.GetType() == typeof(EnemyCombo) || gravityItem.GetType() == typeof(EnemyLeftRight)) { counters["gravitySet"] = gravitySetTime; gravityItem.Direction = GravityDirection.Left; gravityItem.GravitySet = true; fireGravEffect.Play(); } } } else if (controllerMode == true) { if (PolyInput.GamePads[0].RightStickDownCheck(0.3f) == true) { if (gravityItem.GetType() == typeof(GravityBoxSmallUpDown) || gravityItem.GetType() == typeof(GravityBoxSmallCombo) || gravityItem.GetType() == typeof(GravityBoxMediumCombo) || gravityItem.GetType() == typeof(GravityBoxMediumUpDown) || gravityItem.GetType() == typeof(EnemyCombo) || gravityItem.GetType() == typeof(EnemyUpDown)) { counters["gravitySet"] = gravitySetTime; gravityItem.Direction = GravityDirection.Down; gravityItem.GravitySet = true; fireGravEffect.Play(); } } else if (PolyInput.GamePads[0].RightStickUpCheck(0.3f) == true) { if (gravityItem.GetType() == typeof(GravityBoxSmallUpDown) || gravityItem.GetType() == typeof(GravityBoxSmallCombo) || gravityItem.GetType() == typeof(GravityBoxMediumCombo) || gravityItem.GetType() == typeof(GravityBoxMediumUpDown) || gravityItem.GetType() == typeof(EnemyCombo) || gravityItem.GetType() == typeof(EnemyUpDown)) { counters["gravitySet"] = gravitySetTime; gravityItem.Direction = GravityDirection.Up; gravityItem.GravitySet = true; fireGravEffect.Play(); } } else if (PolyInput.GamePads[0].RightStickRightCheck(0.3f) == true) { if (gravityItem.GetType() == typeof(GravityBoxSmallLeftRight) || gravityItem.GetType() == typeof(GravityBoxSmallCombo) || gravityItem.GetType() == typeof(GravityBoxMediumCombo) || gravityItem.GetType() == typeof(GravityBoxMediumLeftRight) || gravityItem.GetType() == typeof(EnemyCombo) || gravityItem.GetType() == typeof(EnemyLeftRight)) { counters["gravitySet"] = gravitySetTime; gravityItem.Direction = GravityDirection.Right; gravityItem.GravitySet = true; fireGravEffect.Play(); } } else if (PolyInput.GamePads[0].RightStickLeftCheck(0.3f) == true) { if (gravityItem.GetType() == typeof(GravityBoxSmallLeftRight) || gravityItem.GetType() == typeof(GravityBoxSmallCombo) || gravityItem.GetType() == typeof(GravityBoxMediumCombo) || gravityItem.GetType() == typeof(GravityBoxMediumLeftRight) || gravityItem.GetType() == typeof(EnemyCombo) || gravityItem.GetType() == typeof(EnemyLeftRight)) { counters["gravitySet"] = gravitySetTime; gravityItem.Direction = GravityDirection.Left; gravityItem.GravitySet = true; fireGravEffect.Play(); } } } } }
protected virtual void Movement() { if (counters.Check("dodgeTimer") == false) { if (boast != 0) { if (engineOn == false) { spriteEngine.ResetAnimation(); } engineOn = true; engineInstance.Play(); } else { engineOn = false; engineInstance.Stop(); } Velocity.Y += boastAcc * boast; Velocity.Y += gravity; Velocity.Y = MathHelper.Clamp(Velocity.Y, -boastMaxSpeed, fallMaxSpeed); } if (counters.Check("dodgeTimer") == true) { if (dodgeStart == true) { dodgeStart = false; if (signX != 0 || xLast == true) { Velocity.X = 0; } else if (signY != 0 || yLast == true) { Velocity.Y = 0; } } if (signX != 0 && signY != 0) { Vector2 movement = new Vector2(signX, signY); movement.Normalize(); Velocity += dodgeAccel * movement; yLast = false; xLast = false; } if (signY != 0 && signX == 0) { Velocity.Y += dodgeAccel * signY; } else if (yLast == true) { Velocity.Y += dodgeAccel * lastSignY; } if (signX != 0 && signY == 0) { Velocity.X += dodgeAccel * signX; } else if (xLast == true) { Velocity.X += dodgeAccel * lastSignX; } Velocity.X = MathHelper.Clamp(Velocity.X, -dodgeSpeed, dodgeSpeed); Velocity.Y = MathHelper.Clamp(Velocity.Y, -dodgeSpeed, dodgeSpeed); } else { if (isOnGround == true) { Velocity.X += runAccel * signX; Velocity.X = MathHelper.Clamp(Velocity.X, -normMaxHorizSpeed, normMaxHorizSpeed); } else { Velocity.X += airAccel * signX; Velocity.X = MathHelper.Clamp(Velocity.X, -airMaxHorizSpeed, airMaxHorizSpeed); } } float currentSign = Math.Sign(Velocity.X); if (currentSign != 0 && currentSign != signX && isOnGround == true) { Velocity.X *= turnMul; } else if (currentSign != 0 && currentSign != signX && isOnGround == false && counters.Check("dodgeTimer") == false) { Velocity.X *= airturnMul; } MovementHorizontal(Velocity.X); MovementVerical(Velocity.Y); if (signX != 0) { xLast = true; yLast = false; lastSignX = signX; } if (signY != 0) { xLast = false; yLast = true; lastSignY = signY; } }