From 4a1404e212d4621c12e2b3a95e04e50cc64eb3e8 Mon Sep 17 00:00:00 2001 From: 99jamin <99jamin56@gmail.com> Date: Tue, 13 May 2025 22:41:47 +0900 Subject: [PATCH] =?UTF-8?q?DEG-165=20[Fix]=20=EC=9D=B4=EC=A0=84=20?= =?UTF-8?q?=EB=B8=8C=EB=9E=9C=EC=B9=98=20=EB=B3=91=ED=95=A9=20=EC=9A=94?= =?UTF-8?q?=EC=86=8C=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlayerAction/PlayerActionAttack.cs | 2 +- Assets/JAY/Scripts/PlayerController.cs | 40 +++++++++++++++++++ Assets/KJM/KJM.unity | 4 +- Assets/KJM/KJM_Test/Save/TestScript.cs | 30 +++++++------- .../Upgrade/Prefabs/SaveManager.prefab | 3 ++ .../Upgrade/Prefabs/SaveManager.prefab.meta | 7 ++++ .../Upgrade/Prefabs/UpgradeManager.prefab | 3 ++ .../Prefabs/UpgradeManager.prefab.meta | 7 ++++ Assets/KJM/KJM_Test/Upgrade/UpgradeManager.cs | 16 +++++++- Assets/KSH/DungeonLogic.cs | 2 - Assets/KSH/DungeonPanelController.cs | 23 ++++++++++- Assets/KSH/PlayerStats.cs | 29 +++++++++++++- Assets/LYM/Scripts/ClearPanelController.cs | 1 + Assets/Scripts/Common/GameManager.cs | 31 +++++++++++++- 14 files changed, 172 insertions(+), 26 deletions(-) create mode 100644 Assets/KJM/KJM_Test/Upgrade/Prefabs/SaveManager.prefab create mode 100644 Assets/KJM/KJM_Test/Upgrade/Prefabs/SaveManager.prefab.meta create mode 100644 Assets/KJM/KJM_Test/Upgrade/Prefabs/UpgradeManager.prefab create mode 100644 Assets/KJM/KJM_Test/Upgrade/Prefabs/UpgradeManager.prefab.meta diff --git a/Assets/JAY/Scripts/PlayerAction/PlayerActionAttack.cs b/Assets/JAY/Scripts/PlayerAction/PlayerActionAttack.cs index 154d9f60..e0662afa 100644 --- a/Assets/JAY/Scripts/PlayerAction/PlayerActionAttack.cs +++ b/Assets/JAY/Scripts/PlayerAction/PlayerActionAttack.cs @@ -35,7 +35,7 @@ public class PlayerActionAttack : IPlayerAction { comboQueued = true; } - if (comboTimer >= comboDuration) { + if (comboTimer >= comboDuration-player.attackSpeedLevel) { ProceedComboOrEnd(); } } diff --git a/Assets/JAY/Scripts/PlayerController.cs b/Assets/JAY/Scripts/PlayerController.cs index b3720cfe..3af1b575 100644 --- a/Assets/JAY/Scripts/PlayerController.cs +++ b/Assets/JAY/Scripts/PlayerController.cs @@ -30,6 +30,12 @@ public class PlayerController : CharacterBase, IObserver private IPlayerAction _currentAction; public IPlayerAction CurrentAction => _currentAction; + // 강화 관련 + private float attackPowerLevel; + private float moveSpeedLevel; + private float dashCoolLevel; + public float attackSpeedLevel; + // 상태 관련 private PlayerStateIdle _playerStateIdle; private PlayerStateMove _playerStateMove; @@ -37,6 +43,12 @@ public class PlayerController : CharacterBase, IObserver private PlayerStateHit _playerStateHit; private PlayerStateDead _playerStateDead; + //대시 쿨타임 관련 + [SerializeField] private float dashCooldownDuration = 1.5f; + private float dashCooldownTimer = 0f; + public bool IsDashOnCooldown => dashCooldownTimer > 0f; + public float DashCooldownRatio => dashCooldownTimer / dashCooldownDuration; + // 행동 관련 private PlayerActionAttack _attackAction; private PlayerActionDash _actionDash; @@ -72,6 +84,20 @@ public class PlayerController : CharacterBase, IObserver hitEffectController = GetComponentInChildren(); PlayerInit(); + + //강화 수치 적용 + //attackPowerLevel = 1 + (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.AttackPower) / 2; + attackPowerLevel = 1.1f; + //moveSpeedLevel = 1 + (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.MoveSpeed) / 2; + moveSpeedLevel = 1.1f; + //dashCoolLevel = (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.DashCoolDown)/5; + dashCoolLevel = 0.2f; + //attackSpeedLevel = (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.AttackSpeed)/10; + attackSpeedLevel = 0.1f; + + attackPower *= attackPowerLevel; + moveSpeed *= moveSpeedLevel; + dashCooldownDuration -= dashCoolLevel; } private void Update() @@ -81,6 +107,10 @@ public class PlayerController : CharacterBase, IObserver _playerStates[CurrentState].Update(); } + //대시 쿨타임 진행 + if (dashCooldownTimer > 0f) + dashCooldownTimer -= Time.deltaTime; + // Hit 상태거나 게임 끝났을 땐 땐 입력 무시 if (CurrentState == PlayerState.Hit || CurrentState == PlayerState.Dead || CurrentState == PlayerState.Win) return; @@ -223,6 +253,13 @@ public class PlayerController : CharacterBase, IObserver { if (!_isBattle) return; + // 쿨타임 중이면 무시 + if (IsDashOnCooldown) + { + Debug.Log("대시 쿨타임 중"); + return; + } + _currentAction = _attackAction; _currentAction.StartAction(this); } @@ -244,6 +281,9 @@ public class PlayerController : CharacterBase, IObserver _currentAction = _actionDash; _actionDash.StartAction(this); + + // 쿨타임 시작 + dashCooldownTimer = dashCooldownDuration; } public void OnActionEnded(IPlayerAction action) diff --git a/Assets/KJM/KJM.unity b/Assets/KJM/KJM.unity index c0fd141b..cb936039 100644 --- a/Assets/KJM/KJM.unity +++ b/Assets/KJM/KJM.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e4246afb41d86d6a92c3bcf1325630d7871a5e59255be61a927c5994dfc1ea81 -size 75255 +oid sha256:bde7a603bba4913552736fd24ee6f8ff6dbcd9511042ef8fc2f0880294387169 +size 78356 diff --git a/Assets/KJM/KJM_Test/Save/TestScript.cs b/Assets/KJM/KJM_Test/Save/TestScript.cs index 1d863d71..108cfffb 100644 --- a/Assets/KJM/KJM_Test/Save/TestScript.cs +++ b/Assets/KJM/KJM_Test/Save/TestScript.cs @@ -38,13 +38,13 @@ public class TestScript : MonoBehaviour,ISaveable // attackSpeedLevel = intValue; // heartLevel = intValue; // moveSpeedLevel = intValue; - stageLevel = intValue; + //stageLevel = intValue; - time = floatValue; - currentDay = intValue; - health = floatValue; - reputation = floatValue; + // time = floatValue; + // currentDay = intValue; + // health = floatValue; + // reputation = floatValue; mealCount = intValue; houseworkCount = intValue; @@ -64,15 +64,15 @@ public class TestScript : MonoBehaviour,ISaveable // heartLevel = save.dungeonSave.heartLevel; // moveSpeedLevel = save.dungeonSave.moveSpeedLevel; // dashCoolDownLevel = save.dungeonSave.dashCoolDownLevel; - stageLevel = save.dungeonSave.stageLevel; + //stageLevel = save.dungeonSave.stageLevel; } if (save?.homeSave != null) { - time = save.homeSave.time; - currentDay = save.homeSave.currentDay; - health = save.homeSave.health; - reputation = save.homeSave.reputation; + // time = save.homeSave.time; + // currentDay = save.homeSave.currentDay; + // health = save.homeSave.health; + // reputation = save.homeSave.reputation; mealCount = save.homeSave.mealCount; houseworkCount = save.homeSave.houseworkCount; @@ -95,16 +95,16 @@ public class TestScript : MonoBehaviour,ISaveable // heartLevel = this.heartLevel, // moveSpeedLevel = this.moveSpeedLevel, // dashCoolDownLevel = this.dashCoolDownLevel, - stageLevel = this.stageLevel, + //stageLevel = this.stageLevel, }, homeSave = new HomeSave { - time = this.time, - currentDay = this.currentDay, - health = this.health, - reputation = this.reputation, + // time = this.time, + // currentDay = this.currentDay, + // health = this.health, + // reputation = this.reputation, mealCount = this.mealCount, houseworkCount = this.houseworkCount } diff --git a/Assets/KJM/KJM_Test/Upgrade/Prefabs/SaveManager.prefab b/Assets/KJM/KJM_Test/Upgrade/Prefabs/SaveManager.prefab new file mode 100644 index 00000000..51ffd182 --- /dev/null +++ b/Assets/KJM/KJM_Test/Upgrade/Prefabs/SaveManager.prefab @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ad0b15cfe6cefa2e27d326d363d8144f357d1b1879c5a3392581699f0bb54f6 +size 1858 diff --git a/Assets/KJM/KJM_Test/Upgrade/Prefabs/SaveManager.prefab.meta b/Assets/KJM/KJM_Test/Upgrade/Prefabs/SaveManager.prefab.meta new file mode 100644 index 00000000..3c01190a --- /dev/null +++ b/Assets/KJM/KJM_Test/Upgrade/Prefabs/SaveManager.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 322b2c3b468b7714ea61240f9ca7952b +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/KJM/KJM_Test/Upgrade/Prefabs/UpgradeManager.prefab b/Assets/KJM/KJM_Test/Upgrade/Prefabs/UpgradeManager.prefab new file mode 100644 index 00000000..3b685f42 --- /dev/null +++ b/Assets/KJM/KJM_Test/Upgrade/Prefabs/UpgradeManager.prefab @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2e7a0d966af4c7e6b8b16729c50291d61752e463b349333bbaf557dd1849790 +size 1999 diff --git a/Assets/KJM/KJM_Test/Upgrade/Prefabs/UpgradeManager.prefab.meta b/Assets/KJM/KJM_Test/Upgrade/Prefabs/UpgradeManager.prefab.meta new file mode 100644 index 00000000..8c795775 --- /dev/null +++ b/Assets/KJM/KJM_Test/Upgrade/Prefabs/UpgradeManager.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 903a43d31237e6d4cb31a9ad566f4481 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/KJM/KJM_Test/Upgrade/UpgradeManager.cs b/Assets/KJM/KJM_Test/Upgrade/UpgradeManager.cs index f7bf555e..db209224 100644 --- a/Assets/KJM/KJM_Test/Upgrade/UpgradeManager.cs +++ b/Assets/KJM/KJM_Test/Upgrade/UpgradeManager.cs @@ -18,7 +18,6 @@ public enum StatType public class UpgradeManager : Singleton { - //캔버스 프리팹 사용..? Canvas canvas; public GameObject backgroundPanel; @@ -157,6 +156,18 @@ public class UpgradeManager : Singleton //배경 패널 비활성화 StartCoroutine(CoFade(backgroundRectTransform.gameObject, 0.7f,0f,0.2f)); + + if (SceneManager.GetActiveScene().name == "ReDungeon") + { + StartCoroutine(DelayedSceneChange()); // n초 대기 후 전환 + } + } + + //씬 전환 대기 코루틴 + private IEnumerator DelayedSceneChange() + { + yield return new WaitForSeconds(2f); + GameManager.Instance.ChangeToHomeScene(); } @@ -232,7 +243,8 @@ public class UpgradeManager : Singleton protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode) { - + if(canvas == null) + canvas = FindObjectOfType(); } } diff --git a/Assets/KSH/DungeonLogic.cs b/Assets/KSH/DungeonLogic.cs index 1bc28af7..9a1251c0 100644 --- a/Assets/KSH/DungeonLogic.cs +++ b/Assets/KSH/DungeonLogic.cs @@ -114,8 +114,6 @@ public class DungeonLogic : MonoBehaviour // TODO: 강화 시스템으로 넘어가고 일상 맵으로 이동 GameManager.Instance.PanelManager.GetPanel("ClearPanelBG"); - - StartCoroutine(DelayedSceneChange()); // 5초 대기 후 전환 } } diff --git a/Assets/KSH/DungeonPanelController.cs b/Assets/KSH/DungeonPanelController.cs index 684b3e7a..4c645e8e 100644 --- a/Assets/KSH/DungeonPanelController.cs +++ b/Assets/KSH/DungeonPanelController.cs @@ -9,6 +9,25 @@ public class DungeonPanelController : MonoBehaviour [SerializeField] private Slider _bossHealthBar; // 0~1 value [SerializeField] private Image[] _playerHealthImages; // color 값 white / black 로 조정 private int _countHealth = 0; + private int visibleHeartCount = 3; // 강화 레벨로 설정됨 + + private void Start() + { + //int level = UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.Heart); // 1~3 + int level = 2; + + visibleHeartCount = 3 + (level - 1); // level 1=3개, 2=4개, 3=5개 + + for (int i = 0; i < _playerHealthImages.Length; i++) + { + var color = _playerHealthImages[i].color; + color.a = (i < visibleHeartCount) ? 1f : 0f; + color = (i < visibleHeartCount) ? Color.white : new Color(1,1,1,0); + _playerHealthImages[i].color = color; + } + + _countHealth = 0; + } public void SetBossHealthBar(float hp) // hp: 0~300 { @@ -21,11 +40,11 @@ public class DungeonPanelController : MonoBehaviour { StartCoroutine(WaitForOneSecond()); // out of index error 방지 - if (_countHealth > _playerHealthImages.Length - 1) return false; + if (_countHealth >= visibleHeartCount) return false; _playerHealthImages[_countHealth].color = Color.black; _countHealth++; - return _countHealth <= _playerHealthImages.Length - 1; + return _countHealth < visibleHeartCount; } IEnumerator WaitForOneSecond() diff --git a/Assets/KSH/PlayerStats.cs b/Assets/KSH/PlayerStats.cs index ea614d58..7fd0e33d 100644 --- a/Assets/KSH/PlayerStats.cs +++ b/Assets/KSH/PlayerStats.cs @@ -5,7 +5,7 @@ using UnityEngine; using UnityEngine.SceneManagement; using Random = UnityEngine.Random; -public class PlayerStats : MonoBehaviour +public class PlayerStats : MonoBehaviour,ISaveable { public class StatsChangeData // 변경된 스탯 데이터 { @@ -385,4 +385,31 @@ public class PlayerStats : MonoBehaviour } #endregion + + public void ApplySaveData(Save save) + { + if (save?.homeSave != null) + { + TimeStat = save.homeSave.time; + HealthStat = save.homeSave.health; + ReputationStat = save.homeSave.reputation; + //mealCount = save.homeSave.mealCount; + //houseworkCount = save.homeSave.houseworkCount; + } + } + + public Save ExtractSaveData() + { + return new Save + { + homeSave = new HomeSave + { + time = this.TimeStat, + health = this.HealthStat, + reputation = this.ReputationStat, + //mealCount = this.mealCount, + //houseworkCount = this.houseworkCount + } + }; + } } diff --git a/Assets/LYM/Scripts/ClearPanelController.cs b/Assets/LYM/Scripts/ClearPanelController.cs index e79991d5..8de3197a 100644 --- a/Assets/LYM/Scripts/ClearPanelController.cs +++ b/Assets/LYM/Scripts/ClearPanelController.cs @@ -61,5 +61,6 @@ public class ClearPanelController : PanelController, IPointerClickHandler { onCompleted?.Invoke(); Hide(); + UpgradeManager.Instance.StartUpgrade(); } } \ No newline at end of file diff --git a/Assets/Scripts/Common/GameManager.cs b/Assets/Scripts/Common/GameManager.cs index 871d1795..85f65d7c 100644 --- a/Assets/Scripts/Common/GameManager.cs +++ b/Assets/Scripts/Common/GameManager.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; -public partial class GameManager : Singleton +public partial class GameManager : Singleton,ISaveable { // 게임 진행 상태 private int currentDay = 1; // 날짜 @@ -109,4 +109,33 @@ public partial class GameManager : Singleton { // TODO: 게임 종료 시 로직 추가 } + + public void ApplySaveData(Save save) + { + if (save?.dungeonSave != null) + { + stageLevel = save.dungeonSave.stageLevel; + } + + if (save?.homeSave != null) + { + currentDay = save.homeSave.currentDay; + } + } + + public Save ExtractSaveData() + { + return new Save + { + dungeonSave = new DungeonSave() + { + stageLevel = this.stageLevel, + }, + + homeSave = new HomeSave + { + currentDay = this.currentDay, + } + }; + } }