Example #1
0
        private float GetShotAngleSmart()
        {
            Vector2 dir =
                SpaceObjectMngr.SmartPath(this.View.Pos, this.Ship.Pos);

            return(Vector2.Angle(Vector2.right, dir) * Mathf.Sign(dir.y));
        }
Example #2
0
        /// <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);
        }