Arbeit an Kleiner Stern Szene 4

This commit is contained in:
Philipp Sander 2024-12-19 23:55:04 +01:00
parent b3ce6bfd3f
commit fd55e1c608
8 changed files with 2738 additions and 14 deletions

View file

@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.Universal;
public class AblaufKleinerStern4 : MonoBehaviour
{
public GameObject wirt;
public GameObject maria;
public GameObject joseph;
public GameObject kleinerStern;
public GameObject globalLight;
private Action nextStep;
private class Task {
private Action action;
private float time;
public Task(Action action, float time){
this.action = action;
this.time = time;
}
public bool isDue(){
return Time.time >= time;
}
public void Do(){
action();
}
}
private List<Task> taskList;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
taskList = new();
nextStep = AuftrittMariaUndJoseph;
globalLight.GetComponent<Light2D>().intensity = 0;
wirt.transform.position = new(3.41f, -2.6f);
joseph.transform.position = new(-6.8f, -2.81f);
maria.transform.position = new(-11.4f, -1.5f);
}
// Update is called once per frame
void Update()
{
List<Task> newlist = new();
foreach (Task t in taskList){
if (t.isDue()){
t.Do();
} else {
newlist.Add(t);
}
}
taskList = newlist;
if (Input.GetKeyDown(KeyCode.Space) && taskList.Count == 0){
nextStep();
}
}
private void scheduleNewTask(float timeFromNow, Action action){
Task t = new(action, Time.time + timeFromNow);
taskList.Add(t);
}
private void AuftrittMariaUndJoseph(){
kleinerStern.GetComponent<SternBewegung>().GoToPosition(new(-5.6f, 3), 0);
globalLight.GetComponent<Lichtsteuerung>().FadeToIntensity(1, 0.5f);
joseph.GetComponent<FigurMitBeinenBewegung>().GoToXPosition(-2.64f);
maria.GetComponent<FigurMitBeinenBewegung>().GoToXPosition(-7.24f);
scheduleNewTask(0.001f, delegate(){
kleinerStern.GetComponent<SternBewegung>().GoToPositionWithVelocity(new(-3.5f, 3), 1);
});
nextStep = AuftrittWirt;
}
private void AuftrittWirt(){
wirt.GetComponent<FigurMitBeinenBewegung>().GoToXPosition(0.76f);
nextStep = SchwenkAufStall;
}
private void SchwenkAufStall(){
GetComponent<FigurMitBeinenBewegung>().GoToXPosition(-15);
transform.rotation = Quaternion.identity;
scheduleNewTask(3, delegate(){
kleinerStern.GetComponent<SternBewegung>().GoToPosition(new(-4, 3), 0);
});
nextStep = SternWandert;
}
private void SternWandert(){
kleinerStern.GetComponent<SternBewegung>().GoToPositionWithVelocity(new(-16, 3), 2);
nextStep = SchwenkZurueck;
}
private void SchwenkZurueck(){
GetComponent<FigurMitBeinenBewegung>().GoToXPosition(0);
nextStep = WirtFuehrtZumStall;
}
private void WirtFuehrtZumStall(){
nextStep = delegate(){};
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b4aeb3a59e2d9f63c824496a17159d8b

View file

@ -8,6 +8,9 @@ public class FigurMitBeinenBewegung : MonoBehaviour
public GameObject[] wobblingParts; public GameObject[] wobblingParts;
public float[] wobblingMaxAngles; public float[] wobblingMaxAngles;
public bool[] wobblingInversed; public bool[] wobblingInversed;
/// <summary>
/// Periodendauer des Wackelns wackelnder Körperteile (in Sekunden). 0, falls kein Wackeln.
/// </summary>
public float wobblingPeriod; public float wobblingPeriod;
public float movementVelocity; public float movementVelocity;
@ -47,13 +50,13 @@ public class FigurMitBeinenBewegung : MonoBehaviour
deltaX *= -1; deltaX *= -1;
} }
if ((transform.position.x - targetPositionX) * (transform.position.x + deltaX - targetPositionX) <= 0){ if ((transform.position.x - targetPositionX) * (transform.position.x + deltaX - targetPositionX) <= 0){
transform.position = new Vector2(targetPositionX, transform.position.y); transform.position = new(targetPositionX, transform.position.y, transform.position.z);
moving = false; moving = false;
} else { } else {
transform.position += Vector3.right * deltaX; transform.position += Vector3.right * deltaX;
} }
} }
if (wobbling){ if (wobbling && wobblingPeriod != 0){
float phase = math.sin((Time.time - movementStartTime) * math.PI2 / wobblingPeriod); float phase = math.sin((Time.time - movementStartTime) * math.PI2 / wobblingPeriod);
if (!moving && phase * lastPhase <= 0){ if (!moving && phase * lastPhase <= 0){
wobbling = false; wobbling = false;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0b0186d0541ff531196529db11b23370
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -120,8 +120,8 @@ TextureImporter:
y: 189 y: 189
width: 1161 width: 1161
height: 1871 height: 1871
alignment: 0 alignment: 9
pivot: {x: 0, y: 0} pivot: {x: -0.009351259, y: 0.95028347}
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
customData: customData:
outline: [] outline: []
@ -138,7 +138,7 @@ TextureImporter:
customData: customData:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: spriteID: 9c6d312c6bb0c4479a890ed0e2e9f372
internalID: 0 internalID: 0
vertices: [] vertices: []
indices: indices:
@ -147,7 +147,8 @@ TextureImporter:
secondaryTextures: [] secondaryTextures: []
spriteCustomMetadata: spriteCustomMetadata:
entries: [] entries: []
nameFileIdTable: {} nameFileIdTable:
Herbergswirt - Bein1_0: 5183861950505300048
mipmapLimitGroupName: mipmapLimitGroupName:
pSDRemoveMatte: 0 pSDRemoveMatte: 0
userData: userData:

View file

@ -120,8 +120,8 @@ TextureImporter:
y: 102 y: 102
width: 1142 width: 1142
height: 1976 height: 1976
alignment: 0 alignment: 9
pivot: {x: 0, y: 0} pivot: {x: 0.94689023, y: 0.9509539}
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
customData: customData:
outline: [] outline: []
@ -138,7 +138,7 @@ TextureImporter:
customData: customData:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: spriteID: 0d21c2d4a7e9d1cd49f5d46efad0d442
internalID: 0 internalID: 0
vertices: [] vertices: []
indices: indices:
@ -147,7 +147,8 @@ TextureImporter:
secondaryTextures: [] secondaryTextures: []
spriteCustomMetadata: spriteCustomMetadata:
entries: [] entries: []
nameFileIdTable: {} nameFileIdTable:
Herbergswirt - Bein2_0: 1004018132125385856
mipmapLimitGroupName: mipmapLimitGroupName:
pSDRemoveMatte: 0 pSDRemoveMatte: 0
userData: userData:

View file

@ -120,8 +120,8 @@ TextureImporter:
y: 3759 y: 3759
width: 725 width: 725
height: 878 height: 878
alignment: 0 alignment: 9
pivot: {x: 0, y: 0} pivot: {x: 0.16479526, y: 0.10326453}
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
customData: customData:
outline: [] outline: []
@ -138,7 +138,7 @@ TextureImporter:
customData: customData:
physicsShape: [] physicsShape: []
bones: [] bones: []
spriteID: spriteID: 6edffbc0b9a9a623e8e29a5f4ffa9ae5
internalID: 0 internalID: 0
vertices: [] vertices: []
indices: indices:
@ -147,7 +147,8 @@ TextureImporter:
secondaryTextures: [] secondaryTextures: []
spriteCustomMetadata: spriteCustomMetadata:
entries: [] entries: []
nameFileIdTable: {} nameFileIdTable:
Herbergswirt - Kopf_0: -1262375488264224170
mipmapLimitGroupName: mipmapLimitGroupName:
pSDRemoveMatte: 0 pSDRemoveMatte: 0
userData: userData: