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
6 changes: 6 additions & 0 deletions UnityClient/.vsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}
8 changes: 8 additions & 0 deletions UnityClient/Assets/Epure Hristu-Stefan.meta

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

74 changes: 74 additions & 0 deletions UnityClient/Assets/Epure Hristu-Stefan/EnemyCombat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyCombat : MonoBehaviour
{

public Transform attackPoint;
public Animator animator;
public LayerMask playerLayer;

public int attackModifier;
public float attackRange;
public int MaxHealth;
public int attackPower;
int currentHealth;
public int defense;
// Start is called before the first frame update
void Start()
{
currentHealth = MaxHealth;
}

public void TakeDamage(int damage)
{
currentHealth -= damage;

animator.SetTrigger("hurt");

if (currentHealth <= 0)
{
Die();
}
}

void Die()
{
animator.SetBool("IsDead", true);
GetComponent<Collider2D>().enabled = false;
this.enabled = false;
}

// Update is called once per frame
void Update()
{
//enemy AI here
}

void Attack()
{
//Play attack animation
animator.SetTrigger("Attack");
//Detect enemies hit by attack
Collider2D[] playersHit = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, playerLayer);

//Apply damage to enemies
foreach (Collider2D player in playersHit)
{
Debug.Log("we hit" + player.name);
player.GetComponent<PlayerCombat>().TakeDamage(DamageFormula(player.GetComponent<PlayerCombat>()));
}
}

public void SetAttackModifier(int modifier)
{
attackModifier = modifier;
}

int DamageFormula(PlayerCombat player)
{
int damage = 5 * attackPower * attackModifier / player.GetComponent<Stats>().defense;
return damage;
}
}
11 changes: 11 additions & 0 deletions UnityClient/Assets/Epure Hristu-Stefan/EnemyCombat.cs.meta

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

77 changes: 77 additions & 0 deletions UnityClient/Assets/Epure Hristu-Stefan/PlayerCombat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerCombat : MonoBehaviour
{

public Animator animator;
public Transform attackPoint;
public LayerMask enemyLayer;
public GameObject currentSword; //assume there are multiple types of swords each with its own stats

float nextAttackTime;

public int attackModifier = 1;
// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
if (Time.time >= nextAttackTime)
{
if (Input.GetMouseButtonDown(0))
{
Attack();
nextAttackTime = Time.time + 1f / currentSword.GetComponent<WeaponStats>().attackRate;
}
}
}

public void TakeDamage(int damage)
{
GetComponent<Stats>().attack.currentHealth -= damage;

animator.SetTrigger("hurt");

if (GetComponent<Stats>().attackcurrentHealth <= 0)
{
Die();
}
}

void Die()
{
animator.SetBool("IsDead", true);
}

void Attack()
{
//Play attack animation
animator.SetTrigger("Attack");
//Detect enemies hit by attack
Collider2D[] enemiesHit = Physics2D.OverlapCircleAll(attackPoint.position, currentSword.GetComponent<WeaponStats>().attackRange, enemyLayer);

//Apply damage to enemies
foreach(Collider2D enemy in enemiesHit)
{
Debug.Log("we hit" + enemy.name);
enemy.GetComponent<EnemyCombat>().TakeDamage(DamageFormula(enemy.GetComponent<EnemyCombat>()));
}
}

public void SetAttackModifier(int modifier)
{
attackModifier = modifier;
}

int DamageFormula(EnemyCombat enemy)
{
int damage = 5 * GetComponent<Stats>().attack * currentSword.GetComponent<WeaponStats>().attackPower * attackModifier / enemy.defense;
return damage;
}
}
11 changes: 11 additions & 0 deletions UnityClient/Assets/Epure Hristu-Stefan/PlayerCombat.cs.meta

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

15 changes: 15 additions & 0 deletions UnityClient/Assets/Epure Hristu-Stefan/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Am implementat un Combat system de baza.

