diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 4c616dc..fd18700 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -505,7 +505,7 @@ MeshCollider: m_GameObject: {fileID: 9053857059518369811} m_Material: {fileID: 0} m_IsTrigger: 0 - m_Enabled: 1 + m_Enabled: 0 serializedVersion: 3 m_Convex: 0 m_CookingOptions: 14 diff --git a/Assets/Scenes/main.unity b/Assets/Scenes/main.unity index 7b7c20e..749d937 100644 --- a/Assets/Scenes/main.unity +++ b/Assets/Scenes/main.unity @@ -142,7 +142,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!54 &10774712 Rigidbody: m_ObjectHideFlags: 0 @@ -1873,8 +1873,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 1} m_AnchorMax: {x: 0.5, y: 1} - m_AnchoredPosition: {x: 0, y: -268} - m_SizeDelta: {x: 1267.4, y: 327.7} + m_AnchoredPosition: {x: -0.000030518, y: -77.1} + m_SizeDelta: {x: 1828, y: 154.2} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &697913066 MonoBehaviour: @@ -1903,7 +1903,7 @@ MonoBehaviour: m_BestFit: 0 m_MinSize: 0 m_MaxSize: 147 - m_Alignment: 1 + m_Alignment: 4 m_AlignByGeometry: 0 m_RichText: 1 m_HorizontalOverflow: 0 @@ -2625,10 +2625,11 @@ GameObject: - component: {fileID: 1228665501} - component: {fileID: 1228665503} - component: {fileID: 1228665505} + - component: {fileID: 1228665504} m_Layer: 0 m_Name: GameManager m_TagString: GameManager - m_Icon: {fileID: 0} + m_Icon: {fileID: 2800000, guid: 342a0f8aca7f4f0691338912faec0494, type: 3} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 @@ -2767,6 +2768,30 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 +--- !u!114 &1228665504 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1228665500} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4521a81efd1bf4242ae19ce6c321b40b, type: 3} + m_Name: + m_EditorClassIdentifier: + seconds: 3.9 + lockControls: 1 + tickSound: {fileID: 8300000, guid: 630669a9bc24ce44cb3639a85b517c6b, type: 3} + startSound: {fileID: 8300000, guid: 849a4835a1f3317429e69f659a969d6c, type: 3} + audioSource: {fileID: 1577603976} + enableOnZero: + - {fileID: 10774711} + disableOnZero: [] + finalText: Go! + finalTextScreentime: 0.5 + uiText: {fileID: 1577603977} + remaining: 0 --- !u!114 &1228665505 MonoBehaviour: m_ObjectHideFlags: 0 @@ -3242,6 +3267,7 @@ RectTransform: m_Children: - {fileID: 697913065} - {fileID: 1880081386} + - {fileID: 1577603975} m_Father: {fileID: 0} m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -3397,6 +3423,182 @@ MonoBehaviour: gm: {fileID: 0} playerNumber: 1 goalLight: {fileID: 740373801} +--- !u!1 &1577603974 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1577603975} + - component: {fileID: 1577603978} + - component: {fileID: 1577603977} + - component: {fileID: 1577603976} + m_Layer: 5 + m_Name: Countdown + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1577603975 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1577603974} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 2, y: 2, z: 2} + m_Children: [] + m_Father: {fileID: 1485996213} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0.00012207, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!82 &1577603976 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1577603974} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 0} + m_PlayOnAwake: 1 + 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!114 &1577603977 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1577603974} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 12800000, guid: 04fed28f55f61f54f91b5b7894fd42c0, type: 3} + m_FontSize: 300 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 0 + m_MaxSize: 300 + m_Alignment: 4 + m_AlignByGeometry: 1 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: '-' +--- !u!222 &1577603978 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1577603974} + m_CullTransparentMesh: 0 --- !u!1 &1657943311 GameObject: m_ObjectHideFlags: 0 @@ -3651,8 +3853,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} m_Name: m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Material: {fileID: 2100000, guid: 04fed28f55f61f54f91b5b7894fd42c0, type: 3} + m_Color: {r: 1, g: 0.95140254, b: 0, a: 1} m_RaycastTarget: 1 m_OnCullStateChanged: m_PersistentCalls: @@ -3660,19 +3862,19 @@ MonoBehaviour: m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 144 + m_Font: {fileID: 12800000, guid: 04fed28f55f61f54f91b5b7894fd42c0, type: 3} + m_FontSize: 216 m_FontStyle: 0 - m_BestFit: 0 + m_BestFit: 1 m_MinSize: 0 - m_MaxSize: 147 - m_Alignment: 1 + m_MaxSize: 300 + m_Alignment: 4 m_AlignByGeometry: 0 m_RichText: 1 m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 + m_VerticalOverflow: 1 m_LineSpacing: 1 - m_Text: _ Wins ! + m_Text: Player 0 won! --- !u!222 &1880081388 CanvasRenderer: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Countdown.cs b/Assets/Scripts/Countdown.cs new file mode 100644 index 0000000..d2184b8 --- /dev/null +++ b/Assets/Scripts/Countdown.cs @@ -0,0 +1,73 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class Countdown : MonoBehaviour +{ + + public float seconds = 3; + public bool lockControls = true; + public AudioClip tickSound; + public AudioClip startSound; + public AudioSource audioSource; + public GameObject[] enableOnZero; + public GameObject[] disableOnZero; + public string finalText = "Go!"; + public float finalTextScreentime = 0.5f; //How long should we display the final text + public Text uiText; + + public float remaining; + + // Start is called before the first frame update + void Start() + { + if (this.lockControls) + { + GameObject.FindGameObjectWithTag("GameManager").GetComponent().LockControls(this.seconds); + } + + this.remaining = this.seconds; + } + + // Update is called once per frame + void Update() + { + int second = (int)Mathf.Ceil(this.remaining); + this.UpdateText(second); + + + if(this.remaining <= 0) + { + this.ProcessGameObjects(this.enableOnZero, true); + this.ProcessGameObjects(this.disableOnZero, false); + } + + if(this.remaining <= -finalTextScreentime) + { + this.uiText.gameObject.SetActive(false); + this.enabled = false; + } + + this.remaining -= Time.deltaTime; + } + + private void UpdateText(int second) + { + string newText = this.remaining > 0 ? second.ToString() : this.finalText; + + if(newText != this.uiText.text) + { + this.uiText.text = newText; + this.audioSource.PlayOneShot(newText == this.finalText ? this.startSound : this.tickSound); + } + } + + private void ProcessGameObjects(GameObject[] objectList, bool enable) + { + for (int i = 0; i < objectList.Length; i++) + { + objectList[i].SetActive(enable); + } + } +} diff --git a/Assets/Scripts/Countdown.cs.meta b/Assets/Scripts/Countdown.cs.meta new file mode 100644 index 0000000..a8e828e --- /dev/null +++ b/Assets/Scripts/Countdown.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4521a81efd1bf4242ae19ce6c321b40b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index c86e485..38010aa 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -36,7 +36,7 @@ public class GameManager : MonoBehaviour private AudioSource audioSource; // Start is called before the first frame update - void Start() + void Awake() { this.players = GameObject.FindGameObjectsWithTag("Player"); this.initialPositions = new Vector3[this.players.Length]; @@ -71,14 +71,14 @@ public class GameManager : MonoBehaviour if (this.scorePlayer1 >= maxGoals) { - winLabel.text = "Player 1 wins the game!"; + winLabel.text = "Player 1 won!"; winLabel.transform.gameObject.SetActive(true); Time.timeScale = 0.0f; } if (this.scorePlayer2 >= maxGoals) { - winLabel.text = "Player 2 wins the game!"; + winLabel.text = "Player 2 won!"; winLabel.transform.gameObject.SetActive(true); Time.timeScale = 0.0f; } @@ -110,4 +110,12 @@ public class GameManager : MonoBehaviour this.ball.GetComponent().velocity = Vector3.zero; } + + public void LockControls(float duration) + { + for (int i = 0; i < this.players.Length; i++) + { + this.players[i].GetComponent().InputTimeout(duration); + } + } } diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 2e15d93..e50d36c 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -85,7 +85,6 @@ public class PlayerController : MonoBehaviour transform.Rotate(Vector3.up, -this.rotationSpeed * Time.deltaTime); } - Debug.Log(movementDirection); //Forward if (movementDirection != 0) { diff --git a/Assets/Sfx/selection.wav b/Assets/Sfx/selection.wav new file mode 100644 index 0000000..6dacb8e Binary files /dev/null and b/Assets/Sfx/selection.wav differ diff --git a/Assets/Sfx/selection.wav.meta b/Assets/Sfx/selection.wav.meta new file mode 100644 index 0000000..201e4b1 --- /dev/null +++ b/Assets/Sfx/selection.wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: e75abec2b09871a429a53346b4579798 +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sfx/tick.wav b/Assets/Sfx/tick.wav new file mode 100644 index 0000000..af4be8c Binary files /dev/null and b/Assets/Sfx/tick.wav differ diff --git a/Assets/Sfx/tick.wav.meta b/Assets/Sfx/tick.wav.meta new file mode 100644 index 0000000..63cff91 --- /dev/null +++ b/Assets/Sfx/tick.wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: 630669a9bc24ce44cb3639a85b517c6b +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sfx/tick_go.wav b/Assets/Sfx/tick_go.wav new file mode 100644 index 0000000..c40bb23 Binary files /dev/null and b/Assets/Sfx/tick_go.wav differ diff --git a/Assets/Sfx/tick_go.wav.meta b/Assets/Sfx/tick_go.wav.meta new file mode 100644 index 0000000..b230b27 --- /dev/null +++ b/Assets/Sfx/tick_go.wav.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: 849a4835a1f3317429e69f659a969d6c +AudioImporter: + externalObjects: {} + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 3b90199..7528ec9 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -51,7 +51,7 @@ PlayerSettings: m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 m_MTRendering: 1 - m_StackTraceTypes: 000000000000000000000000000000000000000001000000 + m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 displayResolutionDialog: 0