Skip to content

Commit

Permalink
fix: waves no pausing with level
Browse files Browse the repository at this point in the history
  • Loading branch information
samOtero committed Jul 5, 2022
1 parent 2e3ea2d commit a3ea509
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 3 deletions.
14 changes: 14 additions & 0 deletions Assets/Events/DoRun.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2e5c76654e1de804eb74282cdc7cacf9, type: 3}
m_Name: DoRun
m_EditorClassIdentifier:
8 changes: 8 additions & 0 deletions Assets/Events/DoRun.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions Assets/Prefab/Basics/LevelRunner.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5916099752294032635
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5916099752294032637}
- component: {fileID: 5916099752294032636}
m_Layer: 0
m_Name: LevelRunner
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5916099752294032637
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5916099752294032635}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -5.38, y: 5.7, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5916099752294032636
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5916099752294032635}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3f7643af8978a9f4cb15fdc4b962f30d, type: 3}
m_Name:
m_EditorClassIdentifier:
DoRun: {fileID: 11400000, guid: 51ad0ea913bd05041a6ae62cfcc3674e, type: 2}
levelSpeed: 1
7 changes: 7 additions & 0 deletions Assets/Prefab/Basics/LevelRunner.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions Assets/Scenes/SampleScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: eb77bd5bf3a4ba64b9643b02d343f2fb, type: 3}
m_Name:
m_EditorClassIdentifier:
PauseStatus: {fileID: 11400000, guid: a264ff026ea714e449ebd2932560c752, type: 2}
DoRun: {fileID: 11400000, guid: 51ad0ea913bd05041a6ae62cfcc3674e, type: 2}
UnitLeftEvent: {fileID: 11400000, guid: b3943d2a975a94546b36fe35990302e2, type: 2}
UnitDefeatedEvent: {fileID: 11400000, guid: 09522cd547de67c42bbdaf82ca1f1423, type: 2}
UnitCapturedEvent: {fileID: 11400000, guid: f77cec3988eae6745b00a667a21340a9, type: 2}
Expand Down Expand Up @@ -2371,6 +2373,67 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3158c629b2a398b4181486f94e34d4ff, type: 3}
--- !u!1001 &5916099751534448664
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 5916099752294032635, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_Name
value: LevelRunner
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032636, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: levelSpeed
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032637, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_RootOrder
value: 18
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032637, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_LocalPosition.x
value: -5.38
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032637, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_LocalPosition.y
value: 5.7
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032637, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032637, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032637, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032637, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032637, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032637, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032637, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5916099752294032637, guid: 56de205773340a0498a304d410934320, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 56de205773340a0498a304d410934320, type: 3}
--- !u!1001 &8894169555492242278
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down
24 changes: 24 additions & 0 deletions Assets/Scripts/Level/LevelRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LevelRunner : MonoBehaviour
{
public BasicEvent DoRun;
public int levelSpeed;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
// Run our level
DoRun.Raise();
if (levelSpeed > 1) DoRun.Raise();
if (levelSpeed > 2) DoRun.Raise();
if (levelSpeed > 3) DoRun.Raise();
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Level/LevelRunner.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions Assets/Scripts/Waves/LevelWave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

public class LevelWave : MonoBehaviour
{
public IntVariable PauseStatus;
public BasicEvent DoRun;
public UnitEvent UnitLeftEvent;
public UnitEvent UnitDefeatedEvent;
public UnitEvent UnitCapturedEvent;
Expand All @@ -24,6 +26,7 @@ void Start()
UnitDefeatedEvent.RegisterListener(onUnitDefeated);
UnitCapturedEvent.RegisterListener(onUnitCaptured);
SpawnEnemyInPathEvent.RegisterListener(onSpawnEnemyInPath);
DoRun.RegisterListener(onDoRun);
setContainer();
}

Expand Down Expand Up @@ -66,15 +69,17 @@ void spawnEnemyOnPath(UnitProfile profile, Waypoint path) {
spawnEnemy(unit, path);
}

void Update() {
if (isCompleted) return;
public int onDoRun() {
if (PauseStatus.Value > 0) return 0; // Don't run if the game is paused
if (isCompleted) return 0;
if (currentContainer.isCompleted) {
waveNum++;
setContainer();
return;
return 1;
}

currentContainer.Run();
return 1;
}

private void spawnEnemy(Unit whichUnit, Waypoint path) {
Expand Down

0 comments on commit a3ea509

Please sign in to comment.