Esempio n. 1
0
        public void SpawnPlayer(int playerNumber)
        {
            Debug.Log("Spawning player " + playerNumber);

            var position = new Vector3();
            do
            {
                position = GetRandomSpawnPosition();
            } while (Physics2D.OverlapCircle(position, 3f));

            if (playerNumber == 1)
            {
                player1Ship = (Instantiate(GameSettings.instance.player1ShipPrefab,
                    GetRandomArenaPosition(GameSettings.instance.spawnRadius, GameSettings.instance.spawnRadius),
                    Quaternion.identity) as GameObject).GetComponent<Ship>();
                player1Ship.InstallWeapon(GameSettings.instance.starterWeaponPrefab);
            }
            else
            {
                player2Ship = (Instantiate(GameSettings.instance.player2ShipPrefab,
                    GetRandomArenaPosition(GameSettings.instance.spawnRadius, GameSettings.instance.spawnRadius),
                    Quaternion.identity) as GameObject).GetComponent<Ship>();
                player2Ship.InstallWeapon(GameSettings.instance.starterWeaponPrefab);
            }
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
 public static SpaceObject GetOtherShip(Ship ship)
 {
     return ship == instance.player1Ship ? instance.player2Ship : instance.player1Ship;
 }