Skip to content

Commit

Permalink
Destroy Button
Browse files Browse the repository at this point in the history
  • Loading branch information
doingitraith committed Jan 22, 2017
1 parent e12face commit 8f2d603
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 23 deletions.
Binary file modified GGJ17/Assets/Prefab/Dialog/Dialog Left.prefab
Binary file not shown.
Binary file modified GGJ17/Assets/Prefab/Dialog/Dialog Right.prefab
Binary file not shown.
Binary file added GGJ17/Assets/Prefab/Dialog/Dialog.prefab
Binary file not shown.
8 changes: 8 additions & 0 deletions GGJ17/Assets/Prefab/Dialog/Dialog.prefab.meta

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

Binary file modified GGJ17/Assets/Prefab/UI.prefab
Binary file not shown.
Binary file modified GGJ17/Assets/Scene/IntroScene.unity
Binary file not shown.
42 changes: 26 additions & 16 deletions GGJ17/Assets/Script/Dialog/Dialog.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Dialog : MonoBehaviour
{
public List<string> speeches;
public GameObject dialogLeft, dialogRight;
public List<GameObject> dialogBoxes;

public struct DialogElement
{
public GameObject dialogBox;
public string text;
}

public List<DialogElement> speeches;

// Use this for initialization
void Start()
{
IEnumerator t = Talk();
StartCoroutine(t);
//IEnumerator t = Talk();
//StartCoroutine(t);
}

// Update is called once per frame
Expand All @@ -23,20 +31,15 @@ public IEnumerator Talk()
{
for(int i = 0; i < speeches.Count; ++i)
{
GameObject box = null;
if(i%2 == 0)
{
box = Instantiate(dialogLeft);
}
else
GameObject box = Instantiate(speeches[i].dialogBox);
Canvas canvas = FindObjectOfType<Canvas>();

if(canvas == null)
{
box = Instantiate(dialogRight);
throw new System.Exception("No Canvas in the Scene");
}

Canvas canvas = FindObjectOfType<Canvas>();

box.transform.parent = canvas.transform;

RectTransform rect = box.GetComponent<RectTransform>();

rect.anchoredPosition = new Vector3(rect.rect.width / 2 + 17,
Expand All @@ -46,7 +49,9 @@ public IEnumerator Talk()
new Vector3(rect.anchoredPosition.x,
-rect.rect.height / 2 - (i * rect.rect.height) - 14)));

yield return StartCoroutine(box.GetComponent<DialogBox>().Speak(speeches[i]));
DialogBox d = box.GetComponent<DialogBox>();
d.text = speeches[i].text;
yield return StartCoroutine(d.Speak());
}
}

Expand All @@ -57,6 +62,11 @@ public IEnumerator MoveDialogBox(RectTransform rect, Vector3 target)
rect.anchoredPosition += Vector2.up * 1000 * Time.deltaTime;
yield return null;
}
}

internal void Clear()
{
speeches.Clear();
}


Expand Down
3 changes: 2 additions & 1 deletion GGJ17/Assets/Script/Dialog/DialogBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class DialogBox : MonoBehaviour
{
private Text textbox;
public string text;

// Use this for initialization
void Start()
Expand All @@ -19,7 +20,7 @@ void Update()

}

public IEnumerator Speak(string text)
public IEnumerator Speak()
{
int i = 0;
textbox.text = "";
Expand Down
54 changes: 54 additions & 0 deletions GGJ17/Assets/Script/IntroSequence.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class IntroSequence : MonoBehaviour
{

public GameObject dialog;
private Dialog d;
// Use this for initialization
void Start()
{
d = dialog.GetComponent<Dialog>();
StartCoroutine(PlayIntro());
}

// Update is called once per frame
void Update()
{

}

public IEnumerator PlayIntro()
{
d.speeches = new List<Dialog.DialogElement>();

Dialog.DialogElement e = new Dialog.DialogElement();
e.dialogBox = d.dialogBoxes[0];
e.text = "Waverider, please come in. This is Mission Control.";
d.speeches.Add(e);

e = new Dialog.DialogElement();
e.dialogBox = d.dialogBoxes[1];
e.text = "Mission Control, this is the Waverider! What are your orders?";
d.speeches.Add(e);

e = new Dialog.DialogElement();
e.dialogBox = d.dialogBoxes[0];
e.text = "We have an important mission for you. You have to travel to a near solar system where you will find the planet of Psion. Our research team has located a powerful new energy source below the planet's surface.";
d.speeches.Add(e);

e = new Dialog.DialogElement();
e.dialogBox = d.dialogBoxes[0];
e.text = "Your mission will be to retrieve a probe from this new energy form and bring it back to Earth! This is a mission of the highest priority. I am sending the coordinates to your computer as we speak. Good luck Waverider!";
d.speeches.Add(e);

e = new Dialog.DialogElement();
e.dialogBox = d.dialogBoxes[1];
e.text = "Roger mission control! We will not let you down! Over.";
d.speeches.Add(e);

yield return StartCoroutine(d.Talk());
}
}
12 changes: 12 additions & 0 deletions GGJ17/Assets/Script/IntroSequence.cs.meta

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

15 changes: 9 additions & 6 deletions GGJ17/Assets/Script/ResourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ResourceManager : MonoBehaviour
{
public float ousaResource, ousaDelta, timeWait;
public float ousiaResource, ousiaDelta, timeWait;
public Text resourceText;

// Use this for initialization
void Start()
{
ousaResource = 0f;
ousaDelta = 0f;
ousiaResource = 0f;
ousiaDelta = 0f;
timeWait = 0f;

}
Expand All @@ -30,16 +32,17 @@ void Update()

private void updateResources()
{
ousaResource += ousaDelta;
ousiaResource += ousiaDelta;
resourceText.text = ousiaResource.ToString();
}

public void RegisterResources(float resource_value)
{
ousaDelta += resource_value;
ousiaDelta += resource_value;
}

public void DeregisterResources(float resource_value)
{
ousaDelta -= resource_value;
ousiaDelta -= resource_value;
}
}
Binary file modified GGJ17/ProjectSettings/EditorBuildSettings.asset
Binary file not shown.

0 comments on commit 8f2d603

Please sign in to comment.