Skip to content

Commit eb149ee

Browse files
committed
Fix font, add cinematic camera that switches through holes while we're waiting for players
1 parent 9f5a824 commit eb149ee

11 files changed

+187
-87
lines changed

Assets/prefabs/ball.prefab

+16
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,22 @@
129129
"go": "ddc725f2-256d-4ee1-96d8-bc60dee11ed2",
130130
"component_type": "CameraComponent"
131131
}
132+
},
133+
{
134+
"__type": "Facepunch.Minigolf.CinematicCamera",
135+
"__guid": "77c95f6a-84ff-4e6d-8559-2c8bc0730a86",
136+
"Ball": {
137+
"_type": "component",
138+
"component_id": "17a459ff-756b-4a1a-9a80-dd7b584d894c",
139+
"go": "476b1b4a-4184-4332-9e05-fd85af624ae2",
140+
"component_type": "Ball"
141+
},
142+
"Camera": {
143+
"_type": "component",
144+
"component_id": "c3cfe019-6e47-4213-b7eb-981379700aca",
145+
"go": "ddc725f2-256d-4ee1-96d8-bc60dee11ed2",
146+
"component_type": "CameraComponent"
147+
}
132148
}
133149
],
134150
"Children": [

Assets/scenes/courses/course_one.scene

+8-9
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@
620620
"__PrefabVariables": {
621621
"Hole": {
622622
"_type": "component",
623-
"component_id": "401eac07-f1fb-4095-ac17-97ece862f3b2",
623+
"component_id": "ef11f634-23cf-4f98-88c8-7c44960cd383",
624624
"go": "511f1d03-7f4d-4057-ab67-f2b306b129a3",
625625
"component_type": "Hole"
626626
}
@@ -650,7 +650,7 @@
650650
"__guid": "c99d0932-8a38-4b44-85dd-0044a6a53ba8",
651651
"Hole": {
652652
"_type": "component",
653-
"component_id": "401eac07-f1fb-4095-ac17-97ece862f3b2",
653+
"component_id": "ef11f634-23cf-4f98-88c8-7c44960cd383",
654654
"go": "511f1d03-7f4d-4057-ab67-f2b306b129a3",
655655
"component_type": "Hole"
656656
}
@@ -1250,7 +1250,7 @@
12501250
"__PrefabVariables": {
12511251
"Hole": {
12521252
"_type": "component",
1253-
"component_id": "694c207b-6c21-4a6f-8251-06401645e671",
1253+
"component_id": "155714e7-4d14-44e2-987c-54e2ec342e29",
12541254
"go": "2b45b25f-e329-413a-b804-68bb8fefefa9",
12551255
"component_type": "Hole"
12561256
}
@@ -1280,7 +1280,7 @@
12801280
"__guid": "791212d7-c89d-40ab-ac78-37994e118b9e",
12811281
"Hole": {
12821282
"_type": "component",
1283-
"component_id": "694c207b-6c21-4a6f-8251-06401645e671",
1283+
"component_id": "155714e7-4d14-44e2-987c-54e2ec342e29",
12841284
"go": "2b45b25f-e329-413a-b804-68bb8fefefa9",
12851285
"component_type": "Hole"
12861286
}
@@ -1888,7 +1888,7 @@
18881888
"__PrefabVariables": {
18891889
"Hole": {
18901890
"_type": "component",
1891-
"component_id": "2fab5bb7-5210-4a75-80ec-649e3da750d7",
1891+
"component_id": "013466c0-9063-4a82-8c14-921757a5b1bc",
18921892
"go": "097cf5cc-b809-4c3d-aca5-d4b34ccc2dec",
18931893
"component_type": "Hole"
18941894
}
@@ -1918,7 +1918,7 @@
19181918
"__guid": "b9490bbc-8071-48c7-9379-1b677a56651c",
19191919
"Hole": {
19201920
"_type": "component",
1921-
"component_id": "2fab5bb7-5210-4a75-80ec-649e3da750d7",
1921+
"component_id": "013466c0-9063-4a82-8c14-921757a5b1bc",
19221922
"go": "097cf5cc-b809-4c3d-aca5-d4b34ccc2dec",
19231923
"component_type": "Hole"
19241924
}
@@ -2687,7 +2687,7 @@
26872687
"__PrefabVariables": {
26882688
"Hole": {
26892689
"_type": "component",
2690-
"component_id": "1291784d-8992-47b4-a012-4286e9049f9b",
2690+
"component_id": "f71dc224-b90e-44eb-8aaa-aaeda46cf869",
26912691
"go": "3b357604-4fe4-4b53-86cd-a9c7de235f14",
26922692
"component_type": "Hole"
26932693
}
@@ -2717,7 +2717,7 @@
27172717
"__guid": "87011444-1cca-4d6e-a290-f2e32223d476",
27182718
"Hole": {
27192719
"_type": "component",
2720-
"component_id": "1291784d-8992-47b4-a012-4286e9049f9b",
2720+
"component_id": "f71dc224-b90e-44eb-8aaa-aaeda46cf869",
27212721
"go": "3b357604-4fe4-4b53-86cd-a9c7de235f14",
27222722
"component_type": "Hole"
27232723
}
@@ -2803,6 +2803,5 @@
28032803
"__references": [
28042804
"agentab.plainsky#31314"
28052805
],
2806-
"IsValid": true,
28072806
"__version": 1
28082807
}

Code/Ball/BallController.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public sealed class BallController : Component
2929
/// <returns></returns>
3030
public BaseCamera GetActiveCamera()
3131
{
32+
if ( Facepunch.Minigolf.GameManager.Instance.State == GameState.WaitingForPlayers )
33+
return GetComponent<CinematicCamera>();
34+
3235
if ( WantsFreeCamera() ) return GetComponent<FreeCamera>();
3336
return GetComponent<BallCamera>();
3437
}
@@ -64,7 +67,7 @@ private void UpdateCamera()
6467
last.OnCameraInactive();
6568
}
6669

67-
cam.Tick();
70+
cam.OnCameraUpdate();
6871
}
6972
}
7073

Code/Camera/BallCamera.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private void UpdateDefault()
5959
Camera.FieldOfView = Preferences.FieldOfView;
6060
}
6161

