public override IEnumerator ProcessPlayerContact(GameEntity player, BlockContactData contact) { if (Vector2.Dot(contact.Normal, Vector2.up) > 0.9f) { var playerController = player.GetComponent <Controller.PlayerController>(); var motionController = player.GetComponent <Controller.PlayerMotionController>(); var input = player.GetComponent <Controller.PlayerInput>(); motionController.XControl = Controller.ControlType.Force; while (playerController.IsContactedWith(this)) { if (!motionController.OnGround) { yield break; } if (input.CachedJumpPress) { motionController.Jump(playerController.CalculateJumpVelocity(playerController.JumpHeight)); yield break; } motionController.Move(input.Movement * MoveForce); yield return(new WaitForFixedUpdate()); } } yield break; }
public override IEnumerator ProcessPlayerContact(GameEntity player, BlockContactData contact) { var motionController = player.GetComponent <Controller.PlayerMotionController>(); var playerController = player.GetComponent <Controller.PlayerController>(); var input = player.GetComponent <Controller.PlayerInput>(); if (Vector2.Dot(contact.Normal, DirectionVector) < -0.9f) { yield break; } if (BlockDirection == BlockDirection.Down || BlockDirection == BlockDirection.Up) { motionController.YControl = Controller.ControlType.Velocity; motionController.ControlledVelocityLimit = new Vector2(Speed, Speed); motionController.Move(Speed * DirectionVector); while (playerController.IsContactedWith(this)) { motionController.Move(Speed * DirectionVector); if (Vector2.Dot(input.Movement, contact.Normal) > 0) { motionController.YControl = Controller.ControlType.Ignored; yield break; } if (input.CachedJumpPress) { motionController.YControl = Controller.ControlType.Ignored; yield break; } yield return(new WaitForFixedUpdate()); } motionController.YControl = Controller.ControlType.Ignored; yield break; } else if (BlockDirection == BlockDirection.Left || BlockDirection == BlockDirection.Right) { motionController.XControl = Controller.ControlType.Velocity; motionController.Move(Speed * DirectionVector); motionController.ControlledVelocityLimit = new Vector2(Speed, Speed); while (playerController.IsContactedWith(this)) { motionController.Move(Speed * DirectionVector); if (input.CachedJumpPress) { motionController.YControl = Controller.ControlType.Ignored; motionController.XControl = Controller.ControlType.Velocity; yield break; } yield return(new WaitForFixedUpdate()); } yield break; } }
public override IEnumerator ProcessPlayerContact(GameEntity player, BlockContactData contact) { if (Vector2.Dot(contact.Normal, Vector2.up) > 0.9f) { var motionController = player.GetComponent <Controller.PlayerMotionController>(); var playerController = player.GetComponent <Controller.PlayerController>(); motionController.Jump(new Vector2(motionController.velocity.x, playerController.CalculateJumpVelocity(BounceHeight))); yield break; } yield break; }
public virtual IEnumerator ProcessPlayerContact(GameEntity player, BlockContactData contact) { return(null); }