Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoborks committed Nov 2, 2016
1 parent a59c987 commit 8f32c8a
Show file tree
Hide file tree
Showing 72 changed files with 1,126 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# =============== #
# Unity generated #
# =============== #
Temp/
Library/

# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
ExportedObj/
obj/
*.svd
*.userprefs
/*.csproj
*.pidb
*.suo
/*.sln
*.user
*.unityproj
*.booproj

# ============ #
# OS generated #
# ============ #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
9 changes: 9 additions & 0 deletions Assets/Animations.meta

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

Binary file added Assets/Animations/Disappoint.anim
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Animations/Disappoint.anim.meta

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

Binary file added Assets/Animations/Eat.anim
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Animations/Eat.anim.meta

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

Binary file added Assets/Animations/Frog.controller
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Animations/Frog.controller.meta

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

Binary file added Assets/Animations/Idle.anim
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Animations/Idle.anim.meta

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

Binary file added Assets/Animations/OpenMouth.anim
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Animations/OpenMouth.anim.meta

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

9 changes: 9 additions & 0 deletions Assets/Materials.meta

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

Binary file added Assets/Materials/Rope.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Materials/Rope.mat.meta

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

9 changes: 9 additions & 0 deletions Assets/Prefabs.meta

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

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

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

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

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

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

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

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

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

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

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

9 changes: 9 additions & 0 deletions Assets/Scenes.meta

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

Binary file added Assets/Scenes/level_0.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Scenes/level_0.unity.meta

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

Binary file added Assets/Scenes/level_1.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Scenes/level_1.unity.meta

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

Binary file added Assets/Scenes/level_2.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Scenes/level_2.unity.meta

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

9 changes: 9 additions & 0 deletions Assets/Scripts.meta

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

30 changes: 30 additions & 0 deletions Assets/Scripts/BottomLine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using UnityEngine;
using System.Collections;

public class BottomLine : MonoBehaviour
{
public Vector2 offset;
public Vector2 size;
public LayerMask layer;

Frog frog;

void Awake()
{
frog = FindObjectOfType<Frog>();
}

void Update()
{
if (Physics2D.OverlapBox(transform.position + (Vector3)offset, size, 0, layer))
{
frog.Lose();
}
}

void OnDrawGizmos()
{
Gizmos.color = Color.green;
Gizmos.DrawWireCube(transform.position + (Vector3)offset, size);
}
}
12 changes: 12 additions & 0 deletions Assets/Scripts/BottomLine.cs.meta

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

18 changes: 18 additions & 0 deletions Assets/Scripts/Candy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using UnityEngine;
using System.Collections;

public class Candy : MonoBehaviour
{
public Rope[] ropes;

void Awake()
{
foreach (Rope rope in ropes)
rope.AttachCandy(transform);
}

public void GetEaten()
{
gameObject.SetActive(false);
}
}
12 changes: 12 additions & 0 deletions Assets/Scripts/Candy.cs.meta

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

75 changes: 75 additions & 0 deletions Assets/Scripts/Frog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;

public class Frog : MonoBehaviour
{
[Range(2, 5)]
public float mouthRange = 4;
[Range(.3f, .5f)]
public float eatRange = .4f;
public LayerMask mask;

Animator anim;
Collider2D hit;
bool done;

void Awake()
{
anim = GetComponent<Animator>();
}

void FixedUpdate()
{
if (done)
return;

hit = Physics2D.OverlapCircle(transform.position, eatRange, mask);
if (hit != null)
{
anim.SetTrigger("eat");
hit.GetComponent<Candy>().GetEaten();
done = true;
StartCoroutine(LoadNextScene());
}
else if (Physics2D.OverlapCircle(transform.position, mouthRange, mask))
anim.SetTrigger("openMouth");
else
anim.SetTrigger("idle");
}

public void Lose()
{
if (done)
return;
anim.SetTrigger("disappoint");
done = true;
StartCoroutine(LoadActualScene());
}

void OnDrawGizmos()
{
Gizmos.color = Color.green;
Gizmos.DrawWireSphere(transform.position, mouthRange);
Gizmos.DrawWireSphere(transform.position, eatRange);
}

IEnumerator LoadActualScene()
{
yield return new WaitForSeconds(3);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}

IEnumerator LoadNextScene()
{
yield return new WaitForSeconds(3);
int activeScene = SceneManager.GetActiveScene().buildIndex;
if (activeScene + 1 < SceneManager.sceneCountInBuildSettings)
SceneManager.LoadScene(activeScene + 1);
else
{
print("<color=yellow>Game Over</color>");
Application.Quit();
}
}
}
12 changes: 12 additions & 0 deletions Assets/Scripts/Frog.cs.meta

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

Loading

0 comments on commit 8f32c8a

Please sign in to comment.