public IEnumerator SpreadShot(int pellets)
        {
            slowWalkDisableTimer = 15f;
            GameCameras.instance.cameraShakeFSM.SendEvent("SmallShake");
            HP_Sprites.StartGunAnims();
            HP_Sprites.StartFlash();
            HP_Sprites.StartMuzzleFlash(HP_DirectionHandler.finalDegreeDirection);
            PlayGunSounds("Shotgun");

            float direction = HP_DirectionHandler.finalDegreeDirection;

            for (int i = 0; i < pellets; i++)
            {
                yield return(new WaitForEndOfFrame());

                GameObject         bullet = HP_Prefabs.SpawnBullet(direction);
                HP_BulletBehaviour hpbb   = bullet.GetComponent <HP_BulletBehaviour>();
                hpbb.bulletDegreeDirection += UnityEngine.Random.Range(-20, 20);
                hpbb.pierce = PlayerData.instance.equippedCharm_13;
                bullet.transform.localScale = new Vector3(0.3f, 0.3f, 0.1f);

                Destroy(bullet, HP_Stats.bulletRange);
            }

            yield return(new WaitForSeconds(0.05f));

            isFiring = false;
        }
        public IEnumerator BurstShot(int burst)
        {
            GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake");
            for (int i = 0; i < burst; i++)
            {
                HP_HeatHandler.IncreaseHeat(0.5f);

                GameObject bullet = HP_Prefabs.SpawnBullet(HP_DirectionHandler.finalDegreeDirection);
                PlayGunSounds("rifle");
                Destroy(bullet, .2f);

                HP_Sprites.StartGunAnims();
                HP_Sprites.StartFlash();
                HP_Sprites.StartMuzzleFlash(HP_DirectionHandler.finalDegreeDirection);
                yield return(new WaitForSeconds(0.12f)); //0.12f This yield will determine the time inbetween shots

                if (h_state.dashing || h_state.jumping)
                {
                    break;
                }
            }
            isFiring             = false;
            isBursting           = false;
            slowWalkDisableTimer = 4f * burst;
        }
        public IEnumerator SingleShot()
        {
            HP_HeatHandler.IncreaseHeat(HP_Stats.heatPerShot);
            GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake");
            GameObject         bullet = HP_Prefabs.SpawnBullet(HP_DirectionHandler.finalDegreeDirection);
            HP_BulletBehaviour hpbb   = bullet.GetComponent <HP_BulletBehaviour>();

            hpbb.fm = FireModes.Single;

            //Charm 14 Steady Body
            hpbb.noDeviation = (PlayerData.instance.equippedCharm_14 && HeroController.instance.cState.onGround) ? true : false;
            //Charm 13 Mark of Pride gives perfect accuracy and pierce
            hpbb.perfectAccuracy = (PlayerData.instance.equippedCharm_13 && (HP_HeatHandler.currentHeat < 10)) ? true : false;
            hpbb.pierce          = PlayerData.instance.equippedCharm_13;

            //set the origin position of where the bullet was spawned
            hpbb.bulletOriginPosition = bullet.transform.position;

            Destroy(bullet, HP_Stats.bulletRange + 3f);

            HP_Sprites.StartGunAnims();
            HP_Sprites.StartFlash();
            HP_Sprites.StartMuzzleFlash(HP_DirectionHandler.finalDegreeDirection);

            slowWalkDisableTimer = 10f;

            string weaponType = PlayerData.instance.equippedCharm_13 ? "sniper" : "rifle";

            PlayGunSounds("sniper");
            if (weaponType == "sniper")
            {
                bullet.transform.localScale = new Vector3(1.8f, 1.8f, 0.1f);
            }

            yield return(new WaitForSeconds(0.02f));

            isFiring = false;
        }
        public IEnumerator FireFlare()
        {
            airStrikeActive              = false;
            HP_Stats.currentPrimaryAmmo -= 1;
            HP_SpellControl.artifactActivatedEffect.SetActive(false);

            GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake");
            GameObject bullet = HP_Prefabs.SpawnBullet(HP_DirectionHandler.finalDegreeDirection);

            PlayGunSounds("flare");

            HP_BulletBehaviour bullet_behaviour = bullet.GetComponent <HP_BulletBehaviour>();

            bullet_behaviour.flareRound = true;

            HP_Sprites.StartGunAnims();
            HP_Sprites.StartFlash();
            HP_Sprites.StartMuzzleFlash(HP_DirectionHandler.finalDegreeDirection);

            yield return(new WaitForSeconds(0.04f));

            isFiring = false;
        }
        public void SpawnFireball()
        {
            int soulCost = (PlayerData.instance.equippedCharm_33) ? 33 : 50;

            if (HP_WeaponHandler.currentGun.gunName == "Nail" || PlayerData.instance.fireballLevel == 0 || PlayerData.instance.MPCharge < soulCost)
            {
                HeroController.instance.spellControl.SetState("Inactive");
                return;
            }
            HeroController.instance.TakeMP(soulCost);
            HeroController.instance.spellControl.SetState("Spell End");

            float directionMultiplier = (HeroController.instance.cState.facingRight) ? 1f : -1f;
            float wallClimbMultiplier = (HeroController.instance.cState.wallSliding) ? -1f : 1f;

            directionMultiplier *= wallClimbMultiplier;
            GameObject bullet = HP_Prefabs.SpawnBullet(HP_DirectionHandler.finalDegreeDirection);

            bullet.SetActive(true);
            HP_BulletBehaviour hpbb = bullet.GetComponent <HP_BulletBehaviour>();

            hpbb.perfectAccuracy = true;
            bullet.GetComponent <BoxCollider2D>().size *= 1.5f;
            hpbb.bulletDegreeDirection = HP_DirectionHandler.finalDegreeDirection;
            hpbb.specialAttrib         = "Explosion";
            hpbb.bulletSpeedMult       = 2;

            HP_Prefabs.projectileSprites.TryGetValue("specialbullet.png", out Sprite specialBulletTexture);
            bullet.GetComponent <SpriteRenderer>().sprite = specialBulletTexture;

            //HP_Sprites.StartMuzzleFlash(HP_DirectionHandler.finalDegreeDirection);
            GameCameras.instance.cameraShakeFSM.SendEvent("EnemyKillShake");

            PlayAudio("firerocket", true);

            HP_Sprites.StartGunAnims();
        }
