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); }
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); }