예제 #1
0
    void octopusMissionComplete()
    {
        PlayerStats.Instance.TakeDamage(damage);
        Destroy(gameObject);
        GameObject         WaveObject = GameObject.Find("EnemySpawnObject");
        WaveTrackingScript waveScript = WaveObject.GetComponent <WaveTrackingScript> ();

        waveScript.numEmemies--;
    }
예제 #2
0
    void OnGUI()
    {
        for (int i = 0; i < towerObjects.Length; i++)
        {
            tex = towerObjects[i].GetComponent <GUITexture> (); // we are accessing the SpriteRenderer that is attached to the Gameobject
            towerButtomImages [i] = tex.texture;                // set the sprite to sprite1
        }
        GUILayout.BeginArea(new Rect(Screen.width * .8f, 0, Screen.width * .2f, Screen.height));
        GUILayout.BeginVertical("box");

        GUILayout.Box("heath: " + health.ToString() + "\n" + "cash: " + cash.ToString());

        if (IsPlacing() == false)
        {
            selGridInt = -1;                                     //OnGui is called every timestep, so this is to tell if the button is clicked.
        }
        selGridInt = GUILayout.SelectionGrid(selGridInt, towerButtomImages, 1, GUILayout.MaxHeight(Screen.height * 0.3f));
        if (selGridInt != -1)
        {
            if (cash - towerCost[selGridInt] < 0)
            {
                selGridInt = -1;
            }
            else
            {
                PlaceTurret(towerObjects[selGridInt]);
            }
        }
        fastForward = GUILayout.Toggle(fastForward, "fast forward");
        switch (fastForward)
        {
        case true:
            Time.timeScale = 3.0f;
            break;

        case false:
            Time.timeScale = 1.0f;
            break;
        }
        GameObject         WaveObject = GameObject.Find("EnemySpawnObject");
        WaveTrackingScript waveScript = WaveObject.GetComponent <WaveTrackingScript> ();

        if (waveScript.midWave == false)
        {
            if (GUILayout.Button("Start Wave"))
            {
                waveScript.startWave();
            }
        }
        GUILayout.Box(selGridInt.ToString());
        GUILayout.EndVertical();
        GUILayout.EndArea();
    }
예제 #3
0
    public void TakeDamage(int damage)
    {
        health          = System.Math.Max(health - damage, 0);
        healthBar.Value = health;


        if (health <= 0)
        {
            PlayerStats.Instance.Earn(cashReward);
            Destroy(gameObject);
            GameObject         WaveObject = GameObject.Find("EnemySpawnObject");
            WaveTrackingScript waveScript = WaveObject.GetComponent <WaveTrackingScript> ();
            waveScript.numEmemies--;
        }
    }
예제 #4
0
    void Start()
    {
        //initialize the times array. this is the main thing that needs added with the update
        //count the total number of enemies to be made.  This might not actually be needed.
        numOfEnemies = 0;
        foreach (int i in enemiesToMake)
        {
            numOfEnemies += i;
        }

        times = new float[numOfEnemies];

        float curser         = 0;
        int   enemiesSpawned = 0;

        foreach (int i in enemiesToMake)
        {
            for (int j = 0; j < i; j++)
            {
                times[enemiesSpawned] = curser + (((float)j + 1) / ((float)i + 1));
                enemiesSpawned++;
            }
            curser = curser + 1;
        }

        wasMade = new bool[times.Length];
        for (int i = 0; i < times.Length; i++)
        {
            wasMade [i] = false;
        }
        Debug.Log(wasMade);
        int numSelectors = times.Length;

        enemyArr           = new GameObject[numSelectors];
        waveTrackingScript = GetComponent <WaveTrackingScript> ();
    }