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); } }
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); } }
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); } }
public GuardState(GuardStateMachine context) { this.context = context; }
public SearchingGuardState(GuardStateMachine context, Vector3 targetPosition) : base(context) { this.targetPosition = targetPosition; }
public AlertGuardState(GuardStateMachine context) : base(context) { }
public ChaseGuardState(GuardStateMachine context) : base(context) { }
public PatrollingState(GuardStateMachine context) : base(context) { }
public CluelessWaitingState(GuardStateMachine context, float waitForSeconds, GuardState goToState) : base(context) { waitingTime = waitForSeconds; this.goToState = goToState; }
public CluelessGuardState(GuardStateMachine context) : base(context) { }
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) { }