private float GetShotAngleSmart() { Vector2 dir = SpaceObjectMngr.SmartPath(this.View.Pos, this.Ship.Pos); return(Vector2.Angle(Vector2.right, dir) * Mathf.Sign(dir.y)); }
//====================================================================== public void Init(int size, float speed) { _trans.position = SpaceObjectMngr.LateralRandomPos(); _trans.localScale = SMALL_SCALE * (size + 1); _sense = _trans.position.x > 0 ? -1 : 1; this.speed = speed; StartCoroutine(this.SetRandomDirection()); }
/// <summary> /// Implements <see cref="CgfGames.IAsteroidView.SpawnAsteroid"/> /// </summary> public IAsteroidView SpawnAsteroid(Vector3 shipPos) { // Get random asteroid init pos far from the ship. Vector3 pos = SpaceObjectMngr.RandomPos(); while (SpaceObjectMngr.SmartPath(pos, shipPos).sqrMagnitude < 2.5f * 2.5f) { pos = SpaceObjectMngr.RandomPos(); } // Spawn and init ship. AsteroidView asteroidView = this.asteroidPool .Get( pos, Quaternion.Euler(0, 0, Random.value * 360) ).GetComponent <AsteroidView> (); asteroidView.Init( AsteroidCtrl.MAX_SIZE, this.asteroidPool, this.powerupPool, this.asteroidExplosionPool ); return(asteroidView); }
/// <summary> /// Coroutine for the previous method. /// </summary> private IEnumerator Teleport2(Action teleportDone) { // Complex sequence for teleporting: // Step 1: this.teleportPs.Play(); _audio.PlayOneShot(this.teleportClip); _col.enabled = false; yield return(new WaitForSeconds(0.25f)); // Step 2: _rend.enabled = false; yield return(new WaitForSeconds(1.5f)); // Step 3: _trans.position = SpaceObjectMngr.RandomPos(); _rb.Sleep(); teleportPs.Play(); yield return(new WaitForSeconds(0.25f)); // Step 4: this.SetActiveSoft(true); _audio.PlayOneShot(this.teleportClip); teleportDone.Invoke(); }