Reviewed-on: #50 Reviewed-by: Sehyeon <sehyeon1837@gmail.com> Reviewed-by: jay <ayjindev@gmail.com>
This commit is contained in:
commit
bb480fa452
@ -35,7 +35,7 @@ public class PlayerActionAttack : IPlayerAction {
|
||||
comboQueued = true;
|
||||
}
|
||||
|
||||
if (comboTimer >= comboDuration) {
|
||||
if (comboTimer >= comboDuration-player.attackSpeedLevel) {
|
||||
ProceedComboOrEnd();
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,12 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
||||
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<GameObject>
|
||||
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,16 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
||||
hitEffectController = GetComponentInChildren<PlayerHitEffectController>();
|
||||
|
||||
PlayerInit();
|
||||
|
||||
//강화 수치 적용
|
||||
attackPowerLevel = 1 + (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.AttackPower) / 2;
|
||||
moveSpeedLevel = 1 + (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.MoveSpeed) / 2;
|
||||
dashCoolLevel = (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.DashCoolDown)/5;
|
||||
attackSpeedLevel = (float)UpgradeManager.Instance.upgradeStat.CurrentUpgradeLevel(StatType.AttackSpeed)/10;
|
||||
|
||||
attackPower *= attackPowerLevel;
|
||||
moveSpeed *= moveSpeedLevel;
|
||||
dashCooldownDuration -= dashCoolLevel;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -81,6 +103,10 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
||||
_playerStates[CurrentState].Update();
|
||||
}
|
||||
|
||||
//대시 쿨타임 진행
|
||||
if (dashCooldownTimer > 0f)
|
||||
dashCooldownTimer -= Time.deltaTime;
|
||||
|
||||
// Hit 상태거나 게임 끝났을 땐 땐 입력 무시
|
||||
if (CurrentState == PlayerState.Hit || CurrentState == PlayerState.Dead || CurrentState == PlayerState.Win)
|
||||
return;
|
||||
@ -231,6 +257,13 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
||||
{
|
||||
if (!_isBattle) return;
|
||||
|
||||
// 쿨타임 중이면 무시
|
||||
if (IsDashOnCooldown)
|
||||
{
|
||||
Debug.Log("대시 쿨타임 중");
|
||||
return;
|
||||
}
|
||||
|
||||
// 만약 공격 중이면 강제로 공격 종료
|
||||
if (_currentAction == _attackAction && _attackAction.IsActive)
|
||||
{
|
||||
@ -244,6 +277,9 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
||||
|
||||
_currentAction = _actionDash;
|
||||
_actionDash.StartAction(this);
|
||||
|
||||
// 쿨타임 시작
|
||||
dashCooldownTimer = dashCooldownDuration;
|
||||
}
|
||||
|
||||
public void OnActionEnded(IPlayerAction action)
|
||||
|
BIN
Assets/KJM/KJM.unity
(Stored with Git LFS)
BIN
Assets/KJM/KJM.unity
(Stored with Git LFS)
Binary file not shown.
@ -44,7 +44,6 @@ public class HomeSave
|
||||
|
||||
//이벤트
|
||||
public int mealCount = 999;
|
||||
public int houseworkCount = 999;
|
||||
|
||||
//병합을 위한 메서드
|
||||
public void MergeWith(HomeSave other)
|
||||
@ -56,7 +55,6 @@ public class HomeSave
|
||||
if (other.health < 999) health = other.health;
|
||||
if (other.reputation < 999) reputation = other.reputation;
|
||||
if (other.mealCount < 999) mealCount = other.mealCount;
|
||||
if (other.houseworkCount < 999) houseworkCount = other.houseworkCount;
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,4 +64,28 @@ public class Save
|
||||
{
|
||||
public HomeSave homeSave;
|
||||
public DungeonSave dungeonSave;
|
||||
|
||||
public Save InitSave()
|
||||
{
|
||||
return new Save
|
||||
{
|
||||
homeSave = new HomeSave
|
||||
{
|
||||
currentDay = 1,
|
||||
time = 8.0f,
|
||||
health = 8.0f,
|
||||
reputation = 2.0f,
|
||||
mealCount = 0
|
||||
},
|
||||
dungeonSave = new DungeonSave
|
||||
{
|
||||
attackPowerLevel = 1,
|
||||
attackSpeedLevel = 1,
|
||||
heartLevel = 1,
|
||||
moveSpeedLevel = 1,
|
||||
dashCoolDownLevel = 1,
|
||||
stageLevel = 1
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -103,14 +103,7 @@ public class SaveManager : Singleton<SaveManager>
|
||||
{
|
||||
Debug.LogWarning("Backup 세이브 로드 실패: " + e.Message);
|
||||
|
||||
// 백업 시도
|
||||
if (QuickSaveRaw.Exists(MainSaveFilePath))
|
||||
{
|
||||
Debug.LogWarning("메인 세이브로 복구 시도");
|
||||
return LoadMain();
|
||||
}
|
||||
|
||||
// 메인도 없을 경우 새 세이브 생성
|
||||
// 새 세이브 생성
|
||||
Debug.LogError("세이브 전체 손상 → 새 세이브 생성");
|
||||
return CreateNewSave();
|
||||
}
|
||||
@ -119,7 +112,10 @@ public class SaveManager : Singleton<SaveManager>
|
||||
//더미 세이브 파일 생성
|
||||
private Save CreateNewSave()
|
||||
{
|
||||
var fresh = saveDataController.GetSaveData();
|
||||
Save fresh = new Save();
|
||||
mainSave = fresh.InitSave();
|
||||
backupSave = fresh.InitSave();
|
||||
|
||||
SaveMain();
|
||||
SaveBackup();
|
||||
return fresh;
|
||||
@ -184,5 +180,15 @@ public class SaveManager : Singleton<SaveManager>
|
||||
Debug.Log("자동저장 되었습니다.");
|
||||
}
|
||||
|
||||
public void ResetSave()
|
||||
{
|
||||
Save fresh = new Save();
|
||||
mainSave = fresh.InitSave();
|
||||
backupSave = fresh.InitSave();
|
||||
SaveMain();
|
||||
SaveBackup();
|
||||
saveDataController.ApplySaveData(fresh);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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,17 +64,17 @@ 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;
|
||||
mealCount = save.homeSave.mealCount;
|
||||
houseworkCount = save.homeSave.houseworkCount;
|
||||
// time = save.homeSave.time;
|
||||
// currentDay = save.homeSave.currentDay;
|
||||
// health = save.homeSave.health;
|
||||
// reputation = save.homeSave.reputation;
|
||||
//mealCount = save.homeSave.mealCount;
|
||||
//houseworkCount = save.homeSave.houseworkCount;
|
||||
|
||||
Debug.Log("ApplySaveData : " + reputation);
|
||||
}
|
||||
@ -95,18 +95,18 @@ 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,
|
||||
mealCount = this.mealCount,
|
||||
houseworkCount = this.houseworkCount
|
||||
// time = this.time,
|
||||
// currentDay = this.currentDay,
|
||||
// health = this.health,
|
||||
// reputation = this.reputation,
|
||||
//mealCount = this.mealCount,
|
||||
//houseworkCount = this.houseworkCount
|
||||
}
|
||||
};
|
||||
}
|
||||
|
BIN
Assets/KJM/KJM_Test/Upgrade/Prefabs/SaveManager.prefab
(Stored with Git LFS)
Normal file
BIN
Assets/KJM/KJM_Test/Upgrade/Prefabs/SaveManager.prefab
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 322b2c3b468b7714ea61240f9ca7952b
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/KJM/KJM_Test/Upgrade/Prefabs/UpgradeManager.prefab
(Stored with Git LFS)
Normal file
BIN
Assets/KJM/KJM_Test/Upgrade/Prefabs/UpgradeManager.prefab
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 903a43d31237e6d4cb31a9ad566f4481
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -18,7 +18,6 @@ public enum StatType
|
||||
|
||||
public class UpgradeManager : Singleton<UpgradeManager>
|
||||
{
|
||||
//캔버스 프리팹 사용..?
|
||||
Canvas canvas;
|
||||
|
||||
public GameObject backgroundPanel;
|
||||
@ -157,6 +156,18 @@ public class UpgradeManager : Singleton<UpgradeManager>
|
||||
|
||||
//배경 패널 비활성화
|
||||
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<UpgradeManager>
|
||||
|
||||
protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
|
||||
if(canvas == null)
|
||||
canvas = FindObjectOfType<Canvas>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -92,11 +92,11 @@ public class UpgradeStat : MonoBehaviour, ISaveable
|
||||
{
|
||||
dungeonSave = new DungeonSave
|
||||
{
|
||||
attackPowerLevel = levels[StatType.AttackPower],
|
||||
attackSpeedLevel = levels[StatType.AttackSpeed],
|
||||
moveSpeedLevel = levels[StatType.MoveSpeed],
|
||||
dashCoolDownLevel = levels[StatType.DashCoolDown],
|
||||
heartLevel = levels[StatType.Heart]
|
||||
attackPowerLevel = Mathf.Clamp(levels[StatType.AttackPower],1, DEFAULT_MAX),
|
||||
attackSpeedLevel = Mathf.Clamp(levels[StatType.AttackSpeed],1, DEFAULT_MAX),
|
||||
moveSpeedLevel = Mathf.Clamp(levels[StatType.MoveSpeed],1, DEFAULT_MAX),
|
||||
dashCoolDownLevel = Mathf.Clamp(levels[StatType.DashCoolDown],1, DEFAULT_MAX),
|
||||
heartLevel = Mathf.Clamp(levels[StatType.Heart],1, MAX_HEART)
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -109,11 +109,12 @@ public class UpgradeStat : MonoBehaviour, ISaveable
|
||||
{
|
||||
if (save?.dungeonSave == null) return;
|
||||
|
||||
levels[StatType.AttackPower] = save.dungeonSave.attackPowerLevel;
|
||||
levels[StatType.AttackSpeed] = save.dungeonSave.attackSpeedLevel;
|
||||
levels[StatType.MoveSpeed] = save.dungeonSave.moveSpeedLevel;
|
||||
levels[StatType.DashCoolDown] = save.dungeonSave.dashCoolDownLevel;
|
||||
levels[StatType.Heart] = save.dungeonSave.heartLevel;
|
||||
levels[StatType.AttackPower] = Mathf.Clamp(save.dungeonSave.attackPowerLevel,1, DEFAULT_MAX);
|
||||
levels[StatType.AttackSpeed] = Mathf.Clamp(save.dungeonSave.attackSpeedLevel,1, DEFAULT_MAX);
|
||||
levels[StatType.MoveSpeed] = Mathf.Clamp(save.dungeonSave.moveSpeedLevel,1, DEFAULT_MAX);
|
||||
levels[StatType.DashCoolDown] = Mathf.Clamp(save.dungeonSave.dashCoolDownLevel,1, DEFAULT_MAX);
|
||||
levels[StatType.Heart] = Mathf.Clamp(save.dungeonSave.heartLevel,1, MAX_HEART);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,8 +114,6 @@ public class DungeonLogic : MonoBehaviour
|
||||
|
||||
// TODO: 강화 시스템으로 넘어가고 일상 맵으로 이동
|
||||
GameManager.Instance.PanelManager.GetPanel("ClearPanelBG");
|
||||
|
||||
StartCoroutine(DelayedSceneChange()); // 5초 대기 후 전환
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,24 @@ 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
|
||||
|
||||
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 +39,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()
|
||||
|
@ -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,29 @@ public class PlayerStats : MonoBehaviour
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void ApplySaveData(Save save)
|
||||
{
|
||||
if (save?.homeSave != null)
|
||||
{
|
||||
TimeStat = Mathf.Clamp(save.homeSave.time, 0, _gameConstants.maxTime);
|
||||
HealthStat = Mathf.Clamp(save.homeSave.health, 0, _gameConstants.maxHealth);
|
||||
ReputationStat = Mathf.Clamp(save.homeSave.reputation, 0, _gameConstants.maxReputation);
|
||||
_mealCount = Mathf.Clamp(save.homeSave.mealCount, 0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public Save ExtractSaveData()
|
||||
{
|
||||
return new Save
|
||||
{
|
||||
homeSave = new HomeSave
|
||||
{
|
||||
time = Mathf.Clamp(this.TimeStat,0,_gameConstants.maxTime),
|
||||
health = Mathf.Clamp(this.HealthStat,0,_gameConstants.maxHealth),
|
||||
reputation = Mathf.Clamp(this.ReputationStat,0,_gameConstants.maxReputation),
|
||||
mealCount = Mathf.Clamp(this._mealCount,0,2)
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
BIN
Assets/KSH/ReDungeon.unity
(Stored with Git LFS)
BIN
Assets/KSH/ReDungeon.unity
(Stored with Git LFS)
Binary file not shown.
BIN
Assets/KSH/ReHousing.unity
(Stored with Git LFS)
BIN
Assets/KSH/ReHousing.unity
(Stored with Git LFS)
Binary file not shown.
@ -61,5 +61,6 @@ public class ClearPanelController : PanelController, IPointerClickHandler
|
||||
{
|
||||
onCompleted?.Invoke();
|
||||
Hide();
|
||||
UpgradeManager.Instance.StartUpgrade();
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public partial class GameManager : Singleton<GameManager>
|
||||
public partial class GameManager : Singleton<GameManager>,ISaveable
|
||||
{
|
||||
// 게임 진행 상태
|
||||
private int currentDay = 1; // 날짜
|
||||
@ -109,4 +109,33 @@ public partial class GameManager : Singleton<GameManager>
|
||||
{
|
||||
// TODO: 게임 종료 시 로직 추가
|
||||
}
|
||||
|
||||
public void ApplySaveData(Save save)
|
||||
{
|
||||
if (save?.dungeonSave != null)
|
||||
{
|
||||
stageLevel = Mathf.Clamp(save.dungeonSave.stageLevel,1,2);
|
||||
}
|
||||
|
||||
if (save?.homeSave != null)
|
||||
{
|
||||
currentDay = Mathf.Clamp(save.homeSave.currentDay,1,maxDays);
|
||||
}
|
||||
}
|
||||
|
||||
public Save ExtractSaveData()
|
||||
{
|
||||
return new Save
|
||||
{
|
||||
dungeonSave = new DungeonSave()
|
||||
{
|
||||
stageLevel = Mathf.Clamp(this.stageLevel,1,2),
|
||||
},
|
||||
|
||||
homeSave = new HomeSave
|
||||
{
|
||||
currentDay = Mathf.Clamp(this.currentDay,1,maxDays),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user