示例#1
0
    void Shoot()
    {
        timer           = 0f;
        gunLine.enabled = true;
        gunLine.SetPosition(0, shootingPoint.position);
        shootRay.origin    = shootingPoint.position;
        shootRay.direction = transform.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            NormalAgent normalAgent = shootHit.collider.GetComponent <NormalAgent>();
            if (normalAgent != null)
            {
                //Debug.Log("Hit!");
                AddReward(0.33f);
                normalAgent.TakeDamage(damagePerShot, this);
            }
            else
            {
                //Debug.Log("Missed!");
                AddReward(-0.1f);
            }

            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);
            //Debug.Log("Missed!");
        }
    }
示例#2
0
 public void TakeDamage(int damage, NormalAgent NA)
 {
     //Debug.Log(this + " Take " + damage + " damage from: " + NA);
     AddReward(-0.2f);
     currentHealth -= damage;
     if (currentHealth <= 0)
     {
         RegisterDeath();
         NA.RegisterKill();
     }
 }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        rndFindHiding = 0;
        SetDestination();
        NormalAgent normalAgent = closest.GetComponent <NormalAgent>();

        if (normalAgent.hiding == true)
        {
            rndFindHiding = Random.Range(0, 2);
            if (rndFindHiding >= 1)
            {
                Vector3 targetDest = notClosest.transform.position;
                _navMeshAgent.SetDestination(targetDest);
            }
        }
    }