Пример #1
0
    void Patrulha()
    {
        pulseTime -= Time.deltaTime;

        if(pulseTime < 0){
         scannedColliders = Physics.OverlapSphere(myTransform.position,16,enemyMask);//
           if(scannedColliders.Length > 0)
         enemyAround = true;
           else enemyAround = false;
          pulseTime = 2.0f;
        }

        if(enemyAround){

          // Fase de teste
          if(scannedColliders.Length > 1){
        float tempdistance = Mathf.Infinity;
        for(int i = 0; i < scannedColliders.Length; i ++ ){
          if(!scannedColliders[i]){
            Debug.LogWarning("Scanned colliders are empty somehow");
            return;
          }
          target = scannedColliders[i].transform;
          targetEntity = target.GetComponent<CBaseEntity>();
          Debug.Log("targetEntity: " + targetEntity);
          if(!targetEntity) return;
          if(targetEntity.Type == CBaseEntity.eObjType.Building) continue;
          float tempdistanceindex = Vector3.Distance(myTransform.position,target.position);
          if(tempdistanceindex < tempdistance){
            tempdistance = tempdistanceindex;
            break;
          }else{
            target = scannedColliders[0].transform;
            targetEntity = target.GetComponent<CBaseEntity>();
          }
        }

          }else{
        target = scannedColliders[0].transform;
        targetEntity = target.GetComponent<CBaseEntity>();
          }

          targetVector = target.position - myTransform.position;

           if(Vector3.Distance(myTransform.position,target.position) < detectionDistance
          && Vector3.Angle(targetVector,myTransform.forward) < detectionRadius){
        if(targetEntity.Type == CBaseEntity.eObjType.Building) return;
          pulseTime = 2.0f;
          status = eAlertLevel.DETECT;
          Debug.LogWarning("Angle enemy is found: " + Vector3.Angle(targetVector,myTransform.forward));
          existingAlert = GameObject.Instantiate(detectAlert,new Vector3(target.position.x,target.position.y + 15, target.position.z), Quaternion.identity) as GameObject;
           }else if(Vector3.Distance(myTransform.position,target.position) < detectionDistance
                && Vector3.Angle(targetVector,myTransform.forward) < alertRadius){
          status = eAlertLevel.ALERT;
           }

        }else{
          target = null;
        }

        Debug.DrawRay(myTransform.position,myTransform.forward * 10);
    }
Пример #2
0
    void Detecta()
    {
        Debug.DrawRay(myTransform.position,myTransform.forward * 10,Color.red); // Found ya !
        pulseTime -= Time.deltaTime;

        if(pulseTime < 0){
        status = eAlertLevel.PATROL;
        GameObject.Destroy(existingAlert);
        }
    }
Пример #3
0
    void Alerta()
    {
        targetVector = target.position - myTransform.position;

          Debug.DrawRay(myTransform.position,myTransform.forward * 10,Color.yellow); // Smelled ya !

          if(Vector3.Distance(myTransform.position,target.position) < detectionDistance){
        if(Vector3.Angle(targetVector,myTransform.forward) < detectionRadius ){
        if(targetEntity.Type == CBaseEntity.eObjType.Building) return;
        pulseTime = 2.0f;
        status = eAlertLevel.DETECT;
        Debug.LogWarning("Angle enemy is found in alert status: " + Vector3.Angle(targetVector,myTransform.forward));
        existingAlert = GameObject.Instantiate(detectAlert,new Vector3(target.position.x,myTransform.position.y + 15,myTransform.position.z),
                                              Quaternion.identity) as GameObject;
        }
          }else status = eAlertLevel.PATROL;
    }
Пример #4
0
    void Patrol()
    {
        //
        fTimer += Time.deltaTime;
        Transform tempTarget;

        if(fTimer > fCheckViewTimer){

          scannedColliders = Physics.OverlapSphere(this.transform.position,viewRadius,1<<myEnemyLayer);
          if(scannedColliders.Length > 0)
        foreach(Collider colliderScanned in scannedColliders){
          if(colliderScanned.tag != "Building"){

            if(colliderScanned.tag == "Drone"){
              tempTarget = colliderScanned.transform;
              if(tempTarget.GetComponent<CDrone>().droneType == CDrone.eDroneType.Saboteur)
                Debug.Log("Saboteur");
            }

            Debug.LogWarning("Alert Mode !");
            alertLevel = eAlertLevel.ALERT;
            break;
          }
        }
          fTimer = 0;
        }
        //*/
    }
Пример #5
0
    void Detect()
    {
        //
        fTimer += Time.deltaTime;

         if(!existingAlert)
           existingAlert = GameObject.Instantiate(detectAlert,new Vector3(currentTarget.position.x,currentTarget.position.y + 15, currentTarget.position.z),
                                              Quaternion.identity) as GameObject;

           if(mySightTrigger.oppositeDroneLost != null){

        Transform targetExit = mySightTrigger.oppositeDroneLost;
        if(targetExit == currentTarget){

          alertLevel = eAlertLevel.ALERT;
          if(OnEnemyFound != null)
            OnEnemyFound(this.transform,currentTarget);

        }else{

          currentTarget = targetExit;

          if(existingAlert) GameObject.Destroy(existingAlert);

          existingAlert = GameObject.Instantiate(detectAlert,new Vector3(currentTarget.position.x,currentTarget.position.y + 15, currentTarget.position.z),
                                                  Quaternion.identity) as GameObject;
          if(OnEnemyFound != null)
            OnEnemyFound(this.transform,currentTarget);

          alertLevel = eAlertLevel.ALERT;
        }
          }

        //*/
    }
Пример #6
0
    void Alert()
    {
        //
        fTimer += Time.deltaTime;

          //currentTarget = mySightTrigger.oppositeDroneSeen;

          if(mySightTrigger.oppositeDroneSeen != null){
        currentTarget = mySightTrigger.oppositeDroneSeen;

        alertLevel = eAlertLevel.DETECT;
        if(existingAlert) GameObject.Destroy(existingAlert);

        if(OnEnemyFound != null)
          OnEnemyFound(this.transform,currentTarget);
          }

        if(fTimer > fAlertViewTimer){
          fTimer = 0;
          alertLevel = eAlertLevel.PATROL;
          if(currentTarget) currentTarget = null;
          if(existingAlert) GameObject.Destroy(existingAlert);
          Debug.LogWarning("Back to Patrol mode");
        }
        //*/
    }