/***********Secondary Fire Powerup**********/ IEnumerator HomingCooldown() { firemode = FireMode.homing; yield return(new WaitForSeconds(5f)); firemode = FireMode.laser; }
void fireShot() { shotProjection.enabled = false; touchInput.enabled = false; switch (fireMode) { case FireMode.regular: recieverRB.velocity = -shotVelocity; rb.velocity = -shotVelocity; break; case FireMode.bulletTime: bullet.SetActive(true); bullet.transform.SetParent(null, true); bullet.transform.position = transform.position; bullet.GetComponent <Rigidbody>().velocity = -shotVelocity; fireMode = FireMode.regular; break; case FireMode.grapplingHook: grapplingHook.SetActive(true); grapplingHook.transform.SetParent(null, true); grapplingHook.transform.position = transform.position; grapplingHook.GetComponent <Rigidbody>().velocity = -shotVelocity; fireMode = FireMode.regular; break; } }
//*******************************************************************// void Start() { //Reset the player position when game starts transform.position = new Vector3(0f, -3f, 0f); audioSource = GetComponent <AudioSource>(); firemode = FireMode.laser; spawnManager = GameObject.Find("Game_Manager").GetComponent <SpawnManager>(); uiManager = GameObject.Find("Game_Manager").GetComponent <UIManager>(); audioManager = GameObject.Find("Audio_Manager").GetComponent <AudioManager>(); if (spawnManager == null) { Debug.LogError("No SpawnManager found"); } if (uiManager == null) { Debug.LogError("No UIManager found"); } if (audioManager == null) { Debug.LogError("No AudioManager found"); } }
IEnumerator TripleShotCooldown() { firemode = FireMode.tripleShot; yield return(new WaitForSeconds(_tripleShotTime)); firemode = FireMode.laser; }
/// <summary> /// Take a given FireMode and return an increment/loop to the next enum value /// </summary> /// <param name="currentSelection"></param> /// <returns></returns> public static FireMode CycleFireMode(FireMode currentSelection, List <int> allowedFireModes = null) { int selectionIndex = (int)currentSelection; selectionIndex++; if (allowedFireModes != null) { foreach (var _ in Enumerable.Range(0, fireModeEnums.Length)) { if (allowedFireModes.Contains(selectionIndex)) { return((FireMode)fireModeEnums.GetValue(selectionIndex)); } selectionIndex++; if (selectionIndex >= fireModeEnums.Length) { selectionIndex = 0; } } return(currentSelection); } else { if (selectionIndex < fireModeEnums.Length) { return((FireMode)fireModeEnums.GetValue(selectionIndex)); } else { return((FireMode)fireModeEnums.GetValue(0)); } } }
private void Assemble() { // Get all firemodes on this weapon var modes = GetComponentsInChildren <FireMode>(); foreach (var mode in modes) { mode.Weapon = this; } // the first firemode will be called OnFire() and will call subsequent firemodes after it. fireMode = modes[0]; OnFire += fireMode.Fire; OnHold += fireMode.Hold; OnRelease += fireMode.Release; if (projectors == null || projectors.Count == 0) { // assign a weapon and damage to all projectors, and register callbacks for OnHitAny and OnHitDamage projectors = new List <Projector>(GetComponentsInChildren <Projector>()); foreach (var p in projectors) { p.Setup(this, damage, HitDamage, HitAny); } } }
private void SelectFireModeWithNumberKeys() { if (!EnableModeSelectionWithNumberKeys.Value) { return; } if (Input.GetKeyDown(KeyCode.Alpha1)) { fireMode = FireMode.Normal; return; } if (Input.GetKeyDown(KeyCode.Alpha2)) { fireMode = FireMode.Auto; return; } if (Input.GetKeyDown(KeyCode.Alpha3)) { fireMode = FireMode.AutoCharge; } }
private void SwitchFiringMethod() { if (secondMode == FireMode.None && thirdMode == FireMode.None) { maxIndex = 0; } else if (thirdMode == FireMode.None) { maxIndex = 1; } if (fireModeIndex > maxIndex) { fireModeIndex = 0; } if (fireModeIndex == 0) { currentFireMode = firstMode; } if (fireModeIndex == 1 && secondMode != FireMode.None) { currentFireMode = secondMode; } if (fireModeIndex == 2 && thirdMode != FireMode.None) { currentFireMode = thirdMode; } }
// Function that adjusts the crit and damage modifiers based on firing mode public void SetAttackModifiers(int mode) { if (mode == (int)FireMode.AUTO) { fireMode = FireMode.AUTO; timeBetweenBurst = 0.01f; critChance = 40.0f; critModifier = 0.7f; baseDamage = 5.0f; } else if (mode == (int)FireMode.THREE_BURST) { fireMode = FireMode.THREE_BURST; timeBetweenBurst = 0.0f; critChance = 30.0f; critModifier = 0.5f; baseDamage = 10.0f; } else if (mode == (int)FireMode.SINGLE) { fireMode = FireMode.SINGLE; timeBetweenBurst = 0.0f; critChance = 10.0f; critModifier = 1.0f; baseDamage = 20.0f; } }
void ChangeFireMode() { int currentFireMode = (int)fireMode; switch (gunType) { case GunType.SingleFire: //ma timeout na kazdou strelu currentFireMode = 0; break; case GunType.SemiAuto: //nema timeout currentFireMode = 1; break; case GunType.FullAuto: if (currentFireMode == 0) //pokud je firemode single zmen ho na semiauto { currentFireMode = 1; } if (Input.GetKeyDown(KeyCode.B)) //pri zmacknuti zmen mod u fullauto zbrane { currentFireMode = currentFireMode == 2 ? 1 : currentFireMode + 1; } break; } fireMode = (FireMode)currentFireMode; UpdateFireModeText(); }
public void Update() { if (Input.GetKeyDown(KeyCode.Alpha1)) { switch (fireMode) { case FireMode.Normal: fireMode = FireMode.Auto; break; case FireMode.Auto: fireMode = FireMode.AutoCharge; break; case FireMode.AutoCharge: fireMode = FireMode.Normal; break; default: // ERROR: fire mode isn't implemented yet // fallback to single fire mode fireMode = FireMode.Normal; break; } } // TODO: add gamepad button to cycle through fire modes }
void SwitchFireMode() { if (Input.GetKeyDown(KeyCode.Alpha1) && acquiredBlueLaser == true) { firemode = FireMode.Blue; blueGunImage.enabled = true; greenGunImage.enabled = false; redGunImage.enabled = false; } if (Input.GetKeyDown(KeyCode.Alpha2) && acquiredGreenLaser == true) { firemode = FireMode.Green; blueGunImage.enabled = false; greenGunImage.enabled = true; redGunImage.enabled = false; } if (Input.GetKeyDown(KeyCode.Alpha3) && acquiredRedLaser == true) { firemode = FireMode.Red; blueGunImage.enabled = false; greenGunImage.enabled = false; redGunImage.enabled = true; } LaserColor(); }
private void SwitchFireMode(FireMode mode, bool isMainFireMode = true) { if (isMainFireMode) { _fireMode = mode; } switch (mode) { case FireMode.NoGuns: _shouldMainGunShoot = false; _shouldOnboardGunShoot = false; break; case FireMode.OnlyMain: _shouldMainGunShoot = true; _shouldOnboardGunShoot = false; break; case FireMode.OnlyOnboard: _shouldMainGunShoot = false; _shouldOnboardGunShoot = true; break; case FireMode.AllGuns: _shouldMainGunShoot = true; _shouldOnboardGunShoot = true; break; } }
private void Start() { muzzleFlashParticles.Stop(); currentBulletSpread = minimumBulletSpread; isTriggerHeld = false; Random.InitState(System.Environment.TickCount); var audioSources = GetComponents <AudioSource>(); shootAudioPlayer = audioSources[0]; shootAudioPlayer.loop = false; shootAudioPlayer.playOnAwake = false; emptyAudioPlayer = audioSources[1]; emptyAudioPlayer.loop = false; emptyAudioPlayer.playOnAwake = false; reloadAudioPlayer = audioSources[2]; reloadAudioPlayer.loop = false; reloadAudioPlayer.playOnAwake = false; metalHitAudioPlayer = audioSources[3]; metalHitAudioPlayer.loop = false; metalHitAudioPlayer.playOnAwake = false; currentRoundsInClip = maxRoundsInClip; chosenFireMode = fireMode; bulletSpreadRatio = (maximumBulletSpread - minimumBulletSpread) * 0.1f; UpdateGUI(); }
public void ChangeFireMod() { int i = ((fireModeSelect++) % 3); string type = ""; switch (i) { case 0: fireMode = FireMode.Auto; type = "Automatic"; break; case 1: fireMode = FireMode.Burst; type = "Burst"; break; case 2: fireMode = FireMode.Single; type = "Single"; break; } if (!flagFirstTime) { gameUi.OnNewFireMode(type); } flagFirstTime = false; }
private void SelectFireModeWithNumberKeys() { if (!EnableModeSelectionWithNumberKeys.Value) { return; } // not using IsDown because it doesn't work while moving if (Input.GetKeyDown(FireModeNormalKey.Value.MainKey)) { fireMode = FireMode.Normal; return; } if (Input.GetKeyDown(FireModeSpamKey.Value.MainKey)) { fireMode = FireMode.Spam; return; } if (Input.GetKeyDown(FireModeDoubleDoubleTapKey.Value.MainKey)) { fireMode = FireMode.DoubleDoubleTap; } }
/// <summary> /// Cycles through all available fire modes in order /// </summary> public void ToggleFireMode() { int currentFireModeNum = this.availableFireModes.IndexOf(this.currentFireModeInt); currentFireModeNum = (currentFireModeNum + 1) % this.availableFireModes.Count; this.currentFireModeInt = this.availableFireModes.ElementAt(currentFireModeNum); }
// Use this for initialization private void Awake() { //Resize fireModeList if inspector input too large (max. size 3) if (fireModeList.Count > 3) { fireModeList.RemoveRange(3, fireModeList.Count - 3); } //Assign firemodes to map for (int i = 0; i < fireModeList.Count - 1; ++i) { FireModesMap.Add(fireModeList[i], fireModeList[i + 1]); } if (FireModesMap.Contains(fireModeList[0])) { FireModesMap.Add(fireModeList[fireModeList.Count - 1], fireModeList[0]); } //Assign first firemode fireMode = fireModeList[0]; //Assign bullet count according to firemodes available switch (fireMode) { case FireMode.FT_SEMI: bulletsToFire = 1; break; case FireMode.FT_BURST: bulletsToFire = 3; break; } }
void SwitchFireMode() { switch (fireMode) { case FireMode.FREE: fireMode = FireMode.POINT; if (tempAttackDirectional != null) { Destroy(tempAttackDirectional); fireModePointObject = Instantiate(attackOnLinePrefab); //fireModePointObject.name = "IM HERE"; } break; case FireMode.POINT: fireMode = FireMode.TARGET; if (fireModePointObject != null) { Destroy(fireModePointObject); } break; case FireMode.TARGET: fireMode = FireMode.FREE; if (selectedNPC != null) { selectedNPC.GetComponent <Renderer>().material.color = Color.white; selectedNPC = null; } tempAttackDirectional = Instantiate(attackDirectionalPrefab); break; } }
void Start() { IsInBattle = true; motionMode = motionModes[Random.Range(0, motionModes.Length)]; switch (motionMode) { case MotionMode.TRACE: gameObject.AddComponent <Tracer>().Begin(); break; case MotionMode.MARBLE: gameObject.AddComponent <Marble>().Begin(); break; case MotionMode.SPRINTER: gameObject.AddComponent <Sprinter>().Begin(); break; case MotionMode.CRUISE_WAVE: gameObject.AddComponent <WaveCruiser>().Begin(); break; case MotionMode.CRUISE_CIRCLE: gameObject.AddComponent <CircleCruiser>().Begin(); break; case MotionMode.CRUISE_MOBIUS: gameObject.AddComponent <MobiusCruiser>().Begin(); break; } if (motionMode == MotionMode.SPRINTER) { fireMode = modeGroup0[Random.Range(0, modeGroup0.Length)]; } else { fireMode = modeGroup1[Random.Range(0, modeGroup1.Length)]; } switch (fireMode) { case FireMode.NORMAL: gameObject.AddComponent <NormalWeapon>().StartWeapon(0.25f, 0.5f); break; case FireMode.RAPID: gameObject.AddComponent <RapidWeapon>().StartWeapon(8, 1f, 0.5f); break; case FireMode.RING: gameObject.AddComponent <RingWeapon>().StartWeapon(8, 2f, 0.5f); break; case FireMode.SIDE: gameObject.AddComponent <SideWeapon>().StartWeapon(0.25f, 0.5f); break; } }
// Change firemode public void ChangeFiretype() { if (fireModeList.Count > 1) { fireMode = (FireMode)FireModesMap[fireMode]; ResetWeapon(); } }
protected override void SpawnProjectile(FireMode fireMode) { Projectile clone = Instantiate(fireMode.projectile, transform.position, graphics.rotation) as Projectile; //clone.transform.LookAt(EntityManager.Player.transform.position); clone.SetupProjectile(fireMode.damage, fireMode.velocity, fireMode.lifespan, LayerMask.GetMask("Default")); clone.transform.rotation *= GetSpread(fireMode.spread); }
public bool CompareWeaponFireMode(FireMode fireMode) { if (WeaponNullCheck()) { return(false); } return(loadout[CurrentWeaponIndex].fireMode == fireMode); }
public bool CanSetFireMode(FireMode fireMode) { if (System.Array.IndexOf(this.fireModes, fireMode) == -1) { return(false); } return(true); }
public void SetFireMode(FireMode fireMode) { if (System.Array.IndexOf(this.fireModes, fireMode) == -1) { return; } this.currentFireMode = fireMode; }
void Start() { _fireMode = GetComponent <FireMode>(); _player = GameObject.FindWithTag("Player").transform; _spriteRenderer = GetComponent <SpriteRenderer>(); _health = GetComponent <Health>(); _health.onDied += OnDied; _health.onDamaged += OnDamage; }
IEnumerator ReloadDone() { yield return(new WaitForSeconds(reloadTime)); weaponEnabled = true; currentRoundsInClip = maxRoundsInClip; fireMode = chosenFireMode; UpdateGUI(); }
public override void activate() { base.activate(); currentWeapon = player.CurrentWeapon; currentWeaponMode = currentWeapon.FireMode; currentWeaponBulletsPerShot = player.CurrentWeapon.BulletsPerShot; currentWeapon.FireMode = FireMode.MULTIPLE_FIXED; currentWeapon.BulletsPerShot += additionalBullets; }
protected override void Awake() { base.Awake(); if(!HasFireMode(current)) { current = GetAvailableFireMode(); } }
protected virtual bool CanSetFireMode(FireMode fireMode) { if (object.ReferenceEquals(this.currentWeapon, null)) { return(false); } return(this.currentWeapon.CanSetFireMode(fireMode)); }
void EvaluateBody(GunBody body) { fireMode = body.fireMode; burstCount = body.burstCount; fireRate += body.fireRate; projectileSpeed += body.muzzleVelocity; damage += body.damage; }
//attachments, weapon xp, ... public Firearm(int x, int y, int z, String name, String desc, char displaychar, double weight, Caliber cal, GunType type, List<FireMode> modes, int mag_cap) : base(x,y,z,name,desc,displaychar, weight, EquipmentSlot.Ranged) { caliber = cal; this.type = type; this.modes = new List<FireMode>(modes); this.mode = modes[0]; MagazineCapacity = mag_cap; }
/// <summary> /// Resets the selected fire mode to the first one available (e.g. when the gun is dropped) /// </summary> public void ResetModes() { //Required since availableFireModes.Capacity is set but its contents aren't so ElementAt(0) causes errors in some instances if (availableFireModes.Count > 0) { currentFireModeInt = availableFireModes.ElementAt(0); } currentAimModeInt = availableAimModes.ElementAt(0); }
public Shotgun(IGunner owner, int damage, float range, int fireRate, float bulletSpeed, FireMode fireMode, float recoilPerShot, float maxRecoil, int clipSize, int reserveSize, int reloadTime, int subShells, float shellSpread, bool clipReload, World world, string weaponName) : base(owner, damage, range, fireRate, bulletSpeed, fireMode, recoilPerShot, maxRecoil, clipSize, reserveSize, reloadTime, world, weaponName, GunType.Shotgun) { this.subShells = subShells; this.shellSpread = shellSpread; this.clipReload = clipReload; singleReloadTime = reloadTime; }
protected override void Update() { base.Update(); if (activated && currentWeapon != player.CurrentWeapon) { currentWeapon = player.CurrentWeapon; currentWeaponMode = currentWeapon.FireMode; currentWeaponBulletsPerShot = player.CurrentWeapon.BulletsPerShot; currentWeapon.FireMode = FireMode.MULTIPLE_FIXED; currentWeapon.BulletsPerShot += 2; } }
/// <summary> /// Constructor /// </summary> public BasicGun(IGunner owner, int damage, float range, int fireRate, float bulletSpeed, FireMode fireMode, float recoilPerShot, float maxRecoil, int clipSize, int reserveSize, int reloadTime, World world, string weaponName, GunType gunType) { this.owner = owner; this.damage = damage; this.range = range; this.fireRate = fireRate; this.bulletSpeed = bulletSpeed; this.fireMode = fireMode; this.recoilPerShot = recoilPerShot; this.maxRecoil = maxRecoil; this.clipSize = clipSize; this.reserveSize = reserveSize; this.reloadTime = reloadTime; this.world = world; this.weaponName = weaponName; this.gunType = gunType; clipAmmo = clipSize; reserveAmmo = reserveSize; currentRecoil = 0; random = new Random(); }
public void SetFireMode(FireMode mode) { fireMode = mode; crosshair.SetActive(mode == FireMode.Face); weaponLaser.SetActive(mode == FireMode.Phone); if (mode == FireMode.Face) weaponTransform.localRotation = weaponBaseRotation; }
private void OnSwitchFireModeEvent(SwitchFireModeEvent evt) { current = GetNextFireMode(); }
public void ModFullAuto() { if (this.fireMode == Weapons.FireMode.Auto || hasFullAuto) throw new Exception("already have full auto"); else { hasFullAuto = true; this.fireMode = Weapons.FireMode.Auto; if (gunType == Weapons.GunType.Shotgun) { fireRate = (int)(fireRate * 2f); recoilPerShot = 0; } } }
private bool HasFireMode(FireMode target) { return (fireModes & target) == target; }