Skip to content

Commit

Permalink
Merged branch master into master
Browse files Browse the repository at this point in the history
  • Loading branch information
AdronTech committed Jan 21, 2017
2 parents 9fd6a3a + e49c902 commit 83588c6
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 21 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 modified GGJ17/Assets/Prefab/UI.prefab
Binary file not shown.
Binary file modified GGJ17/Assets/Scene/IntroScene.unity
Binary file not shown.
Binary file removed GGJ17/Assets/Scene/New Scene.unity
Binary file not shown.
8 changes: 0 additions & 8 deletions GGJ17/Assets/Scene/New Scene.unity.meta

This file was deleted.

45 changes: 39 additions & 6 deletions GGJ17/Assets/Script/Dialog/Dialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,59 @@
public class Dialog : MonoBehaviour
{
public List<string> speeches;
public GameObject dialogLeft, dialogRight;

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

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

public IEnumerator talk()
public IEnumerator Talk()
{
foreach(string s in speeches)
for(int i = 0; i < speeches.Count; ++i)
{
GameObject g = new GameObject();
g.transform.parent = this.gameObject.transform;
DialogBox d = new DialogBox();
GameObject box = null;
if(i%2 == 0)
{
box = Instantiate(dialogLeft);
}
else
{
box = Instantiate(dialogRight);
}

yield return new WaitForSeconds(2.0f);
Canvas canvas = FindObjectOfType<Canvas>();

box.transform.parent = canvas.transform;

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

rect.anchoredPosition = new Vector3(rect.rect.width / 2 + 17,
-(canvas.pixelRect.height + rect.rect.height / 2));

yield return StartCoroutine(MoveDialogBox(rect,
new Vector3(rect.anchoredPosition.x,
-rect.rect.height / 2 - (i * rect.rect.height) - 14)));

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

public IEnumerator MoveDialogBox(RectTransform rect, Vector3 target)
{
while(rect.anchoredPosition.y <= target.y)
{
rect.anchoredPosition += Vector2.up * 1000 * Time.deltaTime;
yield return null;
}
}


}
4 changes: 2 additions & 2 deletions GGJ17/Assets/Script/Dialog/DialogBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class DialogBox : MonoBehaviour
// Use this for initialization
void Start()
{
textbox = GetComponent<Text>();
textbox = GetComponentInChildren<Text>();
}

// Update is called once per frame
Expand All @@ -28,7 +28,7 @@ public IEnumerator Speak(string text)
{
textbox.text += text[i];
++i;
yield return new WaitForSeconds(.5f);
yield return new WaitForSeconds(.07f);
}
}
}
5 changes: 0 additions & 5 deletions GGJ17/Assets/Script/WorldScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ public class WorldScript : MonoBehaviour {
[HideInInspector]
public AbstractBuildingBlock flag;

void Awake()
{
GenerateWorld();
}

void Start()
{
Vector3 flagSpawn = blocks[(int)size.x / 2, (int)size.y / 2].transform.position;
Expand Down

0 comments on commit 83588c6

Please sign in to comment.