Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        speedChange speedScript        = gameObject.GetComponent <speedChange>();
        float       speedModSpearSpawn = speedScript.speedMod;

        newSpawnRate = spawnRate;

        //Get boat vector direction at time of instantiation.
        randomDirection = boatFront.transform.position - boatBack.transform.position;
        timer          += Time.deltaTime;

        if (timer >= (newSpawnRate - .4f) && spearIndicNumber == 0)
        {
            indicator(count);
            spearIndicNumber = 1;
        }

        if (timer >= newSpawnRate && count < 5)
        {
            spawn(count);
            count++;
            timer            = 0.0f;
            count            = count % 5;
            spearIndicNumber = 0;
        }
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        speedChange speedScript       = guiTextBox.GetComponent <speedChange>();
        float       speedModSpearGrow = speedScript.speedMod;

        transform.localScale = Vector3.Lerp(transform.localScale, new Vector3(5.0f, 5.0f, 5.0f), speedModSpearGrow * Time.deltaTime * scaleRate);
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        //Define boat vector using empty game objects at front and back.
        //That's wrong don't listen to him. This part's weird but working.

        boatDirection = Vector3.forward;
        //front.transform.RotateAround(Vector3.zero, Vector3.forward, boatRate * Time.deltaTime);
        //back.transform.RotateAround (Vector3.zero, Vector3.forward, boatRate * Time.deltaTime);
        this.transform.Rotate(boatDirection * boatRate * Time.deltaTime);
        boatMoveTimer += Time.deltaTime;

        //Set spear timers between boat and spear spawn equal.

        spearSpawn spearScript     = GameManager.GetComponent <spearSpawn>();
        float      spearThrowTimer = spearScript.timer;

        //Get game speed modifier
        speedChange speedScript  = GameManager.GetComponent <speedChange>();
        float       speedModBoat = speedScript.speedMod;

        //Get spear spawn rate.

        float spearSpawnRate = spearScript.newSpawnRate;

        //Pause briefly for spear throw
        if (spearThrowTimer < 0.5)
        {
            boatRate = 0.0f;
        }
        else if (spearThrowTimer > spearSpawnRate - 1.0f)
        {
            boatRate = 0.0f;
        }
        else
        {
            if (boatMoveTimer >= 2)
            {
                degreeVariable = speedModBoat * Random.Range(20, 100);
                intDegrees     = Mathf.RoundToInt(degreeVariable);
                boatMoveTimer  = 0.0f;
            }

            if (degreeVariable % 2 == 0)
            {
                boatRate = -intDegrees;
            }

            else
            {
                boatRate = intDegrees;
            }
        }
    }
Ejemplo n.º 4
0
    void spawn(int count)
    {
        //Spear instantiated velocity relative to selected game speed.
        speedChange speedScript   = gameObject.GetComponent <speedChange>();
        float       speedModSpear = speedScript.speedMod;

        //Instantiate spear at origin according to boat's direction.
        if (spearClone [count] != null)
        {
            Object.Destroy(spearClone[count]);
        }
        t = Quaternion.LookRotation(randomDirection);
        spearClone[count] = (GameObject)Instantiate(g, new Vector3(0, 0, 0), t);
        spearClone[count].GetComponent <Rigidbody>().velocity = speedModSpear * randomDirection * spearSpeed;
    }