From c99febd2219c055b9ca23e8cd697e76ee1246a28 Mon Sep 17 00:00:00 2001 From: Joao Coelho Date: Thu, 11 Aug 2022 16:25:05 +0100 Subject: [PATCH 1/2] redo and undo twice --- .../Rebind keys/Scripts/GameController.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Assets/Patterns/1. Command/Rebind keys/Scripts/GameController.cs b/Assets/Patterns/1. Command/Rebind keys/Scripts/GameController.cs index 127037b..37ed062 100644 --- a/Assets/Patterns/1. Command/Rebind keys/Scripts/GameController.cs +++ b/Assets/Patterns/1. Command/Rebind keys/Scripts/GameController.cs @@ -94,6 +94,23 @@ void Update() redoCommands.Push(lastCommand); } } + //Undo with Q + else if (Input.GetKeyDown(KeyCode.Q)) + { + if (undoCommands.Count < 2) + { + Debug.Log("Can't undo twice because we are back where we started or there is only one undo command"); + } + else + { + Command lastCommand = undoCommands.Pop(); + lastCommand.Undo(); + redoCommands.Push(lastCommand); + lastCommand = undoCommands.Pop(); + lastCommand.Undo(); + redoCommands.Push(lastCommand); + } + } //Redo with r else if (Input.GetKeyDown(KeyCode.R)) { @@ -111,6 +128,23 @@ void Update() undoCommands.Push(nextCommand); } } + //Redo twice + else if (Input.GetKeyDown(KeyCode.Alpha2)) + { + if (redoCommands.Count < 2) + { + Debug.Log("Can't redo twice because we are at the end or there is only one left"); + } + else + { + Command nextCommand = redoCommands.Pop(); + nextCommand.Execute(); + undoCommands.Push(nextCommand); + nextCommand = redoCommands.Pop(); + nextCommand.Execute(); + undoCommands.Push(nextCommand); + } + } //Rebind keys by just swapping A and D buttons From 0f2b1d371089a248c31cabc1c6cd2ad0948cf605 Mon Sep 17 00:00:00 2001 From: Joao Coelho Date: Mon, 15 Aug 2022 16:08:32 +0100 Subject: [PATCH 2/2] flyweight changed to cube in scene --- Assets/Patterns/2. Flyweight/.DS_Store | Bin 0 -> 6148 bytes .../2. Flyweight/Scripts/Flyweight.cs | 11 +- .../Scripts/FlyweightController.cs | 18 +-- Assets/Patterns/2. Flyweight/flyweight.unity | 117 ++++++++++++++++-- 4 files changed, 126 insertions(+), 20 deletions(-) create mode 100644 Assets/Patterns/2. Flyweight/.DS_Store diff --git a/Assets/Patterns/2. Flyweight/.DS_Store b/Assets/Patterns/2. Flyweight/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d1a1123224df88fdc2c8b1040d82a8758201e08c GIT binary patch literal 6148 zcmeHKT}s3-5T4N$3%>Nx$6R4=P?zon>;Y-l}l|)pa39={|k?E}I$ed4roN`QbPuqUm4egjo^cSaO z@2AvIM|X5fd;1>;+3pw9aJ_80aWm;j%GX1W%~;p%Ft)H1kGr?$r^}a%oLB!1ujyug zwTLt>&VV!E3^)VMz|R@Ln=MkDDSGb=I0MeWCj)Xn1T?|QFe;|216?WsfD23~fiAU# z#0102Fe<_VVGRXpC|ila8jks3ewATV)No=eKG;_NC|)?Nj{G6H6IY7fI|I(ZoPlE< zmh%3u@yTS1{CS9voB?OxpE1CTx~W$A}(WIlxh{YM}X;+-?_3k heavyObjects = new List(); private List flyweightObjects = new List(); - + void Start() { - int numberOfObjects = 1000000; + int numberOfObjects = 10; //Generate Heavy objects that doesn't share any data - for (int i = 0; i < numberOfObjects; i++) + /* for (int i = 0; i < numberOfObjects; i++) { Heavy newHeavy = new Heavy(); heavyObjects.Add(newHeavy); - } + } */ //Generate Flyweight objects @@ -33,12 +33,12 @@ void Start() //Generate the data that's being shared among all objects //Data data = new Data(); - //for (int i = 0; i < numberOfObjects; i++) - //{ - // Flyweight newFlyweight = new Flyweight(data); + for (int i = 0; i < numberOfObjects; i++) + { + Flyweight newFlyweight = new Flyweight(GameObject.CreatePrimitive(PrimitiveType.Cube)); - // flyweightObjects.Add(newFlyweight); - //} + flyweightObjects.Add(newFlyweight); + } } } } diff --git a/Assets/Patterns/2. Flyweight/flyweight.unity b/Assets/Patterns/2. Flyweight/flyweight.unity index 3e86d3c..af95792 100644 --- a/Assets/Patterns/2. Flyweight/flyweight.unity +++ b/Assets/Patterns/2. Flyweight/flyweight.unity @@ -38,12 +38,12 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1} + m_IndirectSpecularColor: {r: 0.44657815, g: 0.49641192, b: 0.57481617, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 - serializedVersion: 11 + serializedVersion: 12 m_GIWorkflowMode: 0 m_GISettings: serializedVersion: 2 @@ -54,7 +54,7 @@ LightmapSettings: m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 1 m_LightmapEditorSettings: - serializedVersion: 10 + serializedVersion: 12 m_Resolution: 2 m_BakeResolution: 40 m_AtlasSize: 1024 @@ -62,6 +62,7 @@ LightmapSettings: m_AOMaxDistance: 1 m_CompAOExponent: 1 m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 m_Padding: 2 m_LightmapParameters: {fileID: 0} m_LightmapsBakeMode: 1 @@ -76,10 +77,16 @@ LightmapSettings: m_PVRDirectSampleCount: 32 m_PVRSampleCount: 500 m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 m_PVRFilterTypeDirect: 0 m_PVRFilterTypeIndirect: 0 m_PVRFilterTypeAO: 0 - m_PVRFilteringMode: 1 + m_PVREnvironmentMIS: 0 m_PVRCulling: 1 m_PVRFilteringGaussRadiusDirect: 1 m_PVRFilteringGaussRadiusIndirect: 5 @@ -87,9 +94,11 @@ LightmapSettings: m_PVRFilteringAtrousPositionSigmaDirect: 0.5 m_PVRFilteringAtrousPositionSigmaIndirect: 2 m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ShowResolutionOverlay: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 m_LightingDataAsset: {fileID: 0} - m_UseShadowmask: 1 + m_LightingSettings: {fileID: 138077691} --- !u!196 &4 NavMeshSettings: serializedVersion: 2 @@ -109,9 +118,73 @@ NavMeshSettings: manualTileSize: 0 tileSize: 256 accuratePlacement: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!850595691 &138077691 +LightingSettings: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Settings.lighting + serializedVersion: 4 + m_GIWorkflowMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_RealtimeEnvironmentLighting: 1 + m_BounceScale: 1 + m_AlbedoBoost: 1 + m_IndirectOutputScale: 1 + m_UsingShadowmask: 1 + m_BakeBackend: 1 + m_LightmapMaxSize: 1024 + m_BakeResolution: 40 + m_Padding: 2 + m_LightmapCompression: 3 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAO: 0 + m_MixedBakeMode: 2 + m_LightmapsBakeMode: 1 + m_FilterMode: 1 + m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0} + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_RealtimeResolution: 2 + m_ForceWhiteAlbedo: 0 + m_ForceUpdates: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 256 + m_FinalGatherFiltering: 1 + m_PVRCulling: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVREnvironmentSampleCount: 500 + m_PVREnvironmentReferencePointCount: 2048 + m_LightProbeSampleCountMultiplier: 4 + m_PVRBounces: 2 + m_PVRMinBounces: 2 + m_PVREnvironmentMIS: 0 + m_PVRFilteringMode: 2 + m_PVRDenoiserTypeDirect: 0 + m_PVRDenoiserTypeIndirect: 0 + m_PVRDenoiserTypeAO: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_PVRTiledBaking: 0 --- !u!1 &1130163256 GameObject: m_ObjectHideFlags: 0 @@ -151,6 +224,7 @@ Transform: 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_RootOrder: 2 @@ -193,9 +267,10 @@ Camera: m_ClearFlags: 1 m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 m_SensorSize: {x: 36, y: 24} m_LensShift: {x: 0, y: 0} - m_GateFitMode: 2 m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 @@ -233,6 +308,7 @@ Transform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 1, z: -10} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 @@ -262,12 +338,14 @@ Light: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1680646096} m_Enabled: 1 - serializedVersion: 8 + serializedVersion: 10 m_Type: 1 + m_Shape: 0 m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} m_Intensity: 1 m_Range: 10 m_SpotAngle: 30 + m_InnerSpotAngle: 21.802082 m_CookieSize: 10 m_Shadows: m_Type: 2 @@ -277,6 +355,24 @@ Light: m_Bias: 0.05 m_NormalBias: 0.4 m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 m_Cookie: {fileID: 0} m_DrawHalo: 0 m_Flare: {fileID: 0} @@ -284,12 +380,16 @@ Light: m_CullingMask: serializedVersion: 2 m_Bits: 4294967295 + m_RenderingLayerMask: 1 m_Lightmapping: 4 m_LightShadowCasterMode: 0 m_AreaSize: {x: 1, y: 1} m_BounceIntensity: 1 m_ColorTemperature: 6570 m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 m_ShadowRadius: 0 m_ShadowAngle: 0 --- !u!4 &1680646098 @@ -302,6 +402,7 @@ Transform: m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} m_LocalPosition: {x: 0, y: 3, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 1