protected IEnumerator ShootPowered(Vector3 offset, bool shootLeft, int damageMultiplier, float speed, float charge) { // Prevents the player from moving // and puts them in a throwing animation. owner.canMove = false; owner.body.gravityScale = 1.0f; owner.body.velocity = Vector2.zero; owner.throwTime = 0.1f; yield return(null); // Each shot is a simple big shot, with a small delay between shots. for (int i = 0; i < 3; i++) { // Sets the velocity, position and orientation of each shot. owner.body.velocity = -owner.right * 70.0f + owner.up * 100.0f; Pl_Shot newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/PharaohShotPowered")); newShot.transform.position = owner.transform.position + offset; if (shootLeft) { newShot.transform.localScale = Vector3.Scale(newShot.transform.localScale, new Vector3(-1, 1, 1)); } // Sets the damage of and starts the shot. newShot.damage *= damageMultiplier; newShot.Start(); // Adds a small delay after every shot. yield return(new WaitForSecondsRealtime(0.1f)); } // Lets the player move again. owner.canMove = true; owner.body.gravityScale = 1.0f; }
public override void Release() { // If there is enough charge and a big shot hasn't been consumed, // shoots the big shot at the desired angle. if (charge > 0.8f && shotBig) { Shoot(owner.right * owner.width * 1.3f, Vector3.Angle(owner.right, Vector3.right) > 90, 1, 300, charge); owner.throwTime = 0.2f; weaponEnergy -= 2f; owner.audioWeapon.PlaySound(owner.SFXLibrary.pharaohShot, true); shotBig = null; smallShotCooldown = 0.2f; } // If there isn't enough charge, // the big shot gets destroyed. else if (shotBig) { Object.Destroy(shotBig.gameObject); smallShotCooldown = 0.2f; } // Sets the variables tat keep track of the big shot. bigShotShouldBeActive = false; bigShotCanBeCreated = false; charge = 0.0f; }
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(); }
protected void Shoot(Vector3 offset, bool shootLeft, int damageMultiplier, float speed, float charge, bool powerGear) { // Finds the right shot based on the charge given. // The charge variable here is local, so you can lie // when you call Shoot() and just shoot fully charged // shots forever. This would be considered lying though. Pl_Shot newShot = null; if (powerGear) { if (charge > 1.0f) { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/PowerBigBoom")); } else { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/PowerShockwave")); } } else { if (charge > 1.0f) { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/PowerExplosion")); } else if (charge > 0.5f) { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/PowerShockwave")); } else { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/PowerPunch")); } } // Finds the right position and orientation for the shot. newShot.transform.position = owner.transform.position + offset; if (shootLeft) { newShot.transform.localScale = Vector3.Scale(newShot.transform.localScale, new Vector3(-1, 1, 1)); } // Sets the damage and speed of the shot. //newShot.damage *= damageMultiplier; //newShot.speed = speed; }
protected void Shoot(Vector3 offset, bool shootLeft, int damageMultiplier, float speed, float charge) { // Finds the right shot based on the charge given. // The charge variable here is local, so you can lie // when you call Shoot() and just shoot fully charged // shots forever. This would be considered lying though. Pl_Shot newShot = null; if (charge > 1.0f) { if (owner != null && owner.curPlayer == GameManager.Players.ProtoMan) { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/ProtoManChargedShot")); } else { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/MegaManChargedShot")); } } else if (charge > 0.3f) { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/MegaManMidShot")); } else { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/MegaManSmallShot")); } // Finds the right position and orientation for the shot. newShot.transform.position = owner.transform.position + offset; if (shootLeft) { newShot.transform.localScale = Vector3.Scale(newShot.transform.localScale, new Vector3(-1, 1, 1)); } // Sets the damage and speed of the shot. newShot.damage *= damageMultiplier; newShot.speed = speed; }
protected void Shoot(Vector3 offset, bool shootLeft, int damageMultiplier, float speed, float angle) { Pl_Shot newShot = null; if (owner.gearActive_Power) { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/BassShotPierce")); } else { newShot = Object.Instantiate(Resources.Load <Pl_Shot>("Prefabs/PlayerWeapons/BassShot")); } // Finds the right position and orientation for the shot. newShot.transform.position = owner.transform.position + offset; if (shootLeft) { newShot.transform.localScale = Vector3.Scale(newShot.transform.localScale, new Vector3(-1, 1, 1)); } newShot.transform.localRotation = Quaternion.AngleAxis(angle * (shootLeft ? -1 : 1), Vector3.forward); // Sets the damage and speed of the shot. newShot.damage *= damageMultiplier; newShot.speed = speed; }