Ejemplo n.º 1
0
    /***********Secondary Fire Powerup**********/
    IEnumerator HomingCooldown()
    {
        firemode = FireMode.homing;
        yield return(new WaitForSeconds(5f));

        firemode = FireMode.laser;
    }
Ejemplo n.º 2
0
    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;
        }
    }
Ejemplo n.º 3
0
    //*******************************************************************//

    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");
        }
    }
Ejemplo n.º 4
0
    IEnumerator TripleShotCooldown()
    {
        firemode = FireMode.tripleShot;
        yield return(new WaitForSeconds(_tripleShotTime));

        firemode = FireMode.laser;
    }
Ejemplo n.º 5
0
        /// <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));
                }
            }
        }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 8
0
    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;
        }
    }
Ejemplo n.º 9
0
 // 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;
     }
 }
Ejemplo n.º 10
0
    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();
    }
Ejemplo n.º 11
0
        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
        }
Ejemplo n.º 12
0
    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();
    }
Ejemplo n.º 13
0
        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;
            }
        }
Ejemplo n.º 14
0
    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();
    }
Ejemplo n.º 15
0
    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;
    }
Ejemplo n.º 16
0
        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;
            }
        }
Ejemplo n.º 17
0
        /// <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);
        }
Ejemplo n.º 18
0
    // 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;
        }
    }
Ejemplo n.º 19
0
    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;
        }
    }
Ejemplo n.º 20
0
    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;
        }
    }
Ejemplo n.º 21
0
 // Change firemode
 public void ChangeFiretype()
 {
     if (fireModeList.Count > 1)
     {
         fireMode = (FireMode)FireModesMap[fireMode];
         ResetWeapon();
     }
 }
Ejemplo n.º 22
0
    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);
    }
Ejemplo n.º 23
0
 public bool CompareWeaponFireMode(FireMode fireMode)
 {
     if (WeaponNullCheck())
     {
         return(false);
     }
     return(loadout[CurrentWeaponIndex].fireMode == fireMode);
 }
Ejemplo n.º 24
0
 public bool CanSetFireMode(FireMode fireMode)
 {
     if (System.Array.IndexOf(this.fireModes, fireMode) == -1)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 25
0
 public void SetFireMode(FireMode fireMode)
 {
     if (System.Array.IndexOf(this.fireModes, fireMode) == -1)
     {
         return;
     }
     this.currentFireMode = fireMode;
 }
Ejemplo n.º 26
0
 void Start()
 {
     _fireMode          = GetComponent <FireMode>();
     _player            = GameObject.FindWithTag("Player").transform;
     _spriteRenderer    = GetComponent <SpriteRenderer>();
     _health            = GetComponent <Health>();
     _health.onDied    += OnDied;
     _health.onDamaged += OnDamage;
 }
Ejemplo n.º 27
0
    IEnumerator ReloadDone()
    {
        yield return(new WaitForSeconds(reloadTime));

        weaponEnabled       = true;
        currentRoundsInClip = maxRoundsInClip;
        fireMode            = chosenFireMode;
        UpdateGUI();
    }
Ejemplo n.º 28
0
 public override void activate()
 {
     base.activate();
     currentWeapon = player.CurrentWeapon;
     currentWeaponMode = currentWeapon.FireMode;
     currentWeaponBulletsPerShot = player.CurrentWeapon.BulletsPerShot;
     currentWeapon.FireMode = FireMode.MULTIPLE_FIXED;
     currentWeapon.BulletsPerShot += additionalBullets;
 }
Ejemplo n.º 29
0
	protected override void Awake()
	{
		base.Awake();

		if(!HasFireMode(current))
		{
			current = GetAvailableFireMode();
		}
	}
Ejemplo n.º 30
0
        protected virtual bool CanSetFireMode(FireMode fireMode)
        {
            if (object.ReferenceEquals(this.currentWeapon, null))
            {
                return(false);
            }

            return(this.currentWeapon.CanSetFireMode(fireMode));
        }
Ejemplo n.º 31
0
            void EvaluateBody(GunBody body)
            {
                fireMode   = body.fireMode;
                burstCount = body.burstCount;

                fireRate        += body.fireRate;
                projectileSpeed += body.muzzleVelocity;
                damage          += body.damage;
            }
Ejemplo n.º 32
0
        //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;
        }
Ejemplo n.º 33
0
        /// <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);
        }
Ejemplo n.º 34
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;
        }
Ejemplo n.º 35
0
    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;
        }
    }
Ejemplo n.º 36
0
        /// <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();
        }
Ejemplo n.º 37
0
    public void SetFireMode(FireMode mode)
    {
        fireMode = mode;

        crosshair.SetActive(mode == FireMode.Face);
        weaponLaser.SetActive(mode == FireMode.Phone);

        if (mode == FireMode.Face)
            weaponTransform.localRotation = weaponBaseRotation;
    }
Ejemplo n.º 38
0
	private void OnSwitchFireModeEvent(SwitchFireModeEvent evt)
	{
		current = GetNextFireMode();
	}
Ejemplo n.º 39
0
 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;
         }
     }
 }
Ejemplo n.º 40
0
	private bool HasFireMode(FireMode target)
	{
		return (fireModes & target) == target;
	}