Scoring and stuff.

This commit is contained in:
Khauvinkh 2024-08-18 18:42:01 +02:00
parent 1946669e64
commit 5bcc96a4a0
17 changed files with 587 additions and 42 deletions

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6e7e8ae76ff1c5b4aab543fbaebcbac6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 8c21db8e71083614d9ac3d0a2806ea4e
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: cf1261045ab6d8242adafc4270a58783
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 92b52ec8a69551746943394b818ffeb8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 65221132d7bd4e79856cce65eeb5ce58, type: 3}
m_Name: Level 1
m_EditorClassIdentifier:
Stage: 1
Quotas:
- Type: {fileID: 11400000, guid: 42240b227563f074aa0dd8fee3c0cb35, type: 2}
Quantity: 10
TimeLimit: 60
MaxDefectivePercentage: 100
SuccessMessage: Great job!
FailureMessage: Try again!

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b1326e0e514393547971198daa612d49
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,88 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2691121107702918304
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6124643934757847502}
- component: {fileID: 1803345453588852622}
- component: {fileID: 2049186239399771702}
m_Layer: 0
m_Name: Cube (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6124643934757847502
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2691121107702918304}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.75, y: 0.1875, z: -1.125}
m_LocalScale: {x: 2.75, y: 1.625, z: 0.25}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6238139087991197689}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1803345453588852622
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2691121107702918304}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &2049186239399771702
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2691121107702918304}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &3300142079730169062
GameObject:
m_ObjectHideFlags: 0
@ -97,6 +180,89 @@ MonoBehaviour:
x: 0
y: 0
z: 0
--- !u!1 &4146203376468199520
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4748086957800454890}
- component: {fileID: 7569872471742462254}
- component: {fileID: 2056203298572318800}
m_Layer: 0
m_Name: Cube (2)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4748086957800454890
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4146203376468199520}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.8125, y: 0.1875, z: 0}
m_LocalScale: {x: 0.3751, y: 1.625, z: 2}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6238139087991197689}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &7569872471742462254
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4146203376468199520}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &2056203298572318800
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4146203376468199520}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &5578451197856738425
GameObject:
m_ObjectHideFlags: 0
@ -128,6 +294,9 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 29782541997105855}
- {fileID: 6124643934757847502}
- {fileID: 4748086957800454890}
- {fileID: 7524344916720894899}
- {fileID: 1037217556386504287}
- {fileID: 8893193092501905694}
m_Father: {fileID: 0}
@ -160,6 +329,89 @@ MonoBehaviour:
x: 0
y: 0
z: 0
--- !u!1 &8709015778225462089
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7524344916720894899}
- component: {fileID: 1582601958366311740}
- component: {fileID: 3143886536820141369}
m_Layer: 0
m_Name: Cube (3)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7524344916720894899
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8709015778225462089}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.5625, y: 1.1110001, z: 0}
m_LocalScale: {x: 3.125108, y: 0.25, z: 2}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6238139087991197689}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1582601958366311740
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8709015778225462089}
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &3143886536820141369
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8709015778225462089}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &9029570661290360059
GameObject:
m_ObjectHideFlags: 0
@ -187,8 +439,8 @@ Transform:
m_GameObject: {fileID: 9029570661290360059}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.75, y: 0, z: 0}
m_LocalScale: {x: 2.75, y: 1.25, z: 1.25}
m_LocalPosition: {x: 0.75, y: 0.1875, z: 1.125}
m_LocalScale: {x: 2.75, y: 1.625, z: 0.25}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 6238139087991197689}
@ -261,19 +513,19 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7314620182520817234, guid: 2309dc97898f5884fbb87ba691f13d1b, type: 3}
propertyPath: m_LocalScale.y
value: 0.75
value: 0.6961451
objectReference: {fileID: 0}
- target: {fileID: 7314620182520817234, guid: 2309dc97898f5884fbb87ba691f13d1b, type: 3}
propertyPath: m_LocalPosition.x
value: 2.3000002
value: 2.078
objectReference: {fileID: 0}
- target: {fileID: 7314620182520817234, guid: 2309dc97898f5884fbb87ba691f13d1b, type: 3}
propertyPath: m_LocalPosition.y
value: 0.318
value: 0.26
objectReference: {fileID: 0}
- target: {fileID: 7314620182520817234, guid: 2309dc97898f5884fbb87ba691f13d1b, type: 3}
propertyPath: m_LocalPosition.z
value: -0.020006057
value: -0.02
objectReference: {fileID: 0}
- target: {fileID: 7314620182520817234, guid: 2309dc97898f5884fbb87ba691f13d1b, type: 3}
propertyPath: m_LocalRotation.w

View File

