public override void Awake() { base.Awake(); cursor_boundaries_.GetLimits(cursor, gameObject); SetBloomGain(incIndicator, 1.0f); SetBloomGain(decIndicator, 1.0f); }
public Vector2 Move(Vector2 direction) { _rigidBody.velocity = direction * speed; if (limits != null) { var currentLimits = limits.GetLimits(); _rigidBody.position = new Vector2 ( Mathf.Clamp(_rigidBody.position.x, currentLimits.XMin, currentLimits.XMax), Mathf.Clamp(_rigidBody.position.y, currentLimits.YMin, currentLimits.YMax) ); } return(_rigidBody.velocity); }
private void SpawnSingleAsteroid(Models.Asteroid asteroid, float speedMultiplier) { var currentLimits = limits.GetLimits(); Vector3 spawnPosition = new Vector3(Random.Range(currentLimits.XMin, currentLimits.XMax), Random.Range(currentLimits.YMin, currentLimits.YMax), 0); Quaternion spawnRotation = Quaternion.identity; GameObject asteroidGameObject = GetAsteroidGameObject(asteroid.Type); var instantiatedAsteroid = Instantiate(asteroidGameObject, spawnPosition, spawnRotation) as GameObject; var onDeathComponent = instantiatedAsteroid.GetComponent <OnDeath> (); var destroyOnImpactComponent = instantiatedAsteroid.GetComponent <DestroyOnImpact> (); var hasHealthComponent = instantiatedAsteroid.GetComponent <HasHealth> (); var asteroidControlComponent = instantiatedAsteroid.GetComponent <AsteroidControl> (); var hasPointsComponent = instantiatedAsteroid.GetComponent <HasPoints>(); hasPointsComponent.SetPointsController(_levelController); // So that levelcontroller gets points from asteroid asteroidControlComponent.SetSpeed(asteroid.Speed * speedMultiplier); hasHealthComponent.SetHealth(asteroid.Health); onDeathComponent.RegisterDeathController(_registerDeath); destroyOnImpactComponent.RegisterDeathController(_registerDeath); }