public void SetGroundState(GroundedStates newGroundState) { //Fire the event if the grounded state was changed if (GroundedState != newGroundState) { if (GroundStateChangedEvent != null) { GroundStateChangedEvent(newGroundState); } } GroundedState = newGroundState; }
private void Update() { ApplyHorizontalMovement(); if (Input.GetButtonDown("Jump")) { groundedState = GroundedCheck(); switch (groundedState) { case GroundedStates.Ground: superJumper.Jump(); break; case GroundedStates.BoostGround: superJumper.SuperJump(); break; } } }
private void Awake() { //Default to Grounded GroundedState = GroundedStates.Grounded; }
/// <summary> /// Called by enemy things when they hit the PC /// </summary> //public void onHitByEnemyObject(Enemies enemy, float dmg) //{ // if (OnHit != null) // OnHit(dmg); //} void FixedUpdate() { //check for grabbing ledge if (pc.facingDir == Alias.RIGHT) { if (sensorRightHigh.isCollTile && !sensorRightLedge.isCollTile) { isForRightLedgeGrab = true; } else { isForRightLedgeGrab = false; } isForLeftLedgeGrab = false; } else { if (sensorLeftHigh.isCollTile && !sensorLeftLedge.isCollTile) { isForLeftLedgeGrab = true; } else { isForLeftLedgeGrab = false; } isForRightLedgeGrab = false; } //check if collide wall on the left if (sensorLeftLow.isCollTile && sensorLeftHigh.isCollTile) { isTouchingLeftTile = true; } else { isTouchingLeftTile = false; } //check if collide wall on the right if (sensorRightLow.isCollTile && sensorRightHigh.isCollTile) { isTouchingRightTile = true; } else { isTouchingRightTile = false; } //check if collide floor if (sensorBottomLeft.isCollTile && sensorBottomRight.isCollTile) { groundedState = GroundedStates.bothSides; } else if (sensorBottomLeft.isCollTile || sensorBottomRight.isCollTile) { groundedState = GroundedStates.oneSideOnly; } else { groundedState = GroundedStates.no; } //check if collide nothing if (groundedState == GroundedStates.no && !isTouchingLeftTile && !isTouchingRightTile && !isForLeftLedgeGrab && !isForRightLedgeGrab) { isInAir = true; } else { isInAir = false; } }