In script-ul PlayerCombat, am implementat o functie simpla de atac, in care
utilizatorul ataca folosind mouse-ul. In cazul in care sunt inamici in zona,
acestia primesc damage. Jucatorul poate fi lovit si poate muri. Damage-ul
aplicat inamicului se calculeaza in functie de puterea atacului, puterea
player-ului, modificatorului de atac, daca e cazul, si nivelul de defensiva
al inamicului, precum si de puterea armei jucatorului.

In script-ul EnemyCombat, am implementat functionalitati similare cu
player-ul, dar am trecut stats-urile in acelasi script, gandindu-ma ca
inamicul nu are stats-uri atasate de gameObject.

In script-ul WeaponStats, am implementat stats-urile posibile pe care le poate
avea o arma, si anume un attackPower, attackRange, attackRate sau enchantLevel.
7 changes: 7 additions & 0 deletions UnityClient/Assets/Epure Hristu-Stefan/README.txt.meta

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

45 changes: 45 additions & 0 deletions UnityClient/Assets/Epure Hristu-Stefan/WeaponStats.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WeaponStats : MonoBehaviour
{
public int attackPower;
public float attackRange;
public float attackRate;
public int enchantLevel;

private void Awake()
{
enchantLevel = 0;
}

public void SetEnchantLevel()
{
if(enchantLevel >= 5)
{
Debug.Log("This weapon is at the maximum enchant level!");
return;
}

enchantLevel += 1;
attackPower = (int)Mathf.Ceil(attackPower * 1.2f);
attackRange *= 1.1f;
attackRate *= 1.2f;
}

public void SetAttackPower(int newAttackPower)
{
attackPower = newAttackPower;
}

public void SetAttackRange(float newAttackRange)
{
attackRange = newAttackRange;
}

public void SetAttackRate(float newAttackRate)
{
attackRate = newAttackRate;
}
}
11 changes: 11 additions & 0 deletions UnityClient/Assets/Epure Hristu-Stefan/WeaponStats.cs.meta

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

13 changes: 7 additions & 6 deletions UnityClient/Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"dependencies": {
"com.unity.collab-proxy": "1.2.16",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.vscode": "1.2.2",
"com.unity.test-framework": "1.1.18",
"com.unity.textmeshpro": "2.1.1",
"com.unity.timeline": "1.2.17",
"com.unity.collab-proxy": "1.9.0",
"com.unity.ide.rider": "2.0.7",
"com.unity.ide.visualstudio": "2.0.14",
"com.unity.ide.vscode": "1.2.4",
"com.unity.test-framework": "1.1.29",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.4.8",
"com.unity.ugui": "1.0.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
Expand Down
44 changes: 35 additions & 9 deletions UnityClient/Packages/packages-lock.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,57 @@
{
"dependencies": {
"com.unity.collab-proxy": {
"version": "1.2.16",
"version": "1.9.0",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ext.nunit": {
"version": "1.0.0",
"version": "1.0.6",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "1.1.4",
"version": "2.0.7",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.1"
},
"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
"version": "2.0.14",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.9"
},
"url": "https://packages.unity.com"
},
"com.unity.ide.vscode": {
"version": "1.2.2",
"version": "1.2.4",
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.test-framework": {
"version": "1.1.18",
"version": "1.1.29",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ext.nunit": "1.0.0",
"com.unity.ext.nunit": "1.0.6",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.textmeshpro": {
"version": "2.1.1",
"version": "3.0.6",
"depth": 0,
"source": "registry",
"dependencies": {
Expand All @@ -51,10 +60,15 @@
"url": "https://packages.unity.com"
},
"com.unity.timeline": {
"version": "1.2.17",
"version": "1.4.8",
"depth": 0,
"source": "registry",
"dependencies": {},
"dependencies": {
"com.unity.modules.director": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.ugui": {
Expand Down Expand Up @@ -199,6 +213,18 @@
"depth": 0,
"source": "builtin",
"dependencies": {
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.uielementsnative": "1.0.0"
}
},
"com.unity.modules.uielementsnative": {
"version": "1.0.0",
"depth": 1,
"source": "builtin",
"dependencies": {
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
}
Expand Down
Loading