@ -144,7 +144,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4626647624635935874, guid: 52253a366fba6644b8983c5cf7fbfc9f, type: 3}
propertyPath: m_LocalPosition.x
value: -1.875
value: -0.875
objectReference: {fileID: 0}
- target: {fileID: 4626647624635935874, guid: 52253a366fba6644b8983c5cf7fbfc9f, type: 3}
propertyPath: m_LocalPosition.y
@ -826,6 +826,52 @@ MonoBehaviour:
throwKey: 102
examineKey: 101
placeKey: 116
--- !u!1 &721670237
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 721670239}
- component: {fileID: 721670238}
m_Layer: 0
m_Name: Scoreboard
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &721670238
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 721670237}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 49f7d9fae60a4082a271f0a2fa185f79, type: 3}
m_Name:
m_EditorClassIdentifier:
CurrentObjective: {fileID: 11400000, guid: b1326e0e514393547971198daa612d49, type: 2}
_timeLeft: 0
--- !u!4 &721670239
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 721670237}
serializedVersion: 2
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: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &969068469
GameObject:
m_ObjectHideFlags: 0
@ -1412,6 +1458,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 892330fb84d24d79b298b2fa65e8e92f, type: 3}
m_Name:
m_EditorClassIdentifier:
Objectives: []
CurrentStage: 0
--- !u!4 &1503113266
Transform:
@ -1597,7 +1644,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7806859308007633956, guid: 77ee7ec75f83819418bba995d0824dc4, type: 3}
propertyPath: m_LocalPosition.x
value: -1.875
value: -0.875
objectReference: {fileID: 0}
- target: {fileID: 7806859308007633956, guid: 77ee7ec75f83819418bba995d0824dc4, type: 3}
propertyPath: m_LocalPosition.y
@ -1670,7 +1717,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7806859308007633956, guid: 77ee7ec75f83819418bba995d0824dc4, type: 3}
propertyPath: m_LocalPosition.x
value: -1.875
value: -0.875
objectReference: {fileID: 0}
- target: {fileID: 7806859308007633956, guid: 77ee7ec75f83819418bba995d0824dc4, type: 3}
propertyPath: m_LocalPosition.y
@ -1815,10 +1862,6 @@ PrefabInstance:
propertyPath: m_Name
value: Product Receiver
objectReference: {fileID: 0}
- target: {fileID: 5578451197856738425, guid: b5bb2f074e9e2c04baf833ea6393a1f6, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 6238139087991197689, guid: b5bb2f074e9e2c04baf833ea6393a1f6, type: 3}
propertyPath: m_LocalPosition.x
value: -6.5
@ -1876,6 +1919,14 @@ PrefabInstance:
propertyPath: m_Name
value: Product Spawner
objectReference: {fileID: 0}
- target: {fileID: 6186656074767359943, guid: a3cb7267f99421c4b9912896d1eb7a41, type: 3}
propertyPath: ProductionPhases.Array.data[0].Duration
value: 40
objectReference: {fileID: 0}
- target: {fileID: 6186656074767359943, guid: a3cb7267f99421c4b9912896d1eb7a41, type: 3}
propertyPath: ProductionPhases.Array.data[0].TotalSpawnCount
value: 15
objectReference: {fileID: 0}
- target: {fileID: 9072778288000056937, guid: a3cb7267f99421c4b9912896d1eb7a41, type: 3}
propertyPath: m_LocalPosition.x
value: 3.25
@ -1938,3 +1989,4 @@ SceneRoots:
- {fileID: 24716034}
- {fileID: 1736605487}
- {fileID: 164936391}
- {fileID: 721670239}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CreateAssetMenu(fileName = "New Level Objective", menuName = "Data/Level Objective", order = 0)]
public class LevelObjective : ScriptableObject
{
public StagingManager.StageEnum Stage;
[Serializable]
public struct ProductQuota
{
public ProductType Type;
public int Quantity;
}
public List<ProductQuota> Quotas;
public float TimeLimit;
[Range(0, 100)]
public int MaxDefectivePercentage;
[TextArea]
public string SuccessMessage;
[TextArea]
public string FailureMessage;
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 65221132d7bd4e79856cce65eeb5ce58
timeCreated: 1723996942

View File

@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class Scoreboard: MonoBehaviour
{
public static Scoreboard Instance;
public LevelObjective CurrentObjective;
public Dictionary<ProductType, Vector2Int> ProductCounts = new ();
public float _timeLeft;
public bool _running;
public void Start()
{
if (!Instance)
{
Instance = this;
}
_running = true;
SetObjective(CurrentObjective);
}
public void SetObjective(LevelObjective objective)
{
CurrentObjective = objective;
ProductCounts = new();
_timeLeft = objective.TimeLimit;
}
public void ScoreProduct(Product product)
{
if (!ProductCounts.ContainsKey(product.Type))
{
ProductCounts[product.Type] = new Vector2Int();
}
var currentCount = ProductCounts[product.Type];
if (product.Defect == DefectType.None)
{
currentCount.x++;
}
else
{
currentCount.y++;
}
ProductCounts[product.Type] = currentCount;
}
private int TotalCount(ProductType type)
{
return ProductCounts[type].x + ProductCounts[type].y;
}
private int DefectPercentage(ProductType type)
{
if (TotalCount(type) == 0)
{
return 0;
}
return 100 * ProductCounts[type].y / TotalCount(type);
}
private void Update()
{
if (!_running)
{
return;
}
_timeLeft -= Time.deltaTime;
Debug.Log(_timeLeft);
if (_timeLeft <= 0)
{
CountScores();
_running = false;
}
}
public void CountScores()
{
bool success = true;
foreach (var quota in CurrentObjective.Quotas)
{
if (quota.Quantity > TotalCount(quota.Type))
{
success = false;
Debug.LogError($"Not enough {quota.Type.name}");
break;
}
Debug.Log($"{quota.Type.name}: {TotalCount(quota.Type)}/{quota.Quantity}");
if (CurrentObjective.MaxDefectivePercentage < DefectPercentage(quota.Type))
{
success = false;
Debug.LogError($"Too many broken {quota.Type.name}");
break;
}
Debug.Log($"{quota.Type.name}: Quality level: {DefectPercentage(quota.Type)}%");
}
Debug.Log(success? CurrentObjective.SuccessMessage : CurrentObjective.FailureMessage);
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 49f7d9fae60a4082a271f0a2fa185f79
timeCreated: 1723996883

View File

@ -8,6 +8,8 @@ public class StagingManager: MonoBehaviour
public static StagingManager Instance;
public static List<StageProp> StageProps;
public List<LevelObjective> Objectives;
public StageEnum CurrentStage;
[Flags]
@ -63,13 +65,17 @@ public class StagingManager: MonoBehaviour
}
}
#if UNITY_EDITOR
[MenuItem("Tools/Staging/Level1")]
#endif
public static void SetStage1()
{
SetStage(StageEnum.Level1);
}
#if UNITY_EDITOR
[MenuItem("Tools/Staging/Level2")]
#endif
public static void SetStage2()
{
SetStage(StageEnum.Level2);

View File

@ -6,7 +6,6 @@ using quaternion = Unity.Mathematics.quaternion;
public static class Grid
{
public static float CellSize = 0.25f;
public static float HalfCellSize => CellSize / 2;

View File

@ -5,39 +5,36 @@ using static Unity.Mathematics.math;
using static Grid;
using Color = UnityEngine.Color;
#if UNITY_EDITOR
[ExecuteAlways]
[SelectionBase]
[DisallowMultipleComponent]
public class GridUnit : MonoBehaviour
{
public int3 Size = new (1, 1, 1);
private Vector3 SizeInMeters => new (Size.x * CellSize, Size.y * CellSize, Size.z * CellSize);
public int3 Size = new(1, 1, 1);
private Vector3 SizeInMeters => new(Size.x * CellSize, Size.y * CellSize, Size.z * CellSize);
public float3 CenterOffset;
[SerializeField, HideInInspector]
private int3 cachedSize = new (1, 1, 1);
[SerializeField, HideInInspector]
private float3 cachedOffset;
private bool isDirty => transform.hasChanged ||
!all(cachedOffset != CenterOffset) ||
[SerializeField, HideInInspector] private int3 cachedSize = new(1, 1, 1);
[SerializeField, HideInInspector] private float3 cachedOffset;
private bool isDirty => transform.hasChanged ||
!all(cachedOffset != CenterOffset) ||
!all(cachedSize == Size);
#if UNITY_EDITOR
public void Update()
{
if (!isDirty)
{
return;
}
SnapUnit(transform, Size, CenterOffset);
transform.hasChanged = false;
cachedOffset = CenterOffset;
cachedSize = Size;
}
@ -48,11 +45,10 @@ public class GridUnit : MonoBehaviour
Transform t = unit.transform;
quaternion rotation = t.rotation;
var position = (float3)t.position + mul(rotation, unit.CenterOffset);
Gizmos.color = Color.white;
Gizmos.matrix = Matrix4x4.TRS(position, rotation, Vector3.one);
Gizmos.DrawWireCube(Vector3.zero, unit.SizeInMeters);
}
}
#endif
}

View File

@ -15,14 +15,7 @@ public class ProductReceiver : MonoBehaviour
if (product != null)
{
if (product.Defect != DefectType.None)
{
defectiveProductCount++;
}
else
{
normalProductCount++;
}
Scoreboard.Instance.ScoreProduct(product);
Destroy(product.gameObject);
}

View File

@ -4,5 +4,8 @@
EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes: []
m_Scenes:
- enabled: 1
path: Assets/Scenes/Main.unity
guid: 12264ad5f5014704f852121ae907d689
m_configObjects: {}