Skip to content

Commit

Permalink
Small Updates and upgrade to 2019.4.8f1
Browse files Browse the repository at this point in the history
  • Loading branch information
mdschuster committed Sep 21, 2020
1 parent 62da698 commit 52eaf2a
Show file tree
Hide file tree
Showing 6 changed files with 425 additions and 29 deletions.
17 changes: 10 additions & 7 deletions Assets/Scripts/Enemy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// <summary>
/// Enemy Class.
/// Contains movement and collision detection for the spawned ememy gameobjects.
/// Contains movement and collision detection for the spawned enemy gameobjects.
/// </summary>
[RequireComponent(typeof(Collider))]
public class Enemy : MonoBehaviour
Expand Down Expand Up @@ -77,7 +77,7 @@ public class Enemy : MonoBehaviour
/// </summary>
void Start()
{
//pick random balue between min and max speed
//pick random value between min and max speed
speed = Random.Range(minSpeed, maxSpeed);

p = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
Expand All @@ -98,17 +98,20 @@ void Update()
/// and/or instantiates particle effects.
/// </summary>
/// <param name="collision">Collider that was triggered.</param>
private void OnTriggerEnter2D(Collider2D collision) {
if (collision.tag == "Player") {
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "Player")
{
//reduce player health
p.takeDamage(damage);
Instantiate(hitEffect, new Vector3(transform.position.x, transform.position.y-0.3f, -0.3f), Quaternion.identity);
Instantiate(hitEffect, new Vector3(transform.position.x, transform.position.y - 0.3f, -0.3f), Quaternion.identity);
GameObject.Destroy(gameObject);
}

//destroy enemy if hits the ground
if (collision.tag == "Ground") {
Instantiate(deathEffect, new Vector3(transform.position.x, transform.position.y-0.5f, -0.3f), Quaternion.identity);
if (collision.tag == "Ground")
{
Instantiate(deathEffect, new Vector3(transform.position.x, transform.position.y - 0.5f, -0.3f), Quaternion.identity);
GameObject.Destroy(gameObject);
}
}
Expand Down
40 changes: 25 additions & 15 deletions Assets/Scripts/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,38 @@ void Start()
/// <summary>
/// Sets animation states depending on input and facing direction.
/// </summary>
private void Update() {
if (input > 0+eps || input<0-eps) {
private void Update()
{
if (input > 0 + eps || input < 0 - eps)
{
anim.SetBool("isRunning", true);
} else {
}
else
{
anim.SetBool("isRunning", false);
}

if (input > 0) {
if (input > 0)
{
transform.eulerAngles = new Vector3(0f, 0f, 0f);
}
else if(input < 0){
else if (input < 0)
{
transform.eulerAngles = new Vector3(0f, 180f, 0f);
}
}

/// <summary>
/// Physics update. Gets the raw input and updates rigidbody velocity.
/// </summary>
void FixedUpdate() {
void FixedUpdate()
{
//geting player input
//input = Input.GetAxis("Horizontal"); //Has smoothing
input = Input.GetAxisRaw("Horizontal"); //Has no smoothing

//move player
rb.velocity = new Vector2(input*speed,rb.velocity.y);
rb.velocity = new Vector2(input * speed, rb.velocity.y);
}

/// <summary>
Expand All @@ -119,27 +126,30 @@ void FixedUpdate() {
/// panel is displayed.
/// </summary>
/// <param name="value">Amount of damage for player to take.</param>
public void takeDamage(int value) {
public void takeDamage(int value)
{
health -= value;
GameManager.instance().updateHealthText(health);

if (health <= 0) {
if (health <= 0)
{
//player dies
Instantiate(deathFX, new Vector3(transform.position.x, transform.position.y, 0f), Quaternion.identity);
this.gameObject.SetActive(false);
//GameObject.Destroy(gameObject); //can't have this for an easy reset
GameManager.instance().deathPanelSwitch(true);

}
}

/// <summary>
/// Resets the game to the inital conditions.
/// Resets the game to the initial conditions.
/// </summary>
public void reset(){
health=3;
Vector3 pos =new Vector3(0.14f,-1.41f,0.0781f);
this.transform.position=pos;
public void reset()
{
health = 3;
Vector3 pos = new Vector3(0.14f, -1.41f, 0.0781f);
this.transform.position = pos;
GameManager.instance().updateHealthText(health);
this.gameObject.SetActive(true);
}
Expand Down
12 changes: 12 additions & 0 deletions Logs/Packages-Update.log
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,15 @@ Update Mode: updateDependencies

The following packages were updated:
com.unity.test-framework from version 1.1.9 to 1.1.11

=== Thu Aug 20 11:21:47 2020

Packages were changed.
Update Mode: updateDependencies

The following packages were updated:
com.unity.ads from version 2.3.1 to 3.4.7
com.unity.ide.vscode from version 1.1.4 to 1.2.1
com.unity.multiplayer-hlapi from version 1.0.4 to 1.0.6
com.unity.test-framework from version 1.1.11 to 1.1.16
com.unity.xr.legacyinputhelpers from version 2.0.2 to 2.1.4
10 changes: 5 additions & 5 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
"dependencies": {
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.ads": "2.3.1",
"com.unity.ads": "3.4.7",
"com.unity.analytics": "3.3.5",
"com.unity.collab-proxy": "1.2.16",
"com.unity.ext.nunit": "1.0.0",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.vscode": "1.1.4",
"com.unity.multiplayer-hlapi": "1.0.4",
"com.unity.ide.vscode": "1.2.1",
"com.unity.multiplayer-hlapi": "1.0.6",
"com.unity.purchasing": "2.0.6",
"com.unity.test-framework": "1.1.11",
"com.unity.test-framework": "1.1.16",
"com.unity.textmeshpro": "2.0.1",
"com.unity.timeline": "1.2.10",
"com.unity.ugui": "1.0.0",
"com.unity.xr.legacyinputhelpers": "2.0.2",
"com.unity.xr.legacyinputhelpers": "2.1.4",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
Expand Down
Loading

0 comments on commit 52eaf2a

Please sign in to comment.