Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .plastic/plastic.changes
Binary file not shown.
Binary file modified .plastic/plastic.wktree
Binary file not shown.
19 changes: 19 additions & 0 deletions Assets/Scripts/Main.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Main",
"rootNamespace": "",
"references": [
"GUID:4307f53044263cf4b835bd812fc161a4",
"GUID:0da6d172d18a54e4389d0dce1e1ffdf2",
"GUID:8f342294dfb958a4694b67859092b749",
"GUID:6055be8ebefd69e48b49212b09b47b2f"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Assets/Scripts/Main.asmdef.meta

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

17 changes: 17 additions & 0 deletions Assets/Scripts/Player/PlayerMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,21 @@ void Move()
// Apply the movement to the Rigidbody2D's velocity
player.velocity = movement;
}

public void MoveRight()
{
movementVector.x = 1;
}
public void MoveLeft()
{
movementVector.x = -1;
}
public void MoveUp()
{
movementVector.y = 1;
}
public void MoveDown()
{
movementVector.x = -1;
}
}
2 changes: 2 additions & 0 deletions Assets/Scripts/Player/PlayerStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ public void DestroySingleton()
Destroy(gameObject);
}



private IEnumerator DestroyAfterAnimation(GameObject statusEffect)
{
Animator statusAnimator = statusEffect.GetComponent<Animator>();
Expand Down
8 changes: 8 additions & 0 deletions Assets/Tests.meta

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

8 changes: 8 additions & 0 deletions Assets/Tests/EditMode.meta

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

113 changes: 113 additions & 0 deletions Assets/Tests/EditMode/GameTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;

public class NewTestScript
{
private GameObject player;
private Rigidbody2D rb;
private PlayerMovement playerMove;

[SetUp]
public void SetUp()
{
// Create a new GameObject with a PlayerController and Rigidbody2D
player = new GameObject("Player");
rb = player.AddComponent<Rigidbody2D>();

// Optionally set up initial conditions here
rb.gravityScale = 0; // Disable gravity if not needed
}

[TearDown]
public void TearDown()
{
// Clean up after each test
Object.Destroy(player);
}


[Test]
public IEnumerator PlayerMovesRight()
{
PlayerStats.instance.MoveSpeed = 10f;

// Simulate movement
Vector3 initialPosition = player.transform.position;
playerMove.MoveRight();

// Allow some time for movement
yield return new WaitForSeconds(0.1f);

// Assert that the player has moved to the right
Vector3 newPosition = player.transform.position;
Assert.Greater(newPosition.x, initialPosition.x, "Player moves to the right.");
}

public IEnumerator PlayerMovesLeft()
{
PlayerStats.instance.MoveSpeed = 10f;

// Simulate movement
Vector3 initialPosition = player.transform.position;
playerMove.MoveLeft();

// Allow some time for movement
yield return new WaitForSeconds(0.1f);

// Assert that the player has moved to the left
Vector3 newPosition = player.transform.position;
Assert.Greater(newPosition.x, initialPosition.x, "Player moves to the left.");
}

public IEnumerator PlayerMovesUp()
{
PlayerStats.instance.MoveSpeed = 10f;

// Simulate movement
Vector3 initialPosition = player.transform.position;
playerMove.MoveUp();

// Allow some time for movement
yield return new WaitForSeconds(0.1f);

// Assert that the player has moved up
Vector3 newPosition = player.transform.position;
Assert.Greater(newPosition.x, initialPosition.x, "Player moves up.");
}

public IEnumerator PlayerMovesDown()
{
PlayerStats.instance.MoveSpeed = 10f;

// Simulate movement
Vector3 initialPosition = player.transform.position;
playerMove.MoveDown();

// Allow some time for movement
yield return new WaitForSeconds(0.1f);

// Assert that the player has moved down
Vector3 newPosition = player.transform.position;
Assert.Greater(newPosition.x, initialPosition.x, "Player moves down.");
}

[Test]
public void PlayerHealthDoesNotGoBelowZero()
{
// Arrange
PlayerStats.instance.CurrentHealth = 10; // Set current health close to zero
int damageAmount = 15;

// Act
PlayerStats.instance.TakeDamage(damageAmount);

// Assert
Assert.AreEqual(0, PlayerStats.instance.CurrentHealth, "Player's health should not go below zero.");
}



}
11 changes: 11 additions & 0 deletions Assets/Tests/EditMode/GameTests.cs.meta

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

24 changes: 24 additions & 0 deletions Assets/Tests/EditMode/Tests.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Tests",
"rootNamespace": "",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"Main"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Assets/Tests/EditMode/Tests.asmdef.meta

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