Aug19 serv build

This commit is contained in:
Nim-XD
2025-08-19 14:19:44 +05:30
parent 19fff3745e
commit 907924c620
31 changed files with 53609 additions and 1954 deletions

View File

@@ -34,7 +34,7 @@ public class PlayerAttack : NetworkBehaviour{
}
public void onStatChange(){
damage = statManager.GetEffectiveValue("strength");
damage = statManager.GetEffectiveValue("strength") + 10; // Added base damage bonus of 10
}
// void Update(){
// //Get player look dir
@@ -62,7 +62,7 @@ public class PlayerAttack : NetworkBehaviour{
if(hit.collider == null){return;}
if(hit.collider.transform.GetComponent<enemyScript>() != null){
int damageamount = damage + (pnet.lvl*5);
int damageamount = damage + (pnet.lvl*10); // damage amount
if(isMagical){
hit.collider.transform.GetComponent<enemyScript>().TakeMagicalDamage(damageamount, netId);
}else{

View File

@@ -0,0 +1,60 @@
using UnityEngine;
public class ResistanceTest : MonoBehaviour
{
[Header("Test Settings")]
public int testLevel = 5;
public int testPhysicalDamage = 25; // Increased test damage to show more impact
public int testMagicalDamage = 30; // Increased test damage to show more impact
[Header("Results")]
[SerializeField] private string resistanceInfo;
[SerializeField] private int effectivePhysicalDamage;
[SerializeField] private int effectiveMagicalDamage;
[SerializeField] private bool shieldActive;
private enemyScript testEnemy;
void Start()
{
// Create a test enemy
GameObject enemyObj = new GameObject("TestEnemy");
testEnemy = enemyObj.AddComponent<enemyScript>();
// Set the enemy level
testEnemy.SetLevel(testLevel);
// Calculate and display results
CalculateTestResults();
}
void CalculateTestResults()
{
if (testEnemy == null) return;
resistanceInfo = testEnemy.GetResistanceInfo();
effectivePhysicalDamage = testEnemy.CalculateEffectiveDamage(testPhysicalDamage, false);
effectiveMagicalDamage = testEnemy.CalculateEffectiveDamage(testMagicalDamage, true);
shieldActive = testEnemy.IsShieldActive();
Debug.Log($"=== Resistance & Shield Test Results ===");
Debug.Log($"Enemy Level: {testLevel}");
Debug.Log($"Resistance: {resistanceInfo}");
Debug.Log($"Physical Damage: {testPhysicalDamage} -> {effectivePhysicalDamage}");
Debug.Log($"Magical Damage: {testMagicalDamage} -> {effectiveMagicalDamage}");
Debug.Log($"Shield Active: {shieldActive}");
Debug.Log($"Shield Health: {testEnemy.magicalHealth}");
Debug.Log($"Regular Health: {testEnemy.health}");
Debug.Log($"===============================");
}
[ContextMenu("Run Test")]
void RunTest()
{
if (testEnemy != null)
{
testEnemy.SetLevel(testLevel);
CalculateTestResults();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5a18c72b0873842d1973b5396e0901cd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class ResistanceUI : MonoBehaviour
{
[Header("UI References")]
public TextMeshProUGUI resistanceText;
public Slider physicalResistanceSlider;
public Slider magicalResistanceSlider;
public TextMeshProUGUI shieldStatusText;
public Image shieldStatusIcon;
[Header("Target Enemy")]
public enemyScript targetEnemy;
void Start()
{
// Initialize sliders
if (physicalResistanceSlider != null)
{
physicalResistanceSlider.minValue = 0;
physicalResistanceSlider.maxValue = 100;
}
if (magicalResistanceSlider != null)
{
magicalResistanceSlider.minValue = 0;
magicalResistanceSlider.maxValue = 100;
}
}
void Update()
{
if (targetEnemy != null)
{
UpdateResistanceDisplay();
}
}
void UpdateResistanceDisplay()
{
// Update text
if (resistanceText != null)
{
resistanceText.text = $"Resistance: {targetEnemy.GetResistanceInfo()}";
}
// Update sliders
if (physicalResistanceSlider != null)
{
physicalResistanceSlider.value = targetEnemy.physicalResistance;
}
if (magicalResistanceSlider != null)
{
magicalResistanceSlider.value = targetEnemy.magicalResistance;
}
// Update shield status
if (shieldStatusText != null)
{
string shieldStatus = targetEnemy.IsShieldActive() ? "Shield Active" : "Shield Broken";
shieldStatusText.text = shieldStatus;
}
if (shieldStatusIcon != null)
{
Color shieldColor = targetEnemy.IsShieldActive() ? Color.cyan : Color.gray;
shieldStatusIcon.color = shieldColor;
}
}
public void SetTargetEnemy(enemyScript enemy)
{
targetEnemy = enemy;
}
public void ClearTarget()
{
targetEnemy = null;
if (resistanceText != null)
resistanceText.text = "No Target";
if (physicalResistanceSlider != null)
physicalResistanceSlider.value = 0;
if (magicalResistanceSlider != null)
magicalResistanceSlider.value = 0;
if (shieldStatusText != null)
shieldStatusText.text = "No Target";
if (shieldStatusIcon != null)
shieldStatusIcon.color = Color.gray;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6085d8ce013d8431c97ce8c9a356f781
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

66
Assets/Script/XPTest.cs Normal file
View File

@@ -0,0 +1,66 @@
using UnityEngine;
public class XPTest : MonoBehaviour
{
[Header("Test Settings")]
public int testPlayerLevel = 1;
public int maxEnemyLevel = 50;
[Header("Results")]
[SerializeField] private string xpComparison;
void Start()
{
TestXPComparison();
}
void TestXPComparison()
{
string comparison = "=== XP Comparison (Old vs New System) ===\n";
comparison += $"Player Level: {testPlayerLevel}\n\n";
comparison += "Enemy Level | Old XP | New XP | Difference\n";
comparison += "-----------|--------|--------|------------\n";
for (int enemyLevel = 1; enemyLevel <= maxEnemyLevel; enemyLevel += 5)
{
int oldXP = enemyScript.CalculateLegacyXP(enemyLevel);
int newXP = enemyScript.CalculateExponentialXP(enemyLevel, testPlayerLevel);
int difference = newXP - oldXP;
comparison += $"{enemyLevel,10} | {oldXP,6} | {newXP,6} | {difference:+0;-0}\n";
}
comparison += "\n=== Key Examples ===\n";
comparison += $"Level 10 Enemy: {enemyScript.CalculateExponentialXP(10, testPlayerLevel)} XP\n";
comparison += $"Level 20 Enemy: {enemyScript.CalculateExponentialXP(20, testPlayerLevel)} XP\n";
comparison += $"Level 30 Enemy: {enemyScript.CalculateExponentialXP(30, testPlayerLevel)} XP\n";
comparison += $"Level 40 Enemy: {enemyScript.CalculateExponentialXP(40, testPlayerLevel)} XP\n";
comparison += $"Level 50 Enemy: {enemyScript.CalculateExponentialXP(50, testPlayerLevel)} XP\n";
comparison += $"Level 60 Enemy: {enemyScript.CalculateExponentialXP(60, testPlayerLevel)} XP (Capped)\n";
xpComparison = comparison;
Debug.Log(comparison);
}
[ContextMenu("Run XP Test")]
void RunXPTest()
{
TestXPComparison();
}
[ContextMenu("Test Risk Reward")]
void TestRiskReward()
{
Debug.Log("=== Risk Reward Testing ===");
int enemyLevel = 40;
for (int playerLevel = 1; playerLevel <= 50; playerLevel += 10)
{
int xp = enemyScript.CalculateExponentialXP(enemyLevel, playerLevel);
int levelDiff = enemyLevel - playerLevel;
string risk = levelDiff > 0 ? $"Risk (+{levelDiff} levels)" : "Safe";
Debug.Log($"Player Level {playerLevel} vs Enemy Level {enemyLevel}: {xp} XP ({risk})");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4765b4891053f4000aa0ae81c8429bd0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,37 +1,199 @@
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using DG.Tweening;
public class cameraRPG : MonoBehaviour
{
[Header("Core Settings")]
public static cameraRPG instance;
public Transform focus;
public float smoothTime = 2;
public Transform focus;
public Vector3 offset = new Vector3(0, 0, -10);
[Header("Movement")]
public float followSpeed = 2f;
public bool useSmoothing = true;
[Header("Deadzone (Optional)")]
public bool useDeadzone = false;
public Vector2 deadzoneSize = new Vector2(2f, 1f);
public Vector3 offset;
void Awake()
[Header("Look Ahead")]
public bool useLookAhead = false;
public float lookAheadDistance = 2f;
public float lookAheadSpeed = 1f;
[Header("Shake")]
public float shakeDuration = 0.5f;
public float shakeStrength = 1f;
// Private variables
private Vector3 targetPosition;
private Vector3 lookAheadOffset;
private bool isPaused = false;
private Tween currentMoveTween;
private Camera cam;
void Awake()
{
if (instance == null)
{
instance = this;
}
public void SetTarget(Transform target){
focus = target;
//offset = focus.position - transform.position;
}
public bool isPaused =false;
void Update()
else
{
if(focus == null){return;}
if(isPaused){return;}
transform.position = Vector3.Lerp(transform.position, focus.position - offset, Time.deltaTime * smoothTime);
Destroy(gameObject);
return;
}
public void Teleport(Vector3 newLocation){
transform.position = newLocation - offset;
}
}
cam = GetComponent<Camera>();
}
void Start()
{
if (focus != null)
{
transform.position = focus.position + offset;
}
}
public void SetTarget(Transform target)
{
focus = target;
}
public void SetPaused(bool paused)
{
isPaused = paused;
}
void LateUpdate()
{
if (focus == null || isPaused) return;
CalculateTargetPosition();
MoveCamera();
}
void CalculateTargetPosition()
{
targetPosition = focus.position + offset;
// Look ahead based on movement
if (useLookAhead)
{
Vector3 targetLookAhead = Vector3.zero;
// You might want to get velocity from your player controller instead
Rigidbody2D focusRb = focus.GetComponent<Rigidbody2D>();
if (focusRb != null)
{
Vector3 velocity = focusRb.velocity;
targetLookAhead = velocity.normalized * lookAheadDistance;
}
lookAheadOffset = Vector3.Lerp(lookAheadOffset, targetLookAhead, Time.deltaTime * lookAheadSpeed);
targetPosition += lookAheadOffset;
}
// Apply deadzone
if (useDeadzone)
{
Vector3 currentPos = transform.position;
Vector3 difference = targetPosition - currentPos;
// Only move if outside deadzone
if (Mathf.Abs(difference.x) > deadzoneSize.x / 2f)
{
targetPosition.x = currentPos.x + (difference.x - Mathf.Sign(difference.x) * deadzoneSize.x / 2f);
}
else
{
targetPosition.x = currentPos.x;
}
if (Mathf.Abs(difference.y) > deadzoneSize.y / 2f)
{
targetPosition.y = currentPos.y + (difference.y - Mathf.Sign(difference.y) * deadzoneSize.y / 2f);
}
else
{
targetPosition.y = currentPos.y;
}
}
}
void MoveCamera()
{
if (useSmoothing)
{
transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * followSpeed);
}
else
{
transform.position = targetPosition;
}
}
// DOTween enhanced methods
public void TeleportTo(Vector3 newPosition)
{
currentMoveTween?.Kill();
transform.position = newPosition + offset;
}
public void SmoothTeleportTo(Vector3 newPosition, float duration = 1f, Ease easeType = Ease.OutCubic)
{
currentMoveTween?.Kill();
Vector3 targetPos = newPosition + offset;
currentMoveTween = transform.DOMove(targetPos, duration).SetEase(easeType);
}
public void Shake(float duration = -1, float strength = -1)
{
if (duration < 0) duration = shakeDuration;
if (strength < 0) strength = shakeStrength;
transform.DOShakePosition(duration, strength);
}
public void ZoomTo(float targetSize, float duration = 1f, Ease easeType = Ease.OutCubic)
{
if (cam != null)
{
cam.DOOrthoSize(targetSize, duration).SetEase(easeType);
}
}
public void PunchScale(float strength = 0.1f, float duration = 0.3f)
{
transform.DOPunchScale(Vector3.one * strength, duration);
}
// Utility methods
public Vector3 GetTargetPosition()
{
return targetPosition;
}
public bool IsMoving()
{
return Vector3.Distance(transform.position, targetPosition) > 0.01f;
}
void OnDrawGizmosSelected()
{
// Draw deadzone
if (useDeadzone)
{
Gizmos.color = Color.yellow;
Gizmos.DrawWireCube(transform.position, new Vector3(deadzoneSize.x, deadzoneSize.y, 0));
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@ public class teleporter : MonoBehaviour
if(other.tag == "Player"){
if(other.transform == playerNetwork.localPlayerTransform){
other.transform.position = teleportLocation.position;
cameraRPG.instance.Teleport(teleportLocation.position);
cameraRPG.instance.TeleportTo(teleportLocation.position);
}
}
}