private void Start() { gfm = FindObjectOfType <GameFeelManager>(); rb = GetComponentInParent <Rigidbody2D>(); cc = GetComponentInParent <CharacterController2D>(); ss = GetComponentInParent <SwordSwing>(); }
// Use this for initialization void Start() { rb = GetComponent <Rigidbody2D>(); boxColl = GetComponent <BoxCollider2D>(); scale = GetComponentInChildren <ScaleWithVelocity>(); swordSwing = GetComponent <SwordSwing>(); audioManager = FindObjectOfType <AudioManager>(); gfm = FindObjectOfType <GameFeelManager>(); SetupMoveAndJumpSpeed(); }
void Start() { swordSwing = GetComponent <SwordSwing>(); }
void Update() { input.UpdateInput(); if (input.holdingMove) { facingAngle = input.moveAngle; } // Move sword around with player while held if (currSwordSwing) { currSwordSwing.SetHeldRotation(Mathf.Rad2Deg * facingAngle); } // Rotate visual around visual.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, Mathf.Rad2Deg * facingAngle)); PlayerInput.ButtonState swordButton = input.swordButton.state; lockFacingAngle = false; if (!currSwordSwing) // No sword out { if (swordButton == PlayerInput.ButtonState.Press && dashAmount == 0) { // Swing sword currSwordSwing = GameObject.Instantiate(swordSwing, transform.position, Quaternion.identity, transform); currSwordSwing.aimAngle = facingAngle * Mathf.Rad2Deg; currSwordSwing.arc = 170; currSwordSwing.swingTime = .18f; currSwordSwing.reverse = false; timeHeldAtFull = 0; releasedCurrSwordSwing = false; } } else // Sword out { bool releasing = swordButton == PlayerInput.ButtonState.Release; bool holding = swordButton == PlayerInput.ButtonState.Hold || swordButton == PlayerInput.ButtonState.Press; if (releasing) { releasedCurrSwordSwing = true; } if (releasedCurrSwordSwing) { holding = false; } bool couldDash = timeHeldAtFull >= dashButtonHoldTime; if (!currSwordSwing.DoneSwinging()) { lockFacingAngle = true; } if (holding) // Holding { if (currSwordSwing.DoneSwinging()) { timeHeldAtFull += Time.deltaTime; } } else // Released { if (couldDash && input.holdingMove) { // Dash input.lockMoveButtons = true; dashAmount = 1; Invoke("StopDashing", dashTime); dashSwing = GameObject.Instantiate(swordSwing, transform.position, Quaternion.identity, transform); dashSwing.aimAngle = facingAngle * Mathf.Rad2Deg; dashSwing.arc = 190; dashSwing.swingTime = dashTime - .1f; dashSwing.reverse = true; } // Destroy sword when done with the whole swing // if (currSwordSwing.DoneSwinging()) { GameObject.Destroy(currSwordSwing.gameObject); currSwordSwing = null; timeHeldAtFull = 0; } } } }