//------------------------------------------------------------------------------------------------------------------------------------ private void Update() { if (nextGalaxySpawn > 0) { nextGalaxySpawn -= Time.deltaTime; } else { SpawnGalaxy(); nextGalaxySpawn = GetNextGalaxyCountdown(); } bool wasActive = pusherActive; if (Input.GetMouseButton(0)) { pusherActive = GetClickPosition(out pusherPosition); if (pusherActive) { clickFX.transform.position = pusherPosition; } } else { pusherActive = false; } if (!wasActive && pusherActive) { asPush.Play(); clickFX.SetActive(true); } else if (wasActive && !pusherActive) { asPush.Stop(); clickFX.SetActive(false); } for (int i = 0; i < galaxies.Count - 1; ++i) { for (int j = i + 1; j < galaxies.Count; ++j) { if (Galaxy.UpdateVelocities(galaxies[i], galaxies[j], mergeGalaxyFactor, i, j, deleteList)) { asMerge.Play(); } } } float totalSize = 0; for (int i = 0; i < galaxies.Count; ++i) { if (pusherActive) { galaxies[i].ApplyPush(pusherPosition, pushValue); } galaxies[i].Update(Time.deltaTime, velocityDiffusion, ref totalSize, galaxyCollapseSize); } if (deleteList.Count > 0) { for (int i = 0; i < deleteList.Count; ++i) { int index = deleteList[i]; if (index >= 0 && index < galaxies.Count) { galaxies[index].OnDestroy(); galaxies.RemoveAt(index); } } deleteList.Clear(); } maxGalaxies = Mathf.Max(maxGalaxies, galaxies.Count); int oldScore = (int)score; float deltaScore = diameterScoreScale * totalSize * Mathf.Max(0, galaxies.Count - 1); score += deltaScore * Time.deltaTime; int newScore = (int)score; if (oldScore != newScore) { txtScore.text = string.Format("{0} (d={1:0.000} Hz)", newScore, deltaScore); } MaxRate = Mathf.Max(MaxRate, deltaScore); if (galaxies.Count == 1 && maxGalaxies > 1) { if (galaxies[0].IsGreaterOrEqual(maxGalaxies)) { OnGameOver.Invoke(); } } }