void Start() { _primaryGun.SetActive(false); _secondaryGun.SetActive(true); _primary = _primaryGun.GetComponent <GunClass>(); _secondary = _secondaryGun.GetComponent <GunClass>(); }
void Start() { _reloadInterface = FindObjectOfType <ReloadBar>(); _granadeCount = 3; _poolHolder = new GameObject("GranedePool"); gun = GetComponentInChildren <GunClass>(); }
protected override void Initialized() { GunClass[] guns = GetComponentsInChildren <GunClass>(); foreach (GunClass item in guns) { m_Guns.Add(item); } m_CurrentlyActiveGun = m_Guns[Random.Range(0, m_Guns.Count)]; float sqrRange = m_AIGunnerField.AttackbyGunRange * m_AIGunnerField.AttackbyGunRange; m_unwareAIState = new AIUnwareState <AIManager>(this, sqrRange); m_patrolAIState = new AIPatrolState <AIManager>(this, sqrRange); m_chaseAIState = new AIChaseState <AIManager>(this, sqrRange); m_searchAIState = new AISearchState <AIManager>(this, sqrRange); m_coverAIState = new AICoverState <AIManager>(this); m_gunFireAIState = new AIGunFireState(this); if (m_unwareAIState == null || m_patrolAIState == null || m_chaseAIState == null || m_searchAIState == null || m_gunFireAIState == null) { Debug.LogError("AI State is null"); } base.Initialized(); }
private void Start() { base.Initialized(); m_sceneCharactersManager.AddPlayerToCharaterList(this.gameObject, CharacterType.Player); m_InputKeyManager = GetComponent <InputKeyManager>(); GunClass[] guns = GetComponentsInChildren <GunClass>(); m_Guns = new List <GunClass>(); for (int i = 0; i < guns.Length; i++) { m_Guns.Add(guns[i]); } m_currentlyActiveGun = m_Guns[0]; if (m_MainCameraTransform == null) { m_MainCameraTransform = Camera.main.transform; } m_simpleLocomotionState = new PlayerSimpleLocomotionState(this, m_animator); m_gunFireState = new PlayerGunFiringState(this, m_animator); if (m_typeOfCameraMovement == CameraMovementType.FreeLook) { OnStateChanged(m_simpleLocomotionState); } else { OnStateChanged(m_gunFireState); } }
protected virtual void Start() { _rb = GetComponent <Rigidbody2D>(); _source = GetComponent <AudioSource>(); _anim = GetComponent <Animator>(); _gun = GetComponentInChildren <GunClass>(); _reloadInterface = FindObjectOfType <ReloadBar>(); }
void Start() { _playerTransform = FindObjectOfType <PlayerClass>().transform; if (_type == 1) { _gun = _playerTransform.GetChild(0).GetComponent <GunClass>(); } else if (_type == 2) { _gun = _playerTransform.GetChild(1).GetComponent <GunClass>(); } _particle = GetComponent <ParticleSystem>(); }
public void init(GunClass _gunClass, Rarity _rarity, int _damage, int _fireRate, float _bulletSpd, float _accuracy, float _reloadSpd, int _magazine) { gunClass = _gunClass; rarity = _rarity; damage = _damage; fireRate = _fireRate; bulletSpd = _bulletSpd; accuracy = Mathf.Clamp(_accuracy, 0, 100); reloadSpd = _reloadSpd; magazine = _magazine; lastFired = Time.time - (1 / (float)fireRate); currentMagazine = magazine; lastReload = Time.time; isReloading = false; }
void Awake() { // Create a layer mask for the Shootable layer. shootableMask = LayerMask.GetMask("Shootable"); // Set up the references. gunParticles = GetComponent <ParticleSystem> (); gunLine = GetComponent <LineRenderer> (); gunShotClips = GetComponents <AudioSource> (); gunLight = GetComponent <Light> (); //faceLight = GetComponentInChildren<Light> (); gunShotClips[2].volume = 0.8f; gunList [0] = new GunClass(20, 0.15f, 32f, gunShotClips[0], 0.8f); // Rifle gunList [1] = new GunClass(100, 0.8f, 10f, gunShotClips[2], 0.2f); // Shotgun gunList [2] = new GunClass(200, 1.5f, 50f, gunShotClips[1], 1.1f); // Laser gunType = Gun.Rifle; }
void Update() { if (Input.GetKeyDown(KeyCode.F) && _trowTimer <= 0 && _granadeCount > 0) { ShootGranade(); } if (_trowTimer > 0) { _trowTimer -= Time.deltaTime; } if (!gun.gameObject.activeInHierarchy) { gun = GetComponentInChildren <GunClass>(); } _reloadInterface.ShowGrenades(_granadeCount); }