# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*
+
+.DS_Store
- component: {fileID: 1029364543094105199}
- component: {fileID: 2639737386686648195}
- component: {fileID: 1022133350338841181}
+ - component: {fileID: 5401724803266703353}
m_Layer: 0
m_Name: Hoop
m_TagString: Untagged
m_EditorClassIdentifier:
Rim: {fileID: 2639737386686648195}
Net: {fileID: 1029364543094105199}
+ shotSound: {fileID: 5401724803266703353}
+--- !u!82 &5401724803266703353
+AudioSource:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 2106494524751008836}
+ m_Enabled: 1
+ serializedVersion: 4
+ OutputAudioMixerGroup: {fileID: 0}
+ m_audioClip: {fileID: 8300000, guid: 0626d151c4dfd8345b0f548141ea4a73, type: 3}
+ m_PlayOnAwake: 0
+ m_Volume: 1
+ m_Pitch: 1
+ Loop: 0
+ Mute: 0
+ Spatialize: 0
+ SpatializePostEffects: 0
+ Priority: 128
+ DopplerLevel: 1
+ MinDistance: 1
+ MaxDistance: 500
+ Pan2D: 0
+ rolloffMode: 0
+ BypassEffects: 0
+ BypassListenerEffects: 0
+ BypassReverbZones: 0
+ rolloffCustomCurve:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: 1
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.33333334
+ outWeight: 0.33333334
+ - serializedVersion: 3
+ time: 1
+ value: 0
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.33333334
+ outWeight: 0.33333334
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
+ panLevelCustomCurve:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: 0
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.33333334
+ outWeight: 0.33333334
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
+ spreadCustomCurve:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: 0
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.33333334
+ outWeight: 0.33333334
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
+ reverbZoneMixCustomCurve:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: 1
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.33333334
+ outWeight: 0.33333334
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
m_Component:
- component: {fileID: 1174357919}
- component: {fileID: 1174357920}
+ - component: {fileID: 1174357921}
m_Layer: 0
m_Name: Game
m_TagString: Untagged
ball: {fileID: 707826158}
PlayerHoop: {fileID: 614591307}
EnemyHoop: {fileID: 1354192742}
+ dribbleSound: {fileID: 1174357921}
+--- !u!82 &1174357921
+AudioSource:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1174357918}
+ m_Enabled: 1
+ serializedVersion: 4
+ OutputAudioMixerGroup: {fileID: 0}
+ m_audioClip: {fileID: 8300000, guid: 09f412701b6b62449ae56680cf2812f5, type: 3}
+ m_PlayOnAwake: 0
+ m_Volume: 1
+ m_Pitch: 1
+ Loop: 0
+ Mute: 0
+ Spatialize: 0
+ SpatializePostEffects: 0
+ Priority: 128
+ DopplerLevel: 1
+ MinDistance: 1
+ MaxDistance: 500
+ Pan2D: 0
+ rolloffMode: 0
+ BypassEffects: 0
+ BypassListenerEffects: 0
+ BypassReverbZones: 0
+ rolloffCustomCurve:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: 1
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.33333334
+ outWeight: 0.33333334
+ - serializedVersion: 3
+ time: 1
+ value: 0
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.33333334
+ outWeight: 0.33333334
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
+ panLevelCustomCurve:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: 0
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.33333334
+ outWeight: 0.33333334
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
+ spreadCustomCurve:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: 0
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.33333334
+ outWeight: 0.33333334
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
+ reverbZoneMixCustomCurve:
+ serializedVersion: 2
+ m_Curve:
+ - serializedVersion: 3
+ time: 0
+ value: 1
+ inSlope: 0
+ outSlope: 0
+ tangentMode: 0
+ weightedMode: 0
+ inWeight: 0.33333334
+ outWeight: 0.33333334
+ m_PreInfinity: 2
+ m_PostInfinity: 2
+ m_RotationOrder: 4
--- !u!4 &1189511746 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 6095859834264611321, guid: c64ad9b908cb44602b3d13a74aef751f, type: 3}
[SerializeField] private Transform target;
[SerializeField] private float speed;
- private void Update()
+ private void FixedUpdate()
{
transform.position = Vector3.MoveTowards(transform.position, new Vector3(target.transform.position.x, target.transform.position.y, -10f), Time.deltaTime * speed);
}
[SerializeField] public Hoop PlayerHoop;
[SerializeField] public Hoop EnemyHoop;
+ [SerializeField] public AudioSource dribbleSound;
+
private void Awake()
{
player = new Player { isEnemy = false, controller = this };
enemy = new Player { isEnemy = true, controller = this };
ball.controller = this;
+ PlayerHoop.controller = this;
+ EnemyHoop.controller = this;
}
public struct Player
if (Vector2.Distance(controller.ball.transform.position, handPosition) >= 1f) return false;
controller.state = dribble;
+ controller.dribbleSound.Play();
Move(handPosition);
return true;
}
public bool Shoot(Transform playerTransform)
{
if (controller.state != dribble) return false; // We must be dribbling the ball to shoot it.
+ controller.dribbleSound.Stop();
controller.state = shoot;
controller.ball.Shoot(hoop.transform.position);
lastShotPosition = playerTransform.position;
internal void BallDropped()
{
+ dribbleSound.Stop();
state = State.Idle;
}
namespace Controllers
{
+ [RequireComponent(typeof(AudioSource))]
public class Hoop : MonoBehaviour
{
+ internal GameController controller;
+
[SerializeField] private BoxCollider2D Rim;
[SerializeField] private BoxCollider2D Net;
+ [SerializeField] private AudioSource shotSound;
private void OnTriggerEnter2D(Collider2D other)
{
if (other.GetComponent<Ball>() == null) return;
-
+
if (Rim.IsTouching(other) && Net.IsTouching(other))
- Debug.Log("Swish!");
+ {
+ shotSound.Play();
+ if (this == controller.PlayerHoop)
+ controller.player.Score(Rim.transform.position);
+ else if (this == controller.EnemyHoop)
+ controller.enemy.Score(Rim.transform.position);
+ }
}
}
}
\ No newline at end of file