Merge branch 'dev' of https://github.com/2aurore/Gameton-06 into dev
This commit is contained in:
@@ -13,27 +13,19 @@ namespace TON
|
||||
public string name;
|
||||
// 몬스터 레벨
|
||||
public int level;
|
||||
// 몬스터 타입 ex : melee, ranged
|
||||
public string monsterType;
|
||||
// 몬스터 체력
|
||||
public int hp;
|
||||
// 기본 공격력
|
||||
public int attackPower;
|
||||
// 기본 방어력
|
||||
public int defencePower;
|
||||
// 몬스터 스킬 ID 1
|
||||
// 몬스터 스킬 ID
|
||||
public int monsterSkillID;
|
||||
// 몬스터 스킬 ID 2
|
||||
public int monsterSkillIDTwo;
|
||||
// 패트롤 범위
|
||||
public float patrolRange;
|
||||
// 인식 범위
|
||||
public float detectionRange;
|
||||
// 추적 범위
|
||||
public float chaseRange;
|
||||
public float moveSpeed;
|
||||
// 공격 범위
|
||||
public float attackRange;
|
||||
|
||||
// 골드
|
||||
public int Gold;
|
||||
// 경험치
|
||||
public int Exp;
|
||||
// 점수
|
||||
public int Score;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace TON
|
||||
[SerializeField] private GameObject _target; // 몬스터의 타겟
|
||||
[SerializeField] private Collider2D _collider; // 몬스터의 콜라이더
|
||||
[SerializeField] private SpriteRenderer _spriteRenderer; // 몬스터의 스프라이트 렌더러
|
||||
[SerializeField] private TextMeshProUGUI _textState;
|
||||
// [SerializeField] private TextMeshProUGUI _textState;
|
||||
[SerializeField] public int id; // 몬스터의 ID
|
||||
public float defencePower;
|
||||
public float defenceIntention = 30; // 몬스터 방어력 변수
|
||||
@@ -20,10 +20,12 @@ namespace TON
|
||||
public float currentHP { get; private set; } // 몬스터 현재 체력
|
||||
private float hpMaxWidth;
|
||||
|
||||
private PlayerData _playerData;
|
||||
private MonsterData _monsterData;
|
||||
private Animator _animator; // 몬스터 애니메이터
|
||||
private string currentAnimationState; // 현재 애니메이션 상태
|
||||
|
||||
private float moveSpeed = 2f;
|
||||
|
||||
StateMachine _stateMachine;
|
||||
private SkillPattern _skillPattern;
|
||||
|
||||
@@ -33,6 +35,10 @@ namespace TON
|
||||
public bool IsFinishAttack { get; set; } // 몬스터 공격 모션이 끝났는지 여부
|
||||
public bool IsSkillAttackable => _skillPattern.IsAttackable;
|
||||
|
||||
public int Gold = 0;
|
||||
public int Exp = 0;
|
||||
public int Score = 0;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_animator = GetComponent<Animator>(); // 애니메이터 컴포넌트 초기화
|
||||
@@ -45,8 +51,6 @@ namespace TON
|
||||
|
||||
_skillPattern = new Monster1SkillPattern(_monsterData, this);
|
||||
|
||||
id = _monsterData.id;
|
||||
|
||||
_direction = new Vector3(1, 0, 0); // 초기 이동 방향 (x 축 양의 방향)
|
||||
|
||||
_spriteRenderer.flipX = !(_direction.x > 0); // 이동 방향에 따라 스프라이트 플립
|
||||
@@ -62,8 +66,11 @@ namespace TON
|
||||
{
|
||||
currentHP = _monsterData.hp;
|
||||
defencePower = _monsterData.defencePower;
|
||||
Gold = _monsterData.Gold;
|
||||
Exp = _monsterData.Exp;
|
||||
Score = _monsterData.Score;
|
||||
|
||||
Debug.Log($"몬스터 {_monsterData.name} 데이터 로드 완료");
|
||||
// Debug.Log($"몬스터 {_monsterData.name} 데이터 로드 완료");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -71,6 +78,11 @@ namespace TON
|
||||
}
|
||||
}
|
||||
|
||||
public void RewardData()
|
||||
{
|
||||
StageManager.Singleton.SetRewardData(Gold, Exp, Score);
|
||||
}
|
||||
|
||||
public void ChangeAnimationState(string newState)
|
||||
{
|
||||
if (currentAnimationState == newState) return; // 현재 상태와 동일한 상태일 경우, 애니메이션을 변경하지 않음
|
||||
@@ -94,7 +106,7 @@ namespace TON
|
||||
float prevHP = currentHP; // 몬스터의 체력을 감소시키고, 죽었을 경우 파괴 처리
|
||||
currentHP -= damage;
|
||||
|
||||
UpdateHPBar();
|
||||
UpdateHPBar(currentHP);
|
||||
|
||||
if (prevHP > 0 && currentHP <= 0)
|
||||
{
|
||||
@@ -107,7 +119,7 @@ namespace TON
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateHPBar()
|
||||
private void UpdateHPBar(float currentHP)
|
||||
{
|
||||
if (_hpBarImage != null)
|
||||
{
|
||||
@@ -118,15 +130,14 @@ namespace TON
|
||||
}
|
||||
}
|
||||
|
||||
public void Attack(GameObject player)
|
||||
public void Attack()
|
||||
{
|
||||
// 데미지 계산 (현재 임시 값)
|
||||
DamageCalculator damageCalculator = new DamageCalculator();
|
||||
|
||||
float baseAttack = _monsterData.attackPower; // 기본 공격력
|
||||
float equipmentAttack = 0; // 장비 공격력
|
||||
// float defense = _monsterData.defencePower; // 방어력 비율
|
||||
float defense = PlayerDataManager.Singleton.defensiveIntention; // 캐릭터 방어력
|
||||
float defense = PlayerDataManager.Singleton.player.defensivePower / (PlayerDataManager.Singleton.player.defensivePower + PlayerDataManager.Singleton.defensiveIntention); // 캐릭터 방어력
|
||||
|
||||
// 기본 데미지 계산 (치명타 없음)
|
||||
float damage = damageCalculator.CalculateBaseDamage(baseAttack, equipmentAttack, defense);
|
||||
@@ -134,12 +145,6 @@ namespace TON
|
||||
Debug.Log($" 몬스터 공격! 최종 데미지: {damage}"); // 데미지 출력
|
||||
}
|
||||
|
||||
public void PlayerAttack()
|
||||
{
|
||||
var target = GameObject.FindGameObjectWithTag("Player");
|
||||
Attack(target);
|
||||
}
|
||||
|
||||
public void SetOppositionDirection()
|
||||
{
|
||||
_direction *= -1; // 이동 방향 반전
|
||||
@@ -148,7 +153,7 @@ namespace TON
|
||||
|
||||
public void Move()
|
||||
{
|
||||
transform.Translate(_direction * _monsterData.moveSpeed * Time.deltaTime); // 몬스터를 이동시킴
|
||||
transform.Translate(_direction * moveSpeed * Time.deltaTime); // 몬스터를 이동시킴
|
||||
}
|
||||
|
||||
public void Chasing()
|
||||
@@ -157,17 +162,21 @@ namespace TON
|
||||
UnityEngine.Vector2 direction = target.transform.position - transform.position; // 타겟과의 방향 계산
|
||||
_spriteRenderer.flipX = target.transform.position.x < transform.position.x; // 타겟이 왼쪽에 있으면 스프라이트를 왼쪽으로, 오른쪽에 있으면 오른쪽으로 바라보도록 설정
|
||||
|
||||
transform.Translate(direction.normalized * _monsterData.moveSpeed * Time.deltaTime); // 타겟 방향으로 이동
|
||||
transform.Translate(direction.normalized * moveSpeed * Time.deltaTime); // 타겟 방향으로 이동
|
||||
}
|
||||
|
||||
public void MonsterSkillLaunch()
|
||||
{
|
||||
var target = GameObject.FindGameObjectWithTag("Player");
|
||||
_skillPattern.Attack(target);
|
||||
if (_monsterData.monsterSkillID != 0)
|
||||
{
|
||||
var target = GameObject.FindGameObjectWithTag("Player");
|
||||
_skillPattern.Attack(target);
|
||||
}
|
||||
}
|
||||
|
||||
public void DestroyMonster()
|
||||
{
|
||||
RewardData();
|
||||
Destroy(gameObject); // 몬스터 파괴
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.PixelFantasy.PixelMonsters.Common.Scripts;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -8,6 +9,7 @@ namespace TON
|
||||
{
|
||||
public class MonsterSpawner : MonoBehaviour
|
||||
{
|
||||
private MonsterBase _monsterBase;
|
||||
public Transform[] spawnPoints; // 스폰 위치 배열
|
||||
|
||||
private List<GameObject> monsterPool; // 몬스터 오브젝트 풀
|
||||
@@ -76,6 +78,9 @@ namespace TON
|
||||
private void StartNextWave()
|
||||
{
|
||||
currentWave++;
|
||||
|
||||
StageManager.Singleton.SetWaveData(currentWave); // 웨이브 정보 전달.
|
||||
|
||||
if (currentWave > TOTAL_WAVES)
|
||||
{
|
||||
// Debug.Log("모든 웨이브 완료!");
|
||||
|
||||
@@ -24,42 +24,43 @@ namespace TON
|
||||
public class Monster1SkillPattern : SkillPattern
|
||||
{
|
||||
private float _skill1CoolTime;
|
||||
private float _skill2CoolTime;
|
||||
// private float _skill2CoolTime;
|
||||
|
||||
private MonsterSkillData _monsterSkillData;
|
||||
private MonsterSkillData _monsterSkillDataTwo;
|
||||
// private MonsterSkillData _monsterSkillDataTwo;
|
||||
|
||||
private MonsterSkill _skill1;
|
||||
private MonsterSkill _skill2;
|
||||
// private MonsterSkill _skill2;
|
||||
|
||||
private Vector3 _skillOffset = new Vector3(0, -0.5f, 0); // 스킬 생성 위치 조정값
|
||||
|
||||
public Monster1SkillPattern(MonsterData monsterData, MonsterBase monsterBase) : base(monsterData, monsterBase)
|
||||
{
|
||||
_monsterSkillData = MonsterSkillDataManager.Singleton.GetMonsterSkillData(_monsterData.monsterSkillID);
|
||||
if (_monsterData.monsterSkillIDTwo > -1)
|
||||
{
|
||||
_monsterSkillDataTwo = MonsterSkillDataManager.Singleton.GetMonsterSkillData(_monsterData.monsterSkillIDTwo);
|
||||
}
|
||||
// if (_monsterData.monsterSkillIDTwo > -1)
|
||||
// {
|
||||
// _monsterSkillDataTwo = MonsterSkillDataManager.Singleton.GetMonsterSkillData(_monsterData.monsterSkillIDTwo);
|
||||
// }
|
||||
|
||||
if (_monsterSkillData != null && _monsterSkillDataTwo != null)
|
||||
// if (_monsterSkillData != null && _monsterSkillDataTwo != null)
|
||||
if (_monsterSkillData != null)
|
||||
{
|
||||
|
||||
Debug.Log($"몬스터 {_monsterSkillData.skillName} 데이터 로드 완료");
|
||||
Debug.Log($"몬스터 {_monsterSkillDataTwo.skillName} 데이터 로드 완료");
|
||||
// Debug.Log($"몬스터 {_monsterSkillDataTwo.skillName} 데이터 로드 완료");
|
||||
|
||||
// 프리팹을 연결한 코드
|
||||
_skill1 = Resources.Load<MonsterSkill>($"MonsterSkillPrefabs/{_monsterSkillData.skillName}");
|
||||
_skill2 = Resources.Load<MonsterSkill>($"MonsterSkillPrefabs/{_monsterSkillDataTwo.skillName}");
|
||||
// _skill2 = Resources.Load<MonsterSkill>($"MonsterSkillPrefabs/{_monsterSkillDataTwo.skillName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"몬스터 스킬 ID {_monsterSkillData.skillId}에 대한 데이터를 찾을 수 없습니다.");
|
||||
Debug.LogError($"몬스터 스킬 ID {_monsterSkillDataTwo.skillId}에 대한 데이터를 찾을 수 없습니다.");
|
||||
// Debug.LogError($"몬스터 스킬 ID {_monsterSkillDataTwo.skillId}에 대한 데이터를 찾을 수 없습니다.");
|
||||
}
|
||||
|
||||
_skill1CoolTime = Time.realtimeSinceStartup;
|
||||
_skill2CoolTime = Time.realtimeSinceStartup;
|
||||
// _skill2CoolTime = Time.realtimeSinceStartup;
|
||||
|
||||
}
|
||||
|
||||
@@ -84,11 +85,11 @@ namespace TON
|
||||
IsAttackable = true;
|
||||
}
|
||||
|
||||
if (Time.realtimeSinceStartup - _skill2CoolTime >= _monsterSkillDataTwo.cooldown)
|
||||
{
|
||||
// TODO : 범위 체크
|
||||
IsAttackable = true;
|
||||
}
|
||||
// if (Time.realtimeSinceStartup - _skill2CoolTime >= _monsterSkillDataTwo.cooldown)
|
||||
// {
|
||||
// // TODO : 범위 체크
|
||||
// IsAttackable = true;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,6 @@ namespace TON
|
||||
|
||||
_monsterBase = monsterBase;
|
||||
_monsterBase.ChangeAnimationState(AniWalk);
|
||||
|
||||
}
|
||||
|
||||
public void Update()
|
||||
@@ -182,7 +181,6 @@ namespace TON
|
||||
|
||||
// 추적 상태
|
||||
return this;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +224,7 @@ namespace TON
|
||||
private void Attack()
|
||||
{
|
||||
_monsterBase.ChangeAnimationState(AniAttack);
|
||||
_monsterBase.PlayerAttack();
|
||||
_monsterBase.Attack();
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
|
||||
Reference in New Issue
Block a user