Пример #1
0
    protected override IEnumerator Alarm()
    {
        //Debug.Log("Overrided Alarm for Bear started");
        agent.speed = runSpeed;
        float chaseTime = 0.0f;

        while (true)
        {
            float dist = Vec3Mathf.DistanceTo(transform.position, visibleTarget.position);
            if (dist < attackDistance)
            {
                PlayerHealth playerHP = FindObjectOfType <PlayerHealth> ();
                if (playerHP != null)
                {
                    playerHP.TakeDamage(30);
                }
                animator.SetTrigger("Attack");
                agent.ResetPath();
                yield return(new WaitForSeconds(0.5f));
            }
            animator.SetTrigger("Walk");
            chaseTime += Time.deltaTime;
            agent.ResetPath();
            agent.SetDestination(destination = visibleTarget.position);
            if (chaseTime > 1.0f && fow.visibleTargets.Count < 1)
            {
                break;
            }
            yield return(new WaitForSeconds(0.1f));
        }
        agent.ResetPath();
        // Debug.Log("Остновка погони, переход в поиск цели");
        ChangeCondition(Condition.Safety, "Alarm", "Safety");
    }
Пример #2
0
 protected override IEnumerator Alarm()
 {
     TestPointer.instance.target3d = this.transform;
     if (!model.enabled)
     {
         ai.FindAreaCenter(visibleTarget.position);
         agent.Warp(ai.areaCenter.position);
         model.enabled = true;
     }
     agent.speed = runSpeed;
     while (fow.visibleTargets.Count > 0)
     {
         float dist = Vec3Mathf.DistanceTo(transform.position, visibleTarget.position);
         if (dist < attackDistance)
         {
             PlayerHealth playerHP = FindObjectOfType <PlayerHealth> ();
             if (playerHP != null)
             {
                 playerHP.TakeDamage(30);
             }
             agent.ResetPath();
             yield return(new WaitForSeconds(1f));
         }
         agent.SetDestination(destination = visibleTarget.position);
         yield return(new WaitForSeconds(0.1f));
     }
     agent.ResetPath();
     TestPointer.instance.target3d = null;
     ChangeCondition(Condition.Safety, "Alarm", "Safety");
 }
Пример #3
0
 public void FindAreaCenter(Vector3 nearWithPos)
 {
     foreach (Transform trans in SaveZones)
     {
         if (areaCenter == null || Vec3Mathf.DistanceTo(nearWithPos, trans.position) < Vec3Mathf.DistanceTo(nearWithPos, areaCenter.position))
         {
             areaCenter = trans;
         }
     }
     walkBounds.SetBounds(walkWidth, walkLength, areaCenter.position);
 }
Пример #4
0
 void ChooseZone(Transform[] zones)
 {
     foreach (Transform zone in zones)
     {
         if (finalZone == null || Vec3Mathf.DistanceTo(transform.position, zone.position) < Vec3Mathf.DistanceTo(transform.position, finalZone.position))
         {
             finalZone = zone;
         }
     }
     //Debug.Log(finalZone);
     areaCenter = finalZone;
     walkBounds.SetBounds(walkWidth, walkLength, areaCenter.position);
 }
Пример #5
0
 private void Update()
 {
     if (canvas.enabled)
     {
         float distance = Vec3Mathf.DistanceTo(rectTrans.position, menuPoint.position);
         if (distance > 20)
         {
             canvas.enabled = false;
         }
     }
     if (OVRInput.Get(OVRInput.Button.One) && canActive)
     {
         rectTrans.position = menuPoint.position;
         rectTrans.rotation = Quaternion.LookRotation(menuPoint.forward);
         canvas.enabled     = true;
     }
 }
Пример #6
0
    protected override IEnumerator Secure()
    {
        while (fow.visibleTargets.Count < 1)
        {
            yield return(null);

            if (Vec3Mathf.DistanceTo(transform.position, ai.areaCenter.position) < 1.3f)
            {
                model.enabled = false;
            }
        }
        visibleTarget = fow.visibleTargets [0];
        yield return(new WaitForSeconds(5));

        if (fow.visibleTargets.Count > 0)
        {
            ChangeCondition(Condition.Alarm, "Secure", "Alarm");
        }
        else
        {
            StartCoroutine("Secure");
        }
    }
Пример #7
0
 // методы траектории
 IEnumerator MakeDive()
 {
     agent.enabled             = false;
     traectory.graphCorrection = 50.0f;
     traectory.CalcGraph(transform.position, visibleTarget.position);
     destination = traectory.GetNextPoint();
     Debug.Log("Совершили атаку на игрока");
     transform.rotation = Vec3Mathf.GetDirXY(transform.position, visibleTarget.position);
     while (Vector3.Distance(transform.position, visibleTarget.position) > 1.0f)
     {
         transform.rotation = Vec3Mathf.GetDirXY(transform.position, visibleTarget.position);
         transform.position = Vector3.MoveTowards(transform.position, visibleTarget.position, 1.0f);
         float dist = Vec3Mathf.DistanceTo(transform.position, visibleTarget.position);
         Debug.Log(dist);
         if (dist < attackDistance)
         {
             PlayerHealth playerHP = FindObjectOfType <PlayerHealth>();
             if (playerHP != null)
             {
                 playerHP.TakeDamage(70);
             }
             break;
         }
         yield return(new WaitForEndOfFrame());
     }
     traectory.graphCorrection = 0.0f;
     traectory.CalcGraph(transform.position, destination = eaglePatrolPos);
     transform.rotation = Vec3Mathf.GetDirXY(transform.position, destination);
     while (Vector3.Distance(transform.position, destination) > 1.0f)
     {
         transform.position = Vector3.MoveTowards(transform.position, destination, 1.0f);
         yield return(new WaitForEndOfFrame());
     }
     isEnemyInSight = false;
     ChangeCondition(Condition.Alarm, "MakeDive", "Alarm");
 }