-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
God Game/Assets/PlayModeTests/FreeFallingObjectPlayTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
using NUnit.Framework; | ||
using System.Collections; | ||
|
||
public class FreeFallingObjectPlayTests { | ||
[UnityTest] | ||
public IEnumerator objectShouldBeDestroyedWhenTooHigh() { | ||
var gameObject = new GameObject(); | ||
var fallingScripts = gameObject.AddComponent<FreeFallingObject>(); | ||
|
||
yield return null; | ||
|
||
Assert.IsFalse(gameObject == null); | ||
|
||
fallingScripts.transform.position = new Vector3(0, Constants.MaxHeight + 1, 0); | ||
|
||
yield return null; | ||
yield return null; | ||
|
||
Assert.IsTrue(gameObject == null); | ||
} | ||
|
||
[UnityTest] | ||
public IEnumerator objectShouldBeDestroyedWhenTooLow() { | ||
var gameObject = new GameObject(); | ||
var fallingScripts = gameObject.AddComponent<FreeFallingObject>(); | ||
|
||
yield return null; | ||
|
||
Assert.IsFalse(gameObject == null); | ||
|
||
fallingScripts.transform.position = new Vector3(0, Constants.MaxHeight + 1, 0); | ||
|
||
yield return null; | ||
yield return null; | ||
|
||
Assert.IsTrue(gameObject == null); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
God Game/Assets/PlayModeTests/FreeFallingObjectPlayTests.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using UnityEngine; | ||
|
||
public class FreeFallingObject : MonoBehaviour { | ||
// Update is called once per frame | ||
void Update () { | ||
if (transform.position.y > Constants.MaxHeight || transform.position.y < Constants.MinHeight) { | ||
Destroy(gameObject); | ||
} | ||
} | ||
|
||
public static void freeObject(Transform obj) { | ||
obj.parent = null; | ||
Rigidbody rigidBody = obj.gameObject.AddComponent<Rigidbody>(); | ||
rigidBody.mass = 5; | ||
rigidBody.useGravity = true; | ||
obj.GetComponent<Collider>().enabled = true; | ||
obj.gameObject.AddComponent<FreeFallingObject>(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.