public void ExitMech() { if (mechImIn == null) { return; } //transform.position += Vector3.up * mechImIn.transform.lossyScale.y * 0.5f; if (mechImIn.isFacingRight) { //transform.position += Vector3.left * mechImIn.transform.lossyScale.y * 0.5f; isFacingRight = false; weapon.SetDir(false); playerBody.AddForce(Vector3.up * playerEjectForceMagnitude * 2f + Vector3.left * playerEjectForceMagnitude); } else if (!mechImIn.isFacingRight) { transform.position += Vector3.right * mechImIn.transform.lossyScale.y * 0.5f; isFacingRight = true; weapon.SetDir(true); playerBody.AddForce(Vector3.up * playerEjectForceMagnitude * 2f + Vector3.right * playerEjectForceMagnitude); } WeaponManager mechWeaponManager = mechImIn.GetComponent <WeaponManager>(); for (int i = 0; i < mechWeaponManager.equippedWeapons.Count; i++) { mechWeaponManager.equippedWeapons[i].FromTeam = Team.Independant; } mechImIn.wasExited(); mechImIn = null; // enable human character GetComponent <BoxCollider2D>().enabled = true; spriteRenderer.enabled = true; playerBody.gravityScale = oldGravityScale; EnableWeapons(true); playerHealthUI.SetHealthVisibility(true); _state = PlayerState.outOfMech; if (!isAiPlayer) { camScript.MechZoom(); //default cam size firstIcon.SetIcon("pilotGunIcon"); secondIcon.SetIcon("enterIcon"); } }
void EnterMech(Mech mech) { if (mech.mechModel == null) { //Debug.Log("Attempt to enter mech with no model. Exiting..."); Debug.Log("Entering mech with no model... :/"); //return; } if (mech.driver && !mech.canBeStolen) { return; } if (mech.inUse && isAiPlayer) { return; // block mech stealing by AI } // eject the previous pilot if (mech.driver && mech.driver.GetInstanceID() != gameObject.GetInstanceID() && mech.canBeStolen) { mech.driver.ExitMech(); mech.ToggleCanBeStolen(); } if (enterMechTooltipToHide) { enterMechTooltipToHide.SetActive(false); enterMechTooltipToHide = null; } EnableWeapons(false); mech.wasEntered(this.transform.gameObject); // tell the mech who is driving mechImIn = mech; WeaponManager mechWeaponManager = mech.GetComponent <WeaponManager>(); for (int i = 0; i < mechWeaponManager.equippedWeapons.Count; i++) { mechWeaponManager.equippedWeapons[i].FromTeam = team; } //Disables human character GetComponent <BoxCollider2D>().enabled = false; spriteRenderer.enabled = false; oldGravityScale = playerBody.gravityScale; playerBody.gravityScale = 0; jetpack.JetpackToggle(false); playerHealthUI.SetHealthVisibility(false); _state = PlayerState.inMech; //changes player state if (!isAiPlayer) { camScript.MechZoom(mechImIn); //firstIcon.SetIcon( "turretGatling" ); //weaponManager.IsPlayerDriving( true ); secondIcon.SetIcon("exitIcon"); } }