public override void Hold() { if (owner.gearActive_Power) { // Can't have a big shot with the Power Gear. charge = 0.0f; if (shotBig != null) { Release(); } return; } // Adds to the charge. charge += Time.unscaledDeltaTime; // If the charge is over a threshold, there is no active big shot, // the player has enough weapon energy, there is no expected shot to be active // and a big shot hasn't been just consumed by an enemy, spawns a shot. if (charge >= 0.2f && shotBig == null && weaponEnergy > 0 && !bigShotShouldBeActive && bigShotCanBeCreated) { // Creates a big shot at the right position and makes it track the player. shotBig = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/PharaohShotBig")); shotBig.transform.position = owner.transform.position + owner.up * 26.0f; shotBig.GetComponent <Misc_FollowTransform>().displacement = owner.up * 26.0f; shotBig.GetComponent <Misc_FollowTransform>().target = owner.transform; // A big shot should be active now. bigShotShouldBeActive = true; // No big shots can be created again until // the fire button is released. bigShotCanBeCreated = false; // Plays a shoot sound. owner.audioWeapon.PlaySound(owner.SFXLibrary.pharaohCharge, true); } }
protected void Shoot(Vector3 offset, bool shootLeft, int damageMultiplier, float speed, float charge) { // If there is no charge, creates a big shot, // and if there is enough charge, it selects the big // shot and tells it to no longer follow the player. // If there is some charge but not enough, or the big shot // has been destroyed, nothing happens. Pl_Shot newShot = null; if (charge == 0.0f) { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/PharaohShotsmall")); } else if (charge > 0.8f && shotBig) { newShot = shotBig; Object.Destroy(newShot.GetComponent <Misc_FollowTransform>()); shotBig = null; } else { return; } // Both the big shot and small shot act the same, // so the newShot can be either. newShot.transform.position = owner.transform.position + offset; if (shootLeft) { newShot.transform.localScale = Vector3.Scale(newShot.transform.localScale, new Vector3(-1, 1, 1)); } if ((Input.GetAxisRaw("Vertical") > 0.5f && !shootLeft) || (Input.GetAxisRaw("Vertical") < -0.5f && shootLeft)) { newShot.transform.eulerAngles += Vector3.forward * 45.0f; } if ((Input.GetAxisRaw("Vertical") < -0.5f && !shootLeft) || (Input.GetAxisRaw("Vertical") > 0.5f && shootLeft)) { newShot.transform.eulerAngles -= Vector3.forward * 45.0f; } // Sets the damage and speed, and starts the shot. newShot.damage *= damageMultiplier; newShot.speed = speed; newShot.Start(); }