62-
public override void Tick()
62+
public override void OnCameraUpdate()
6363
{
6464
UpdateDefault();
6565
UpdateViewBlockers();

Code/Camera/BaseCamera.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public virtual void OnCameraInactive()
4949
{
5050
}
5151

52-
public virtual void Tick()
52+
public virtual void OnCameraUpdate()
5353
{
5454
}
5555
}

Code/Camera/CinematicCamera.cs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace Facepunch.Minigolf;
2+
3+
public partial class CinematicCamera : BaseCamera
4+
{
5+
TimeUntil TimeUntilNextTarget { get; set; }
6+
7+
public GameObject Target { get; set; }
8+
9+
private GameObject FindRandomTarget()
10+
{
11+
return Scene.GetAllComponents<HoleGoal>()
12+
.FirstOrDefault( x => x.GameObject != Target )
13+
.GameObject;
14+
}
15+
16+
public override void OnCameraUpdate()
17+
{
18+
if ( TimeUntilNextTarget )
19+
{
20+
Target = FindRandomTarget();
21+
TimeUntilNextTarget = 5f;
22+
}
23+
24+
if ( Target.IsValid() )
25+
{
26+
Camera.WorldPosition = Target.WorldPosition + Vector3.Backward * 256f + Vector3.Up * 64f;
27+
Camera.WorldRotation = Rotation.LookAt( Target.WorldPosition, Vector3.Up );
28+
}
29+
}
30+
}

Code/Camera/FreeCamera.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public override void OnCameraActive()
1212
freeCamAngles = Camera.WorldRotation.Angles();
1313
}
1414

15-
public override void Tick()
15+
public override void OnCameraUpdate()
1616
{
1717
Vector3 movement = Input.AnalogMove;
1818
float speed = 350.0f;

Code/GameLoop/GameManager.cs

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ namespace Facepunch.Minigolf;
33
public partial class GameManager : Component, Component.INetworkListener,
44
ISceneStartup, IGameEvent
55
{
6+
[ConVar( "minigolf_min_players" )]
7+
public static int MinPlayers { get; set; } = 1;
8+
69
void ISceneStartup.OnHostInitialize()
710
{
811
// If we're not hosting a lobby, start hosting one
@@ -25,6 +28,11 @@ void ISceneStartup.OnHostInitialize()
2528
void INetworkListener.OnActive( Connection channel )
2629
{
2730
SpawnPlayerForConnection( channel );
31+
32+
if ( Connection.All.Count >= MinPlayers && State == GameState.WaitingForPlayers )
33+
{
34+
State = GameState.InPlay;
35+
}
2836
}
2937

3038
/// <summary>

Code/UI/HUD/HUDComponent.razor

+17-5
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,29 @@
33
@attribute [Title( "HUD" )]
44

55
<root>
6-
<PowerBar />
7-
<HoleScore />
8-
<ControlHints />
9-
<HoleMarker />
6+
@if ( GameManager.Instance.State == GameState.InPlay )
7+
{
8+
<PowerBar />
9+
<HoleScore />
10+
<ControlHints />
11+
<HoleMarker />
12+
}
13+
14+
@if ( GameManager.Instance.State == GameState.WaitingForPlayers )
15+
{
16+
<div class="notice">
17+
<label class="title">Waiting for players</label>
18+
<label class="title">(@(Connection.All.Count())/@(GameManager.MinPlayers))</label>
19+
</div>
20+
}
21+
1022
<GolfScoreboard />
1123
</root>
1224

1325
@code
1426
{
1527
protected override int BuildHash()
1628
{
17-
return HashCode.Combine( Ball.Local, Ball.Local.GetCurrentPar(), GameManager.Instance, GameManager.Instance.CurrentHole.Number );
29+
return HashCode.Combine( Ball.Local, Ball.Local.GetCurrentPar(), GameManager.Instance, GameManager.Instance.CurrentHole.Number, GameManager.Instance.State );
1830
}
1931
}

Code/UI/HUD/HUDComponent.razor.scss

+24-5
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,37 @@ $green: #16261c;
33
$text: #f4efec;
44
$transition: all 150ms ease;
55

6-
@import "/UI/_theme.scss";
7-
86
HUDComponent
97
{
108
font-family: FredokaOne;
11-
font-size: 24px;
129
font-weight: bolder;
1310
color: $text;
14-
text-shadow: 5px 5px 1px rgba(black, 0.2);
1511
flex-direction: column;
16-
justify-content: center;
1712
align-items: flex-start;
1813
width: 100%;
1914
height: 100%;
15+
}
16+
17+
label, text
18+
{
19+
font-family: FredokaOne;
20+
color: $text;
21+
font-weight: bolder;
22+
23+
&.title
24+
{
25+
text-shadow: 5px 5px 1px rgba(black, 0.2);
26+
font-size: 30px;
27+
}
28+
}
29+
30+
.notice
31+
{
32+
position: absolute;
33+
transform: translateX(-50%);
34+
top: 20%;
35+
left: 50%;
36+
flex-direction: column;
37+
justify-content: center;
38+
align-items: center;
2039
}

0 commit comments

Comments
 (0)