private void LashGrabbedEnemy() { if (_stormlight >= _lashHandler.ObjectLashCost) { if (Input.GetKeyDown(KeyCode.W)) //We want to lash to the relative up { _lashHandler.Lash(relativeUp, true); grabbedObject.GetComponentInParent <IEnemy>().SetLashing(true, _lashHandler.ObjectLashCost); _stormlight -= _lashHandler.ObjectLashCost; } else if (Input.GetKeyDown(KeyCode.S)) //We want to lash to the relative down { _lashHandler.Lash(relativeDown, true); grabbedObject.GetComponentInParent <IEnemy>().SetLashing(true, _lashHandler.ObjectLashCost); _stormlight -= _lashHandler.ObjectLashCost; } else if (Input.GetKeyDown(KeyCode.D)) //We want to lash to the relative right { _lashHandler.Lash(relativeRight, true); grabbedObject.GetComponentInParent <IEnemy>().SetLashing(true, _lashHandler.ObjectLashCost); _stormlight -= _lashHandler.ObjectLashCost; } else if (Input.GetKeyDown(KeyCode.A))//We want to lash to the relative left { _lashHandler.Lash(relativeLeft, true); grabbedObject.GetComponentInParent <IEnemy>().SetLashing(true, _lashHandler.ObjectLashCost); _stormlight -= _lashHandler.ObjectLashCost; } } }
private void OnTriggerEnter2D(Collider2D collision) { if (_isLashed & collision.gameObject.tag == "Enemy") { Debug.Log(myRigidbody2D.velocity.sqrMagnitude); collision.gameObject.GetComponent <IEnemy>().OnHit(myRigidbody2D.velocity.sqrMagnitude, transform.position); if (myRigidbody2D.velocity.sqrMagnitude >= _terminalVelocity) { DestroyInteractable(); } else { myLashHandler.Lash(DOWN, true); LashInteractable(false, 0f); } } else if (_isLashed & collision.gameObject.tag == "Breakable") { DestroyInteractable(); } }