Exemplo n.º 1
0
        private IEnumerator MoveShipToOtherSide(Ship ship)
        {
            while (Vector3.Distance(ship.transform.position, otherSide.transform.position) > GameSettings.instance.wormholeExitThreshold)
            {
                var direction = (otherSide.transform.position - ship.transform.position).normalized;

                var pos = ship.transform.position;
                pos += direction * GameSettings.instance.wormholeMovementSpeed * Time.deltaTime;
                ship.transform.position = pos;

                yield return null;
            }

            // Spawn the workhole exit effect
            otherSide.SpawnWormholeExitEffect();

            // Player the wormhole exit sound
            Sounds.PlayOneShot("WormholeShipExit");

            // Exit the wormhole
            ship.transform.position = otherSide.transform.position;
            ship.SetVisible(true);

            // Give the ship a random weapon
            ship.RandomizeWeapon();

            // Throw the player out of the wormhole
            ship.ApplyForce((otherSide.transform.position - transform.position).normalized *
                            GameSettings.instance.wormholeExitImpulse / Time.deltaTime);
        }