Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.31 KB | None | 0 0
  1. // Copyright ©2015 Austin R. Snider and Brandon L. Snider; do not copy modify or distribute without permisson.
  2. #include "DragonsLair.h"
  3. #include "DragonsLairPlayerController.h"
  4. #include "Engine.h"
  5.  
  6.  
  7. ADragonsLairPlayerController::ADragonsLairPlayerController(const FObjectInitializer& ObjectInitializer)
  8. {
  9.  
  10. }
  11.  
  12. void ADragonsLairPlayerController::BeginPlay()
  13. {
  14. PlayerCharacterRef = Cast<APlayerCharacter>(GetPawn());
  15.  
  16. PlayerCameraRef = PlayerCharacterRef->PlayerCameraRef;
  17.  
  18. }
  19.  
  20. void ADragonsLairPlayerController::SetupInputComponent()
  21. {
  22. Super::SetupInputComponent();
  23. InputComponent->BindAxis("MoveForwardAxis", this, &ADragonsLairPlayerController::MoveForwardAxis);
  24. InputComponent->BindAxis("MoveSideAxis", this, &ADragonsLairPlayerController::MoveSideAxis);
  25. InputComponent->BindAxis("LookVertical", this, &ADragonsLairPlayerController::LookVertical);
  26. InputComponent->BindAxis("LookHorizontal", this, &ADragonsLairPlayerController::LookHorizontal);
  27. InputComponent->BindAxis("LeftInteract", this, &ADragonsLairPlayerController::LeftInteract);
  28. InputComponent->BindAxis("RightInteract", this, &ADragonsLairPlayerController::RightInteract);
  29. InputComponent->BindAction("SwitchItem1", IE_Pressed, this, &ADragonsLairPlayerController::SwitchItem1);
  30. InputComponent->BindAction("SwitchItem2", IE_Pressed, this, &ADragonsLairPlayerController::SwitchItem2);
  31. InputComponent->BindAction("SwitchItem3", IE_Pressed, this, &ADragonsLairPlayerController::SwitchItem3);
  32. InputComponent->BindAction("SwitchPreviousItem", IE_Pressed, this, &ADragonsLairPlayerController::SwitchPreviousItem);
  33. InputComponent->BindAction("SwitchNextItem", IE_Pressed, this, &ADragonsLairPlayerController::SwitchNextItem);
  34. InputComponent->BindAction("UseItem", IE_Pressed, this, &ADragonsLairPlayerController::SwitchItem1);
  35. InputComponent->BindAction("UseShield", IE_Pressed, this, &ADragonsLairPlayerController::SwitchItem2);
  36. }
  37.  
  38. void ADragonsLairPlayerController::MoveForwardAxis(float AxisValue)
  39. {
  40. if (PlayerCharacterRef != nullptr)
  41. {
  42. FVector CharacterForwardVector = PlayerCharacterRef->GetActorForwardVector();
  43. FVector MovementInputVector = CharacterForwardVector * PlayerCharacterRef->MovementSpeed;
  44. PlayerCharacterRef->AddMovementInput(MovementInputVector, AxisValue);
  45. }
  46. else
  47. {
  48. GEngine->AddOnScreenDebugMessage(0, 10, FColor::Blue, "PlayerCharRef == nullptr");
  49. PlayerCharacterRef = Cast<APlayerCharacter>(GetPawn());
  50. }
  51. }
  52.  
  53. void ADragonsLairPlayerController::MoveSideAxis(float AxisValue)
  54. {
  55. if (PlayerCharacterRef != nullptr)
  56. {
  57. FVector CharacterRightVector = PlayerCharacterRef->GetActorRightVector();
  58. FVector MovementInputVector = CharacterRightVector * PlayerCharacterRef->MovementSpeed;
  59. PlayerCharacterRef->AddMovementInput(MovementInputVector, AxisValue);
  60. }
  61. else
  62. {
  63. GEngine->AddOnScreenDebugMessage(0, 10, FColor::Blue, "PlayerCharRef == nullptr");
  64. PlayerCharacterRef = Cast<APlayerCharacter>(GetPawn());
  65. }
  66. }
  67.  
  68. void ADragonsLairPlayerController::LookVertical(float AxisValue)
  69. {
  70.  
  71. if (PlayerCharacterRef != nullptr)
  72. {
  73. FRotator DeltaRotation = FRotator(AxisValue, 0.0f, 0.0f);
  74. PlayerCameraRef->AddLocalRotation(DeltaRotation);
  75. }
  76. else
  77. {
  78. GEngine->AddOnScreenDebugMessage(0, 10, FColor::Blue, "PlayerCharRef == nullptr");
  79. PlayerCharacterRef = Cast<APlayerCharacter>(GetPawn());
  80.  
  81. }
  82. }
  83.  
  84. void ADragonsLairPlayerController::LookHorizontal(float AxisValue)
  85. {
  86. if (PlayerCharacterRef != nullptr)
  87. {
  88. FRotator DeltaRotation = FRotator(0.0f, AxisValue, 0.0f);
  89. PlayerCharacterRef->AddActorLocalRotation(DeltaRotation);
  90. }
  91. else
  92. {
  93. GEngine->AddOnScreenDebugMessage(0, 10, FColor::Blue, "PlayerCharRef == nullptr");
  94. PlayerCharacterRef = Cast<APlayerCharacter>(GetPawn());
  95. }
  96. }
  97.  
  98. void ADragonsLairPlayerController::LeftInteract(float AxisValue)
  99. {
  100. }
  101.  
  102. void ADragonsLairPlayerController::RightInteract(float AxisValue)
  103. {
  104. }
  105.  
  106. void ADragonsLairPlayerController::SwitchItem1()
  107. {
  108. }
  109.  
  110. void ADragonsLairPlayerController::SwitchItem2()
  111. {
  112. }
  113.  
  114. void ADragonsLairPlayerController::SwitchItem3()
  115. {
  116.  
  117. }
  118.  
  119. void ADragonsLairPlayerController::SwitchPreviousItem()
  120. {
  121.  
  122. }
  123.  
  124. void ADragonsLairPlayerController::SwitchNextItem()
  125. {
  126.  
  127. }
  128.  
  129. void ADragonsLairPlayerController::UseItem()
  130. {
  131.  
  132. }
  133.  
  134. void ADragonsLairPlayerController::UseShield()
  135. {
  136.  
  137. }
  138.  
  139. void ADragonsLairPlayerController::Interact()
  140. {
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement