Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        activeState.StateUpdate();

        foreach (var bot in GameManager.Instance.botsList)
        {
            if (Vector3.Distance(bot.transform.position, transform.position) < 100)
            {
                Range = Vector3.Distance(bot.transform.position, transform.position);
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        // needs sorting out
        // need to see if roam state and then get closest enemy.

        // Run state specific code
        if (activeState != null)
        {
            activeState.StateUpdate();
        }

        // try changeing this to a list in a game manger class that keeps track of bots
        // bots can notify game manager of death.
        // need a way for each bot to register a kill.
        // maybe by accessing the health variable of the hit collider in shoot.
        foreach (GameObject go in GameManager.Instance.botsList)
        {
            if (go != null && AmmoAmount > 0)
            {
                // Check distance to enemy.
                if (Vector3.Distance(transform.position, go.transform.position) < 50.0f)
                {
                    // Check angle to enemy.
                    //Debug.DrawLine(transform.position, go.transform.position, Color.red, 0.5f);
                    Vector3 targetDir = go.transform.position - transform.position;
                    Vector3 forward   = transform.forward;
                    float   angle     = Vector3.Angle(targetDir, forward);
                    if (angle < 20.0F)
                    {
                        //Debug.Log("Enemy Sighted " + this.name);
                        enemySighted        = true;
                        enemy               = go.transform;
                        activeState.enabled = false;
                        ss.enabled          = true;
                        activeState         = ss;
                    }
                }
            }
        }
        if (enemy != null)
        {
            if (enemy.gameObject.activeSelf == false)
            {
                enemySighted        = false;
                activeState.enabled = false;
                rs.enabled          = true;
                activeState         = rs;
            }
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    private void Update()
    {
        mainCam = GameObject.FindWithTag("MainCamera"); //Finds camera in Scene and assigns it to mainCam

        if (IActiveState != null)
        {
            IActiveState.StateUpdate();
        }

        enemyCountCurrentWave = GameObject.FindWithTag("Player").GetComponent <PlayerCombat>().targets.Length;

        if (Input.GetButtonDown("Pause"))
        {
            UI[2].SetActive(true);
        }

        if (enemiesToKill == 0)
        {
            playerVictory = true;
        }
    }
 // Update is called once per frame
 public virtual void Update()
 {
     activeState.StateUpdate();
 }
Exemplo n.º 5
0
 // Update is called once per frame
 void Update()
 {
     activeState.StateUpdate();
 }