Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "GameFramework/Pawn.h"
- #include "MainPawn.generated.h"
- /**
- *
- */
- UCLASS()
- class SPACEDIVE_API AMainPawn : public APawn
- {
- GENERATED_BODY()
- public:
- AMainPawn(const FObjectInitializer&);
- ////////////////////////// COMPONENTS //////////////////////////////////////////
- /** Main camera */
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
- UCameraComponent* MainCamera;
- /** Capsule for the collision circle */
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
- UCapsuleComponent* CameraCapsule;
- /** Sphere for collision with multiplier */
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Scoring)
- USphereComponent* MultiplierSphere;
- /** Sphere for collision with points */
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Scoring)
- USphereComponent* InnerPointSphere;
- /** Sphere for collision with less points */
- UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Scoring)
- USphereComponent* OuterPointSphere;
- ////////////////////////////// METHODS ///////////////////////////////////////////
- void SetYAxisInverted(bool bInverted);
- void SetupMusic();
- void SetUseMotionControl(bool bUseMotionControl);
- ////////////////////////// DELEGATES ///////////////////////////////
- /** Executes when the player gets hit */
- void OnHit();
- /** When the game is over */
- void GameOver();
- /** Collision of the internal collision capsule */
- UFUNCTION()
- void OnCollide(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
- /** Collision of the multiplier sphere */
- UFUNCTION()
- void OnMultiplierCollide(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
- UFUNCTION()
- void OnInnerPointSphereCollide(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
- UFUNCTION()
- void OnOuterPointSphereCollide(class AActor* OtherActor, class UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);
- UFUNCTION()
- void OnMultiplierDelayEnds();
- ////////////////////////// BLUEPRINT WRAPPERS ///////////////////////
- /** Blueprint wrapper of OnHit */
- UFUNCTION(BlueprintImplementableEvent)
- void PlayerHitsAsteroid();
- /** Blueprint wrapper of GameOver */
- UFUNCTION(BlueprintImplementableEvent, Category = Gameplay)
- void PlayerDies();
- UFUNCTION(BlueprintImplementableEvent)
- void MultiplierCollides();
- ////////////////////////// GETTERS ///////////////////////////////////
- /** Aspect ratio of the camera */
- FORCEINLINE float GetAspectRatio() { return MainCamera->AspectRatio; }
- /** Event for game over */
- DECLARE_EVENT(AMainPawn, FGameOver)
- FGameOver& OnGameOver() { return GameOverEvent; }
- /** Event for player hit */
- DECLARE_EVENT(AMainPawn, FPlayerHit)
- FPlayerHit& OnPlayerHit() { return PlayerHitEvent; }
- //////////////////////////// RESOURCES //////////////////////////////
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Music)
- TArray<USoundBase*> MusicList;
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Sound)
- USoundBase* MultiplierSound;
- ////////////////////////////////////////////// PUBLIC VARIABLES ///////////////////////////////
- /** Factor of how many times the camera bounds are relative to the camera */
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Movement)
- float CameraBoundsFactor;
- /** Factor of movement speed */
- UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = Movement)
- float MovementSpeedFactor;
- /** The divider that is used to calculate the radius (Part of field of view area) */
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Scoring)
- float MultiplierSphereDivider;
- /** The divider that is used to calculate the radius (Part of field of view area) */
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Scoring)
- float InnerPointSphereDivider;
- /** The divider that is used to calculate the radius (Part of field of view area) */
- UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Scoring)
- float OuterPointSphereDivider;
- /** The points you get additionally when the inner sphere collides */
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Scoring)
- float InnerPointSpherePoints;
- /** The points you get when the outer sphere collides */
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Scoring)
- float OuterPointSpherePoints;
- /** The value to move up */
- UPROPERTY(BlueprintReadWrite, Category = Movement)
- float MoveUpVal;
- /** The value to move right */
- UPROPERTY(BlueprintReadWrite, Category = Movement)
- float MoveRightVal;
- UPROPERTY(BlueprintReadWrite, Category = Camera)
- float RollRotationRate;
- UFUNCTION(BlueprintCallable, Category = Input)
- void OnPlayerTouch(bool bTouch);
- /** Width of the near clip plane */
- float NearPlaneWidth;
- /** Width of the near height plane */
- float NearPlaneHeight;
- /** The lifes of the player */
- UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = Game)
- int32 InitialPlayerLifes;
- bool bPlayerDied;
- protected:
- /** Sets up the inner collision capsule */
- virtual void SetupCapsule();
- /** Sets up the point sphere */
- virtual void SetupInnerPointSphere();
- /** Sets up the multiplier sphere */
- virtual void SetupMultiplierSphere();
- /** Sets up the outer point sphere */
- virtual void SetupOuterPointSphere();
- virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
- virtual void Tick(float Delta) override;
- virtual void BeginPlay() override;
- private:
- float CameraBoundsWidth;
- float CameraBoundsHeight;
- bool bDragActivated;
- FVector2D LastTouchPoint;
- int32 PlayerLifesAtMultiplier;
- FGameOver GameOverEvent;
- FPlayerHit PlayerHitEvent;
- bool bUseMotionControl;
- UFUNCTION()
- void MoveUp(float Val);
- UFUNCTION()
- void MoveRight(float Val);
- void AddPlayerPoints(float Points);
- void TickPlayerMovement(float Delta);
- void TickTouchInput(float Delta);
- void TickCameraRoll(float Delta);
- void TickMotionInput(float Delta);
- void SaveScore();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement