コード例 #1
0
        float ComputeCenteredHorizontalOffset()
        {
            Vector3 centerLocation = map.GetCurrentMapLocation();
            Vector2 uv             = Conversion.GetUVFromSpherePoint(centerLocation);

            return(uv.x);
        }
        /// <summary>
        /// Creates a simple gameobject (sphere) on current map position and launch it over a random position on the globe following an arc
        /// </summary>
        void FireBullet()
        {
            // Create a "bullet" with a simple sphere at current map position from camera perspective
            GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);

            sphere.GetComponent <Renderer>().material.color = Color.yellow;

            // Choose starting pos
            Vector3 startPos = map.GetCurrentMapLocation();

            // Get a random target city
            int     randomCity = Random.Range(0, map.cities.Count);
            Vector3 endPos     = map.cities[randomCity].unitySphereLocation;

            // Fire the bullet!
            StartCoroutine(AnimateBullet(sphere, 0.01f, startPos, endPos));
        }