void Start()
    {
        //Load the given objects from ressource folder, for later use
        player = Resources.Load("Spaceships/Player", typeof(GameObject)) as GameObject;
        pilotAI = Resources.Load("Spaceships/PlayerAI", typeof(GameObject)) as GameObject;
        spawner = Resources.Load("Spawner", typeof(GameObject)) as GameObject;
        combatHUD = Resources.Load("HUD/CombatHUD", typeof(GameObject)) as GameObject;
        enemy = Resources.Load("Enemy", typeof(GameObject)) as GameObject;
        enemyHUD = Resources.Load("HUD/EnemyHUD", typeof(GameObject)) as GameObject;
        playerHUD = Resources.Load("HUD/PlayerHUD", typeof(GameObject)) as GameObject;

        //Types of drops
        commonDrop = Resources.Load("Drops/CommonDrop", typeof(GameObject)) as GameObject;
        uncommonDrop = Resources.Load("Drops/UncommonDrop", typeof(GameObject)) as GameObject;
        rareDrop = Resources.Load("Drops/RareDrop", typeof(GameObject)) as GameObject;
        healthDrop = Resources.Load("Drops/HealthDrop", typeof(GameObject)) as GameObject;
        shieldDrop = Resources.Load("Drops/ShieldDrop", typeof(GameObject)) as GameObject;
        powerDrop = Resources.Load("Drops/PowerDrop", typeof(GameObject)) as GameObject;

        getPlayers = GameObject.FindGameObjectsWithTag("Pilot");
        getAIs = GameObject.FindGameObjectsWithTag("PilotAI");
        Instantiate(spawner, new Vector2(10, 0), Quaternion.identity); // Spawn spawner
        spawnerScript = GameObject.Find("Spawner(Clone)").GetComponent<Spawner>();
        Instantiate(combatHUD, transform.position, Quaternion.identity);    // Spawn AI GUI
        waveOutcome = WaveOutcomes.Waiting;

        #region Next Round timer
        nextRoundTimer = new Timer(5000);
        nextRoundTimer.Elapsed += new ElapsedEventHandler(NextRound);
        nextRoundTimer.Enabled = true;

        callNewRound = false;
        #endregion
    }
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            Application.LoadLevel("Main Menu");
        }
        if (Input.GetKeyDown(KeyCode.P))
        {
            if (Time.timeScale == 1)
            {
                Time.timeScale = 0;
            }
            else
            {
                Time.timeScale = 1;
            }
        }

        if (callNewRound)
        {
            NewRound();
        }

        print(waveOutcome.ToString());

        #region Detects Enemies
        enemyDetection = Physics2D.CircleCastAll(transform.position, 30f, transform.right, 500f, enemyLayer);
        pilotDetection = Physics2D.CircleCastAll(transform.position, 30f, transform.right, 500f, pilotLayer);

        if (pilotDetection.Length == 0 && waveOutcome != WaveOutcomes.Waiting)
        {
            waveOutcome = GameController.WaveOutcomes.GameLoss;
        }

        if (enemyDetection.Length == 0 && spawnerScript.countMinions == 10 && (waveOutcome != WaveOutcomes.GameWin || waveOutcome != WaveOutcomes.GameLoss))
        {
            spawnerScript.countMinions = 0;
            waveOutcome = GameController.WaveOutcomes.Win;
            nextRoundTimer.Enabled = true;
        }
        else if (enemyDetection.Length != 0 && waveOutcome == GameController.WaveOutcomes.Win)
        {
            waveOutcome = GameController.WaveOutcomes.Ongoing;
        }
        #endregion
    }
    void NewRound()
    {
        waveOutcome = WaveOutcomes.Waiting;
        callNewRound = false;
        roundNumber++;

        if (playerType == "pilot")
        {
            if (getPlayers.Length == 0)
            {
                GameObject.Find("CombatHUD(Clone)").GetComponent<CombatHUD>().roundEnd.text = "";
                Instantiate(player, new Vector2(-7.50f, 3f), Quaternion.Euler(0, 0, -90));      // Spawn player
                Instantiate(pilotAI, new Vector2(-7.50f, -3f), Quaternion.Euler(0, 0, -90));    // Spawn AI          
                Instantiate(playerHUD, transform.position, Quaternion.identity);    // Spawn Pilot GUI
                playerScript = GameObject.Find("Player(Clone)").GetComponent<Player>();

                playersLeft = 2;
            }
            else if (getPlayers.Length == 1 && getAIs.Length == 0)
            {
                Instantiate(pilotAI, new Vector2(-7.50f, -3f), Quaternion.Euler(0, 0, -90));    // Spawn AI 
                playersLeft++;
            }

            if (getPlayers.Length == 1)
            {
                GameObject.Find("PlayerHUD(Clone)").GetComponent<PlayerHUD>().Open();
            }
            playerScript.missedShots = 0;
        }
        else if (playerType == "alien")
        {
            if (getAIs.Length == 0)
            {
                GameObject.Find("CombatHUD(Clone)").GetComponent<CombatHUD>().roundEnd.text = "";
                Instantiate(pilotAI, new Vector2(-7.50f, -3f), Quaternion.Euler(0, 0, -90));    // Spawn AI  
                Instantiate(pilotAI, new Vector2(-7.50f, 3f), Quaternion.Euler(0, 0, -90));    // Spawn AI  
                Instantiate(enemy, new Vector2(10, 0), Quaternion.identity);            // Spawn enemy
                Instantiate(enemyHUD, transform.position, Quaternion.identity);   // Spawn enemyHUD
            }
            else if (getAIs.Length == 1)
            {
                Instantiate(pilotAI, new Vector2(-7.50f, -3f), Quaternion.Euler(0, 0, -90));    // Spawn AI 
            }

            if (getAIs.Length != 0 && roundNumber != lastRound - 1)
            {
                GameObject.Find("EnemyHUD(Clone)").GetComponent<EnemyHUD>().Open();
            }
        }

        spawnerScript.nextRound.Enabled = true;
        getPlayers = GameObject.FindGameObjectsWithTag("Pilot");
        getAIs = GameObject.FindGameObjectsWithTag("PilotAI");
    }