Add ui controller

fix duplicate gameControllers
This commit is contained in:
Soulaha Balde 2022-10-29 17:38:12 -04:00
parent 7e32d6c205
commit 830e8220d0
9 changed files with 2324 additions and 1821 deletions

View File

@ -1,5 +1,88 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!1 &1829324947821761427
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1679323109552408359}
- component: {fileID: 9084314980681338242}
- component: {fileID: 9067677296112434199}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1679323109552408359
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1829324947821761427}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2391504647050640505}
m_Father: {fileID: 4515361964050757684}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!223 &9084314980681338242
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1829324947821761427}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 0
m_SortingLayerID: 0
m_SortingOrder: 100
m_TargetDisplay: 0
--- !u!114 &9067677296112434199
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1829324947821761427}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!1 &4515361964050757686 --- !u!1 &4515361964050757686
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -28,7 +111,8 @@ Transform:
m_LocalPosition: {x: -6.887238, y: -1.6704996, z: -7.8771486} m_LocalPosition: {x: -6.887238, y: -1.6704996, z: -7.8771486}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children:
- {fileID: 1679323109552408359}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -47,3 +131,81 @@ MonoBehaviour:
startScene: MainMenu startScene: MainMenu
mainScene: LevelDesign mainScene: LevelDesign
endScene: ThanksScene endScene: ThanksScene
fadeSpeed: 2.5
fadeImg: {fileID: 3902665078773332606}
--- !u!1 &5180033606312474289
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2391504647050640505}
- component: {fileID: 1761860175039081855}
- component: {fileID: 3902665078773332606}
m_Layer: 5
m_Name: FadeToBlack
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2391504647050640505
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5180033606312474289}
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1679323109552408359}
m_RootOrder: 0
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, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &1761860175039081855
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5180033606312474289}
m_CullTransparentMesh: 1
--- !u!114 &3902665078773332606
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5180033606312474289}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 0}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1

View File

@ -0,0 +1,115 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3809469071693447799
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3809469071693447787}
- component: {fileID: 3809469071693447796}
- component: {fileID: 3809469071693447797}
- component: {fileID: 3809469071693447798}
- component: {fileID: 3809469071693447786}
m_Layer: 5
m_Name: Main Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &3809469071693447787
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3809469071693447799}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!223 &3809469071693447796
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3809469071693447799}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 1
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!114 &3809469071693447797
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3809469071693447799}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 320, y: 240}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 0
--- !u!114 &3809469071693447798
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3809469071693447799}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &3809469071693447786
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3809469071693447799}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 06cd37efca880db4c897922a3b05a3d9, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6aef2419a46abbf498f5297fc906f3b4
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -217,13 +217,82 @@ RectTransform:
m_Children: m_Children:
- {fileID: 1301531513} - {fileID: 1301531513}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0} m_Pivot: {x: 0, y: 0}
--- !u!1001 &104308487
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 650814744680764505, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_Name
value: Endzone
objectReference: {fileID: 0}
- target: {fileID: 650814744680764510, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 650814744680764510, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_LocalPosition.x
value: 76.06
objectReference: {fileID: 0}
- target: {fileID: 650814744680764510, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_LocalPosition.y
value: 53.11
objectReference: {fileID: 0}
- target: {fileID: 650814744680764510, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_LocalPosition.z
value: 0.55
objectReference: {fileID: 0}
- target: {fileID: 650814744680764510, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 650814744680764510, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 650814744680764510, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 650814744680764510, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 650814744680764510, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 650814744680764510, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 650814744680764510, guid: 3d836690c7327d943babcec93a3c1244,
type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3d836690c7327d943babcec93a3c1244, type: 3}
--- !u!1 &644286413 --- !u!1 &644286413
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -300,7 +369,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 8 m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &646434019 --- !u!1 &646434019
GameObject: GameObject:
@ -368,7 +437,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &921826478 --- !u!1 &921826478
GameObject: GameObject:
@ -463,7 +532,7 @@ Transform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!114 &921826481 --- !u!114 &921826481
MonoBehaviour: MonoBehaviour:
@ -856,7 +925,7 @@ Transform:
m_Children: m_Children:
- {fileID: 1866383021} - {fileID: 1866383021}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 1 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &739494758409349680 --- !u!1001 &739494758409349680
PrefabInstance: PrefabInstance:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,12 +2,18 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameController : MonoBehaviour public class GameController : MonoBehaviour
{ {
private static GameController instance; private static GameController instance;
[SerializeField] [SerializeField]
private string startScene, mainScene, endScene; private string startScene, mainScene, endScene;
[SerializeField]
private float fadeSpeed;
[SerializeField]
private Image fadeImg;
private Coroutine fadeCoroutine;
public static GameController Instance{ public static GameController Instance{
get{ get{
if(instance is null)Debug.LogError("Game controller is null"); if(instance is null)Debug.LogError("Game controller is null");
@ -16,28 +22,62 @@ public class GameController : MonoBehaviour
} }
private void Awake() { private void Awake() {
if(GameController.Instance is null){
instance = this; instance = this;
DontDestroyOnLoad(this.gameObject); DontDestroyOnLoad(this.gameObject);
SceneManager.activeSceneChanged += ChangedScene;
}else{
Destroy(this.gameObject);
} }
}
public void StartGame(){ public void StartGame(){
SceneManager.LoadScene(mainScene); fadeCoroutine = StartCoroutine(FadeToBlack(mainScene, true,fadeSpeed));
} }
public void EndGame(){ public void EndGame(){
Debug.Log("Game is over"); Debug.Log("Game is over");
SceneManager.LoadScene(endScene); fadeCoroutine = StartCoroutine(FadeToBlack(endScene, true,fadeSpeed));
} }
public void QuitGame(){ public void QuitGame(){
//fadeCoroutine = StartCoroutine(FadeToBlack(true,fadeTimer));
Application.Quit(); Application.Quit();
} }
public void Options(){ public void Options(){
//fadeCoroutine = StartCoroutine(FadeToBlack(true,fadeTimer));
Debug.Log("Clicked options"); Debug.Log("Clicked options");
} }
public void MainMenu(){ public void MainMenu(){
SceneManager.LoadScene(startScene); fadeCoroutine = StartCoroutine(FadeToBlack(startScene, true,fadeSpeed));
}
private void ChangedScene(Scene curr, Scene next){
fadeCoroutine = StartCoroutine(FadeToBlack(string.Empty, false, fadeSpeed));
}
public IEnumerator FadeToBlack(string sceneToLoad,bool fadeToBlack = true, float fadeSpeed = 2.5f){
Color imgColor = fadeImg.color;
float fadeAmount;
if(fadeToBlack){
while(fadeImg.color.a < 1){
fadeAmount = imgColor.a + (fadeSpeed * Time.deltaTime);
imgColor = new Color(imgColor.r, imgColor.g, imgColor.b, fadeAmount);
fadeImg.color = imgColor;
yield return null;
}
SceneManager.LoadScene(sceneToLoad);
}else{
while(fadeImg.color.a > 0){
fadeAmount = imgColor.a - (fadeSpeed * Time.deltaTime);
imgColor = new Color(imgColor.r, imgColor.g, imgColor.b, fadeAmount);
fadeImg.color = imgColor;
yield return null;
}
}
} }
} }

View File

@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UIController : MonoBehaviour
{
public void StartGame(){
GameController.Instance.StartGame();
}
public void EndGame(){
GameController.Instance.EndGame();
}
public void QuitGame(){
GameController.Instance.QuitGame();
}
public void Options(){
GameController.Instance.Options();
}
public void MainMenu(){
GameController.Instance.MainMenu();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 06cd37efca880db4c897922a3b05a3d9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: