void ChargeFreeze(FreezeState freeze) { int freezeManaDelta = freezeManaCapacity - freeze.GetMana(); if (freezeManaDelta > Game.Score.GetMana()) { freezeManaDelta = Game.Score.GetMana(); } freeze.AddManaCharge(freezeManaDelta); Game.Score.AddMana(-freezeManaDelta); Log("Charge Freeze: DELTA=" + freezeManaDelta.ToString()); }
void Update() { // Start Telekinesis if (Input.GetButtonDown("Fire1")) { Log("Fire1"); if (interactionSystem.TelekinesisTarget != null) { // Get Target, stop looking target = interactionSystem.TelekinesisTarget.GetComponent <Rigidbody2D>(); interactionSystem.markForTelekinesisTarget = false; // Unfreeze If Frozen { FreezeState freezeState = target.GetComponent <FreezeState>(); if (freezeState != null) { freezeState.Unfreeze(); Log("Unfreeze"); } } // Do Telekinesis thing AdjustRigidbodyForTelekinesis(); costTickCounter = 0f; SetTelekinesisOutlineToTarget(1f, 1f); } } // Release Telekinesis if (Input.GetButtonUp("Fire1")) { Log("Released Telekinesis"); if (target != null) { CancelTelekinesis(); } } // Stop Freeze recharge if (Input.GetButtonUp("Fire2")) { Log("Released Freeze"); ReleaseTarget(); } // Get or Make Freeze if (Input.GetButtonDown("Fire2")) { Log("Pressed Freeze"); TryGetTarget(); if (target != null) { freeze = target.transform.gameObject.GetComponent <FreezeState>(); if (freeze == null) { if (Game.Score.GetMana() > 0) { freeze = ApplyFreezeToTarget(); ChargeFreeze(freeze); } } } } // Charge Freeze if (Input.GetButton("Fire2")) { if (freeze != null) { if (freeze.GetMana() < freezeManaCapacity) { ChargeFreeze(freeze); } } } }