bug fixes

This commit is contained in:
Nim-XD
2025-06-23 17:06:59 +05:30
parent 9255b0f61d
commit 6f66dd5023
26 changed files with 5693 additions and 5406 deletions

View File

@@ -387,15 +387,17 @@ public class enemyScript : NetworkBehaviour
IEnumerator couroutineDeath(){
animationString = "Death";
StartCoroutine(PopDisappearUI());
UpdateAnimation(directionString , animationString);
// RpcUpdateAnim(directionString, animationString,false);
Vector3 lootSpawnPos = transform.position;
lootSpawnPos.z = GameManager.instance.LootSpawnPointsParent.GetChild(0).position.z;
//instantiate loot item
GameObject newLoot = Instantiate(GameManager.instance.GetRandomLoot(), lootSpawnPos, Quaternion.identity);
NetworkServer.Spawn(newLoot);
yield return new WaitForSecondsRealtime(5);
yield return new WaitForSecondsRealtime(7);// dead corpse delay
if (!isServer)
@@ -433,4 +435,39 @@ public class enemyScript : NetworkBehaviour
MagicalhealthBar.SetHealth(newValue,maxHealth);
}
//etc for ui Disspear coroutine
IEnumerator PopDisappearUI(){
Vector3 originalScale = uiEnemy.localScale;
// First, scale up slightly
float popDuration = 0.15f;
float elapsedTime = 0f;
Vector3 popScale = originalScale * 1.2f;
while(elapsedTime < popDuration)
{
float t = elapsedTime / popDuration;
uiEnemy.localScale = Vector3.Lerp(originalScale, popScale, t);
elapsedTime += Time.deltaTime;
yield return null;
}
// Then scale down to zero quickly
float shrinkDuration = 0.3f;
elapsedTime = 0f;
while(elapsedTime < shrinkDuration)
{
float t = elapsedTime / shrinkDuration;
// Use ease-in curve for faster shrinking
float easedT = t * t;
uiEnemy.localScale = Vector3.Lerp(popScale, Vector3.zero, easedT);
elapsedTime += Time.deltaTime;
yield return null;
}
uiEnemy.localScale = Vector3.zero;
uiEnemy.gameObject.SetActive(false);
}
}

View File

@@ -3,17 +3,20 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class healthBar : MonoBehaviour{
public class healthBar : MonoBehaviour
{
public Slider slider;
public Slider slider;
public void SetMaxHealth(int health){
slider.maxValue = health;
slider.value = health;
}
public void SetHealth(int health){
slider.value = health;
}
public void SetMaxHealth(int health)
{
slider.maxValue = health;
slider.value = health;
}
public void SetHealth(int health)
{
slider.value = health;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -27,6 +27,9 @@ public class rangeEnemyFinder : MonoBehaviour
float closestDist = radius * 10f;
targetEnemy = null;
foreach(enemyScript enemy in enemies){
//only consider enemies that are in chase range and have a target
if(!enemy.isInChaseRange || enemy.target == null) continue;
float dist = Vector3.Distance((Vector2)enemy.transform.position,(Vector2)transform.position);
if(dist < radius){
if(dist < closestDist){