Ejemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        game = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControllerScript>();
        rend = GetComponentInChildren <Renderer>();

        if (type == PoliceType.Regular)
        {
            regPoliceList.AddLast(this);
        }

        game.allPoliceList.Add(this);

        rbody = GetComponent <Rigidbody>();
        col   = GetComponent <Collider>();

        play      = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerScript>();
        agent     = GetComponent <NavMeshAgent>();
        targetPos = play.transform.position;

        audio = GetComponent <AudioTriggerScript>();

        RandomizeXOffset();

        InvokeRepeating("SlowUpdate", 0f, 0.1f);

        if (playAudio)
        {
            audio.PlayRandomFromList(0, true);
        }

        if (type == PoliceType.Regular)
        {
            Invoke("ShootBullet", Random.Range(shootFrequencyMin, shootFrequencyMax));
        }
        if (type == PoliceType.Rammer)
        {
            Invoke("StartRam", Random.Range(ramTimeFrequencyMin, ramTimeFrequencyMax));
        }
        if (type == PoliceType.Tanker)
        {
            Invoke("StartMissiles", Random.Range(missileFrequencyMin, missileFrequencyMax));
            game.myMissileAnim     = transform.Find("missile").GetComponent <Animation>();
            game.myMissileParticle = game.myMissileAnim.transform.GetComponentInChildren <ParticleSystem>();
            game.generateObstacles = false;
        }
    }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     anim  = GetComponent <Animator>();
     audio = GetComponent <AudioTriggerScript>();
 }