Exemple #6
0
        public void Start()
        {
            rb2d         = GetComponent <Rigidbody2D>();
            bc2d         = GetComponent <BoxCollider2D>();
            bulletSprite = GetComponent <SpriteRenderer>();
            bc2d.enabled = !ignoreCollisions;

            gameObject.tag = "Wall Breaker";
            //Trail
            bulletTrailObjectClone = Instantiate(HP_Prefabs.bulletTrailPrefab, gameObject.transform);

            //Increase the bullet size
            bc2d.size = new Vector2(1f, 0.65f);

            //Override this entire code if its from fire support and give the bullet its own special properties aka because making new GOs with code is effort
            if (isFireSupportBullet)
            {
                bulletSprite.transform.Rotate(0, 0, 270);
                bulletTrailObjectClone.GetComponent <TrailRenderer>().time = 0.9f;
                HP_Prefabs.projectileSprites.TryGetValue("specialbullet.png", out Sprite fireSupportBulletSprite);

                gameObject.transform.localScale = new Vector3(1.2f, 1.2f, 0.90f);
                bulletSprite.sprite             = fireSupportBulletSprite;

                rb2d.velocity = new Vector2(0, -120);

                return;
            }

            //===================================REGULAR BULLET ATTRIBUTES=========================================


            //Bullet sprite changer
            string sn = HP_Stats.bulletSprite;

            if (sn != "" && false)
            {
                HP_Prefabs.projectileSprites.TryGetValue(HP_Stats.bulletSprite, out Sprite regularBulletSprite);
                bulletSprite.sprite = regularBulletSprite;
            }


            //Bullet Origin for Distance Calculation
            bulletOriginPosition = gameObject.transform.position;

            //Bullet Direction
            float heat = HP_HeatHandler.currentHeat;

            // heat -= (fm == HP_Enums.FireModes.Single && PlayerData.instance.equippedCharm_14 && HeroController.instance.cState.onGround) ? -40 : 0 ;
            // heat = (heat < 0)? 0 :  heat;

            noDeviation = (PlayerData.instance.equippedCharm_14);

            float deviationFromMovement = (noDeviation) ? 0 : SpreadDeviationControl.ExtraDeviation();

            float currentHeat = HP_HeatHandler.currentHeat;

            //Heat add basically dictates how high the multiplier will be depending on your heat level
            //0-32 = 0.05 | 34-65 = 0.15 | 66 - 100 = 0.25
            int heatCount = (int)(currentHeat / 33);


            float heatMult          = 0.01f + (heatCount * 0.035f);
            float deviationFromHeat = (noHeat) ? 0 : (HP_HeatHandler.currentHeat * heatMult);

            deviationFromHeat *= (PlayerData.instance.equippedCharm_37)? 1.25f : 1.15f;                                      //Increase movement penalty when equipping sprint master
            deviationFromHeat -= (PlayerData.instance.equippedCharm_14 && HeroController.instance.cState.onGround) ? 18 : 0; //Decrease innacuracy when on ground and steady body is equipped

            float deviation = (perfectAccuracy)? 0 : (deviationFromHeat + deviationFromMovement);

            deviation = (deviation < 0) ? 0 : deviation; //just set up the minimum value, bullets starts acting weird when deviation is negative

            bulletSpeed = HP_Stats.bulletVelocity;

            //Bullet Sprite Size
            float size = 0.90f;

            //===================================FIRE SUPPORT=========================================
            if (flareRound)
            {
                //OFFENSIVE FIRE SUPPORT
                HP_Prefabs.projectileSprites.TryGetValue("specialbullet.png", out Sprite flareBulletTexture);
                size *= 1.5f;

                bulletSprite.sprite = flareBulletTexture;
            }

            gameObject.transform.localScale = new Vector3(size, size, 0.90f);
            gameObject.transform.localScale = new Vector3(size, size, 0.90f);

            //Handles weapon spread
            //HP_DirectionHandler.finalDegreeDirection

            float degree = bulletDegreeDirection + (rand.Next((int)-deviation, (int)deviation + 1)) - (float)rand.NextDouble();
            float radian = (float)(degree * Math.PI / 180);

            xDeg = bulletSpeed * Math.Cos(radian);
            yDeg = bulletSpeed * Math.Sin(radian);

            //Changes the degree of bullet sprite rotation and the bullet direction when wall sliding
            if (HeroController.instance.cState.wallSliding)
            {
                xDeg   *= -1;
                degree += 180;

                if (HeroController.instance.cState.facingRight)
                {
                    degree += 180;
                }
            }

            rb2d.velocity = new Vector2((float)xDeg, (float)yDeg);

            //Bullet Rotation
            bulletSprite.transform.Rotate(0, 0, degree + HP_Sprites.SpriteRotationWallSlide(), 0);
        }