private void spawnNote() { int position = Random.Range(0, spawnPoints.Length); GameObject go = Instantiate(notePrefab, spawnPoints[position].position, notePrefab.transform.rotation, transform); Note newNote = go.GetComponent <Note>(); newNote.keyCode = keyCodes[position]; newNote.karaoke = this; if (lastSpawnedNote != null) { lastSpawnedNote.nextNote = newNote; } lastSpawnedNote = newNote; spawnedNotesAmount++; if (spawnedNotesAmount < songLength) { float randomCooldown = GaussianDistribution.Generate(noteSpawnCooldownMean, noteSpawnCooldownVariance); randomCooldown = Mathf.Clamp(randomCooldown, 0.15f, float.MaxValue); nextNoteSpawnTime = Time.time + randomCooldown; } else { nextNoteSpawnTime = float.MaxValue; newNote.isLastNote = true; } }
void Update() { if (Time.frameCount % 50 == 0) { turningAngle = GaussianDistribution.Generate(0, 1); } transform.Rotate(0, turningAngle, 0, Space.Self); transform.Translate(transform.forward * speed * Time.deltaTime, Space.World); }
void Update() { if (Time.time > nextSpawnTime) { // Spawn something spawn(); // Update timer nextSpawnTime = Time.time + cooldownGaussianDistribution.Generate(); } }
void Start() { force = GameManager.GetMinigameSetting("DontFallDown", "Force"); inertia = GameManager.GetMinigameSetting("DontFallDown", "Inertia"); handleVelocity = GaussianDistribution.Generate(0, GameManager.GetMinigameSetting("DontFallDown", "StartingVelocityVariance")); losePercentage = GameManager.GetMinigameSetting("DontFallDown", "LosePercentage"); remainingTime = GameManager.GetMinigameSetting("DontFallDown", "Time"); sliderCenter.localScale = new Vector3(1 - losePercentage, 1, 1); sliderSX.localScale = new Vector3(losePercentage / 2, 1, 1); sliderDX.localScale = new Vector3(losePercentage / 2, 1, 1); }
void Start() { songLength = Mathf.FloorToInt(Mathf.Clamp(GaussianDistribution.Generate( GameManager.GetMinigameSetting("Karaoke", "SongLengthMean"), GameManager.GetMinigameSetting("Karaoke", "SongLengthVariance")), 5, float.MaxValue)); spawnedNotesAmount = 0; noteSpawnCooldownMean = GameManager.GetMinigameSetting("Karaoke", "NoteSpawnCooldownMean"); noteSpawnCooldownVariance = GameManager.GetMinigameSetting("Karaoke", "NoteSpawnCooldownVariance"); nextNoteSpawnTime = Time.time + 3; targetPointsText.text = (GameManager.GetMinigameSetting("Karaoke", "TargetPercentage") * correctNotePoints * songLength).ToString(); randomizeKeys(); }
void FixedUpdate() { if (Time.time > nextKeyRandomizationTime) { randomizeKeys(); DrunkMalus currentDrunkMalus = drunkMaluses[GameManager.DrunkLevel]; nextKeyRandomizationTime = Time.time + GaussianDistribution.Generate(currentDrunkMalus.keyRandomizationMeanTime, currentDrunkMalus.keyRandomizationVarianceTime); } move(); respectBounds(); }
void Start() { deactivatePlayerCollisions(); uiManager = FindObjectOfType <UIManager>(); transform.position = GameManager.PlayerSpawnPosition; drunkMaluses = JSONManager.Load <Dictionary <GameManager.Drunkness, DrunkMalus> >("DrunkMaluses"); DrunkMalus currentDrunkMalus = drunkMaluses[GameManager.DrunkLevel]; nextKeyRandomizationTime = Time.time + GaussianDistribution.Generate(currentDrunkMalus.keyRandomizationMeanTime, currentDrunkMalus.keyRandomizationVarianceTime); }
private void spawn() { Transform spawnPoint = spawnPoints[Random.Range(0, spawnPoints.Length)]; GameObjectPooler pool = gameObjectPools[Random.Range(0, gameObjectPools.Length)]; GameObject go = pool.Instantiate(spawnPoint.position, transform.rotation, spawnedObjectsParent); go.GetComponent <Mover>().Speed = speedGaussianDistribution.Generate(); DestroyAfterDistance dad = go.GetComponent <DestroyAfterDistance>(); if (dad == null) { dad = go.AddComponent <DestroyAfterDistance>(); } dad.distance = maxWalkedDistance; dad.onDestroy = g => pool.Destroy(g); }
void Start() { speedGaussianDistribution = new GaussianDistribution(meanSpeed, speedVariance); cooldownGaussianDistribution = new GaussianDistribution(meanCooldown, cooldownVariance); nextSpawnTime = Time.time + cooldownGaussianDistribution.Generate(); spawnedObjectsParent = new GameObject("Spawned Game Objects").transform; spawnedObjectsParent.parent = transform; gameObjectPools = new GameObjectPooler[prefabs.Length]; for (int i = 0; i < prefabs.Length; i++) { Transform poolParent = new GameObject(prefabs[i].name + " pool").transform; poolParent.parent = transform; gameObjectPools[i] = new GameObjectPooler(prefabs[i].gameObject, Vector3.one * 100, poolParent, 20); } }
void Start() { Target.transform.localScale -= new Vector3(GameManager.GetMinigameSetting("Darts", "TargetScale"), GameManager.GetMinigameSetting("Darts", "TargetScale"), 0); float targetSpeed = GaussianDistribution.Generate( GameManager.GetMinigameSetting("Darts", "TargetSpeedMean"), GameManager.GetMinigameSetting("Darts", "TargetSpeedVariance")); targetSpeed = Mathf.Clamp(targetSpeed, 2, float.MaxValue); target.speed = targetSpeed; float aimSpeed = GaussianDistribution.Generate( GameManager.GetMinigameSetting("Darts", "AimSpeedMean"), GameManager.GetMinigameSetting("Darts", "AimSpeedVariance")); aimSpeed = Mathf.Clamp(aimSpeed, 2, float.MaxValue); aim.speed = aimSpeed; }
private void SpawnBeer() { GameObject go = Instantiate(beerPrefab, spawnpoint.position, beerPrefab.transform.rotation, transform); LaunchedBeer newBeer = go.GetComponent <LaunchedBeer>(); newBeer.status = Random.Range(0, 101); float myBeerChance = GameManager.GetMinigameSetting("GrabTheBeer", "MyBeer"); newBeer.Arm = Arm; newBeer.GetComponent <Mover>().Speed = GameManager.GetMinigameSetting("GrabTheBeer", "Speed"); if (newBeer.status > myBeerChance) { float randomCooldown = GaussianDistribution.Generate(beerStatusMean, beerStatusVariance); randomCooldown = Mathf.Clamp(randomCooldown, 3f, float.MaxValue); spawnBeerTimer = Time.time + randomCooldown; } else { spawnBeerTimer = float.MaxValue; } }
private void move() { Vector3 direction = Vector3.zero; if (Input.GetKey(upKey)) { direction.z++; } if (Input.GetKey(downKey)) { direction.z--; } if (Input.GetKey(leftKey)) { direction.x--; } if (Input.GetKey(rightKey)) { direction.x++; } if (Time.time > nextMaxSpeedRandomizationTime) { DrunkMalus currentDrunkMalus = drunkMaluses[GameManager.DrunkLevel]; maxSpeed = GaussianDistribution.Generate(currentDrunkMalus.speedMean, currentDrunkMalus.speedVariance); nextMaxSpeedRandomizationTime = Time.time + GaussianDistribution.Generate(4, 1); } if (direction == Vector3.zero) { velocity -= acceleration * velocity.normalized * Time.deltaTime / 2; if (driftAngle < driftSpeed) { driftAngle = 0; } else { driftAngle = driftAngle - Mathf.Sign(driftAngle) * driftSpeed; } } else { if (velocity.sqrMagnitude > maxSpeed * maxSpeed) { velocity -= acceleration * velocity.normalized * Time.deltaTime / 2; } else { velocity += acceleration * direction.normalized * Time.deltaTime; } transform.rotation = Quaternion.LookRotation(velocity, Vector3.up); // Calculate drifting float angle = Vector3.SignedAngle(velocity, direction, Vector3.up); if (Mathf.Abs(angle) < maxDriftAngle) { angle = 0; // Because it will never be exactly zero } angle = Mathf.Clamp(Mathf.Abs(angle), 0, driftSpeed) * Mathf.Sign(angle); if (Mathf.Abs(angle) < Mathf.Epsilon && Mathf.Abs(driftAngle) > Mathf.Epsilon) { angle = -Mathf.Clamp(Mathf.Abs(driftAngle), 0, driftSpeed) * Mathf.Sign(driftAngle); } driftAngle += angle; } velocity = Vector3.ClampMagnitude(velocity, 15); driftAngle = Mathf.Clamp(Mathf.Abs(driftAngle), 0, maxDriftAngle) * Mathf.Sign(driftAngle); // Drift transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, driftAngle); // Translate transform.Translate(velocity * Time.fixedDeltaTime, Space.World); }
void Start() { speed = GaussianDistribution.Generate(meanSpeed, 0); }