Ejemplo n.º 1
0
    public void ProcessDeath()
    {
        WanderingAI behaviour = GetComponent <WanderingAI>();

        behaviour.SetAlive(false);
        StartCoroutine(Die());
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            Vector3 point = new Vector3(_camera.pixelWidth / 2, _camera.pixelHeight / 2, 0);
            Ray     ray   = _camera.ScreenPointToRay(point);

            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                GameObject     hitObject = hit.transform.gameObject;
                ReactiveTarget target    = hitObject.GetComponent <ReactiveTarget>();
                WanderingAI    ai        = hitObject.GetComponent <WanderingAI>();
                BackAndForth   sphere    = hitObject.GetComponent <BackAndForth>();
                if (target != null && ai._alive)
                {
                    target.ReactToHit();
                    soundSource.PlayOneShot(hitEnemySound);
                    Messenger.Broadcast(GameEvent.ENEMY_HIT);
                }
                else
                {
                    soundSource.PlayOneShot(hitWallSound);
                    StartCoroutine(SphereIndicator(hit.point));
                }

                if (sphere != null)
                {
                    Destroy(sphere.gameObject);
                }
            }
        }
    }
Ejemplo n.º 3
0
    internal void ReactToHit()
    {
        WanderingAI behavior = GetComponent <WanderingAI>();

        behavior.Alive = false;
        StartCoroutine(Die());
    }
Ejemplo n.º 4
0
    public void reactToHit()
    {
        // added after WanderingAI

        if (_alive)
        {
            audioSource.PlayOneShot(dieSound);

            WanderingAI behavior = GetComponent <WanderingAI>();
            if (behavior != null)
            {
                behavior.SetAlive(false);
            }

            Rigidbody body = GetComponent <Rigidbody> ();
            if (body != null)
            {
                body.freezeRotation = false;
            }


            StartCoroutine(Die());
        }

        _alive = false;
    }
Ejemplo n.º 5
0
    public void ReactToHit()
    {
        WanderingAI behavior = GetComponent <WanderingAI>();

        // I want the object to wait on react to hit

        if (behavior != null)
        {
            // Telling the wanderingAI class that the object is waiting...
            behavior.SetWaiting(true);
        }

        StartCoroutine(Wait());



        // If I want to kill the object on react to hit...

        // Telling WanderingAI that this object has died so it can stop it's behavior
        //if (behavior != null)
        //{
        //    behavior.SetAlive(false);
        //}
        //StartCoroutine(Die());
    }
Ejemplo n.º 6
0
    private IEnumerator Die()
    {
        this.transform.Rotate(-75, 0, 0);
        yield return(new WaitForSeconds(1.5f));

        Destroy(this.gameObject);
        WanderingAI nas = GetComponent <WanderingAI>();
    }
