Arbeit an Kleiner Stern Szene 4
This commit is contained in:
parent
b3ce6bfd3f
commit
fd55e1c608
8 changed files with 2738 additions and 14 deletions
105
Assets/AblaufKleinerStern4.cs
Normal file
105
Assets/AblaufKleinerStern4.cs
Normal 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(){};
|
||||
}
|
||||
}
|
||||
2
Assets/AblaufKleinerStern4.cs.meta
Normal file
2
Assets/AblaufKleinerStern4.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b4aeb3a59e2d9f63c824496a17159d8b
|
||||
|
|
@ -8,6 +8,9 @@ public class FigurMitBeinenBewegung : MonoBehaviour
|
|||
public GameObject[] wobblingParts;
|
||||
public float[] wobblingMaxAngles;
|
||||
public bool[] wobblingInversed;
|
||||
/// <summary>
|
||||
/// Periodendauer des Wackelns wackelnder Körperteile (in Sekunden). 0, falls kein Wackeln.
|
||||
/// </summary>
|
||||
public float wobblingPeriod;
|
||||
public float movementVelocity;
|
||||
|
||||
|
|
@ -47,13 +50,13 @@ public class FigurMitBeinenBewegung : MonoBehaviour
|
|||
deltaX *= -1;
|
||||
}
|
||||
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;
|
||||
} else {
|
||||
transform.position += Vector3.right * deltaX;
|
||||
}
|
||||
}
|
||||
if (wobbling){
|
||||
if (wobbling && wobblingPeriod != 0){
|
||||
float phase = math.sin((Time.time - movementStartTime) * math.PI2 / wobblingPeriod);
|
||||
if (!moving && phase * lastPhase <= 0){
|
||||
wobbling = false;
|
||||
|
|
|
|||
2604
Assets/Scenes/kleiner_Stern_4.unity
Normal file
2604
Assets/Scenes/kleiner_Stern_4.unity
Normal file
File diff suppressed because it is too large
Load diff
7
Assets/Scenes/kleiner_Stern_4.unity.meta
Normal file
7
Assets/Scenes/kleiner_Stern_4.unity.meta
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0b0186d0541ff531196529db11b23370
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -120,8 +120,8 @@ TextureImporter:
|
|||
y: 189
|
||||
width: 1161
|
||||
height: 1871
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
alignment: 9
|
||||
pivot: {x: -0.009351259, y: 0.95028347}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
|
|
@ -138,7 +138,7 @@ TextureImporter:
|
|||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
spriteID: 9c6d312c6bb0c4479a890ed0e2e9f372
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
|
|
@ -147,7 +147,8 @@ TextureImporter:
|
|||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
nameFileIdTable:
|
||||
Herbergswirt - Bein1_0: 5183861950505300048
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ TextureImporter:
|
|||
y: 102
|
||||
width: 1142
|
||||
height: 1976
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
alignment: 9
|
||||
pivot: {x: 0.94689023, y: 0.9509539}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
|
|
@ -138,7 +138,7 @@ TextureImporter:
|
|||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
spriteID: 0d21c2d4a7e9d1cd49f5d46efad0d442
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
|
|
@ -147,7 +147,8 @@ TextureImporter:
|
|||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
nameFileIdTable:
|
||||
Herbergswirt - Bein2_0: 1004018132125385856
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ TextureImporter:
|
|||
y: 3759
|
||||
width: 725
|
||||
height: 878
|
||||
alignment: 0
|
||||
pivot: {x: 0, y: 0}
|
||||
alignment: 9
|
||||
pivot: {x: 0.16479526, y: 0.10326453}
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
customData:
|
||||
outline: []
|
||||
|
|
@ -138,7 +138,7 @@ TextureImporter:
|
|||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
spriteID: 6edffbc0b9a9a623e8e29a5f4ffa9ae5
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
|
|
@ -147,7 +147,8 @@ TextureImporter:
|
|||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
nameFileIdTable:
|
||||
Herbergswirt - Kopf_0: -1262375488264224170
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
|
|
|
|||
Loading…
Reference in a new issue