void UpdateIdling() { float elapsedTime = Time.time - lastTimeReachPlanet; if (elapsedTime < 0 || player == null || lookAt == null) { return; } var eyeDirection = (int)Mathf.Sign(lookAt.position.x - player.CatchedTransform.position.x); if (elapsedTime > idleTime) { lastTimeReachPlanet = Time.time + _idleTimeRange.GetRandomValue(); idleTime = _idleTimeRange.GetRandomValue(); eyeDirection = 0; } anim.SetInteger(animatorStaringDirection, eyeDirection); if (isFlippin) { catchedTransform.localRotation = eyeDirection == 0 ? catchedTransform.localRotation : eyeDirection > 0 ? normalRotation : flippedRotation; } }
IEnumerator Blinking() { while (true) { yield return(new WaitForSeconds(_blinkingRate.GetRandomValue())); anim.SetTrigger(animatorBlink); } }
public Orbit(Slot slot, OrbitPath path) { CatchedTransform = slot.CatchedTransform; OrbitPath = path; CatchedPosition = CatchedTransform.position; pathPercentOffset = initialPercentOffsetRange.GetRandomValue(); float difficultyMultiplier = DifficultyConfig.Ref.GetSpeedMultiplier(slot.GalaxyIndex); globalSpeedMultiplier = globalSpeedMultiplierRange.GetRandomValue() * difficultyMultiplier; CreateEnemies(); }
private void Start() { //player = PlayerValues.GetPlayer(0).gameObject;//GameObject.FindGameObjectWithTag("Player"); //player2 = PlayerValues.GetPlayer(1).gameObject;//GameObject.FindGameObjectWithTag("Player2"); Coral = GameObject.FindGameObjectWithTag("Coral"); Destroy(transform.root.gameObject, TimeToDeath); xOrigin = parent.transform.position.x; //random start x timeAlive = Random.Range(0.0f, 100.0f); xSpeed = XSpeed.GetRandomValue(); maxXDelta = MaxXDelta.GetRandomValue(); ShakeVector = new Vector3(Mathf.Clamp(ShakeVector.x, -5, 5), 0, 0); }
bool TrySpawnShield(Slot slot) { if (Player.Ref && Player.Ref.ShieldCount > 0 || shieldsInCurrentGalaxy >= ShieldConfig.Ref.MaxShieldsPerGalaxy || planetsWithoutShield < ShieldConfig.Ref.MinPlanetsWithoutShield || planetsWithoutShield < ShieldConfig.Ref.MaxPlanetsWithoutShield && shieldRandomizer.GetRandomValue() >= ShieldConfig.Ref.ShieldChance) { return(false); } slot.CreateOrbit(shieldOrbit); shieldsInCurrentGalaxy++; return(true); }
void RandomizeNextSign() { nextSign = Mathf.Sign(signRandomizer.GetRandomValue()); }
void CreateSlotAtEnd() { var pos = new Vector3(nextSign * xOffset.GetRandomValue(), yOffset.GetRandomValue(), 0); if (reachedSlots.Count == 0 && unreachedSlots.Count == 0) { pos = Vector3.zero; } if (unreachedSlots.Count > 0) { pos += unreachedSlots.Last().Position; } var galaxySetting = GalaxiesConfig.Ref.GetConfig(galaxyIndex); bool isCheckpoint = planetIndex == 0 && galaxyIndex > 0; var slotPrefab = isCheckpoint ? _checkpointSlotPrefab : _normalSlotPrefab; var slot = Pool.GetInstance(slotPrefab, activate: false); slot.Position = pos; slot.name = "Planet (" + galaxyIndex + ":" + planetIndex + ")"; slot.GalaxyIndex = galaxyIndex; slot.PlanetIndex = planetIndex; unreachedSlots.Enqueue(slot); RandomizeNextSign(); slot.NextPlanetSign = nextSign >= 0; slot.Enable(); if (slot.IsCheckpoint) { slot.name += " Checkpoint"; shieldsInCurrentGalaxy = 0; SlotLabels.CreateLabelForSlot(slot); } else if (galaxyIndex > 0 || planetIndex > 1) { bool includeEarlier = galaxySetting.IncludeEarlier; bool isRandomOrder = !galaxySetting.IsFixedOrder; bool isLastPlanetInGalaxy = planetIndex == galaxySetting.PlanetCount; var pathPrefabs = ChoosePathPrefabs(smallOrbits, galaxyIndex, allSmallOrbits, includeEarlier); TryConcatCustomFolder(ref pathPrefabs, galaxySetting.CustomFolder, false); CreateOrit(slot, pathPrefabs, isRandomOrder); if (isLastPlanetInGalaxy) { pathPrefabs = ChoosePathPrefabs(bigOrbits, galaxyIndex, allBigOrbits, includeEarlier); TryConcatCustomFolder(ref pathPrefabs, galaxySetting.CustomFolder, true); CreateOrit(slot, pathPrefabs, true); } else if (!GameController.Ref.IsSkippingLevels) { if (TrySpawnShield(slot)) { planetsWithoutShield = 0; } else { planetsWithoutShield++; TrySpawnLetter(slot); } } } planetIndex++; if (planetIndex <= galaxySetting.PlanetCount) { return; } planetIndex = 0; if (GameController.Ref.IsSkippingLevels) { galaxyIndex = GameController.Ref.GalaxiesToSkip; } else { galaxyIndex++; } }
public float GetPitch() { return(pitch.GetRandomValue()); }
public float GetVolume() { return(volume.GetRandomValue()); }
void OnBounce() { StartCoroutine(CloseEye(_closeEyeRange.GetRandomValue())); }