public WaveCountSet GenerateScoreWave(int maxScore) { float multiplier = 1.0f; int availableScore = Mathf.Min(maxScore, maxDifficultyCutOff); List <ScoreAwarder> chosen = new List <ScoreAwarder>(); List <ScoreAwarder> possibleEnemies = new List <ScoreAwarder>(); possibleEnemies.AddRange(enemies); Predicate <ScoreAwarder> checkScore = (ScoreAwarder awarder) => { return(awarder.Score * multiplier <= availableScore); }; possibleEnemies = UpdateScoreList(possibleEnemies, checkScore); while (possibleEnemies.Count > 0) { multiplier = EvaluateIntCurve(DifficultyMultiplierPerEnemy, chosen.Count + 1); ScoreAwarder chosenAwarder = possibleEnemies[TimedBoundRandom.RandomInt(0, possibleEnemies.Count)]; chosen.Add(chosenAwarder); availableScore -= (int)(chosenAwarder.Score * multiplier); possibleEnemies = UpdateScoreList(possibleEnemies, checkScore); } return(new WaveCountSet(chosen.ToArray(), enemies)); }
private void InstantiateFromWaveList() { int index = TimedBoundRandom.RandomInt(0, waves.Waves.Length); Transform prefab = waves.Waves[index].transform; for (int i = 0; i < prefab.childCount; i++) { Transform childPrefab = prefab.GetChild(i); Instantiate(childPrefab, childPrefab.position, childPrefab.rotation); } }
private void InstantiatePickups() { SetCurrentIndexValue((int)currentIndex.Value + 1); int toCreate = wavePickupAmounts + 1; float angle = TimedBoundRandom.RandomFloat(0, 360); lastAngle = angle; float offsetInc = pickupOffset.y * 2.0f / (toCreate - 1); PickupRepresentationArr allPickups = isAssistMode.Value? assistModePickups : normalModePickups; List <PickupRepresentation> possiblePickups = new List <PickupRepresentation>(); possiblePickups.AddRange(allPickups.Pickups); for (int i = 0; i < toCreate; i++) { Vector2 anchorPos = Vector2.right * (wallVar.Value.Radius + pickupOffset.x) + Vector2.up * (-pickupOffset.y + offsetInc * i); anchorPos = MathUtils.Rotate(anchorPos, angle); Vector2 dir = (MathUtils.Rotate(Vector2.right, (angle + 180) % 360) - MathUtils.Rotate(Vector2.right, angle)).normalized; Keyframe lastKey = pickupSpeed.keys[pickupSpeed.keys.Length - 1]; float speed = pickupSpeed.Evaluate(Mathf.Clamp(CurrentWave, 0, lastKey.time)); bool isHealthPickup = (i == 1); RoundPickup pickup = null; if (isHealthPickup) { if (playTest.spawnHealthOpposite) { anchorPos += anchorPos.magnitude * dir * 2; dir = -dir; } pickup = Instantiate(healthPickup, (Vector3)anchorPos, Quaternion.identity); } else { pickup = Instantiate(roundPickupPrefab, (Vector3)anchorPos, Quaternion.identity); possiblePickups = PopulatePickup(pickup, possiblePickups); } pickup.SetupPickup(dir, speed); } SetIsInstantiatedValue(true); }
private List <PickupRepresentation> PopulatePickup(RoundPickup pickup, List <PickupRepresentation> pickups) { if (pickups == null || pickups.Count <= 0) { return(pickups); } int chosenIndex = TimedBoundRandom.RandomInt(0, pickups.Count); PickupRepresentation representation = pickups[chosenIndex]; pickup.SetPlayerStats(representation.increments, representation.decrements, representation.image); pickup.topLabel = representation.topLabel; pickup.botLabel = representation.botLabel; pickups.RemoveAt(chosenIndex); return(pickups); }
public Transform GetNextRandomDrop() { Compute(); if (!hasSpawned) { hasSpawned = true; return(drops[firstDropIndex].pickup); } float roll = TimedBoundRandom.RandomFloat(0, 1); for (int i = 0; i < drops.Length; i++) { if (roll <= dropChance[i]) { return(drops[i].pickup); } } return(null); }
protected override void Start() { dir = Mathf.Sign(TimedBoundRandom.RandomFloat(float.MinValue, float.MaxValue)); base.Start(); }
private void InstantiateOnDistance(Transform t) { Vector3 pos = GeometryUtils.PointInCircle(instantiateDistance, TimedBoundRandom.RandomFloat(0, 360)); Instantiate(t, pos, Quaternion.Euler(0, 0, TimedBoundRandom.RandomFloat(0, 360))); }
private void ScoreOnDeath() { roundVar.Value += score + (int)TimedBoundRandom.RandomFloat(-scoreOffsetPercent * score, scoreOffsetPercent * score); }