m_CorrespondingSourceObject: {fileID: 6554888089662917209, guid: be9aa59b997c243a2bf4287cb2129092, type: 3}
m_PrefabInstance: {fileID: 6554888089409436015}
m_PrefabAsset: {fileID: 0}
---- !u!61 &293352247
-BoxCollider2D:
- m_ObjectHideFlags: 0
- m_CorrespondingSourceObject: {fileID: 0}
- m_PrefabInstance: {fileID: 0}
- m_PrefabAsset: {fileID: 0}
- m_GameObject: {fileID: 293352246}
- m_Enabled: 1
- m_Density: 1
- m_Material: {fileID: 0}
- m_IsTrigger: 0
- m_UsedByEffector: 0
- m_UsedByComposite: 0
- m_Offset: {x: 0, y: 0}
- m_SpriteTilingProperty:
- border: {x: 0, y: 0, z: 0, w: 0}
- pivot: {x: 0, y: 0}
- oldSize: {x: 0, y: 0}
- newSize: {x: 0, y: 0}
- adaptiveTilingThreshold: 0
- drawMode: 0
- adaptiveTiling: 0
- m_AutoTiling: 0
- serializedVersion: 2
- m_Size: {x: 5.63, y: 0.13}
- m_EdgeRadius: 0
--- !u!4 &293352248 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 6554888089662917207, guid: be9aa59b997c243a2bf4287cb2129092, type: 3}
m_Modification:
m_TransformParent: {fileID: 244382786}
m_Modifications:
+ - target: {fileID: 6063944130433637649, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
+ propertyPath: game
+ value:
+ objectReference: {fileID: 1174357920}
- target: {fileID: 6095859834264611320, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
propertyPath: m_Name
value: Player
propertyPath: verticalSensitivity
value: 8
objectReference: {fileID: 0}
+ - target: {fileID: 6967752935869289387, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
+ propertyPath: game
+ value:
+ objectReference: {fileID: 1174357920}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
--- !u!114 &984947993 stripped
m_Script: {fileID: 11500000, guid: 261cc3206075846ebbd03b8896e7c733, type: 3}
m_Name:
m_EditorClassIdentifier:
+--- !u!1 &1032129678
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 1032129679}
+ - component: {fileID: 1032129680}
+ m_Layer: 0
+ m_Name: Ground
+ m_TagString: Ground
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &1032129679
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1032129678}
+ 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_Father: {fileID: 293352248}
+ m_RootOrder: 4
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!61 &1032129680
+BoxCollider2D:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1032129678}
+ m_Enabled: 1
+ m_Density: 1
+ m_Material: {fileID: 0}
+ m_IsTrigger: 0
+ m_UsedByEffector: 0
+ m_UsedByComposite: 0
+ m_Offset: {x: 0, y: 0}
+ m_SpriteTilingProperty:
+ border: {x: 0, y: 0, z: 0, w: 0}
+ pivot: {x: 0, y: 0}
+ oldSize: {x: 0, y: 0}
+ newSize: {x: 0, y: 0}
+ adaptiveTilingThreshold: 0
+ drawMode: 0
+ adaptiveTiling: 0
+ m_AutoTiling: 0
+ serializedVersion: 2
+ m_Size: {x: 5.63, y: 0.13}
+ m_EdgeRadius: 0
--- !u!1 &1096236285
GameObject:
m_ObjectHideFlags: 0
m_Script: {fileID: 11500000, guid: 6639705c6da14aab845bd87d3d8fbf38, type: 3}
m_Name:
m_EditorClassIdentifier:
+ freezeMotion: 0
timeLimit: 60
ball: {fileID: 707826158}
PlayerSpawnPoints:
if (remainingRaw <= 0)
{
- resultOverlay.SetActive(true);
var outcome = player.score == enemy.score ? "TIE GAME" : player.score < enemy.score ? "AWAY TEAM WINS" : "HOME TEAM WINS";
- resultText.text = $"{outcome}\n{player.score}-{enemy.score}";
+ ShowModal($"{outcome}\n{player.score}-{enemy.score}");
+
+ freezeMotion = true;
}
}
}
// They made a shot! Now respawn the players and give possession to the opposite player.
- controller.Respawn(isEnemy ? Possession.Player : Possession.Enemy);
+ controller.Respawn(isEnemy ? Possession.Player : Possession.Enemy, $"{controller.player.score}-{controller.enemy.score}");
}
private State dribble => isEnemy ? State.EnemyDribble : State.PlayerDribble;
lastShotPosition = playerTransform.position;
return true;
}
+
+ public void Foul(string reason)
+ {
+ // Give the other player the ball on a foul.
+ controller.Respawn(isEnemy ? Possession.Player : Possession.Enemy, reason);
+ }
}
internal void BallDropped()
state = State.Idle;
}
- private void Respawn(Possession possession)
+ private void Respawn(Possession possession, string message)
{
+ BallDropped();
+
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;
};
// Set a cooldown so they can stop trying to wrangle the player while it respawns.
- StartCoroutine(RespawnCooldown(possession));
+ StartCoroutine(RespawnCooldown(possession, message));
}
- private IEnumerator RespawnCooldown(Possession possession)
+ private IEnumerator RespawnCooldown(Possession possession, string message)
{
// Show the new score.
var possessionText = possession == Possession.Player ? "HOME" : "AWAY";
- ShowModal($"{player.score}-{enemy.score}\n{possessionText}'S POSSESSION");
+ ShowModal($"{message}\n{possessionText}'S POSSESSION");
freezeMotion = true;
internal bool moveleft;
internal bool moveright;
-
+
+ [Header("Controls")]
[SerializeField] public Control left;
[SerializeField] public Control right;
+ [Header("Settings")]
[SerializeField] public Vector3 forceOrigin;
-
[SerializeField] public float height;
[SerializeField] public bool isRoot;
[SerializeField] public bool isTop;
+ [Header("References")]
+ [SerializeField] private GameController game;
+ [SerializeField] private bool callFoulOnContact;
[SerializeField] public Transform flipper;
public Rigidbody2D Rigidbody => _rigidbody != null ? _rigidbody : _rigidbody = GetComponent<Rigidbody2D>();
transform.position + (height * forceOrigin));
}
}
+
+ private void OnCollisionEnter2D(Collision2D other)
+ {
+ if (callFoulOnContact && game.player.HasBall && other.gameObject.CompareTag("Ground"))
+ game.player.Foul("LOOSE BALL FOUL");
+ }
}
[Serializable]