Ejemplo n.º 7
0
 void Update()
 {
     // enables or disables mouse lock and visibility also pauses game if mouse is visible
     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         if (Cursor.visible == true)
         {
             Cursor.lockState = CursorLockMode.Locked;
             Cursor.visible   = false;
             Time.timeScale   = 1f;
             settingsPopUp.Close();
         }
         else
         {
             Cursor.lockState = CursorLockMode.None;
             Cursor.visible   = true;
             Time.timeScale   = 0f;
             settingsPopUp.Open();
         }
     }
     // enables shooing only if game isnt paused
     if (Time.timeScale != 0)
     {
         if ((Input.GetKeyDown(KeyCode.RightControl)) && (!EventSystem.current.IsPointerOverGameObject()))
         {
             // this creates a vector with the coridnates of the rays origin
             Vector3 point = new Vector3(_camera.pixelWidth / 2, _camera.pixelHeight / 2, 0);
             muzzleFlash.Play();
             gunShot.Play();
             // creates ray object with origin cordinates
             Ray ray = _camera.ScreenPointToRay(point);
             // pases the ray and a new object with type RaycastHit
             if (Physics.Raycast(ray, out RaycastHit hit))
             {
                 // this retrieves the object the ray hit
                 GameObject     hitObject  = hit.transform.gameObject;
                 ReactiveTarget target     = hitObject.GetComponent <ReactiveTarget>();
                 GameObject     enemy      = hit.transform.gameObject;
                 WanderingAI    lifeStatus = enemy.GetComponent <WanderingAI>();
                 // this checks if the target is a person though the get component method and if it is
                 // it returns a hit and if not it creates a sphere in the debug console.
                 // get component returns null if the component isnt there.
                 if ((target != null) && (lifeStatus.getAlive()))
                 {
                     target.ReactToHit();
                     Messenger.Broadcast(GameEvent.ENEMY_HIT);
                 }
                 else
                 {
                     // starts the coroutine kicking control to it
                     StartCoroutine(SphereIndicator(hit.point));
                 }
             }
         }
     }
 }
    public void ReactToHit()
    {//метод, вызванный сценарием стрельбы
        WanderingAI behavior = GetComponent <WanderingAI>();

        if (behavior != null)
        {//проверяем, есть ли сценарий WanderingAI
            behavior.SetAlive(false);
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 9
0
    public void ReactToHit()   // իրան կրակելու t կանչվող method․
    {
        WanderingAI behavior = GetComponent <WanderingAI>();

        if (behavior != null)   // սաղ լինի, նոր սպանենք․ եթե սաղ չի, սատկացնել, նոր սպանել․
        {
            behavior.SetAlive(false);
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 10
0
    public void ReactToHit()
    {
        WanderingAI behavior = GetComponent <WanderingAI>();

        if (behavior != null)
        {
            behavior.SetAlive(false);
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 11
0
    public void ReactToHit()
    {
        WanderingAI behaviour = GetComponent <WanderingAI>();

        if (behaviour != null)
        {
            behaviour.Kill();
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 12
0
    public void ReactToHit()                                 //método para matar o inimigo
    {
        WanderingAI behavior = GetComponent <WanderingAI>(); //checa se o objeto tem o script atrelado a ele

        if (behavior != null)
        {
            behavior.SetAlive(false);
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 13
0
    public void ReactToHit()
    {
        WanderingAI wanderingai = GetComponent <WanderingAI>();

        if (wanderingai != null)
        {
            wanderingai.setDie();
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 14
0
    public void ReactToHit()
    {
        WanderingAI behaviour = GetComponent <WanderingAI> ();

        if (behaviour != null)           // if it has a WanderingAI script
        {
            behaviour.SetAlive(false);
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 15
0
    public void ReactToHit()
    {
        WanderingAI ai = GetComponent <WanderingAI>();

        if (ai != null)
        {
            ai.SetAlive(false);
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 16
0
    public void ReactToHit()
    {//метод, вызванный сценарием стрельбы
        WanderingAI behavior = GetComponent <WanderingAI>();

        if (behavior != null)
        {                             //проверяем, есть ли сценарий WanderingAI
            behavior.SetAlive(false); //вызываем метод SetAlive и меняем жизнь врага на false
        }
        StartCoroutine(Die());        //вызываем сопрограмму смерти врага
    }
Ejemplo n.º 17
0
    public void ReactToHit()
    {
        WanderingAI wanderingAI = GetComponent <WanderingAI>();

        if (wanderingAI != null)
        {
            wanderingAI.life = WanderingAI.state.DEAD;
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 18
0
    public void ReactToHit()
    {//метод, вызванный сценарием стрельбы
        WanderingAI behavior = GetComponent <WanderingAI>();

        if (behavior != null)
        {                             //проверяем, есть ли сценарий WanderingAI
            behavior.SetAlive(false); //вызываем функцию SetAlive со значением false
        }
        StartCoroutine(Die());        //вызов сопрограммы
    }
Ejemplo n.º 19
0
    public void reactToHit()
    {
        WanderingAI wanderingAI = GetComponent <WanderingAI>();

        if (wanderingAI != null)
        {
            wanderingAI.setAlive(false);
        }
        StartCoroutine(die());
    }
Ejemplo n.º 20
0
    // Method called by the shooting script
    public void ReactToHit()
    {
        WanderingAI behavior = GetComponent <WanderingAI>();

        if (behavior != null)
        {
            // Set the target state to false to indicate the target's current state is dead
            behavior.SetAlive(false);
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 21
0
    //вызывается сценарием стрельбы RayShooter
    public void ReactToHit()
    {
        WanderingAI behavior = GetComponent <WanderingAI>();

        //проверка нужна т.к. он может и отсутствовать
        if (behavior != null)
        {
            behavior.SetAlive(false);
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 22
0
 void SetInitialReferences()
 {
     enemyMaster  = GetComponent <EnemyMaster>();
     myWanderAI   = GetComponent <WanderingAI>();
     patrollingAI = GetComponent <PatrollingAI>();
     if (GetComponent <NavMeshAgent>() != null)
     {
         myNavMeshAgent = GetComponent <NavMeshAgent>();
     }
     checkRate = Random.Range(0.1f, 0.2f);
 }
Ejemplo n.º 23
0
    public void ReactToHit()
    {
        WanderingAI behaviour = this.GetComponent <WanderingAI>();

        if (null != behaviour)
        {
            behaviour.SetIsAlive(false);
        }

        StartCoroutine(Die());
    }
Ejemplo n.º 24
0
    public void ReactToHit()
    { //Метод, вызванный сценарием стрельбы.
        WanderingAI behavior = GetComponent <WanderingAI>();

        if (behavior != null) //<-Проверяем, присоединен ли к персонажу сценарий
                              //WanderingAI; он может и отсутствовать
        {
            behavior.SetAlive(false);
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 25
0
    public void ReactToHit()
    {
        WanderingAI behavior = GetComponent <WanderingAI>();

        if (behavior != null)
        {
            behavior.SetAlive(false);
        }

        animator.SetBool("isDead", true);
    }
Ejemplo n.º 26
0
    public void ReactToHit()
    {
        WanderingAI behavior = GetComponent <WanderingAI>();

        if (behavior != null)
        {
            //check if this character has a WanderingAI script; it may not
            behavior.SetAlive(false);
        }
        StartCoroutine(Die());
    }
Ejemplo n.º 27
0
 // Use this for initialization
 void Start()
 {
     nav  = GetComponent <NavMeshAgent> ();
     rb   = GetComponent <Rigidbody> ();
     anim = GetComponent <Animator> ();
     sR   = GetComponent <SpriteRenderer> ();
     wAI  = GetComponent <WanderingAI> ();
     eM   = GameObject.FindObjectOfType <EncounterManager> ();
     anim.SetBool("IntroPlaying", true);
     Physics.IgnoreLayerCollision(11, 8);
 }
Ejemplo n.º 28
0
    internal void ReactToHit()
    {
        WanderingAI behaviur = GetComponent <WanderingAI>();

        if (behaviur != null)
        {
            behaviur.setAlive(false);
        }

        StartCoroutine(Die());
    }
    public void ReactToHit()
    {
        // Get the Wandering AI component script
        WanderingAI behavior = GetComponent <WanderingAI>();

        if (behavior != null)
        {
            // if shot, turn the alive bool to false to stop movement
            behavior.SetAlive(false);
        }
        StartCoroutine(Die()); // coroutines are similar to interrupts
    }
Ejemplo n.º 30
0
    public void ReactToHit()
    {
        WanderingAI behavior = GetComponent <WanderingAI> ();

        if (behavior != null)
        {
            behavior.wasKilled();
        }         // wanderingai?


        StartCoroutine(Die());
    }     // hit