Kleiner Stern Szene 1

This commit is contained in:
Philipp Sander 2024-12-13 12:06:38 +01:00
parent c64c2f0dd1
commit 543f0e142e
4 changed files with 165 additions and 20 deletions

View file

@ -11,6 +11,10 @@ public class AblaufKleinerStern1 : MonoBehaviour
public GameObject globalLight;
public GameObject sternenhimmel;
public GameObject hintergrund;
private enum Step {GROSSE_AUFREGUNG, AUFTRITT_KLEINER_STERN, AUFTRITT_GROSSER_STERN, ABGANG_GROSSER_STERN, KLEINER_STERN_FAELLT}
private Step nextStep;
@ -19,7 +23,7 @@ public class AblaufKleinerStern1 : MonoBehaviour
public readonly float time;
public readonly Action action;
Task(float time, Action action) {
public Task(float time, Action action) {
this.time = time;
this.action = action;
}
@ -27,12 +31,21 @@ public class AblaufKleinerStern1 : MonoBehaviour
private List<Task> taskList;
private Camera cameraComponent;
private SternBewegung kleinerSternBewegung;
private SternBewegung grosserSternBewegung;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
nextStep = Step.GROSSE_AUFREGUNG;
taskList = new List<Task>();
globalLight.GetComponent<Light2D>().intensity = 0;
cameraComponent = GetComponent<Camera>();
kleinerSternBewegung = kleinerStern.GetComponent<SternBewegung>();
grosserSternBewegung = grosserStern.GetComponent<SternBewegung>();
}
// Update is called once per frame
@ -40,7 +53,7 @@ public class AblaufKleinerStern1 : MonoBehaviour
{
List<Task> doneList = new List<Task>();
foreach (Task t in taskList) {
if (t.time >= Time.time) {
if (Time.time >= t.time) {
doneList.Add(t);
t.action();
}
@ -75,14 +88,47 @@ public class AblaufKleinerStern1 : MonoBehaviour
}
private void GrosseAufregung(){
globalLight.GetComponent<Lichtsteuerung>().FadeToIntensity(1, 1);
globalLight.GetComponent<Lichtsteuerung>().FadeToIntensity(1, 2);
kleinerSternBewegung.GoToPosition(new Vector2(-12, -3.5f), 0f);
grosserSternBewegung.GoToPosition(new Vector2(12, -3.5f), 0f);
}
private void AuftrittKleinerStern(){}
private void AuftrittKleinerStern(){
kleinerSternBewegung.GoToPosition(new Vector2(-3, -2f), 2f);
}
private void AuftrittGrosserStern(){}
private void AuftrittGrosserStern(){
kleinerSternBewegung.randomnessIntensity = .01f;
kleinerSternBewegung.wobblingAngle = 2f;
kleinerSternBewegung.wobblingDuration = 1.5f;
grosserSternBewegung.GoToPosition(new Vector2(3, -2f), 2.4f);
}
private void AbgangGrosserStern(){}
private void AbgangGrosserStern(){
grosserStern.GetComponent<SpriteRenderer>().flipX = true;
grosserSternBewegung.GoToPosition(new Vector2(12, 0), 2);
kleinerSternBewegung.randomnessIntensity = 1;
kleinerSternBewegung.wobblingAngle = 10;
kleinerSternBewegung.wobblingDuration = .6f;
}
private void KleinerSternFaellt(){}
private void KleinerSternFaellt(){
kleinerSternBewegung.angularVelocity = 300;
kleinerSternBewegung.GoToPosition(new Vector2(-4, -6), 1);
kleinerSternBewegung.randomnessIntensity = 0.01f;
doDelayed(1.0f, delegate(){
globalLight.GetComponent<Lichtsteuerung>().FadeToIntensity(0, .5f);
kleinerSternBewegung.GoToPosition(new Vector2(1, 6.5f), 0);
});
doDelayed(1.5f, delegate(){
hintergrund.GetComponent<SpriteRenderer>().color = Color.black;
sternenhimmel.SetActive(false);
globalLight.GetComponent<Lichtsteuerung>().FadeToIntensity(1, 0);
kleinerSternBewegung.GoToPosition(new Vector2(-1, -6.5f), 3);
});
}
private void doDelayed(float delay, Action task) {
taskList.Add(new Task(Time.time + delay, task));
}
}

View file

@ -319,8 +319,9 @@ MonoBehaviour:
randomnessIntensity: 0
randomnessBaseAngle: 0
randomMovementDuration: 100
wobblingAngle: 8
wobblingDuration: 2
wobblingAngle: 5
wobblingDuration: 3
angularVelocity: 0
--- !u!1 &1319994911
GameObject:
m_ObjectHideFlags: 0
@ -359,7 +360,7 @@ Camera:
m_GameObject: {fileID: 1319994911}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_ClearFlags: 1
m_BackGroundColor: {r: 1, g: 1, b: 1, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
@ -475,6 +476,8 @@ MonoBehaviour:
kleinerStern: {fileID: 1363739540}
grosserStern: {fileID: 1314099120}
globalLight: {fileID: 402771298}
sternenhimmel: {fileID: 1741124233}
hintergrund: {fileID: 2123825385}
--- !u!114 &1319994917
MonoBehaviour:
m_ObjectHideFlags: 0
@ -482,7 +485,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1319994911}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9e8bac4050986ba529605346c1405c4d, type: 3}
m_Name:
@ -523,6 +526,7 @@ MonoBehaviour:
randomMovementDuration: 0.2
wobblingAngle: 10
wobblingDuration: 0.6
angularVelocity: 0
--- !u!212 &1363739542
SpriteRenderer:
m_ObjectHideFlags: 0
@ -587,7 +591,7 @@ Transform:
m_GameObject: {fileID: 1363739540}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -7.34, y: -2.76, z: 0}
m_LocalPosition: {x: -5.82, y: -3.08, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -680,6 +684,93 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2123825385
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2123825387}
- component: {fileID: 2123825386}
m_Layer: 0
m_Name: Hintergrund
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!212 &2123825386
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2123825385}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
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: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 1, y: 1}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &2123825387
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2123825385}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.0144, y: 0.0577, z: 1}
m_LocalScale: {x: 18.51634, y: 10.667906, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
@ -689,3 +780,4 @@ SceneRoots:
- {fileID: 1363739543}
- {fileID: 1314099122}
- {fileID: 402771301}
- {fileID: 2123825387}

View file

@ -13,6 +13,8 @@ public class SternBewegung : MonoBehaviour
public float wobblingDuration;
public float angularVelocity;
private Vector2 targetPosition;
private Vector2 startPosition;
@ -27,9 +29,11 @@ public class SternBewegung : MonoBehaviour
private float endOfRandomMovement;
private float strictRotationAngle;
public void GoToPosition(Vector2 position, float duration){
targetPosition = position;
startPosition = transform.position;
startPosition = (Vector2) transform.position - randomStrictDiff;
timeOfArrival = Time.time + duration;
timeOfDeparture = Time.time;
}
@ -51,7 +55,7 @@ public class SternBewegung : MonoBehaviour
{
Vector2 strictPos;
if (Time.time >= timeOfDeparture && Time.time < timeOfArrival) {
strictPos = Vector2.Lerp(startPosition, startPosition, (Time.time - timeOfDeparture)/(timeOfArrival - timeOfDeparture));
strictPos = Vector2.Lerp(startPosition, targetPosition, (Time.time - timeOfDeparture)/(timeOfArrival - timeOfDeparture));
} else {
strictPos = targetPosition;
}
@ -72,12 +76,13 @@ public class SternBewegung : MonoBehaviour
randomStrictDiff += randomMovement * Time.deltaTime;
transform.position = strictPos + randomStrictDiff;
float rotationAngle;
strictRotationAngle += angularVelocity * Time.deltaTime;
float rotationAngle = strictRotationAngle;
float normalizedTime = (Time.time % wobblingDuration) / wobblingDuration;
if (normalizedTime < .5f){
rotationAngle = - wobblingAngle + 4 * wobblingAngle * normalizedTime;
rotationAngle += - wobblingAngle + 4 * wobblingAngle * normalizedTime;
} else {
rotationAngle = wobblingAngle - 4 * wobblingAngle * (normalizedTime - .5f);
rotationAngle += wobblingAngle - 4 * wobblingAngle * (normalizedTime - .5f);
}
transform.rotation = Quaternion.AngleAxis(rotationAngle, Vector3.forward);
}

View file

@ -2,7 +2,7 @@
%TAG !u! tag:unity3d.com,2011:
--- !u!78 &1
TagManager:
serializedVersion: 2
serializedVersion: 3
tags: []
layers:
- Default
@ -12,8 +12,8 @@ TagManager:
- Water
- UI
-
-
-
- Ground
- Figure
-
-
-
@ -41,3 +41,5 @@ TagManager:
- name: Default
uniqueID: 0
locked: 0
m_RenderingLayers:
- Default