KeepAway updates + GameTimer
This commit is contained in:
@@ -334,6 +334,7 @@ GameObject:
|
||||
- component: {fileID: 444980833}
|
||||
- component: {fileID: 444980836}
|
||||
- component: {fileID: 444980837}
|
||||
- component: {fileID: 444980838}
|
||||
m_Layer: 0
|
||||
m_Name: Hat
|
||||
m_TagString: Hat
|
||||
@@ -497,6 +498,18 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 1803a208ca94f44a189bf03342859d36, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &444980838
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 444980832}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 34a52816a1c62984ea622bbf50849c68, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &612903695
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -645,6 +658,170 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 5794044177371189323, guid: 5ce441c5fe33344a292ef80ef22aaffd, type: 3}
|
||||
m_PrefabInstance: {fileID: 770973616}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &778700331
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 778700332}
|
||||
- component: {fileID: 778700335}
|
||||
- component: {fileID: 778700334}
|
||||
- component: {fileID: 778700333}
|
||||
- component: {fileID: 778700336}
|
||||
m_Layer: 5
|
||||
m_Name: Timer
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &778700332
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 778700331}
|
||||
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: 1994359917}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: -50}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 504, y: 18180}
|
||||
m_SizeDelta: {x: -808, y: -36310}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &778700333
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 778700331}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 012d92d911650b340a4561288484ac28, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
startTime: 180
|
||||
timerText: {fileID: 0}
|
||||
--- !u!114 &778700334
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 778700331}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text:
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_StyleSheet: {fileID: 0}
|
||||
m_TextStyleHashCode: -1183493901
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 36
|
||||
m_fontSizeBase: 36
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 1
|
||||
m_VerticalAlignment: 256
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_TextWrappingMode: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 0
|
||||
m_ActiveFontFeatures: 6e72656b
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_EmojiFallbackSupport: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_IsTextObjectScaleStatic: 0
|
||||
m_VertexBufferAutoSizeReduction: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!222 &778700335
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 778700331}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &778700336
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 778700331}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 34a52816a1c62984ea622bbf50849c68, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &854334842
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1284,63 +1461,6 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &1524919192
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 1375850422501237868, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Bones
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7009259675412950971, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: -2.16
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7009259675412950971, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 14.08
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7009259675412950971, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7009259675412950971, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7009259675412950971, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7009259675412950971, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7009259675412950971, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7009259675412950971, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7009259675412950971, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7009259675412950971, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 1fd31b88e5609482ab7e8ab16a932947, type: 3}
|
||||
--- !u!1001 &1639418690
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4786,6 +4906,108 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 3568111229033857730, guid: fb6bfed040258479fb90fbbe9d408cc1, type: 3}
|
||||
m_PrefabInstance: {fileID: 1919996324}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &1994359916
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1994359917}
|
||||
- component: {fileID: 1994359920}
|
||||
- component: {fileID: 1994359919}
|
||||
- component: {fileID: 1994359918}
|
||||
m_Layer: 5
|
||||
m_Name: TimerCanvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1994359917
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1994359916}
|
||||
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: 778700332}
|
||||
m_Father: {fileID: 6442071445436727403}
|
||||
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!114 &1994359918
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1994359916}
|
||||
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 &1994359919
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1994359916}
|
||||
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!223 &1994359920
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1994359916}
|
||||
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_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 1000
|
||||
m_TargetDisplay: 0
|
||||
--- !u!1 &2119246462
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4901,11 +5123,23 @@ PrefabInstance:
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8079215911535814924, guid: e3c570bb90d434e809aca2a339dadf5d, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: HealthCanvas
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedGameObjects:
|
||||
- targetCorrespondingSourceObject: {fileID: 7676803003410367555, guid: e3c570bb90d434e809aca2a339dadf5d, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1994359917}
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: e3c570bb90d434e809aca2a339dadf5d, type: 3}
|
||||
--- !u!4 &6442071445436727403 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 7676803003410367555, guid: e3c570bb90d434e809aca2a339dadf5d, type: 3}
|
||||
m_PrefabInstance: {fileID: 6442071445436727402}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &8682934954266721942
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -5011,5 +5245,4 @@ SceneRoots:
|
||||
- {fileID: 1639418690}
|
||||
- {fileID: 421411299}
|
||||
- {fileID: 854334845}
|
||||
- {fileID: 1524919192}
|
||||
- {fileID: 444980835}
|
||||
|
||||
@@ -259,10 +259,22 @@ PrefabInstance:
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6251332657995178420, guid: 52622bff9e983494eb206a8735b4dbbf, type: 3}
|
||||
propertyPath: m_Interactable
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7361983102188735562, guid: 52622bff9e983494eb206a8735b4dbbf, type: 3}
|
||||
propertyPath: m_IsOn
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7581121400164956810, guid: 52622bff9e983494eb206a8735b4dbbf, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Player Select
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8309701520800111017, guid: 52622bff9e983494eb206a8735b4dbbf, type: 3}
|
||||
propertyPath: m_IsOn
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8640926751425774204, guid: 52622bff9e983494eb206a8735b4dbbf, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 1012
|
||||
|
||||
@@ -7,7 +7,6 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
public static GameManager Instance { get; private set; }
|
||||
public int maxLives = 3;
|
||||
public int currentLives;
|
||||
public delegate void GameEvent();
|
||||
public event GameEvent StartGameEvent;
|
||||
public event GameEvent EndGameEvent;
|
||||
@@ -18,6 +17,8 @@ public class GameManager : MonoBehaviour
|
||||
public static bool music = true;
|
||||
|
||||
public bool gameOver = false;
|
||||
public GameTimer gameTimer;
|
||||
public static Dictionary<GameObject, float> playerHoldTimes = new Dictionary<GameObject, float>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -39,6 +40,7 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
public void StartGame()
|
||||
{
|
||||
GameManager.playerHoldTimes.Clear();
|
||||
if (GameManager.players.Count == 0) return;
|
||||
|
||||
StartGameEvent?.Invoke();
|
||||
@@ -53,7 +55,7 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
if (gameMode == GameMode.keepAway)
|
||||
{
|
||||
currentLives = 1;
|
||||
gameTimer.StartTimer();
|
||||
foreach (GameObject player in players)
|
||||
{
|
||||
player.transform.position = spawnPosition;
|
||||
@@ -62,7 +64,6 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
if (gameMode == GameMode.obstacleCourse)
|
||||
{
|
||||
currentLives = 1;
|
||||
foreach (GameObject player in players)
|
||||
{
|
||||
player.transform.position = spawnPosition;
|
||||
@@ -121,14 +122,37 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void GameOver()
|
||||
public void GameOver()
|
||||
{
|
||||
gameOver = true;
|
||||
EndGameEvent?.Invoke();
|
||||
print(AlivePlayers()[0].name + " is the winner");
|
||||
FindFirstObjectByType<PlayerCameraMovement>().WinScene(AlivePlayers()[0]);
|
||||
WinScreen.Instance.ShowWinScreen(players.IndexOf(AlivePlayers()[0]) + 1);
|
||||
FindFirstObjectByType<LifeDisplayManager>().HideLifeDisplay();
|
||||
if (gameMode == GameMode.freeForAll)
|
||||
{
|
||||
print(AlivePlayers()[0].name + " is the winner");
|
||||
FindFirstObjectByType<PlayerCameraMovement>().WinScene(AlivePlayers()[0]);
|
||||
WinScreen.Instance.ShowWinScreen(players.IndexOf(AlivePlayers()[0]) + 1);
|
||||
FindFirstObjectByType<LifeDisplayManager>().HideLifeDisplay();
|
||||
}
|
||||
if (gameMode == GameMode.keepAway)
|
||||
{
|
||||
GameObject winner = null;
|
||||
float maxHoldTime = 0f;
|
||||
foreach (var player in GameManager.playerHoldTimes)
|
||||
{
|
||||
if (player.Value > maxHoldTime)
|
||||
{
|
||||
maxHoldTime = player.Value;
|
||||
winner = player.Key;
|
||||
}
|
||||
}
|
||||
if (winner != null)
|
||||
{
|
||||
print(winner.name + " is the winner with " + maxHoldTime + " seconds!");
|
||||
FindFirstObjectByType<PlayerCameraMovement>().WinScene(winner);
|
||||
WinScreen.Instance.ShowWinScreen(players.IndexOf(winner) + 1);
|
||||
FindFirstObjectByType<LifeDisplayManager>().HideLifeDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<GameObject> AlivePlayers()
|
||||
@@ -142,4 +166,12 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
return alivePlayers;
|
||||
}
|
||||
|
||||
public void UpdateLeaderboard()
|
||||
{
|
||||
List<KeyValuePair<GameObject, float>> sortedList =
|
||||
new List<KeyValuePair<GameObject, float>>(playerHoldTimes);
|
||||
sortedList.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
56
Assets/Scripts/GameTimer.cs
Normal file
56
Assets/Scripts/GameTimer.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GameTimer : MonoBehaviour
|
||||
{
|
||||
public float startTime = 180f;
|
||||
private float timeRemaining;
|
||||
private bool timerRunning = false;
|
||||
|
||||
public Text timerText;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
timeRemaining = startTime;
|
||||
UpdateTimerDisplay();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (timerRunning)
|
||||
{
|
||||
timeRemaining -= Time.deltaTime;
|
||||
|
||||
if (timeRemaining <= 0)
|
||||
{
|
||||
timeRemaining = 0;
|
||||
timerRunning = false;
|
||||
OnTimerEnd();
|
||||
}
|
||||
|
||||
UpdateTimerDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
public void StartTimer()
|
||||
{
|
||||
if (!timerRunning)
|
||||
{
|
||||
timeRemaining = startTime;
|
||||
timerRunning = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTimerDisplay()
|
||||
{
|
||||
int minutes = Mathf.FloorToInt(timeRemaining / 60);
|
||||
int seconds = Mathf.FloorToInt(timeRemaining % 60);
|
||||
timerText.text = string.Format("{0:D2}:{1:D2}", minutes, seconds);
|
||||
}
|
||||
|
||||
private void OnTimerEnd()
|
||||
{
|
||||
Debug.Log("Timer ended! KeepAway mode has finished.");
|
||||
GameManager.Instance.GameOver();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/GameTimer.cs.meta
Normal file
2
Assets/Scripts/GameTimer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 012d92d911650b340a4561288484ac28
|
||||
@@ -12,19 +12,20 @@ public class LifeDisplayManager : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
foreach (GameObject player in GameManager.players)
|
||||
if (GameManager.gameMode == GameManager.GameMode.freeForAll)
|
||||
{
|
||||
Transform parent = Instantiate(playerPrefab, players.transform).transform;
|
||||
|
||||
List<GameObject> lives = new List<GameObject>();
|
||||
for (int i = 0; i < player.GetComponent<Damageable>().lives; i++)
|
||||
foreach (GameObject player in GameManager.players)
|
||||
{
|
||||
GameObject life = Instantiate(lifePrefab, parent);
|
||||
life.GetComponentInChildren<Image>().color = GameManager.playerColors[GameManager.players.IndexOf(player)];
|
||||
lives.Add(life);
|
||||
Transform parent = Instantiate(playerPrefab, players.transform).transform;
|
||||
List<GameObject> lives = new List<GameObject>();
|
||||
for (int i = 0; i < player.GetComponent<Damageable>().lives; i++)
|
||||
{
|
||||
GameObject life = Instantiate(lifePrefab, parent);
|
||||
life.GetComponentInChildren<Image>().color = GameManager.playerColors[GameManager.players.IndexOf(player)];
|
||||
lives.Add(life);
|
||||
}
|
||||
lifeDisplays.Add(player.GetComponent<Damageable>(), lives);
|
||||
}
|
||||
|
||||
lifeDisplays.Add(player.GetComponent<Damageable>(), lives);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
26
Assets/Scripts/ObjectVisibility.cs
Normal file
26
Assets/Scripts/ObjectVisibility.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ObjectVisibility : MonoBehaviour
|
||||
{
|
||||
void Start()
|
||||
{
|
||||
UpdateVisibility();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
UpdateVisibility();
|
||||
}
|
||||
|
||||
private void UpdateVisibility()
|
||||
{
|
||||
if (GameManager.gameMode == GameManager.GameMode.keepAway)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/ObjectVisibility.cs.meta
Normal file
2
Assets/Scripts/ObjectVisibility.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34a52816a1c62984ea622bbf50849c68
|
||||
@@ -5,12 +5,24 @@ public class UseItem : MonoBehaviour
|
||||
[SerializeField] private string itemTag;
|
||||
private GameObject heldItem;
|
||||
private bool isHoldingItem = false;
|
||||
private float holdStartTime;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (isHoldingItem)
|
||||
{
|
||||
heldItem.transform.position = transform.position + Vector3.up;
|
||||
if (GameManager.gameMode == GameManager.GameMode.keepAway)
|
||||
{
|
||||
if (GameManager.playerHoldTimes.ContainsKey(gameObject))
|
||||
{
|
||||
GameManager.playerHoldTimes[gameObject] += Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.playerHoldTimes[gameObject] = Time.time - holdStartTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +38,14 @@ public class UseItem : MonoBehaviour
|
||||
{
|
||||
heldItem = item;
|
||||
isHoldingItem = true;
|
||||
holdStartTime = Time.time;
|
||||
item.GetComponent<Collider2D>().enabled = false;
|
||||
item.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Static;
|
||||
item.transform.rotation = Quaternion.identity;
|
||||
if (!GameManager.playerHoldTimes.ContainsKey(gameObject))
|
||||
{
|
||||
GameManager.playerHoldTimes[gameObject] = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void DropItem()
|
||||
@@ -40,6 +57,10 @@ public class UseItem : MonoBehaviour
|
||||
heldItem.transform.position += Vector3.up * 3f;
|
||||
heldItem = null;
|
||||
isHoldingItem = false;
|
||||
if (GameManager.playerHoldTimes.ContainsKey(gameObject))
|
||||
{
|
||||
GameManager.playerHoldTimes.Remove(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user