aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2021-06-13 00:11:14 -0400
committerCameron Katri <me@cameronkatri.com>2021-06-13 00:11:14 -0400
commitb2cb1b8162e404391b2a30b77b2b4c0565adc9c4 (patch)
tree89a2caac46f14e81349021f89562bacdb1d45c8f
parent25192f07018ad142818a87c2aacac1bf0ecdf551 (diff)
parent81dfc0b51dcd0abeae7b47820f54f10050d6a678 (diff)
downloadgmtk-gamejam-b2cb1b8162e404391b2a30b77b2b4c0565adc9c4.tar.gz
gmtk-gamejam-b2cb1b8162e404391b2a30b77b2b4c0565adc9c4.tar.zst
gmtk-gamejam-b2cb1b8162e404391b2a30b77b2b4c0565adc9c4.zip
Merge branch 'master' of git.cameronkatri.com:gmtk-gamejam
-rw-r--r--Assets/Scenes/Main.unity269
-rw-r--r--Assets/Scripts/Controllers/AIController.cs2
-rw-r--r--Assets/Scripts/Controllers/GameController.cs64
-rw-r--r--Assets/Scripts/Controllers/Player/PlayerController.cs2
4 files changed, 332 insertions, 5 deletions
diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity
index 5972c78..590ca34 100644
--- a/Assets/Scenes/Main.unity
+++ b/Assets/Scenes/Main.unity
@@ -123,6 +123,71 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
+--- !u!1 &108876581
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 108876582}
+ m_Layer: 0
+ m_Name: Player
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &108876582
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 108876581}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children:
+ - {fileID: 883099186}
+ - {fileID: 449106401}
+ - {fileID: 619920152}
+ m_Father: {fileID: 1096236286}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &112966577
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 112966578}
+ m_Layer: 0
+ m_Name: Enemy
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &112966578
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 112966577}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children:
+ - {fileID: 1679712819}
+ - {fileID: 468077269}
+ m_Father: {fileID: 1096236286}
+ m_RootOrder: 1
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &140689490
GameObject:
m_ObjectHideFlags: 0
@@ -544,6 +609,36 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 447684161}
m_CullTransparentMesh: 1
+--- !u!1 &449106400
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 449106401}
+ m_Layer: 0
+ m_Name: Character
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &449106401
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 449106400}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: -12.84, y: -2.113885, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 108876582}
+ m_RootOrder: 1
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &453079590
GameObject:
m_ObjectHideFlags: 0
@@ -581,6 +676,36 @@ RectTransform:
m_AnchoredPosition: {x: 0.000061035156, y: 0.000030517578}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
+--- !u!1 &468077268
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 468077269}
+ m_Layer: 0
+ m_Name: Character
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &468077269
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 468077268}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 12.6, y: -2.713885, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 112966578}
+ m_RootOrder: 1
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &519420028
GameObject:
m_ObjectHideFlags: 0
@@ -732,6 +857,36 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 40e5d6a883d14c7fb60913ec2fc3009c, type: 3}
m_Name:
m_EditorClassIdentifier:
+--- !u!1 &619920151
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 619920152}
+ m_Layer: 0
+ m_Name: Character.Top
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &619920152
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 619920151}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: -12.84, y: -0.88, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 108876582}
+ m_RootOrder: 2
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &700993592
PrefabInstance:
m_ObjectHideFlags: 0
@@ -890,6 +1045,36 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
+--- !u!1 &883099185
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 883099186}
+ m_Layer: 0
+ m_Name: Ball
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &883099186
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 883099185}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: -12.839999, y: -0.9, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 108876582}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &896473980
GameObject:
m_ObjectHideFlags: 0
@@ -1200,6 +1385,43 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 261cc3206075846ebbd03b8896e7c733, type: 3}
m_Name:
m_EditorClassIdentifier:
+--- !u!1 &1096236285
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 1096236286}
+ m_Layer: 0
+ m_Name: SpawnPoints
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &1096236286
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1096236285}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children:
+ - {fileID: 108876582}
+ - {fileID: 112966578}
+ m_Father: {fileID: 1174357919}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!4 &1111848677 stripped
+Transform:
+ m_CorrespondingSourceObject: {fileID: 6095859833589646295, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
+ m_PrefabInstance: {fileID: 984947992}
+ m_PrefabAsset: {fileID: 0}
--- !u!1 &1113670439
GameObject:
m_ObjectHideFlags: 0
@@ -1308,7 +1530,8 @@ Transform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
- m_Children: []
+ m_Children:
+ - {fileID: 1096236286}
m_Father: {fileID: 244382786}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -1327,11 +1550,17 @@ MonoBehaviour:
timeLimit: 60
ball: {fileID: 707826158}
PlayerSpawnPoints:
- ball: {fileID: 0}
- character: {fileID: 0}
+ body: {fileID: 1111848677}
+ secondBody: {fileID: 288486053}
+ ball: {fileID: 883099186}
+ character: {fileID: 449106401}
+ secondCharacter: {fileID: 619920152}
EnemySpawnPoints:
- ball: {fileID: 0}
- character: {fileID: 0}
+ body: {fileID: 961513381}
+ secondBody: {fileID: 0}
+ ball: {fileID: 1679712819}
+ character: {fileID: 468077269}
+ secondCharacter: {fileID: 0}
PlayerHoop: {fileID: 614591307}
EnemyHoop: {fileID: 1354192742}
dribbleSound: {fileID: 1174357921}
@@ -1919,6 +2148,36 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &1679712818
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 1679712819}
+ m_Layer: 0
+ m_Name: Ball
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &1679712819
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1679712818}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 12.6, y: -0.9, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_Children: []
+ m_Father: {fileID: 112966578}
+ m_RootOrder: 0
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1742973248
GameObject:
m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/Controllers/AIController.cs b/Assets/Scripts/Controllers/AIController.cs
index 92dc6bc..cdfc9a8 100644
--- a/Assets/Scripts/Controllers/AIController.cs
+++ b/Assets/Scripts/Controllers/AIController.cs
@@ -62,6 +62,8 @@ namespace Controllers
private void Update()
{
+ if (game.freezeMotion) return;
+
var movement = transform.position;
if (!game.enemy.HasBall) // Move towards the ball to grab it.
diff --git a/Assets/Scripts/Controllers/GameController.cs b/Assets/Scripts/Controllers/GameController.cs
index 6ebcabe..303b5a0 100644
--- a/Assets/Scripts/Controllers/GameController.cs
+++ b/Assets/Scripts/Controllers/GameController.cs
@@ -1,4 +1,6 @@
using System;
+using System.Collections;
+using JetBrains.Annotations;
using UnityEngine;
using UnityEngine.UI;
@@ -14,6 +16,8 @@ namespace Controllers
public Player player;
public Player enemy;
+
+ public bool freezeMotion;
private float startTime;
[SerializeField] private float timeLimit;
@@ -104,6 +108,9 @@ namespace Controllers
{
score += 2;
}
+
+ // They made a shot! Now respawn the players and give possession to the opposite player.
+ controller.Respawn(isEnemy ? Possession.Player : Possession.Enemy);
}
private State dribble => isEnemy ? State.EnemyDribble : State.PlayerDribble;
@@ -173,6 +180,54 @@ namespace Controllers
state = State.Idle;
}
+ private void Respawn(Possession possession)
+ {
+ PlayerSpawnPoints.body.transform.position = new Vector3(PlayerSpawnPoints.character.position.x, PlayerSpawnPoints.character.position.y, PlayerSpawnPoints.body.transform.position.y);
+ PlayerSpawnPoints.body.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
+
+ if (PlayerSpawnPoints.secondBody is { })
+ {
+ if (PlayerSpawnPoints.secondCharacter is { })
+ PlayerSpawnPoints.secondBody.transform.position = new Vector3(PlayerSpawnPoints.secondCharacter.position.x, PlayerSpawnPoints.secondCharacter.position.y, PlayerSpawnPoints.body.transform.position.y);
+ PlayerSpawnPoints.secondBody.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
+ }
+
+ PlayerSpawnPoints.body.transform.localRotation = Quaternion.identity;
+ EnemySpawnPoints.body.transform.position = new Vector3(EnemySpawnPoints.character.position.x, EnemySpawnPoints.character.position.y, EnemySpawnPoints.body.transform.position.y);
+ ball.transform.position = possession switch
+ {
+ Possession.Player => new Vector3(PlayerSpawnPoints.ball.position.x, PlayerSpawnPoints.ball.position.y, ball.transform.position.y),
+ Possession.Enemy => new Vector3(EnemySpawnPoints.ball.position.x, EnemySpawnPoints.ball.position.y, ball.transform.position.y),
+ _ => ball.transform.position
+ };
+
+ // Set a cooldown so they can stop trying to wrangle the player while it respawns.
+ StartCoroutine(RespawnCooldown(possession));
+ }
+
+ private IEnumerator RespawnCooldown(Possession possession)
+ {
+ // Show the new score.
+ var possessionText = possession == Possession.Player ? "HOME" : "AWAY";
+ ShowModal($"{player.score}-{enemy.score}\n{possessionText}'S POSSESSION");
+
+ freezeMotion = true;
+
+ yield return new WaitForSeconds(1f);
+
+ HideModal();
+
+ freezeMotion = false;
+ }
+
+ private void ShowModal(string text)
+ {
+ resultOverlay.SetActive(true);
+ resultText.text = text;
+ }
+
+ private void HideModal() => resultOverlay.SetActive(false);
+
internal enum State
{
Idle,
@@ -186,8 +241,17 @@ namespace Controllers
[Serializable]
private struct SpawnPoints
{
+ [SerializeField] internal Transform body;
+ [SerializeField] [CanBeNull] internal Transform secondBody;
[SerializeField] internal Transform ball;
[SerializeField] internal Transform character;
+ [SerializeField] [CanBeNull] internal Transform secondCharacter;
+ }
+
+ private enum Possession
+ {
+ Player,
+ Enemy
}
}
diff --git a/Assets/Scripts/Controllers/Player/PlayerController.cs b/Assets/Scripts/Controllers/Player/PlayerController.cs
index d72b077..9df8c0a 100644
--- a/Assets/Scripts/Controllers/Player/PlayerController.cs
+++ b/Assets/Scripts/Controllers/Player/PlayerController.cs
@@ -33,6 +33,8 @@ namespace Controllers.Player
private void Update()
{
+ if (game.freezeMotion) return;
+
// Loop over each body segment and control it.
for (var i = 0; i < segments.Length; i++)
{