Example #1
0
 public string returnDirec()
 {
     if (scorekeeper.returnBlasterLevel() >= 2)
     {
         if (passes == 2)
         {
             return("Left"); // Moving from right TO left
         }
         else
         {
             return("Right");
         }
     }
     else
     {
         return("Left");
     }
 }
 void Start()
 {
     scorekeeper = globalScore.Instance;
     if (scorekeeper.returnBlasterLevel() == 1 || scorekeeper.returnBlasterLevel() == 2)
     {
         enemyDamage       = 20;
         enemyBulletDamage = 10;
     }
     else if (scorekeeper.returnBlasterLevel() == 3)
     {
         enemyDamage       = 40;
         enemyBulletDamage = 20;
     }
     speed         = 50.0f;
     maxHealth     = rocketHealth;
     blackHoleDrag = 0.0f;
     rb2d          = GetComponent <Rigidbody2D> ();
     isSwift       = false;
 }
Example #3
0
    void Update()
    {
        whalePosition = transform.position;
        // Direction controller
        if (whalePosition.x >= 11.0f)
        {
            passes = 1;
            if (scorekeeper.returnBlasterLevel() >= 2)
            {
                rigidEnemy.velocity = -transform.right * enemySpeed;
                whaleSprite.flipX   = true;
            }
        }
        else if (whalePosition.x <= -11.0f)
        {
            passes = 2;
            if (scorekeeper.returnBlasterLevel() >= 2)
            {
                rigidEnemy.velocity = transform.right * enemySpeed;
                whaleSprite.flipX   = false;
            }
        }

        // Despawns whale based on level conditions
        if (despawnTimer < Time.time)
        {
            if (scorekeeper.returnBlasterLevel() == 1)
            {
                Destroy(gameObject);
            }
            if (scorekeeper.returnBlasterLevel() == 2 && passes == 2)
            {
                Destroy(gameObject);
            }
        }
    }
Example #4
0
    void Start()
    {
        scorekeeper = globalScore.Instance;
        gameLevel   = scorekeeper.returnBlasterLevel();

        /**
         * switch(gameLevel) {
         *  case 1:
         *      healIncr = UnityEngine.Random.Range(20, 30);
         *      bulwarkIncr = UnityEngine.Random.Range(60, 90);
         *      swiftIncr = UnityEngine.Random.Range(40, 60);
         *      rapidIncr = UnityEngine.Random.Range(40, 60);
         *      spreadIncr = UnityEngine.Random.Range(40, 60);
         *      break;
         *  case 2:
         *      healIncr = UnityEngine.Random.Range(40, 60);
         *      bulwarkIncr = UnityEngine.Random.Range(90, 240);
         *      swiftIncr = UnityEngine.Random.Range(60, 120);
         *      rapidIncr = UnityEngine.Random.Range(60, 120);
         *      spreadIncr = UnityEngine.Random.Range(60, 120);
         *      break;
         *  case 3:
         *      healIncr = UnityEngine.Random.Range(60, 120);
         *      bulwarkIncr = UnityEngine.Random.Range(120, 300);
         *      swiftIncr = UnityEngine.Random.Range(120, 240);
         *      rapidIncr = UnityEngine.Random.Range(120, 240);
         *      spreadIncr = UnityEngine.Random.Range(120, 240);
         *      break;
         * }**/

        var spawnFreq = SpawnFrequencyPerLevel[gameLevel - 1];

        healIncr    = GetRandomFromVector2Int(spawnFreq.HealIncreaseFreq);
        bulwarkIncr = GetRandomFromVector2Int(spawnFreq.BulwarkIncreaseFreq);
        swiftIncr   = GetRandomFromVector2Int(spawnFreq.SwiftIncreaseFreq);
        rapidIncr   = GetRandomFromVector2Int(spawnFreq.RapidFireIncreaseFreq);
        spreadIncr  = GetRandomFromVector2Int(spawnFreq.SpreadIncreaseFreq);

        healTimer    = Time.time + healIncr;
        bulwarkTimer = Time.time + bulwarkIncr;
        swiftTimer   = Time.time + swiftIncr;
        rapidTimer   = Time.time + rapidIncr;
        spreadTimer  = Time.time + spreadIncr;
    }
Example #5
0
    void Awake()
    {
        scorekeeper = GameObject.Find("globalScoreObj").GetComponent <globalScore>();
        if (scorekeeper.returnBlasterLevel() == 1)
        {
            spawnIncr       = UnityEngine.Random.Range(0.5f, 5.0f);
            spawnIncr_Whale = UnityEngine.Random.Range(30.0f, 60.0f);
            spawnIncr_Ship  = UnityEngine.Random.Range(55.0f, 120.0f);
            spawnIncr_Hole  = UnityEngine.Random.Range(45.0f, 240.0f);
        }
        else
        {
            spawnIncr       = UnityEngine.Random.Range(0.5f, 3.0f);
            spawnIncr_Whale = UnityEngine.Random.Range(20.0f, 45.0f);
            spawnIncr_Ship  = UnityEngine.Random.Range(30.0f, 90.0f);
            spawnIncr_Hole  = UnityEngine.Random.Range(30.0f, 180.0f);
        }

        //Debug.Log("Start time " + Time.time);

        spawnTimer       = Time.time + spawnIncr;
        spawnTimer_Whale = Time.time + spawnIncr_Whale;
        spawnTimer_Ship  = Time.time + spawnIncr_Ship;

        /** Rather than spawning a new black hole every time, Spawnscript refers
         * to a single hole that already exists in the scene— turns on/off and alters X coordinate.
         * The main reason for this is that the enemy hole behaviour influences player movement,
         * so it needs to reference the playerMovement script on the rocket.
         *
         * If spawnScript references the prefab, can't drag the rocket object into the black hole's
         * inspector (scriptableObject independent of scene, reference to rocket doesn't exist
         * outside of this scene).
         * Short of using GameObject.Find or GameObject.FindWithTag, not sure how else to work around
         * So instead of referencing black hole prefab, will just modify an object in scene
         * "Spawn" AND "despawn" will both be controlled here rather than in obj. script
         */
        holeDespawnLength = 5.0f;
        spawnTimer_Hole   = Time.time + spawnIncr_Hole;
        randomizerX       = UnityEngine.Random.Range(0.0f, 1.0f);
        Debug.Log("Initial hole spawn time " + spawnTimer_Hole);
        holeScript = enem_Hole.GetComponent <enemyScriptHole>();
    }
