public AudioSource ReloadAudio; // The reload audio source //----------------------------------------------------- // Method: Awake() // Description: disable the currently active crosshair //----------------------------------------------------- protected void Awake() { // Added a conditional to prevent unnessecary calls of this method, it only needs to be called once // But depending on which weapon the player first picks up it must be called at least once if (_launchPoint != null) { return; } _launchPoint = Camera.main.transform; // get the launchpoint TagsHashes = FindObjectOfType <TagsHashIDs>(); // get the TagsHashIDs.cs script reference int EnemyLayerInt = LayerMask.NameToLayer("Enemy"); // Set up the shooting layer mask int DefaultLayerInt = LayerMask.NameToLayer("Default"); int ShootableLayerInt = LayerMask.NameToLayer("Shootable"); int EnemyLayerMask = 1 << EnemyLayerInt; int ShootableLayerMask = 1 << ShootableLayerInt; int DefaultLayerMask = 1 << DefaultLayerInt; GunEnemyLayerMask = EnemyLayerMask | DefaultLayerMask | ShootableLayerMask; // bit shift the layer mask MuzzleEffects = MuzzleFlashEffects.GetComponentsInChildren <ParticleSystem>(); // Asigne the muzzle flash effects // Create pools of commonly used particle systems: _envHitEffectPool = ObjectPooler.CreatePool(EnvHitParticles, poolSize, gameObject.name + " Hit Particles", false); ShootableHitFXPool = ObjectPooler.CreatePool(TargetHitFX, 3, gameObject.name + "Target Hit FX", false); MeleeHitFXPool = ObjectPooler.CreatePool(BasicEnemyHitFX, poolSize, gameObject.name + " ImpactVFX", false); ArmouredHitFXPool = ObjectPooler.CreatePool(ArmouredEnemyHitFX, poolSize, gameObject.name + " ArmouredImpactVFX", false); FlameHitFXPool = ObjectPooler.CreatePool(FlameEnemyHitFX, poolSize, gameObject.name + " FlamerImpactVFX", false); EnergyPackHitFXPool = ObjectPooler.CreatePool(EnergyPackHitFX, poolSize, gameObject.name + " EnergyPackVFX", false); }
private void Start() { _impactEffect = GetComponentInChildren <ParticleSystem>(); // meleeAudio = _impactEffect.GetComponent<AudioSource>(); tagsHash = GetComponentInParent <FPSRigAnimator>().TagsHashIDs; meleeEffectPool = ObjectPooler.CreatePool(_impactEffect.gameObject, 3, "MeleeEffects", false); }
//----------------------------------------------------------------------------------- // Method: Start // Desc: Create the layer mask. It is possible for ranged enemies to fire a spherecast // and hit other enemies, which takes damage from them. Also cache comps not // in this object's heirarchy //----------------------------------------------------------------------------------- private void Start() { StateController sc = GetComponentInParent <StateController>(); _playerTransform = sc.Player.transform; _tagsHashes = sc.TagsHash; _layerMask = _tagsHashes.PlayerLayerMask | _tagsHashes.EnemyLayerMask | _tagsHashes.DefaultLayerMask | _tagsHashes.ShootableLayerMask; }
//------------------------------------------------------------------------------------------------------------------------- // Method: Start() // Desc: Get connections to components on other gameobjects, which would have been set up in their own Awake() method // ie StateController.cs grabs the player in it's awake() method, so we get that reference in the Start method // to avoid a null reference. //-------------------------------------------------------------------------------------------------------------------------- private void Start() { _LayerMasks = GetComponentInParent <StateController>().TagsHash; _AITriggerLayerMask = _LayerMasks.AITriggerLayerMask | _LayerMasks.EnemyLayerMask | _LayerMasks.IgnoreRaycastLayerMask; // We have to include the ignore raycast layer, // because spawn trigger colliders are on this layer and if the sight script casts against them the player will never be seen // I don't include the enemy layer in the mask, because the enemy would not see the player // As his sight was being blocked by (presumably) his own collider - at least this is what happened suring testing _AITriggerLayerMask = ~_AITriggerLayerMask; // Only get a reference to the player if he is alive // Avoid a null reference if an enemy spawns after the player has been killed - should not happen but just in case if (PlayerStats.PlayerHealth > 0.0f) { _player = GetComponentInParent <StateController>().Player.gameObject; } }
private PlayerMeleeAttack _meleeAttackScript; // Script for melee Attacking // ------------------------------------------------------------------------------------------ // METHOD: Awake() // DESCRIPTION: Cache global variables and convert layer names to their integer values // ------------------------------------------------------------------------------------------ void Awake() { TagsHashIDs = FindObjectOfType <TagsHashIDs>(); _weaponManagerScript = GetComponent <WeaponManager>(); _fpsAnimator = GetComponent <Animator>(); _noWeaponLayer = _fpsAnimator.GetLayerIndex("NoWeaponLayer"); _handgunLayer = _fpsAnimator.GetLayerIndex("HandgunLayer"); _macheteLayer = _fpsAnimator.GetLayerIndex("MacheteLayer"); _shotgunLayer = _fpsAnimator.GetLayerIndex("ShotgunLayer"); _plasmaRifleLayer = _fpsAnimator.GetLayerIndex("PlasmaRifleLayer"); //_pickupReloadLayer = _fpsAnimator.GetLayerIndex("PickupAndReload"); _handgun = GetComponentInChildren <Handgun>(true); _shotgun = GetComponentInChildren <Shotgun>(true); _plasmaRifle = GetComponentInChildren <PlasmaRifle>(true); }
// --------------------------------------------------------------------------------------------------- // METHOD: Start() // Desciption: Get a reference to the TagsHashIDs.cs file, and construct a new AnimatorSetup.cs class // --------------------------------------------------------------------------------------------------- private void Start() { _hashIDs = _controller.TagsHash; _animatorSetup = new AnimatorSetup(_anim, _hashIDs); }
// Constructor, called by other script when an instance of this class is created: public AnimatorSetup(Animator anim, TagsHashIDs tagsHashes) { _anim = anim; _hashIDs = tagsHashes; }