// Use this for initialization void Start() { spawnRate = Random.Range(spawnRateMin, spawnRateMax); nextSpawn = Time.time + spawnRate; wg = FindObjectOfType <WaveGenerator>(); if (wg == null) { wg = FindObjectOfType <WaveGeneratorTutorial>(); } buildZones = FindObjectsOfType <BuildZone>(); baseCollider = PlayerBase_Stats.Instance.gameObject.GetComponent <Collider2D>(); }
/// <summary> /// Observes a single point of distance <paramref name="y"/> at obervation point <paramref name="x"/> between the two closest lattice points as defined by <paramref name="density"/>. /// </summary> /// <param name="x">Coordinant between the two closest lattice points</param> /// <param name="y">Distance along the wave forms on the lattice points</param> /// <param name="maxHeight">The maximum value to be returned, return value can be between 0 and <paramref name="maxHeight"/></param> /// <param name="density">Used when calculating how close the nearest two lattice poitns are located in coordinant space</param> /// <param name="frequency">Used when calcualting the wave form of each of the two lattice points</param> /// <returns></returns> private double ObserveHeightAtLaticePoint(int x, int y, int maxHeight, double density, double frequency) { double leftWaveOrigin = Math.Floor(x / density) * density; double rightWaveOrigin = Math.Ceiling(x / density) * density; double observationPoint = (x - leftWaveOrigin) / density; observationPoint = SmoothLatticeApproach(observationPoint); IWaveGenerator leftWave = Activator.CreateInstance(waveGeneratorType, (int)leftWaveOrigin) as IWaveGenerator; IWaveGenerator rightWave = Activator.CreateInstance(waveGeneratorType, (int)rightWaveOrigin) as IWaveGenerator; double leftHeight = leftWave.Observe(y, maxHeight, frequency); double rightHeight = rightWave.Observe(y, maxHeight, frequency); double waveDisparity = rightHeight - leftHeight; double observableWaveHeight = leftHeight + waveDisparity * observationPoint; return(observableWaveHeight); }