void Start() { LoadLevelData(); // God I love Unity Time.timeScale = timeScale; inPlay = false; inputController.displayRings = true; lastSafeLanding = new GameObject("Starting Position"); lastSafeLanding.transform.position = rocketStartingPosition; claimedAsteroids = new List <GameObject>(); SetCameraFollowMode(CameraMode.Neutral); SetOxygenMode(OxygenMode.Safe); // sets a callback on inputController, works like magic. inputController.whenUpdated += GestureUpdated; inputController.whenEnded += GestureEnded; blackHoleGObject = Instantiate(blackHolePrefab); blackHoleController = blackHoleGObject.GetComponent <BlackHoleController>(); blackHoleController.gameController = this; rocketGObject = Instantiate(rocketPrefab, rocketStartingPosition, Quaternion.Euler(0, 0, 0)); rocketController = rocketGObject.GetComponent <RocketController>(); inputController.rocketController = rocketController; MakeNewPlanet(planetPosition); foreach (Vector3 position in asteroidStartingPositions) { MakeNewAsteroid(position); } endOfLevelButtons.SetActive(false); pauseMenuButtons.SetActive(false); pauseButton.SetActive(true); }
/// <summary> /// When the ball collides with the ground the ball is destroyed and a message is sent to the /// player being teleported with the new position for that player. The shooting bool for /// the player that shot is also set to false /// </summary> /// <param name="collision"></param> private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Ground" || collision.gameObject.layer == LayerMask.NameToLayer("Wall") || collision.gameObject.layer == LayerMask.NameToLayer("Interactable Objects")) { TeleportBallEvent(); } //if (touchingTeleportableSurface) //{ // TeleportBallEvent(); // ResetShootingVariables(); //} //if (touchingTeleportDestroySurface) //{ // Destroy(gameObject); // ResetShootingVariables(); //} if (collision.gameObject.layer == LayerMask.NameToLayer("Black hole")) { blackHole = collision.transform.gameObject.GetComponent <BlackHoleController>(); blackHoleCheckPoint = collision.transform.gameObject; blackHole.SendMessage("PlayTeleportSound"); playerBeingTeleported.SendMessage("SetBlackHoleCheckPoint", blackHoleCheckPoint); playerShooting.SendMessage("SetBlackHoleCheckPoint", blackHoleCheckPoint); TeleportBothPlayers(); } else if (collision.gameObject.tag == "Teleport destroyer") { Destroy(gameObject); ResetShootingVariables(); } }
// Use this for initialization void Start() { _stellarBodyController = FindObjectOfType <StellarBodyController>(); _shipController = FindObjectOfType <ShipController>(); _blackHoleController = FindObjectOfType <BlackHoleController>(); }