private void FixedUpdate() { if (MinigameManager.GameOver) { return; } // difficulty check { var vectorList = new List <Vector2> { RotationSpeedMinMax, FlySpeedMinMax }; var unparsed = DifficultyAdjuster.SpreadDifficulty(MinigameManager.DiffCurrent, vectorList); RotationSpeed = unparsed[0]; FlySpeed = unparsed[1]; SpeedText.text = $"DIFFICULTY: {Mathf.Round(MinigameManager.DiffCurrent * 100)}"; } // following { // play sound? var direction = (Vector2)Target.position - rigidBody2D.position; direction.Normalize(); var up = rigidBody2D.transform.up; var rotationAngle = Vector3.Cross(direction, up).z; rigidBody2D.angularVelocity = -rotationAngle * RotationSpeed; rigidBody2D.velocity = up * FlySpeed; } }
private void FixedUpdate() { if ((spawnTimer += Time.fixedDeltaTime) > SpawnInBetween) { spawnTimer = 0; spawnCloud(); } if ((difficultyTimer += Time.fixedDeltaTime) > IncreaseAfter) { difficultyTimer = 0; var vectors = new List <Vector2> { CloudMoveSpeedMinMax }; CurrentDifficulty += IncreaseBy; currentCloudSpeed = DifficultyAdjuster.SpreadDifficulty(CurrentDifficulty, vectors)[0]; TextSpeed.text = $"DIFFICULTY: {System.Math.Round(CurrentDifficulty, 2) * 100}"; } foreach (var item in cloudPool) { if (item == null) { continue; } item.transform.position -= new Vector3(currentCloudSpeed * Time.fixedDeltaTime, 0, 0); } }
private void FixedUpdate() { if (MinigameManager.GameOver) { return; } if (lastCactus == null) { spawnCactus(); } spawnTimer = 0; if (liveObjects.Count <= MaxCactusesOnScreen && lastCactus.transform.position.x < Rex.transform.position.x) { MinigameManager.Events.EventScored(); spawnCactus(); if (CurrentDifficulty < 1.0f) { CurrentDifficulty += IncreaseDifficultyBy; var difficulty = DifficultyAdjuster.SpreadDifficulty(CurrentDifficulty, new List <Vector2>() { MinMaxSpeed }); currentSpeed = difficulty[0]; TextDifficulty.text = $"DIFFICULTY: {System.Math.Round(CurrentDifficulty, 2) * 100}"; } } foreach (var item in liveObjects) { item.transform.position -= new Vector3(currentSpeed * Time.fixedDeltaTime, 0, 0); if (item.transform.position.x < xOffscreen) { deadObjects.Add(item); } } if (cleanUp) { deadObjects.AddRange(liveObjects); cleanUp = false; } foreach (var item in deadObjects) { Destroy(item); liveObjects.Remove(item); } deadObjects.Clear(); }
private void Start() { gameManager = GetComponentInParent <MinigameManager>(); rigidbody2d = GetComponent <Rigidbody2D>(); var difficulty = DifficultyAdjuster.SpreadDifficulty( gameManager.Difficulty, new List <Vector2> { MovementSpeedMinMax }); currentSpeed = difficulty[0]; }
private void updateDifficulty() { Difficulty.text = $"DIFFICULTY: {CurrentDifficulty * 100}"; var vectors = new List <Vector2> { FlightSpeedMinMax, SpawnAmountMinMax }; var spread = DifficultyAdjuster.SpreadDifficulty(CurrentDifficulty, vectors); currentFlightSpeed = spread[0]; currentSpawnCount = (int)spread[1]; }
private void createRandomSequence() { for (var i = 0; i < Directions.Length; i++) { var color = Directions[i].color; color.a = Alpha; Directions[i].color = color; } sequenceTimer = 0; waitTimer = 0; // adjust difficulty { var vectors = new List <Vector2> { // reverse because min is hardest, max is easiet new Vector2(TimeInBetweenPlaysMinMax.y, TimeInBetweenPlaysMinMax.x) }; currentTimeInBetweenPlays = DifficultyAdjuster.SpreadDifficulty(DiffCurrent, vectors)[0]; SpeedText.text = $"DIFFICULTY: {Mathf.Round(DiffCurrent * 100)}"; DiffCurrent += DiffIncreaseBy; if (DiffCurrent > 1f) { DiffCurrent = 1; } } var sequence = new List <int>(); for (var i = 0; i < Directions.Length; i++) { sequence.Add(i); } currentSequenceCount = sequence.Count; playersSequenceCount = sequence.Count; sequence.ShuffleList(); currentSequence = new Queue <int>(); playersSequence = new Queue <int>(); foreach (var item in sequence) { currentSequence.Enqueue(item); playersSequence.Enqueue(item); } sequencePlaying = true; ExplainText.text = "Follow Sequence"; }
private void adjustDifficulty() { var vectors = new List <Vector2> { TargetMovementSpeedMinMax, TargetRotationSpeedMinMax, CrosshairMovementSpeedMin, TargetScaleMinMax }; var difficulty = DifficultyAdjuster.SpreadDifficulty( CurrentDifficulty, vectors); Curve.TargetMovementSpeed = difficulty[0]; Curve.TargetRotationSpeed = difficulty[1]; Curve.MovementSpeed = difficulty[2]; Curve.TargetScale = difficulty[3]; }
private void spawnApple() { gameManager.AllowHand = true; followHand = false; fallingApple = true; var vectors = new List <Vector2> { new Vector2(MaxYOffsetMinMax.y, MaxYOffsetMinMax.x), FallSpeedMinMax }; var difficulty = DifficultyAdjuster.SpreadDifficulty(CurrentDifficulty, vectors); var newPosition = new Vector2( SpawnPoint.position.x, SpawnPoint.position.y + difficulty[0]); transform.position = newPosition; rigidbody2d.simulated = true; rigidbody2d.AddForce(Vector2.down * difficulty[1], ForceMode2D.Impulse); }
private void FixedUpdate() { if ((jumpNextString += Time.fixedDeltaTime) > PickJumpRate) { jumpNextString = 0f; if (++pickPositionIndex == Strings.Length) { pickPositionIndex = 0; } Pick.transform.position = new Vector3(Pick.transform.position.x, strings[pickPositionIndex].transform.position.y, 0); } var vectorList = new List <Vector2> { // reverse because it's time and we need it to speed up so it should go lower and lower new Vector2(PickJumprateMinMax.y, PickJumprateMinMax.x) }; PickJumpRate = DifficultyAdjuster.SpreadDifficulty(MinigameManager.DiffCurrent, vectorList)[0]; SoundAttacker.transform.position -= new Vector3(0.1f * AttackerCurrentSpeed, 0, 0); }
private DifficultySetup difficultySetup() { var vectorList = new List <Vector2> { RotationSpeedMinMax, // reverse scale because bigger is easier new Vector2(SpawnSizeMinMax.y, SpawnSizeMinMax.x), // reverse space because bigger space is easier new Vector2(SpawnSpaceInBetweenMinMax.y, SpawnSpaceInBetweenMinMax.x) }; var unparsed = DifficultyAdjuster.SpreadDifficulty(currentDifficulty, vectorList); var newDifficultySetup = new DifficultySetup { RotationSpeed = unparsed[0], Scale = unparsed[1], SpaceInBetween = unparsed[2] }; return(newDifficultySetup); }
private void spawnCar(int amout = 1) { var occupiedSpawnIndex = new List <int>(); for (var i = 0; i < amout; i++) { var randomCarIndex = Random.Range(0, CarPrefabs.Length); int randomSpawnIndex; do { randomSpawnIndex = Random.Range(0, SpawnPoints.Length); } while (occupiedSpawnIndex.Contains(randomSpawnIndex)); occupiedSpawnIndex.Add(randomSpawnIndex); var vectors = new List <Vector2> { CarSpawnOffsetMinMax, CarSpeedMinMax }; var difficulty = DifficultyAdjuster.SpreadDifficulty(CurrentDifficulty, vectors); var spawnPoint = new Vector2( SpawnPoints[randomSpawnIndex].position.x, SpawnPoints[randomSpawnIndex].position.y + difficulty[0]); var newCar = Instantiate( CarPrefabs[randomCarIndex], spawnPoint, Quaternion.identity, transform); newCar.GetComponent <Rigidbody2D>().AddForce(Vector2.down * difficulty[1], ForceMode2D.Impulse); Destroy(newCar, 4.0f); } }