Example #6
0
    public void Update()
    {
        if (spawnTimer < Time.time)
        {
            float randX = UnityEngine.Random.Range(-4.4f, 4.4f);
            //Debug.Log(string.Format("{0:N2}", randX));
            GameObject tmp = Instantiate(enemy, new Vector3(0.0f, 7.0f, 0.0f), Quaternion.identity);
            tmp.transform.position = new Vector3(randX, tmp.transform.position.y, 0.0f);
            if (scorekeeper.returnBlasterLevel() == 1)
            {
                spawnIncr = UnityEngine.Random.Range(0.5f, 5.0f);
            }
            else
            {
                spawnIncr = UnityEngine.Random.Range(0.5f, 3.0f);
            }
            spawnTimer = Time.time + spawnIncr;
        }
        if (spawnTimer_Whale < Time.time)
        {
            float randY = UnityEngine.Random.Range(-0.2f, 3.2f);
            //Debug.Log(string.Format("{0:N2}", randY));
            GameObject tmp_Whale = Instantiate(enem_Whale, new Vector3(-9.0f, -2.0f, 0.0f),
                                               Quaternion.identity);
            tmp_Whale.transform.position = new Vector3(tmp_Whale.transform.position.x, randY, 0.0f);
            if (scorekeeper.returnBlasterLevel() == 1)
            {
                spawnIncr_Whale = UnityEngine.Random.Range(30.0f, 60.0f);
            }
            else
            {
                spawnIncr_Whale = UnityEngine.Random.Range(20.0f, 45.0f);
            }
            spawnTimer_Whale = Time.time + spawnIncr_Whale;
        }
        if (spawnTimer_Ship < Time.time)
        {
            float randY_ship = UnityEngine.Random.Range(-0.2f, 3.2f);
            //Debug.Log(string.Format("{0:N2}", randY_ship));
            GameObject tmp_Ship = Instantiate(enem_Ship, new Vector3(9.0f, -2.0f, 0.0f),
                                              Quaternion.identity);
            tmp_Ship.transform.position = new Vector3(tmp_Ship.transform.position.x, randY_ship, 0.0f);
            if (scorekeeper.returnBlasterLevel() == 1)
            {
                spawnIncr_Ship = UnityEngine.Random.Range(55.0f, 120.0f);
            }
            else
            {
                spawnIncr_Ship = UnityEngine.Random.Range(30.0f, 90.0f);
            }
            spawnTimer_Ship = Time.time + spawnIncr_Ship;
        }
        if (spawnTimer_Hole < Time.time)
        {
            Debug.Log("Spawning black hole");
            enem_Hole.SetActive(true);
            nextHoleSpawnSet = false;
            if (!nextHoleDespawnSet)
            {
                holeDespawnTimer   = Time.time + holeDespawnLength;
                nextHoleDespawnSet = true;
            }
            //float randomizerX = UnityEngine.Random.Range(0.0f, 1.0f);
            if (randomizerX < 0.5)
            {
                holeScript.blackHoleActive(true, false);
                xHole = -3.48f;
            }
            else
            {
                xHole = 3.48f;
                holeScript.blackHoleActive(false, true);
            }
            //Debug.Log(string.Format("{0:N2}", randX));
            //GameObject tmp_Hole = Instantiate(enem_Hole, new Vector3(0.0f, -2.72f, 0.0f), Quaternion.identity);
            enem_Hole.transform.position = new Vector3(xHole, -2.72f, 0.0f);
        }
        if (Time.time > holeDespawnTimer)
        {
            nextHoleDespawnSet = false;
            holeScript.blackHoleActive(false, false);
            rocketMovement.noBlackHole();
            if (!nextHoleSpawnSet && Time.time > 16.0f)
            {
                if (scorekeeper.returnBlasterLevel() == 1)
                {
                    spawnIncr_Hole = UnityEngine.Random.Range(45.0f, 240.0f);
                }
                else
                {
                    spawnIncr_Hole = UnityEngine.Random.Range(30.0f, 180.0f);
                }
                randomizerX      = UnityEngine.Random.Range(0.0f, 1.0f);
                spawnTimer_Hole  = Time.time + spawnIncr_Hole;
                nextHoleSpawnSet = true;
            }
            enem_Hole.SetActive(false);
        }

        /** float randX = UnityEngine.Random.Range(-4.4f, 4.4f);
         * Debug.Log(string.Format("{0:N2}", randX));
         * GameObject tmp = Instantiate(enemy, new Vector3(0.0f, 7.0f, 0.0f), Quaternion.identity);
         * tmp.transform.position = new Vector3(randX, tmp.transform.position.y, 0.0f); **/
    }