// Update is called once per frame
    void Update()
    {
        Buy_Shoot_Modes bsm = GameObject.Find("GameController").GetComponent <Buy_Shoot_Modes> ();

        //	Debug.Log (Mathf.Sin(bsm.fireAngle));
        aimPan.LookAt(bsm.targetPosition);
        if (bsm.fireAngle > 0)
        {
            transform.eulerAngles = new Vector3(-(Mathf.Sin(bsm.fireAngle) * 180.0f) / Mathf.PI, aimPan.eulerAngles.y, 0.0f);
        }
        else
        {
            transform.eulerAngles = new Vector3(aimPan.eulerAngles.x, aimPan.eulerAngles.y, 0.0f);
        }
    }
Beispiel #2
0
    void SpawnEnemy()
    {
        if (numEnemies > 0)
        {
            if (spawnDuration <= 0.0f)
            {
                if (selectEnemy < enemy.Length - 1)
                {
                    Instantiate(enemy[selectEnemy], startPoint, Quaternion.identity);
                }
                else
                {
                    Instantiate(enemy[selectEnemy], new Vector3(Random.Range(85.0f, 100.0f), Random.Range(0, 20),
                                                                Random.Range(-50, 50)), Quaternion.identity);
                }
                numEnemies--;
                numEnemiesRemaining++;

                //Debug.Log (numEnemiesRemaining);
                spawnDuration = spawnTime;
            }
            spawnDuration -= Time.deltaTime;
            //Debug.Log(numEnemies);
        }
        else
        {
            selectEnemy   = Random.Range(0, enemy.Length);
            numEnemies    = initEnemies;
            spawnDuration = 7.0f;
        }
        if (waveNo == 1 || waveNo % 2 == 0)
        {
            if (newEnem > 0)
            {
                if (outsideSpawnDuration <= 0.0f)
                {
                    newEnem--;
                    Buy_Shoot_Modes bsm = theGC.GetComponent <Buy_Shoot_Modes>();
                    GameObject      eO  = (GameObject)Instantiate(enemyOut, new Vector3(95.0f, 0.0f, 15.0f),
                                                                  Quaternion.identity);
                    MoveUsingDFS mud = eO.GetComponent <MoveUsingDFS>();
                    mud.wayPoints = bsm.thePath;
                    Debug.Log(bsm.thePath.Count);
                    numEnemiesRemaining++;
                    outsideSpawnDuration = outSpawnTime;
                }
                outsideSpawnDuration -= Time.deltaTime;
            }
            else
            {
                newEnem = initEnemies / 2;
                outsideSpawnDuration = 7.0f;
            }
        }
        //i'll clean this up later and make it a function
        if (waveNo == 1 || waveNo % 3 == 0)
        {
            if (newEnem1 > 0)
            {
                if (outsideSpawnDuration1 <= 0.0f)
                {
                    newEnem1--;
                    Buy_Shoot_Modes bsm = theGC.GetComponent <Buy_Shoot_Modes>();
                    GameObject      eO  = (GameObject)Instantiate(enemyOut, new Vector3(95.0f, 0.0f, -45.0f),
                                                                  Quaternion.identity);
                    MoveUsingDFS mud = eO.GetComponent <MoveUsingDFS>();
                    mud.wayPoints = bsm.thePath2;
                    Debug.Log(mud.wayPoints.Count);
                    numEnemiesRemaining++;
                    outsideSpawnDuration1 = outSpawnTime1;
                }
                outsideSpawnDuration1 -= Time.deltaTime;
            }
            else
            {
                newEnem1 = initEnemies / 2;
                outsideSpawnDuration1 = 7.0f;
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        //Debug.Log ("is it all blue: " + allBlue);
        waveDuration -= Time.deltaTime;
        if ((waveDuration < 0.0f && numEnemiesRemaining == 0))
        {
            waveNo++;
            if (waveNo % 10 == 0)
            {
                HellWave = Random.Range(waveNo + 8, waveNo + 10);
            }
            if (waveNo % 12 == 0)
            {
                if (difficulty < 3)
                {
                    difficulty++;
                }
            }
            waveCompleted++;
            if (advanced > 0)
            {
                waveCompleted += advanced;
            }
            Debug.Log("NEW WAVE === wave number: " + waveNo);
            waveDuration = waveTime + 10;
            waveTime    += 10;
            spawnCount  += 1;
            if (startWait < 25.0f)
            {
                startWait += 1.0f;
            }
            if (waveNo % 4 == 0)
            {
                healthMultiplier += 0.30f;
                if (speedMultiplier <= 2.0f)
                {
                    speedMultiplier += 0.175f;
                }
                if (spawnWait > 0.5f)
                {
                    spawnWait -= 0.4f;
                }
                if (waveWait > 2.0f)
                {
                    waveWait -= 0.05f;
                }
            }
            if (!allBlue)
            {
                StartCoroutine(SpawnEasyWaves(waveDuration, spawnCount, healthMultiplier, speedMultiplier,
                                              waveWait, spawnWait));
            }
            else
            {
                Debug.Log("Hello there wat up");
                StartCoroutine(SpawnOutsideWavesMid(waveDuration, spawnCount, healthMultiplier, speedMultiplier,
                                                    waveWait, spawnWait));
            }
            for (int i = 0; i < difficulty; i++)
            {
                if (waveNo % 2 == 0)
                {
                    StartCoroutine(SpawnOutsideWavesTop(waveDuration - 15, spawnCount / 2, healthMultiplier, speedMultiplier,
                                                        waveWait, spawnWait));
                }
                if (waveNo % 3 == 0)
                {
                    StartCoroutine(SpawnOutsideWavesBottom(waveDuration - 15, spawnCount / 2, healthMultiplier, speedMultiplier,
                                                           waveWait, spawnWait));
                }
            }
            if (waveNo == HellWave)
            {
                //spawn hell wave
                //spawnHellWave();
                if (!allBlue)
                {
                    StartCoroutine(SpawnEasyWaves(waveDuration, spawnCount, healthMultiplier * 1.2f, speedMultiplier * 1.2f,
                                                  waveWait, spawnWait));
                }
                else
                {
                    StartCoroutine(SpawnOutsideWavesMid(waveDuration, spawnCount, healthMultiplier * 1.2f, speedMultiplier * 1.2f,
                                                        waveWait, spawnWait));
                }
                StartCoroutine(SpawnOutsideWavesTop(waveDuration - 15, spawnCount / 2, healthMultiplier * 1.2f, speedMultiplier * 1.2f,
                                                    waveWait, spawnWait));
                StartCoroutine(SpawnOutsideWavesBottom(waveDuration - 15, spawnCount / 2, healthMultiplier * 1.2f, speedMultiplier * 1.2f,
                                                       waveWait, spawnWait));
            }
            advanced = 0;
        }
        if (advanceTheWave)
        {
            Debug.Log("The wave was advanced to: " + waveNo);
            advanced++;
            waveNo++;
            if (waveNo % 10 == 0)
            {
                HellWave = Random.Range(waveNo + 8, waveNo + 10);
            }
            if (waveNo % 12 == 0)
            {
                if (difficulty < 3)
                {
                    difficulty++;
                }
            }
            Debug.Log("NEW WAVE === wave number: " + waveNo);
            waveDuration = waveTime + 10;
            waveTime    += 10;
            spawnCount  += 1;
            if (startWait < 25.0f)
            {
                startWait += 1.0f;
            }
            if (waveNo % 4 == 0)
            {
                healthMultiplier += 0.3f;
                if (speedMultiplier <= 2.0f)
                {
                    speedMultiplier += 0.1f;
                }
                if (spawnWait > 0.5f)
                {
                    spawnWait -= 0.4f;
                }
                if (waveWait > 2.0f)
                {
                    waveWait -= 0.05f;
                }
            }
            if (!allBlue)
            {
                StartCoroutine(SpawnEasyWaves(waveDuration, spawnCount, healthMultiplier, speedMultiplier,
                                              waveWait, spawnWait));
            }
            else
            {
                Debug.Log("Hello there wat up");
                StartCoroutine(SpawnOutsideWavesMid(waveDuration, spawnCount, healthMultiplier, speedMultiplier,
                                                    waveWait, spawnWait));
            }
            for (int i = 0; i < difficulty; i++)
            {
                if (waveNo % 2 == 0)
                {
                    StartCoroutine(SpawnOutsideWavesTop(waveDuration - 15, spawnCount / 2, healthMultiplier, speedMultiplier,
                                                        waveWait, spawnWait));
                }
                if (waveNo % 3 == 0)
                {
                    StartCoroutine(SpawnOutsideWavesBottom(waveDuration - 15, spawnCount / 2, healthMultiplier, speedMultiplier,
                                                           waveWait, spawnWait));
                }
            }
            if (waveNo == HellWave)
            {
                //spawn hell wave
                //spawnHellWave();
                if (!allBlue)
                {
                    StartCoroutine(SpawnEasyWaves(waveDuration, spawnCount, healthMultiplier * 1.2f, speedMultiplier * 1.2f,
                                                  waveWait, spawnWait));
                }
                else
                {
                    StartCoroutine(SpawnOutsideWavesMid(waveDuration, spawnCount, healthMultiplier * 1.2f, speedMultiplier * 1.2f,
                                                        waveWait, spawnWait));
                }
                StartCoroutine(SpawnOutsideWavesTop(waveDuration - 15, spawnCount / 2, healthMultiplier * 1.2f, speedMultiplier * 1.2f,
                                                    waveWait, spawnWait));
                StartCoroutine(SpawnOutsideWavesBottom(waveDuration - 15, spawnCount / 2, healthMultiplier * 1.2f, speedMultiplier * 1.2f,
                                                       waveWait, spawnWait));
            }
            advanceTheWave = false;
        }

        if (wallsWereDestroyed)
        {
            Debug.Log("DEEEEEEESTROYED");
            Buy_Shoot_Modes bsm = GameObject.FindGameObjectWithTag("GameController").GetComponent <Buy_Shoot_Modes>();
            bsm.thePath3 = bsm.dijkstraPath(bsm.start3, bsm.thePath3);
            bsm.thePath2 = bsm.dijkstraPath(bsm.start2, bsm.thePath2);
            if (allBlue)
            {
                Debug.Log("ehllo");
                bsm.thePath = bsm.dijkstraPath(bsm.start, bsm.thePath);
            }
            wallsWereDestroyed = false;
        }
    }
    IEnumerator SpawnOutsideWavesBottom(float waveDur, int enemyCount, float hMult, float sMult,
                                        float waveWaitTime, float spawnWaitTime)
    {
        Debug.Log("OUTSIDE WAVE BOTTOM");
        yield return(new WaitForSeconds(startWait));

        waveDur -= startWait;
        waveDur -= Time.deltaTime;
        while (waveDur >= 0)
        {
            yield return(new WaitForSeconds(waveWaitTime));

            waveDur -= waveWaitTime;
            if (waveDur < 0)
            {
                break;
            }
            if (gameObject.GetComponent <Buy_Shoot_Modes>().gameover)
            {
                break;
            }
            for (int i = 0; i < enemyCount; i++)
            {
                numEnemiesRemaining++;
                int selectEnemy = 0;
                if (waveNo < 5)
                {
                    selectEnemy = Random.Range(0, enemy.Length - 2);
                }
                else
                {
                    selectEnemy = Random.Range(0, enemy.Length);
                }
                GameObject eO;
                if (selectEnemy < outEnemy.Length - 2)
                {
                    eO = (GameObject)Instantiate(outEnemy[selectEnemy], new Vector3(95.0f, 0.0f, -45.0f), Quaternion.identity);
                }
                else
                {
                    if (selectEnemy == outEnemy.Length - 1)
                    {
                        eO = (GameObject)Instantiate(outEnemy[selectEnemy], new Vector3(Random.Range(85.0f, 100.0f), Random.Range(15.0f, 20.0f),
                                                                                        Random.Range(-50.0f, 50.0f)), Quaternion.identity);
                    }
                    else
                    {
                        eO = (GameObject)Instantiate(outEnemy[selectEnemy], new Vector3(Random.Range(85.0f, 100.0f), Random.Range(10.0f, 15.0f),
                                                                                        Random.Range(-50, 50)), Quaternion.identity);
                    }
                }
                eO.GetComponent <EnemyStats>().mSpeed  = sMult * eO.GetComponent <EnemyStats>().mSpeed;
                eO.GetComponent <EnemyStats>().mHealth = hMult * eO.GetComponent <EnemyStats>().mHealth;


                if (selectEnemy < outEnemy.Length - 2)
                {
                    Buy_Shoot_Modes bsm = theGC.GetComponent <Buy_Shoot_Modes>();
                    MoveUsingDFS    mud = eO.GetComponent <MoveUsingDFS>();
                    mud.wayPoints = bsm.thePath2;
                }
                if (i == enemyCount / 2 || i == 1 || i == enemyCount - 2)
                {
                    int chanceOfBoss = Random.Range(0, 9);
                    if (chanceOfBoss == 0)
                    {
                        Debug.Log("THERE'S A BOSS INCOMING");
                        int selectBaws = Random.Range(0, boss.Length);
                        if (selectBaws < boss.Length - 1)
                        {
                            GameObject      eo  = (GameObject)Instantiate(boss[selectBaws], new Vector3(95.0f, 0.0f, -45.0f), Quaternion.identity);
                            Buy_Shoot_Modes bsm = theGC.GetComponent <Buy_Shoot_Modes>();
                            MoveUsingDFS    mud = eo.GetComponent <MoveUsingDFS>();
                            mud.wayPoints        = bsm.thePath2;
                            numEnemiesRemaining += eo.GetComponent <BossBase> ().numEnemiesReq;
                        }
                        else
                        {
                            GameObject eo = (GameObject)Instantiate(boss[selectBaws], new Vector3(95.0f, 15.0f, -45.0f), Quaternion.identity);
                            numEnemiesRemaining += eo.GetComponent <BossBase> ().numEnemiesReq;
                        }
                    }
                }
                yield return(new WaitForSeconds(spawnWaitTime));

                waveDur -= spawnWaitTime;
                waveDur -= Time.deltaTime;
                if (waveDur < 0)
                {
                    break;
                }
                if (gameObject.GetComponent <Buy_Shoot_Modes>().gameover)
                {
                    break;
                }
            }
        }
        //waveCompleted++;
    }
Beispiel #5
0
    // Update is called once per frame
    void Update()
    {
        if (mHealth <= 0)
        {
            if (!gameOverPlayed)
            {
                AudioListener.volume = 1;
                audio.PlayOneShot(gameOverSound);
                gameOverPlayed = true;
            }
            GameObject      gc  = GameObject.FindGameObjectWithTag("GameController");
            Buy_Shoot_Modes bsm = gc.GetComponent <Buy_Shoot_Modes>();
            bsm.gameover = true;
            GameObject[] towerPieces = GameObject.FindGameObjectsWithTag("TowerPiece");
            if (destroyTower)
            {
                for (int i = 0; i < towerPieces.Length; ++i)
                {
                    GameObject towerPiece = towerPieces[i];
                    towerPiece.AddComponent <Rigidbody>();
                    GameObject theBase = GameObject.Find("theTowerB");
                    if (theBase)
                    {
                        Instantiate(towerType, new Vector3(-85.0f, 0.0f, 0.0f), Quaternion.identity);
                        Destroy(theBase);
                    }

                    /*Vector3 piecePosition = towerPiece.transform.position;
                     * float xPos = towerPiece.transform.position.z;
                     * float yPos = 5;
                     * float zPos = towerPiece.transform.position.z;
                     * Vector3 translateVector = new Vector3(xPos, yPos, zPos);
                     * if (zPos > 0) {
                     *      transform.RotateAround(piecePosition, translateVector, -0.5f);
                     * } else {
                     *      transform.RotateAround(piecePosition, translateVector, 0.5f);
                     * }
                     * translateVector = translateVector.normalized;
                     * towerPiece.transform.Translate(translateVector);*/
                }
                destroyTower = false;
            }
        }
        if (comboKills > currCombo)
        {
            killStreakTimer -= Time.deltaTime;
            if (comboKills >= killsToStreak && killStreakTimer > 0.0f)
            {
                streakNo++;

                if (streakNo > 2)
                {
                    streakNoIncr += 2;
                }
                else if (streakNo > 6)
                {
                    streakNoIncr += 4;
                }
                if (streakNo > currStreak)
                {
                    currStreak = streakNo;
                    killStreak(streakNo);
                }
                comboKills      = 0;
                killsToStreak  += streakNoIncr;
                theStreakTimer += (streakTimerIncr * streakNoIncr) / 3.0f;
                killStreakTimer = theStreakTimer;
                //killsToStreak = 1;
            }
            if (killStreakTimer <= 0)
            {
                comboKills      = 0;
                killStreakTimer = theStreakTimer;
            }
        }
    }
Beispiel #6
0
    void killStreak(int n)
    {
        GameObject      go  = GameObject.FindGameObjectWithTag("GameController");
        Buy_Shoot_Modes bsm = go.GetComponent <Buy_Shoot_Modes>();
        GameObject      f   = GameObject.Find("TowerCannons");

        switch (n)
        {
        case 1:

            break;

        case 2:
            //foreach(Transform child in gameObject.transform)
            //{
            //	Destroy(child.gameObject);
            //}
            //towerType = (GameObject)Instantiate(towers[selectTower], new Vector3(-63.0f,36.0f,3.0f),
            //                                  Quaternion.identity);
            if (f)
            {
                f.GetComponent <upgradeCannons>().timeToUpgrade = true;
            }
            theNextStreak = "Burst Shot";
            if ((mFireRate - 0.1f) > 0.0f)
            {
                mFireRate -= 0.1f;
            }
            selectTower++;
            break;

        case 3:
            //Destroy(towerType);
            //towerType = (GameObject)Instantiate(towers[selectTower], new Vector3(-63.0f,36.0f,3.0f),
            //                                  Quaternion.identity);
            if (f)
            {
                f.GetComponent <upgradeCannons>().timeToUpgrade = true;
            }
            theNextStreak = "Fire Rate UP";
            bsm.numShots  = 1;
            bsm.multiShot = true;
            //bsm.multiShot = true;
            selectTower++;
            break;

        case 4:
            //Destroy(towerType);
            //towerType = (GameObject)Instantiate(towers[selectTower], new Vector3(-63.0f,36.0f,3.0f),
            //                                  Quaternion.identity);
            if (f)
            {
                f.GetComponent <upgradeCannons>().timeToUpgrade = true;
            }
            selectTower++;
            theNextStreak = "Triple Shot";
            if ((mFireRate - 0.1f) > 0.0f)
            {
                mFireRate -= 0.1f;
            }
            break;

        case 5:
            //Destroy(towerType);
            //towerType = (GameObject)Instantiate(towers[selectTower], new Vector3(-63.0f,36.0f,3.0f),
            //                                  Quaternion.identity);
            if (f)
            {
                f.GetComponent <upgradeCannons>().timeToUpgrade = true;
            }
            selectTower++;
            //GameObject go = GameObject.FindGameObjectWithTag("GameController");
            //Buy_Shoot_Modes bsm = go.GetComponent<Buy_Shoot_Modes>();
            theNextStreak = "Splash DMG";
            bsm.numShots  = 3;
            //bsm.theTowerWeapon = 1;
            bsm.multiShot = false;
            break;

        case 6:
            //Destroy(towerType);
            //towerType = (GameObject)Instantiate(towers[selectTower], new Vector3(-63.0f,36.0f,3.0f),
            //                                  Quaternion.identity);
            selectTower++;
            //GameObject go = GameObject.FindGameObjectWithTag("GameController");
            //Buy_Shoot_Modes bsm = go.GetComponent<Buy_Shoot_Modes>();
            theNextStreak      = "Triple Splash";
            bsm.theTowerWeapon = 1;
            bsm.multiShot      = false;
            break;

        case 7:
            //Destroy(towerType);
            //towerType = (GameObject)Instantiate(towers[selectTower], new Vector3(-63.0f,36.0f,3.0f),
            //                                  Quaternion.identity);
            selectTower++;
            theNextStreak = "Radius UP";
            //bsm.theRadiusMult += 1.0f;
            bsm.numShots = 3;
            break;

        case 8:
            theNextStreak      = "Burst Splash";
            bsm.theRadiusMult += 1.0f;
            break;

        case 9:
            bsm.multiShot = true;
            break;

        default:
            break;
        }
    }
Beispiel #7
0
    // Update is called once per frame
    void Update()
    {
        stop = false;
        GameObject gct = GameObject.FindGameObjectWithTag("GameController");

        if (gct)
        {
            Buy_Shoot_Modes bsm = gct.GetComponent <Buy_Shoot_Modes>();
            if (bsm.thePathsHaveChanged)
            {
                //wayPoints = bsm.thePath;
                if (wayPoints.Contains(bsm.theTaken))
                {
                    int currI = wayPoints.IndexOf(bsm.theTaken);
                    //Debug.Log (currI);
                    if (currI < i)
                    {
                        wayPoints = bsm.dijkstraPath(wayPoints[i], wayPoints);
                        //Debug.Log (wayPoints.Count);
                        i   = wayPoints.Count - 1;
                        dir = wayPoints[i].transform.position - transform.position;
                        dir = dir.normalized;
                    }
                    //Debug.Log ("change it");
                }
            }

            /*
             * if(bsm.thePathsHaveChanged1)
             * {
             *      if(wayPoints.Contains(bsm.theTaken))
             *      {
             *              int currI = wayPoints.IndexOf(bsm.theTaken);
             *              Debug.Log ("hello");
             *              if(currI <= i)
             *              {
             *                      wayPoints = bsm.dijkstraPath(wayPoints[i]);
             *                      //Debug.Log (wayPoints.Count);
             *                      i = wayPoints.Count-1;
             *                      dir = wayPoints[i].transform.position - transform.position;
             *                      dir = dir.normalized;
             *              }
             *              //Debug.Log ("change it");
             *      }
             * }
             */
            //bsm.thePathsHaveChanged = false;
        }
        if (i >= 0)
        {
            walkSpeed = gameObject.GetComponent <EnemyStats>().mSpeed;
            transform.Translate(dir * Time.deltaTime * walkSpeed);
            //transform.position = Vector3.Lerp(transform.position, wayPoints[i].position,
            //Time.deltaTime * walkSpeed);
            if ((transform.position - wayPoints[i].transform.position).sqrMagnitude <= 1.0f)
            {
                i--;
                stop = true;
                //Debug.Log(stop);
                if (i >= 0)
                {
                    rotateEnem.LookAt(wayPoints[i].transform.position);
                    rot.eulerAngles = new Vector3(rot.eulerAngles.x, rotateEnem.eulerAngles.y, rot.eulerAngles.z);
                    dir             = wayPoints[i].transform.position - transform.position;
                    dir             = dir.normalized;
                }
            }
            Debug.Log(i);
            if (i > 1)
            {
                if ((transform.position - wayPoints[i].transform.position).sqrMagnitude > 150.0f)
                {
                    rotateEnem.LookAt(wayPoints[i].transform.position);
                    rot.eulerAngles = new Vector3(rot.eulerAngles.x, rotateEnem.eulerAngles.y, rot.eulerAngles.z);
                    Debug.Log("Distance greater than 100" + (transform.position - wayPoints[i].transform.position).sqrMagnitude);
                    dir = wayPoints[i].transform.position - transform.position;
                    dir = dir.normalized;
                }
            }
        }
        else
        {
            GameObject gc = GameObject.FindGameObjectWithTag("GameController");
            if (gc)
            {
                NewSpawnWaves sw = gc.GetComponent <NewSpawnWaves>();
                sw.numEnemiesRemaining--;
            }
            Destroy(gameObject);
        }
    }
Beispiel #8
0
    void OnGUI()
    {
        //button 1
        if (UnityEngine.GUI.Button(new Rect(Screen.width / 100 * 2, Screen.height / 100 * 59, Screen.width / 100 * 10, Screen.height / 100 * 10), button1Text, customGUI))
        {
            GameObject mode = GameObject.FindGameObjectWithTag("GameController");
            if (mode.GetComponent <Buy_Shoot_Modes> ().shootMode == true)
            {
                mode.GetComponent <Buy_Shoot_Modes> ().shootMode = false;
                mode.GetComponent <Buy_Shoot_Modes> ().buyMode   = true;
                mode.GetComponent <Buy_Shoot_Modes> ().theWeapon = 1;
                whichinfo   = 1;
                button1Text = "ATTACK MODE";
            }
            else if (mode.GetComponent <Buy_Shoot_Modes> ().buyMode == true)
            {
                mode.GetComponent <Buy_Shoot_Modes> ().buyMode   = false;
                mode.GetComponent <Buy_Shoot_Modes> ().shootMode = true;
                button1Text = "BUILD MODE";
                whichinfo   = 2;
            }
        }
        //SECONDARY BUTTONS
        GameObject      mmode = GameObject.FindGameObjectWithTag("GameController");
        Buy_Shoot_Modes sell  = mmode.GetComponent <Buy_Shoot_Modes> ();

        if (sell.buyMode)
        {
            if (UnityEngine.GUI.Button(new Rect(Screen.width / 100 * 2, Screen.height / 100 * (float)98.5, Screen.width / 100 * 10, Screen.height / 100 * 5), button2Text, customGUI))
            {
                GameObject      mode = GameObject.FindGameObjectWithTag("GameController");
                Buy_Shoot_Modes sel  = mode.GetComponent <Buy_Shoot_Modes> ();
                if (sel.buyMode)
                {
                    sel.theWeapon = 1;
                }
                whichinfo = 3;
            }
            if (!hardcore)
            {
                if (UnityEngine.GUI.Button(new Rect(Screen.width / 100 * (float)13.5, Screen.height / 100 * (float)98.5, Screen.width / 100 * 10, Screen.height / 100 * 5), button3Text, customGUI))
                {
                    GameObject      mode = GameObject.FindGameObjectWithTag("GameController");
                    Buy_Shoot_Modes sel  = mode.GetComponent <Buy_Shoot_Modes> ();
                    if (sel.buyMode)
                    {
                        sel.theWeapon = 0;
                    }
                    whichinfo = 1;
                }
                if (UnityEngine.GUI.Button(new Rect(Screen.width / 100 * (float)25, Screen.height / 100 * (float)98.5, Screen.width / 100 * 10, Screen.height / 100 * 5), button4Text, customGUI))
                {
                    GameObject      mode = GameObject.FindGameObjectWithTag("GameController");
                    Buy_Shoot_Modes sel  = mode.GetComponent <Buy_Shoot_Modes> ();
                    if (sel.buyMode)
                    {
                        sel.theWeapon = 2;
                    }
                    whichinfo = 4;
                }
                if (UnityEngine.GUI.Button(new Rect(Screen.width / 100 * (float)36.3, Screen.height / 100 * (float)98.5, Screen.width / 100 * (float)12, Screen.height / 100 * 5), button5Text, customGUI))
                {
                    GameObject      mode = GameObject.FindGameObjectWithTag("GameController");
                    Buy_Shoot_Modes sel  = mode.GetComponent <Buy_Shoot_Modes> ();
                    if (sel.buyMode)
                    {
                        sel.theWeapon = 3;
                    }
                    whichinfo = 5;
                }
            }
        }
        else if (sell.shootMode)
        {
            /*if (UnityEngine.GUI.Button (new Rect (Screen.width / 100 * 13, Screen.height / 100 * 95, 105, 50), "grenade")) {
             *      GameObject mode = GameObject.FindGameObjectWithTag ("GameController");
             *      Buy_Shoot_Modes sel = mode.GetComponent<Buy_Shoot_Modes> ();
             *      if (sel.shootMode)
             *              sel.theTowerWeapon = 1;
             * }*/
            //UPGRADE BUTTON
            if (UnityEngine.GUI.Button(new Rect(Screen.width / 100 * (float)1.5, Screen.height / 100 * 99, Screen.width / 100 * 20, Screen.height / 100 * 5), "UPGRADE TOWER" + "\n Cost: "
                                       + GameObject.FindGameObjectWithTag("TheTower").GetComponent <TowerStats>().upgradeCost, customGUI))
            {
                GameObject      mode = GameObject.FindGameObjectWithTag("GameController");
                Buy_Shoot_Modes sel  = mode.GetComponent <Buy_Shoot_Modes> ();
                GameObject      theT = GameObject.FindGameObjectWithTag("TheTower");

                TowerStats ts        = theT.GetComponent <TowerStats>();
                int        resources = ts.mResources;
                int        cost      = ts.upgradeCost;
                if ((resources - cost) >= 0)
                {
                    ts.mResources        -= cost;
                    sel.upgradeTowerMult += 0.5f;
                    theT.GetComponent <TowerStats>().upgradeCost += theT.GetComponent <TowerStats>().upgradeCost;
                }
            }

            /*if (UnityEngine.GUI.Button (new Rect (Screen.width / 100 * 35, Screen.height / 100 * 95, 105, 50), "laser")) {
             *      GameObject mode = GameObject.FindGameObjectWithTag ("GameController");
             *      Buy_Shoot_Modes sel = mode.GetComponent<Buy_Shoot_Modes> ();
             *      if (sel.shootMode)
             *              sel.theTowerWeapon = 2;
             * }*/
        }
        //GAME OVER BUTTON
        GameObject      md  = GameObject.FindGameObjectWithTag("GameController");
        Buy_Shoot_Modes bsm = md.GetComponent <Buy_Shoot_Modes> ();
        //towerinfo
        GameObject tw = GameObject.FindGameObjectWithTag("TheTower");

        if (bsm.gameover)
        {
            UnityEngine.GUI.Box(new Rect(Screen.width / 100 * 45, Screen.height / 100 * 30, Screen.width / 100 * 20, Screen.height / 100 * 20), "Survived  " +
                                (md.GetComponent <NewSpawnWaves>().waveCompleted + " Waves" + "\n\n" + "Score: " + tw.GetComponent <TowerStats>().mScore)
                                , customGUI);
            if (UnityEngine.GUI.Button(new Rect(Screen.width / 100 * (float)47.5, Screen.height / 100 * 54, Screen.width / 100 * 15, Screen.height / 100 * 5), restart, customGUI))
            {
                Application.LoadLevel(Application.loadedLevel);
            }
            if (UnityEngine.GUI.Button(new Rect(Screen.width / 100 * (float)50.5, Screen.height / 100 * 64, Screen.width / 100 * 10, Screen.height / 100 * 5), mainmenu, customGUI))
            {
                Application.LoadLevel("StartMenu");
            }
        }
        //WAVE ADVANCE BUTTON
        if (UnityEngine.GUI.Button(new Rect(Screen.width / 100 * (float)90.5, Screen.height / 100 * 42, Screen.width / 100 * 12, Screen.height / 100 * 5), "Advance Wave", customGUI))
        {
            GameObject    mode = GameObject.FindGameObjectWithTag("GameController");
            NewSpawnWaves nsw  = mode.GetComponent <NewSpawnWaves>();
            nsw.advanceTheWave = true;
        }
        //INFO BOX

        UnityEngine.GUI.Box(new Rect(Screen.width / 100 * (float)0.5, Screen.height / 100 * 72, Screen.width / 100 * 30, Screen.height / 100 * 22), "", customGUI);
        GameObject      tgc         = GameObject.FindGameObjectWithTag("GameController");
        Buy_Shoot_Modes ws          = tgc.GetComponent <Buy_Shoot_Modes>();
        float           towerDamage = ws.towerWeapons[ws.theTowerWeapon].GetComponent <TowerAmmoStats>().mDamage;
        string          towerType   = "";

        if (ws.theTowerWeapon == 0)
        {
            towerType = "Standard";
        }
        else
        {
            towerType = "Splash";
        }
        GameObject tsg = GameObject.FindGameObjectWithTag("TheTower");
        TowerStats tss = tsg.GetComponent <TowerStats> ();

        switch (whichinfo)
        {
        case 0:         //default tower stats


            theinfo = "" + "Tower Stats" + "\n\n"
                      + "Damage" + "#x" + ": " + "#n" + towerDamage * ws.GetComponent <Buy_Shoot_Modes>().upgradeTowerMult + "\n" + "Type" + "#x" + ": " + "#n" + towerType + "\n" + "Fire Rate" + "#x" + ": " + "#n" + tw.GetComponent <TowerStats>().mFireRate + "\n";
            //UnityEngine.GUI.Box (new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100), ""  ,customGUI);
            //FancyLabel( new Rect(Screen.width/100 * 2,Screen.height/100*75, Screen.width/100*20, Screen.height/100*10), theinfo, normal, bold, italic, TextAlignment.Left);

            //UnityEngine.GUI.Box (new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100), "Info: Tower \n Damage: 100 \n Attack Speed: 0.5 \n Type: Normal" );
            break;

        case 1:         //Buy mode default turret.
            theinfo = "" + "Build Mode" + "#x" + ":          " + "#n" + "Turret" + "\n\n"
                      + "Type" + "#x" + ":                   " + "#n" + "Shotgun" + "\n"
                      + "Damage" + "#x" + ":                      " + "#n" + "5" + "#x" + "/" + "#n" + "#FFDDDDFF" + "5" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "5" + "\n" + "#!"
                      + "Attack Speed" + "#x" + ": " + "#n" + "0.6" + "#x" + "/" + "#n" + "#FFDDDDFF" + "0.3" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "0.1" + "\n" + "#!"
                      + "Range" + "#x" + ":                    " + "#n" + "2" + "#x" + "/" + "#n" + "#FFDDDDFF" + "25" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "30" + "\n" + "#!"
                      + "Cost" + "#x" + ":             " + "#n" + "400" + "#x" + "/" + "#n" + "#FFDDDDFF" + "600" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "800" + "\n";
            //UnityEngine.GUI.Box (new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100),"" ,customGUI);
            //FancyLabel( new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100), theinfo, normal, bold, italic, TextAlignment.Left);
            break;

        case 2:         //Shoot mode default cannon
            theinfo = "" + "Tower Stats" + "\n\n"
                      + "Damage" + "#x" + ": " + "#n" + towerDamage * ws.GetComponent <Buy_Shoot_Modes>().upgradeTowerMult + "\n" + "Type" + "#x" + ": " + "#n" + towerType + "\n" + "Fire Rate" + "#x" + ": " + "#n" + tw.GetComponent <TowerStats>().mFireRate + "\n";
            //	UnityEngine.GUI.Box (new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100), ""  ,customGUI);
            //FancyLabel( new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100), theinfo, normal, bold, italic, TextAlignment.Left);
            break;

        case 3:         //Buy mode wall
            theinfo = "" + "Build Mode" + "#x" + ":               " + "#n" + "Wall" + "\n\n\n"
                      + "Type" + "#x" + ":           " + "#n" + "Unit Blocker" + "\n"
                      + "Duration" + "#x" + ":                    " + "#n" + "3" + "#x" + "/" + "#n" + "#FFDDDDFF" + "5" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "9" + "\n" + "#!"
                      + "Cost" + "#x" + ":                      " + "#n" + "10" + "#x" + "/" + "#n" + "#FFDDDDFF" + "50" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "90" + "\n";
            //UnityEngine.GUI.Box (new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100),"" ,customGUI);
            //FancyLabel( new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100), theinfo, normal, bold, italic, TextAlignment.Left);
            break;

        case 4:         //Buy mode slow
            theinfo = "" + "Build Mode" + "#x" + ":  " + "#n" + "Slow Tower" + "\n\n"
                      + "Type" + "#x" + ":              " + "#n" + "Freeze Ray" + "\n"
                      + "Damage" + "#x" + ":                        " + "#n" + "1" + "#x" + "/" + "#n" + "#FFDDDDFF" + "3" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "5" + "\n" + "#!"
                      + "Attack Speed" + "#x" + ":          " + "#n" + "7" + "#x" + "/" + "#n" + "#FFDDDDFF" + "5" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "3" + "\n" + "#!"
                      + "Range" + "#x" + ":                   " + "#n" + "10" + "#x" + "/" + "#n" + "#FFDDDDFF" + "20" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "30" + "\n" + "#!"
                      + "Cost" + "#x" + ":             " + "#n" + "300" + "#x" + "/" + "#n" + "#FFDDDDFF" + "550" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "700" + "\n";
            //	UnityEngine.GUI.Box (new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100),"" ,customGUI);
            //FancyLabel( new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100), theinfo, normal, bold, italic, TextAlignment.Left);
            break;

        case 5:         //Buy mode track
            theinfo = "" + "Build Mode" + "#x" + ":      " + "#n" + "Launcher" + "\n\n"
                      + "Type" + "#x" + ":       " + "#n" + "Homing Missiles" + "\n"
                      + "Damage" + "#x" + ":                 " + "#n" + "10" + "#x" + "/" + "#n" + "#FFDDDDFF" + "20" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "40" + "\n" + "#!"
                      + "Attack Speed" + "#x" + ":          " + "#n" + "6" + "#x" + "/" + "#n" + "#FFDDDDFF" + "4" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "3" + "\n" + "#!"
                      + "Range" + "#x" + ":                  " + "#n" + "35" + "#x" + "/" + "#n" + "#FFDDDDFF" + "40" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "50" + "\n" + "#!"
                      + "Cost" + "#x" + ":              " + "#n" + "500" + "#x" + "/" + "#n" + "#FFDDDDFF" + "900" + "#!" + "#x" + "/" + "#n" + "#FF6666FF" + "1100" + "\n";
            //	UnityEngine.GUI.Box (new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100),"" ,customGUI);
            //FancyLabel( new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100), theinfo, normal, bold, italic, TextAlignment.Left);

            break;

        case 6:
            break;
        }
        FancyLabel(new Rect(Screen.width / 100 * (float)2.5, Screen.height / 100 * 74, Screen.width / 100 * 30, Screen.height / 100 * 20), theinfo, normal, bold, italic, TextAlignment.Left);
        //FancyLabel( new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100), theinfo, normal, bold, italic, TextAlignment.Center);
        //UnityEngine.GUI.Box (new Rect(Screen.width/100 * 2,Screen.height/100*75, 200, 100),"");
    }