Skip to content

Commit

Permalink
Integrate pipeplatformer with minigameAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
foxor committed Nov 14, 2012
1 parent 6c1590c commit 354951e
Show file tree
Hide file tree
Showing 21 changed files with 139 additions and 16 deletions.
2 changes: 2 additions & 0 deletions Assets/Code/Controller/MiniGameController.cs
Expand Up @@ -22,6 +22,7 @@ public class MiniGameController : MonoBehaviour {
public GameObject physics;
public GameObject slideshow;
public GameObject waveDefense;
public GameObject pipePlatformer;

private Dictionary<string, GameObject> miniGameTypes;

Expand All @@ -43,6 +44,7 @@ public class MiniGameController : MonoBehaviour {
miniGameTypes["physics"] = physics;
miniGameTypes["slideshow"] = slideshow;
miniGameTypes["WaveDefense"] = waveDefense;
miniGameTypes["pipePlatformer"] = pipePlatformer;
singleton = this;
}

Expand Down
18 changes: 6 additions & 12 deletions Assets/Code/Mini Games/Platformer.cs
@@ -1,12 +1,6 @@
using UnityEngine;
using System.Collections;
using System.Xml;

public class Platformer : SceneLoadingMiniGame {

void OnGUI() {
if (GUILayout.Button("test")) {
MiniGameController.endMiniGame("firstPuzzleRecur");
}
}
}
using UnityEngine;
using System.Collections;
using System.Xml;

public class Platformer : SceneLoadingMiniGame {
}
21 changes: 21 additions & 0 deletions Assets/PipePlatformer/Code/EndNode.cs
@@ -0,0 +1,21 @@
using UnityEngine;
using System.Collections;

public class EndNode : MonoBehaviour {
public float difficulty;

private Ending ending;
public Ending Ending {
set {
ending = value;
renderer.material.color = ending.color;
}
get {
return ending;
}
}

public void notifyEnd() {
MiniGameController.endMiniGame(ending.edgeId);
}
}
8 changes: 8 additions & 0 deletions Assets/PipePlatformer/Code/EndNode.cs.meta

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

2 changes: 0 additions & 2 deletions Assets/PipePlatformer/Code/LightningArcs.cs
Expand Up @@ -63,12 +63,10 @@ private class ArcPoint {

private int start;
private int end;
private float len;

public Arc(ParticleSystem.Particle[] particles, int start, int count) {
this.start = start;
this.end = start + count;
len = (float)count;
this.particles = particles;
points = new ArcPoint[pointsPerArc];
for (int i = 0; i < pointsPerArc; i++) {
Expand Down
14 changes: 12 additions & 2 deletions Assets/PipePlatformer/Code/PipeController.cs
Expand Up @@ -8,12 +8,15 @@ public class PipeController : MonoBehaviour {
set {
if (value != playerHere) {
playerHere = value;
if (value) {
if (value && GetComponent<LightningArcs>() != null) {
GetComponent<LightningArcs>().Begin();
}
else {
else if (GetComponent<LightningArcs>() != null) {
GetComponent<LightningArcs>().End();
}
if (value && GetComponent<EndNode>() != null) {
GetComponent<EndNode>().notifyEnd();
}
}
}
}
Expand All @@ -27,6 +30,13 @@ public class PipeController : MonoBehaviour {
}
}

public void kill(string edgeId) {
if (playerHere) {
MiniGameController.endMiniGame(edgeId);
}
Destroy(gameObject);
}

void Update () {
if (!playerHere) {
return;
Expand Down
17 changes: 17 additions & 0 deletions Assets/PipePlatformer/Code/PipePlatformer.cs
@@ -0,0 +1,17 @@
using UnityEngine;
using System.Collections;
using System.Linq;

public class PipePlatformer : Platformer {
protected override void onMyLevelLoaded ()
{
Ending[] endings = Ending.findEndings(data).OrderBy<Ending, float>(x => x.difficulty).ToArray();
EndNode[] nodes = FindObjectsOfType(typeof(EndNode)).Cast<EndNode>().OrderBy<EndNode, float>(x => x.difficulty).ToArray();
if (nodes.Length != endings.Length) {
Debug.LogWarning(Application.loadedLevelName + " is only designed to handle " + nodes.Length.ToString() + " endings");
}
for (int i = 0; i < nodes.Length && i < endings.Length; i++) {
nodes[i].Ending = endings[i];
}
}
}
8 changes: 8 additions & 0 deletions Assets/PipePlatformer/Code/PipePlatformer.cs.meta

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

20 changes: 20 additions & 0 deletions Assets/PipePlatformer/Code/RisingWaterEnding.cs
@@ -0,0 +1,20 @@
using UnityEngine;
using System.Collections;

public class RisingWaterEnding : CollisionManager {
public float speed;

public override void manageCollision (CollisionData data)
{
PipeController other = data.other.GetComponent<PipeController>();
if (other != null) {
other.kill(GetComponent<EndNode>().Ending.edgeId);
}
}

void FixedUpdate() {
Vector3 pos = transform.position;
pos.y += speed * Time.deltaTime;
transform.position = pos;
}
}
8 changes: 8 additions & 0 deletions Assets/PipePlatformer/Code/RisingWaterEnding.cs.meta

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

Binary file added Assets/PipePlatformer/Prefabs/DeathWater.prefab
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/PipePlatformer/Prefabs/DeathWater.prefab.meta

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

Binary file modified Assets/PipePlatformer/Prefabs/Pipe.prefab
Binary file not shown.
Binary file added Assets/PipePlatformer/Prefabs/WinBox.prefab
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/PipePlatformer/Prefabs/WinBox.prefab.meta

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

Binary file added Assets/Prefabs/PipePlatformer.prefab
Binary file not shown.
4 changes: 4 additions & 0 deletions Assets/Prefabs/PipePlatformer.prefab.meta

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

25 changes: 25 additions & 0 deletions Assets/Resources/story.xml
Expand Up @@ -13,6 +13,7 @@
<response data="Physics Demo" edge="physicsDemoEdge" />
<response data="Slideshow" edge="slideshowEdge" />
<response data="Wave Defense" edge="waveDefenseEdge" />
<response data="Pipe Platformer" edge="pipePlatformerEdge" />
<response data="I don't know, who am I?" edge="winGame" requires="enoughCpu">
<requirement id="enoughCpu">
<have data="cpuPower">
Expand Down Expand Up @@ -79,6 +80,23 @@
</ending>
</minigame>
</node>
<node id="pipePlatformerNode">
<minigame data="pipePlatformer">
<sceneName data="InternetEscapePlatformer" />
<ending data="loseGame">
<color data="255,0,0" />
<difficulty data="-11" />
</ending>
<ending data="firstPuzzleRecur">
<color data="0,0,255" />
<difficulty data="1" />
</ending>
<ending data="winGame">
<color data="0,255,0" />
<difficulty data="2" />
</ending>
</minigame>
</node>
<node id="physicsDemoNode">
<minigame data="physics">
<sceneName data="PhysicsDemo" />
Expand Down Expand Up @@ -107,6 +125,11 @@
<minigame data="dialog">
<prompt data="You win!" />
</minigame>
</node>
<node id="youLose">
<minigame data="dialog">
<prompt data="You lose!" />
</minigame>
</node>
<edge id="firstPuzzleRecur" data="firstPuzzle">
<consequence>
Expand Down Expand Up @@ -158,6 +181,7 @@


<edge id="winGame" data="youWin" />
<edge id="loseGame" data="youLose" />
<edge id="platformEdge" data="platformer" />
<edge id="laserEdge" data="laserPlumber" />
<edge id="redBlueChoice" data="redBluePlatformer" />
Expand All @@ -166,4 +190,5 @@
<edge id="physicsDemoEdge" data="physicsDemoNode" />
<edge id="slideshowEdge" data="slideshowNode" />
<edge id="waveDefenseEdge" data="waveDefenseNode" />
<edge id="pipePlatformerEdge" data="pipePlatformerNode" />
</story>
Binary file modified Assets/Scenes/InternetEscapePlatformer.unity
Binary file not shown.
Binary file modified Assets/Scenes/Start.unity
Binary file not shown.
Binary file modified ProjectSettings/EditorBuildSettings.asset
Binary file not shown.

0 comments on commit 354951e

Please sign in to comment.