217 - Setting Team Colors
This commit is contained in:
parent
36c39f1c69
commit
19b84ff30f
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -316,6 +316,29 @@ void ABlasterCharacter::MulticastLostTheLead_Implementation()
|
|||
}
|
||||
}
|
||||
|
||||
void ABlasterCharacter::SetTeamColor(ETeam Team)
|
||||
{
|
||||
if (GetMesh() == nullptr) return;
|
||||
switch (Team)
|
||||
{
|
||||
case ETeam::ET_RedTeam:
|
||||
if (RedMaterial == nullptr) return;
|
||||
GetMesh()->SetMaterial(0, RedMaterial);
|
||||
DissolveMaterialInstance = RedDissolveMatInst;
|
||||
break;
|
||||
case ETeam::ET_BlueTeam:
|
||||
if (BlueMaterial == nullptr) return;
|
||||
GetMesh()->SetMaterial(0, BlueMaterial);
|
||||
DissolveMaterialInstance = BlueDissolveMatInst;
|
||||
break;
|
||||
case ETeam::ET_NoTeam:
|
||||
if (OriginalMaterial == nullptr) return;
|
||||
GetMesh()->SetMaterial(0, OriginalMaterial);
|
||||
DissolveMaterialInstance = BlueDissolveMatInst;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterCharacter::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
@ -903,6 +926,7 @@ void ABlasterCharacter::PollInit()
|
|||
// Initialize Score now we have the PlayerState
|
||||
BlasterPlayerState->IncreaseScore(0.f);
|
||||
BlasterPlayerState->IncreaseDefeats(0);
|
||||
SetTeamColor(BlasterPlayerState->GetTeam());
|
||||
|
||||
const ABlasterGameState* BlasterGameState = Cast<ABlasterGameState>(UGameplayStatics::GetGameState(this));
|
||||
if (BlasterGameState && BlasterGameState->TopScoringPlayers.Contains(BlasterPlayerState))
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "CoreMinimal.h"
|
||||
#include "Blaster/Interfaces/InteractWithCrosshairInterface.h"
|
||||
#include "Blaster/Types/CombatState.h"
|
||||
#include "Blaster/Types/Team.h"
|
||||
#include "Blaster/Types/TurningInPlace.h"
|
||||
#include "Components/TimelineComponent.h"
|
||||
#include "GameFramework/Character.h"
|
||||
|
@ -67,6 +68,8 @@ public:
|
|||
UFUNCTION(NetMulticast, Reliable)
|
||||
void MulticastLostTheLead();
|
||||
|
||||
void SetTeamColor(ETeam Team);
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
|
@ -277,9 +280,25 @@ private:
|
|||
UMaterialInstanceDynamic* DynamicDissolveMaterialInstance;
|
||||
|
||||
// Material instance set on the Blueprint, used with the dynamic material instance
|
||||
UPROPERTY(EditAnywhere, Category = Elimination)
|
||||
UPROPERTY(VisibleAnywhere, Category = Elimination)
|
||||
UMaterialInstance* DissolveMaterialInstance;
|
||||
|
||||
// Team colors
|
||||
UPROPERTY(EditAnywhere, Category = Elimination)
|
||||
UMaterialInstance* RedDissolveMatInst;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = Elimination)
|
||||
UMaterialInstance* RedMaterial;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = Elimination)
|
||||
UMaterialInstance* BlueDissolveMatInst;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = Elimination)
|
||||
UMaterialInstance* BlueMaterial;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = Elimination)
|
||||
UMaterialInstance* OriginalMaterial;
|
||||
|
||||
// Elimination effects
|
||||
UPROPERTY(EditAnywhere)
|
||||
UParticleSystem* EliminationBotEffect;
|
||||
|
|
|
@ -70,3 +70,22 @@ void ABlasterPlayerState::OnRep_Defeats()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterPlayerState::SetTeam(ETeam TeamToSet)
|
||||
{
|
||||
Team = TeamToSet;
|
||||
ABlasterCharacter* BCharacter = Cast<ABlasterCharacter>(GetPawn());
|
||||
if (BCharacter)
|
||||
{
|
||||
BCharacter->SetTeamColor(Team);
|
||||
}
|
||||
}
|
||||
|
||||
void ABlasterPlayerState::OnRep_Team()
|
||||
{
|
||||
ABlasterCharacter* BCharacter = Cast<ABlasterCharacter>(GetPawn());
|
||||
if (BCharacter)
|
||||
{
|
||||
BCharacter->SetTeamColor(Team);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,11 +33,13 @@ private:
|
|||
UPROPERTY(ReplicatedUsing = OnRep_Defeats)
|
||||
int32 Defeats;
|
||||
|
||||
UPROPERTY(Replicated)
|
||||
UPROPERTY(ReplicatedUsing = OnRep_Team)
|
||||
ETeam Team = ETeam::ET_NoTeam;
|
||||
|
||||
UFUNCTION()
|
||||
void OnRep_Team();
|
||||
public:
|
||||
FORCEINLINE ETeam GetTeam() const { return Team; }
|
||||
FORCEINLINE void SetTeam(ETeam TeamToSet) { Team = TeamToSet; }
|
||||
void SetTeam(ETeam TeamToSet);
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue