// Use this for initialization
    void Start()
    {
        player              = GameObject.Find("Player");
        shootScript         = gameObject.GetComponent <ShootPredictively>();
        shootScript.enabled = false;
        audioVol            = 0f;

        //set up the boundary circle and its transparency
        if (boundaryCircle != null)
        {
            boundaryCircle.transform.localScale = new Vector3(warningDist * 2f, warningDist * 2f, 1f);
            Color transColor = boundaryCircle.renderer.material.color;
            transColor.a = 0.5f;
            boundaryCircle.renderer.material.color = transColor;
        }
    }
Пример #2
0
    private void spawnBoss()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        if (player == null)
        {
            return;
        }
        GameObject spawningShip = (GameObject)Resources.Load("Prefabs/Enemies/Boss");
        //This portion is for the predictive cannon the boss has
        Rigidbody         r = player.GetComponent <Rigidbody> ();
        Transform         t = spawningShip.transform;
        GameObject        g = t.GetChild(1).gameObject;
        ShootPredictively s = g.GetComponent <ShootPredictively> ();

        s.target = r;
        Vector3 spawnPos = Vector3.zero;
        //If there's a player, we need to make sure the enemies won't spawn in the player's fov.
        float xVal = Random.Range(spawnBound.xMin, spawnBound.xMax);

        while (player.transform.position.x - xVal < 5.5 && player.transform.position.x - xVal > -5.5)
        {
            //get a new xval
            xVal = Random.Range(spawnBound.xMin, spawnBound.xMax);
        }
        float zVal = Random.Range(spawnBound.zMin, spawnBound.zMax);

        while (player.transform.position.z - zVal < 5.5 && player.transform.position.z - zVal > -5.5)
        {
            //get a new zval
            zVal = Random.Range(spawnBound.zMin, spawnBound.zMax);
        }
        spawnPos = new Vector3(
            xVal,
            0.0f,
            zVal);
        GameObject newEnemy = (GameObject)Instantiate(spawningShip, spawnPos, Quaternion.identity);

        //Make sure they track the player!
        newEnemy.GetComponent <TrackTo> ().target = player.transform;

        //Adds the new enemy to the radar track Hashtable
        addEnemyToRadar(newEnemy);
    }