Beispiel #1
0
 void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "ground" && throwing)
     {
         Collider[] hitColliders = Physics.OverlapSphere(gameObject.transform.position, sound_radius);
         foreach (var hitCollider in hitColliders)
         {
             GuardStateMachine enemy_ai = hitCollider.gameObject.GetComponent <GuardStateMachine>();
             if (enemy_ai != null)
             {
                 enemy_ai.noticeSound(gameObject.transform.position);
                 Debug.Log("Enemy noticed thrown object");
             }
         }
         AudioClip clip = clips[0];
         audioSource.PlayOneShot(clip);
         Collider collider = GetComponent <Collider>();
         //MeshRenderer renderer = GetComponent<MeshRenderer>();
         transform.localScale = new Vector3(0, 0, 0);
         collider.enabled     = false;
         //renderer.enabled = false;
         rb.isKinematic = false;
         //Destroy(gameObject);
     }
 }
    public override void OnSoundReceived(GameObject source)
    {
        GuardStateMachine stateMachine = GetComponent <GuardStateMachine>();

        if (stateMachine)
        {
            stateMachine.Distract(source.transform.position);
        }
    }
Beispiel #3
0
    private void OnTriggerEnter(Collider other)
    {
        if (lightIsActive && other.gameObject.GetComponent <MainPlayer>() != null)
        {
            other.gameObject.GetComponent <MainPlayer>().lightStandingIn.Add(this.gameObject);
        }

        GuardStateMachine gsm = other.gameObject.GetComponentInParent <GuardStateMachine>();

        if (lightIsActive && gsm != null)
        {
            gsm.lightsStandingIn.Add(this.gameObject);
            guardsInMe.Add(gsm);
        }
    }
Beispiel #4
0
    private void OnTriggerExit(Collider other)
    {
        if (lightIsActive && other.gameObject.GetComponent <MainPlayer>() != null)
        {
            other.gameObject.GetComponent <MainPlayer>().lightStandingIn.Remove(this.gameObject);
        }

        GuardStateMachine gsm = other.gameObject.GetComponentInParent <GuardStateMachine>();

        if (lightIsActive && gsm != null)
        {
            //Debug.Log("no light");
            gsm.lightsStandingIn.Remove(this.gameObject);
            guardsInMe.Remove(gsm);
        }
    }
Beispiel #5
0
 public GuardState(GuardStateMachine context)
 {
     this.context = context;
 }
 public SearchingGuardState(GuardStateMachine context, Vector3 targetPosition) : base(context)
 {
     this.targetPosition = targetPosition;
 }
Beispiel #7
0
 public AlertGuardState(GuardStateMachine context) : base(context)
 {
 }
 public ChaseGuardState(GuardStateMachine context) : base(context)
 {
 }
Beispiel #9
0
 public PatrollingState(GuardStateMachine context) : base(context)
 {
 }
 public CluelessWaitingState(GuardStateMachine context, float waitForSeconds, GuardState goToState) : base(context)
 {
     waitingTime    = waitForSeconds;
     this.goToState = goToState;
 }
Beispiel #11
0
 public CluelessGuardState(GuardStateMachine context) : base(context)
 {
 }
Beispiel #12
0
 public BlindedGuardState(GuardStateMachine context) : base(context)
 {
 }
 public InvestigationGuardState(GuardStateMachine context, Vector3 targetPosition) : base(context, targetPosition)
 {
     startRotation = context.transform.forward;
 }
 // Use this for initialization
 void Start()
 {
     methods.Invoke();
     myGuard       = GetComponentInParent <GuardStateMachine>();
     laserRenderer = GetComponent <LineRenderer>();
 }
 public LosingGuardState(GuardStateMachine context) : base(context)
 {
 }