// Use this for initialization void Start() { m_elephantMovement = GameObject.FindObjectOfType <ElephantMovement>(); m_sceneLoader = GameObject.FindObjectOfType <SceneLoaderScript>(); m_wantedLevel = GameObject.FindObjectOfType <WantedLevel>(); StatePatternEnemy.OnCaught += OnCaught; Collectable.OnCollect += OnCollect; }
// Use this for initialization void Start() { m_elefantmovement = GetComponent <ElephantMovement>(); foreach (var collisionNotfier in m_trunkRoot.GetComponentsInChildren <CollisionNotifier>()) { collisionNotfier.OnTriggerStayNotification += OnTriggerStayNotification; } m_elephantControl = GetComponent <ElephantControl>(); }
IEnumerator StunRoutine(Interactor interactor) { ElephantMovement movement = interactor.GetComponent <ElephantMovement>(); if (movement) { movement.Punch(); } if (OnStun != null) { OnStun(new StunEventData(interactor.gameObject, gameObject)); } var stateEnemy = GetComponent <StatePatternEnemy>(); var navMeshAgent = GetComponent <NavMeshAgent>(); stateEnemy.StopMovement(); stateEnemy.enabled = false; navMeshAgent.enabled = false; interactor.GetComponent <AudioSource>().PlayOneShot(stunEnemyHitSound); if (stunIndicatorDestroyComp == null) { // Spawn stun indicator GameObject go = Instantiate <GameObject>(stunIndicatorPrefab); go.transform.parent = transform; go.transform.localPosition = stunIndicatorOffset; stunIndicatorDestroyComp = go.GetComponent <FadeAndDestroy>(); stunIndicatorDestroyComp.FadeInOutAndDestroy(0.15f, m_stunDuration.timeInSeconds - 0.5f, 0.35f); } else { stunIndicatorDestroyComp.ResetDuration(); } while (!m_stunDuration.IsOver()) { m_stunDuration.Update(Time.deltaTime); yield return(null); } m_stunDuration.Start(); stateEnemy.enabled = true; navMeshAgent.enabled = true; m_stunRoutine = null; stunIndicatorDestroyComp = null; }
//---------------------------- private void Awake() { m_enemyInteractable = GetComponent <EnemyInteractable>(); audioSource = GetComponent <AudioSource>(); playerActor = GameObject.FindObjectOfType <PlayerActor>(); wantedLevel = GameObject.FindObjectOfType <WantedLevel>(); chaseState = new ChaseState(this); alertState = new AlertState(this); patrolState = new PatrolState(this); m_caughtPlayerState = new CaughtPlayerState(this); navMeshAgent = GetComponent <NavMeshAgent>(); navMeshAgent.speed = standartSpeed; enemyAnimator = GetComponent <Animator>(); elephantMovement = playerActor.GetComponent <ElephantMovement>(); if (wayPoints == null) { wayPoints = new Waypoints() { points = new[] { transform.position }, pairs = new[] { new Pair() } } } ; } void OnValidate() { currentState = patrolState; } void Start() { currentState = patrolState; viewCone.MainViewRadius = toleratedSightrange; viewCone.FullViewRadius = sightRange; viewCone.FieldOfView = fieldOfView; OnCaught += StatePatternEnemy_OnCaught; }
private void Start() { m_playerActor = GetComponent <PlayerActor>(); m_sprintCooldown.End(); m_sprintDurationAfterSprintStopped.End(); m_shootPeanuts = GetComponent <Shoot_Peanuts>(); // get the transform of the main camera if (Camera.main != null) { m_cam = Camera.main.transform; } else { Debug.LogWarning( "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.", gameObject); // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them! } // get the third person character ( this should never be null due to require component ) m_character = GetComponent <ElephantMovement>(); m_interactor = GetComponent <Interactor>(); m_headControl = GetComponent <HeadControl>(); }
void Start() { elephantMovement = m_player.GetComponent <ElephantMovement>(); cameraController = m_mainCamera.GetComponent <CameraController>(); }
private void Start() { m_cameraController = GameObject.FindObjectOfType <CameraController> (); m_elephantMovement = GameObject.FindObjectOfType <ElephantMovement>(); }