Browse Source

2 types of lightning and clouds generated at start

master
Josh 2 years ago
parent
commit
5eac2e4c50
  1. 11
      unity/Assets/Game.cs
  2. 188
      unity/Assets/Prefabs/Cloud.prefab
  3. 1392
      unity/Assets/Scenes/SampleScene.unity
  4. 3
      unity/Assets/Scripts/Cloud.cs
  5. 109
      unity/Assets/Sprites/lightning2_short.png.meta

11
unity/Assets/Game.cs

@ -6,9 +6,18 @@ using UnityEngine.SceneManagement;
public class Game : MonoBehaviour public class Game : MonoBehaviour
{ {
// Start is called before the first frame update // Start is called before the first frame update
[SerializeField] GameObject _cloudPrefab;
const int NUM_CLOUDS = 6;
const float START_X = 1300;
void Start() void Start()
{ {
for (int i = 0; i < NUM_CLOUDS; ++i)
{
GameObject cloud = GameObject.Instantiate(_cloudPrefab);
cloud.transform.position = new Vector3(Random.Range(START_X, START_X + 1920), cloud.transform.position.y, cloud.transform.position.z);
}
} }
// Update is called once per frame // Update is called once per frame

188
unity/Assets/Prefabs/Cloud.prefab

@ -1,5 +1,145 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!1 &1043090684
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1043090685}
- component: {fileID: 1043090686}
m_Layer: 0
m_Name: lightning
m_TagString: Lightning
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1043090685
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1043090684}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: -65.62, z: 0.86}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1880512418}
m_Father: {fileID: 8093627333698608787}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &1043090686
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1043090684}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 38, y: 94.666664}
newSize: {x: 1.14, y: 6.37}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 7.09, y: 94.666664}
m_EdgeRadius: 0
--- !u!1 &1880512417
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1880512418}
- component: {fileID: 1880512419}
m_Layer: 0
m_Name: graphics
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1880512418
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1880512417}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -6.33, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1043090685}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1880512419
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1880512417}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, 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: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: dc9b42400a2750749a98117d1b81e1f1, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 38, y: 94.666664}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &8093627333698608799 --- !u!1 &8093627333698608799
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -11,11 +151,11 @@ GameObject:
- component: {fileID: 8093627333698608787} - component: {fileID: 8093627333698608787}
- component: {fileID: 8093627333698608786} - component: {fileID: 8093627333698608786}
- component: {fileID: 8093627333698608785} - component: {fileID: 8093627333698608785}
- component: {fileID: 8093627333698608784}
- component: {fileID: 8093627333698608788} - component: {fileID: 8093627333698608788}
- component: {fileID: 950892130}
m_Layer: 0 m_Layer: 0
m_Name: Cloud m_Name: Cloud
m_TagString: Untagged m_TagString: Cloud
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
@ -29,8 +169,9 @@ Transform:
m_GameObject: {fileID: 8093627333698608799} m_GameObject: {fileID: 8093627333698608799}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 704, y: 936, z: 0} m_LocalPosition: {x: 704, y: 936, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1.5063, y: 1.5063, z: 1.5063}
m_Children: [] m_Children:
- {fileID: 1043090685}
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}
@ -73,9 +214,9 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0} m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 0 m_SortingOrder: 26
m_Sprite: {fileID: 21300000, guid: 2405928e5513caf448a79082add2204a, type: 3} m_Sprite: {fileID: 21300000, guid: 2405928e5513caf448a79082add2204a, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 0.654902}
m_FlipX: 0 m_FlipX: 0
m_FlipY: 0 m_FlipY: 0
m_DrawMode: 0 m_DrawMode: 0
@ -97,19 +238,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f85dc4bb405207e44bfe557775714307, type: 3} m_Script: {fileID: 11500000, guid: f85dc4bb405207e44bfe557775714307, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
--- !u!114 &8093627333698608784 _lightning: {fileID: 1043090684}
MonoBehaviour: _sprites:
m_ObjectHideFlags: 0 - {fileID: 21300000, guid: d76eaebf0ab92f444837a89b760938ba, type: 3}
m_CorrespondingSourceObject: {fileID: 0} - {fileID: 21300000, guid: dc9b42400a2750749a98117d1b81e1f1, type: 3}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8093627333698608799}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 01a6f95bf180a2a45b1686ea222e1c17, type: 3}
m_Name:
m_EditorClassIdentifier:
_justVertical: 0
--- !u!61 &8093627333698608788 --- !u!61 &8093627333698608788
BoxCollider2D: BoxCollider2D:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -123,16 +255,28 @@ BoxCollider2D:
m_IsTrigger: 1 m_IsTrigger: 1
m_UsedByEffector: 0 m_UsedByEffector: 0
m_UsedByComposite: 0 m_UsedByComposite: 0
m_Offset: {x: 0, y: -16.5} m_Offset: {x: 0, y: -71.1}
m_SpriteTilingProperty: m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5} pivot: {x: 0.5, y: 0.5}
oldSize: {x: 254.33333, y: 109.333336} oldSize: {x: 238.66667, y: 90.666664}
newSize: {x: 763, y: 328} newSize: {x: 763, y: 328}
adaptiveTilingThreshold: 0.5 adaptiveTilingThreshold: 0.5
drawMode: 0 drawMode: 0
adaptiveTiling: 0 adaptiveTiling: 0
m_AutoTiling: 0 m_AutoTiling: 0
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 254.33333, y: 50.28} m_Size: {x: 134.6, y: 81.7}
m_EdgeRadius: 0 m_EdgeRadius: 0
--- !u!114 &950892130
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8093627333698608799}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0688d5c8286e7bf46981061fd36ed817, type: 3}
m_Name:
m_EditorClassIdentifier:

1392
unity/Assets/Scenes/SampleScene.unity

File diff suppressed because it is too large

3
unity/Assets/Scripts/Cloud.cs

@ -5,10 +5,10 @@ using UnityEngine;
public class Cloud : MonoBehaviour public class Cloud : MonoBehaviour
{ {
[SerializeField] GameObject _lightning; [SerializeField] GameObject _lightning;
[SerializeField] List<Sprite> _sprites;
float _timeToHideLightning = 0f; float _timeToHideLightning = 0f;
float _lightningTimeout = 0f; float _lightningTimeout = 0f;
float _timeToRandomStrike; float _timeToRandomStrike;
const bool DO_RANDOM_STRIKES = true; const bool DO_RANDOM_STRIKES = true;
// Start is called before the first frame update // Start is called before the first frame update
@ -67,6 +67,7 @@ public class Cloud : MonoBehaviour
return; return;
_lightning.SetActive(true); _lightning.SetActive(true);
_lightning.transform.GetChild(0).GetComponent<SpriteRenderer>().sprite = _sprites[Random.Range(0, _sprites.Count)];
_lightning.transform.position = new Vector3(x, _lightning.transform.position.y, _lightning.transform.position.z); _lightning.transform.position = new Vector3(x, _lightning.transform.position.y, _lightning.transform.position.z);
_timeToHideLightning = .2f; _timeToHideLightning = .2f;
_lightningTimeout = 2.0f; _lightningTimeout = 2.0f;

109
unity/Assets/Sprites/lightning2_short.png.meta

@ -0,0 +1,109 @@
fileFormatVersion: 2
guid: dc9b42400a2750749a98117d1b81e1f1
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 3
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
cookieLightType: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save