-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
- Loading branch information
There are no files selected for viewing
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.