Advertisement
Guest User

Untitled

a guest
Jan 9th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.25 KB | None | 0 0
  1.  
  2.  
  3. #pragma once
  4.  
  5. #include "GameFramework/Pawn.h"
  6. #include "MainPawn.generated.h"
  7.  
  8. /**
  9.  *
  10.  */
  11. UCLASS()
  12. class SPACEDIVE_API AMainPawn : public APawn
  13. {
  14.     GENERATED_BODY()
  15. public:
  16.     AMainPawn(const FObjectInitializer&);
  17.  
  18.     ////////////////////////// COMPONENTS //////////////////////////////////////////
  19.  
  20.     /** Main camera */
  21.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
  22.     UCameraComponent* MainCamera;
  23.  
  24.     /** Capsule for the collision circle */
  25.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
  26.     UCapsuleComponent* CameraCapsule;
  27.  
  28.     /** Sphere for collision with multiplier */
  29.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Scoring)
  30.     USphereComponent* MultiplierSphere;
  31.    
  32.     /** Sphere for collision with points */
  33.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Scoring)
  34.     USphereComponent* InnerPointSphere;
  35.  
  36.     /** Sphere for collision with less points */
  37.     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Scoring)
  38.     USphereComponent* OuterPointSphere;
  39.  
  40.     ////////////////////////////// METHODS ///////////////////////////////////////////
  41.  
  42.     void SetYAxisInverted(bool bInverted);
  43.     void SetupMusic();
  44.     void SetUseMotionControl(bool bUseMotionControl);
  45.  
  46.     ////////////////////////// DELEGATES ///////////////////////////////
  47.  
  48.     /** Executes when the player gets hit */
  49.     void OnHit();
  50.  
  51.     /** When the game is over */
  52.     void GameOver();
  53.  
  54.     /** Collision of the internal collision capsule */
  55.     UFUNCTION()
  56.     void OnCollide(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
  57.  
  58.     /** Collision of the multiplier sphere */
  59.     UFUNCTION()
  60.     void OnMultiplierCollide(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
  61.  
  62.     UFUNCTION()
  63.     void OnInnerPointSphereCollide(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
  64.  
  65.     UFUNCTION()
  66.     void OnOuterPointSphereCollide(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
  67.  
  68.     UFUNCTION()
  69.     void OnMultiplierDelayEnds();
  70.  
  71.     ////////////////////////// BLUEPRINT WRAPPERS ///////////////////////
  72.  
  73.     /** Blueprint wrapper of OnHit */
  74.     UFUNCTION(BlueprintImplementableEvent)
  75.     void PlayerHitsAsteroid();
  76.  
  77.     /** Blueprint wrapper of GameOver */
  78.     UFUNCTION(BlueprintImplementableEvent, Category = Gameplay)
  79.     void PlayerDies();
  80.  
  81.     UFUNCTION(BlueprintImplementableEvent)
  82.     void MultiplierCollides();
  83.  
  84.     ////////////////////////// GETTERS ///////////////////////////////////
  85.  
  86.     /** Aspect ratio of the camera */
  87.     FORCEINLINE float GetAspectRatio() { return MainCamera->AspectRatio; }
  88.  
  89.     /** Event for game over */
  90.     DECLARE_EVENT(AMainPawn, FGameOver)
  91.     FGameOver& OnGameOver() { return GameOverEvent; }
  92.  
  93.     /** Event for player hit */
  94.     DECLARE_EVENT(AMainPawn, FPlayerHit)
  95.     FPlayerHit& OnPlayerHit() { return PlayerHitEvent; }
  96.  
  97.     //////////////////////////// RESOURCES //////////////////////////////
  98.    
  99.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Music)
  100.     TArray<USoundBase*> MusicList;
  101.  
  102.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Sound)
  103.     USoundBase* MultiplierSound;
  104.  
  105.  
  106.     ////////////////////////////////////////////// PUBLIC VARIABLES ///////////////////////////////
  107.  
  108.  
  109.     /** Factor of how many times the camera bounds are relative to the camera */
  110.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Movement)
  111.     float CameraBoundsFactor;
  112.  
  113.     /** Factor of movement speed */
  114.     UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = Movement)
  115.     float MovementSpeedFactor;
  116.  
  117.     /** The divider that is used to calculate the radius (Part of field of view area) */
  118.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Scoring)
  119.     float MultiplierSphereDivider;
  120.  
  121.     /** The divider that is used to calculate the radius (Part of field of view area) */
  122.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Scoring)
  123.     float InnerPointSphereDivider;
  124.  
  125.     /** The divider that is used to calculate the radius (Part of field of view area) */
  126.     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Scoring)
  127.     float OuterPointSphereDivider;
  128.  
  129.     /** The points you get additionally when the inner sphere collides */
  130.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Scoring)
  131.     float InnerPointSpherePoints;
  132.  
  133.     /** The points you get when the outer sphere collides */
  134.     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Scoring)
  135.     float OuterPointSpherePoints;
  136.    
  137.     /** The value to move up */
  138.     UPROPERTY(BlueprintReadWrite, Category = Movement)
  139.     float MoveUpVal;
  140.  
  141.     /** The value to move right */
  142.     UPROPERTY(BlueprintReadWrite, Category = Movement)
  143.     float MoveRightVal;
  144.  
  145.     UPROPERTY(BlueprintReadWrite, Category = Camera)
  146.     float RollRotationRate;
  147.  
  148.     UFUNCTION(BlueprintCallable, Category = Input)
  149.     void OnPlayerTouch(bool bTouch);
  150.  
  151.     /** Width of the near clip plane */
  152.     float NearPlaneWidth;
  153.     /** Width of the near height plane */
  154.     float NearPlaneHeight;
  155.  
  156.     /** The lifes of the player */
  157.     UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = Game)
  158.     int32 InitialPlayerLifes;
  159.  
  160.     bool bPlayerDied;
  161.  
  162.  
  163. protected:
  164.     /** Sets up the inner collision capsule */
  165.     virtual void SetupCapsule();
  166.  
  167.     /** Sets up the point sphere */
  168.     virtual void SetupInnerPointSphere();
  169.  
  170.     /** Sets up the multiplier sphere */
  171.     virtual void SetupMultiplierSphere();
  172.  
  173.     /** Sets up the outer point sphere */
  174.     virtual void SetupOuterPointSphere();
  175.  
  176.     virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
  177.     virtual void Tick(float Delta) override;
  178.     virtual void BeginPlay() override;
  179.  
  180. private:
  181.     float CameraBoundsWidth;
  182.     float CameraBoundsHeight;
  183.  
  184.     bool bDragActivated;
  185.     FVector2D LastTouchPoint;
  186.  
  187.     int32 PlayerLifesAtMultiplier;
  188.  
  189.     FGameOver GameOverEvent;
  190.     FPlayerHit PlayerHitEvent;
  191.  
  192.     bool bUseMotionControl;
  193.  
  194.     UFUNCTION()
  195.     void MoveUp(float Val);
  196.     UFUNCTION()
  197.     void MoveRight(float Val);
  198.  
  199.     void AddPlayerPoints(float Points);
  200.  
  201.     void TickPlayerMovement(float Delta);
  202.     void TickTouchInput(float Delta);
  203.     void TickCameraRoll(float Delta);
  204.     void TickMotionInput(float Delta);
  205.  
  206.     void SaveScore();
  207. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement