void Magic() { if (bNearCrystal == true) { if (Input.GetButtonDown("X")) { if (Companion != null) { Companion.DestroySelf(); } bCanUseMagic = true; if (sCrystalType == "GravityCrystal") { bCanUseGravity = true; } else if (sCrystalType == "MassCrystal") { bCanUseMass = true; } else if (sCrystalType == "SonarCrystal") { bCanUseSonar = true; } else if (sCrystalType == "ScaleCrystal") { bCanUseScale = true; } } } //Allows player to use shoot mass, sonar and scale magic if (bCanUseMagic && bIsMass && !PlayerShoot.bHoldingCrate) { //PlayerShoot.ShootMass(); } else if (bCanUseMagic && bIsSonar && !PlayerShoot.bHoldingCrate) { PlayerShoot.ShootSonar(); } else if (bCanUseMagic && bIsScale && !PlayerShoot.bHoldingCrate) { //PlayerShoot.ShootScale(); } else if (PlayerShoot.bHoldingCrate) { PlayerShoot.ThrowObject(); } //Allows use of abilities once crystal is picked up if (bCanUseMagic == true) { // Flip Gravity if (bCanUseGravity) { if (Input.GetButtonDown("Y")) { if (bIsGrounded) { if (bIsGravityReversed == false) { bIsGravityReversed = true; bPlayerReversed = true; Physics.gravity = new Vector3(0, 78.48f, 0); } else if (bIsGravityReversed == true) { bIsGravityReversed = false; bPlayerReversed = false; Physics.gravity = new Vector3(0, -78.48f, 0); } } else if (!bIsGrounded && !bHasGravSwitchedOnce) { if (bIsGravityReversed == false) { bIsGravityReversed = true; bPlayerReversed = true; Physics.gravity = new Vector3(0, 78.48f, 0); } else if (bIsGravityReversed == true) { bIsGravityReversed = false; bPlayerReversed = false; Physics.gravity = new Vector3(0, -78.48f, 0); } bHasGravSwitchedOnce = true; } } } //Switching ability modes (mass up to mass down, scaling x up-down to scaling y up-down) float d = Input.GetAxis("Mouse ScrollWheel"); if ((d > 0f) || Input.GetButtonDown("RB")) { if (bIsMass) { bIsHeavySelected = !bIsHeavySelected; } else if (bIsScale) { if (fScaleState == 5) { fScaleState = 0; } else { fScaleState++; } } } else if ((d < 0f) || Input.GetButtonDown("LB")) { if (bIsMass) { bIsHeavySelected = !bIsHeavySelected; } else if (bIsScale) { if (fScaleState == 0) { fScaleState = 5; } else { fScaleState--; } } } //Changes to Mass automatically since it will be the first one accquired. if (bCanUseMass && !bCanUseSonar && !bCanUseScale) { ChangeStateToMass(); } //Changing between abilities using the right mouse click or the B button on controller. if (Input.GetMouseButtonDown(1) || Input.GetButtonDown("B")) { if (bCanUseMass && bCanUseSonar && !bCanUseScale) { if (bIsMass) { ChangeStateToSonar(); } else if (bIsSonar) { ChangeStateToMass(); } } else if (bCanUseMass && bCanUseSonar && bCanUseScale) { if (bIsMass) { ChangeStateToSonar(); } else if (bIsSonar) { ChangeStateToScale(); } else if (bIsScale) { ChangeStateToMass(); } } } } }