몬스터 공격 수정 테스트
This commit is contained in:
@@ -19,7 +19,7 @@ namespace TON
|
||||
|
||||
private void Update()
|
||||
{
|
||||
bool isMoving = false;
|
||||
// bool isMoving = false;
|
||||
|
||||
if (Input.GetKey(KeyCode.RightArrow))
|
||||
{
|
||||
@@ -27,7 +27,7 @@ namespace TON
|
||||
position.x += 5.0f * Time.deltaTime;
|
||||
_cachedTransform.position = position;
|
||||
|
||||
isMoving = true;
|
||||
// isMoving = true;
|
||||
|
||||
_spriteRenderer.flipX = false;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ namespace TON
|
||||
position.x -= 5.0f * Time.deltaTime;
|
||||
_cachedTransform.position = position;
|
||||
|
||||
isMoving = true;
|
||||
// isMoving = true;
|
||||
|
||||
_spriteRenderer.flipX = true;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ namespace TON
|
||||
position.y += 10.0f * Time.deltaTime;
|
||||
_cachedTransform.position = position;
|
||||
|
||||
isMoving = true;
|
||||
// isMoving = true;
|
||||
|
||||
_spriteRenderer.flipX = true;
|
||||
}
|
||||
|
||||
34
Gameton-06/Assets/Gameton/Scripts/GameData/MonsterData.cs
Normal file
34
Gameton-06/Assets/Gameton/Scripts/GameData/MonsterData.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
[System.Serializable]
|
||||
public class MonsterData
|
||||
{
|
||||
// 몬스터 아이디
|
||||
public int id;
|
||||
// 몬스터 명 or 프리팹 명?
|
||||
public string name;
|
||||
// 몬스터 타입 ex : melee, ranged
|
||||
public string monsterType;
|
||||
// 몬스터 체력
|
||||
public int hp;
|
||||
|
||||
// 기본 공격력
|
||||
public int attackPower;
|
||||
// 기본 방어력
|
||||
public int defensivePower;
|
||||
|
||||
public MonsterData(int id, string monsterType, string name, int hp, int attackPower, int defensivePower)
|
||||
{
|
||||
id = this.id;
|
||||
monsterType = this.monsterType == "monster" ? "melle" : "ranged";
|
||||
name = this.name;
|
||||
hp = this.hp;
|
||||
attackPower = this.attackPower;
|
||||
defensivePower = this.defensivePower;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3baf3e61ce1aff24b90ec264fa763bd0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
[System.Serializable]
|
||||
|
||||
public class MonsterSkillData
|
||||
{
|
||||
public int id; // 몬스터 id
|
||||
public string skillType; // 스킬 타입(공격, 근거리, 원거리)
|
||||
public int damage; // 스킬 피해량
|
||||
public float coolTime; // 스킬 쿨타임
|
||||
public float skillRange; // 스킬 범위(콜라이더 조정)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68285054ac94bb741b8b33e422a9e28c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -14,7 +14,7 @@ namespace TON
|
||||
public int id; // 적 고유 ID
|
||||
public float currentHP = 100; // HP
|
||||
|
||||
public string name; // 몬스터 명 or 프리팹 명
|
||||
// public string name; // 몬스터 명 or 프리팹 명
|
||||
public string monsterType; // 몬스터 타입 ex : melee, ranged
|
||||
|
||||
|
||||
@@ -68,12 +68,6 @@ namespace TON
|
||||
// todo : 충돌 했으면 attack 전환 (바로 그냥 공격하게 따라가지 말고)
|
||||
// todo : 시야를 벗어났으면 idle 전환
|
||||
|
||||
if (_isDetect)
|
||||
{
|
||||
_animator.SetTrigger("Attack");
|
||||
_isWalking = false;
|
||||
}
|
||||
|
||||
if (_isWalking)
|
||||
{
|
||||
// walking 상태에서 walkingTime을 초과할 경우 idle 애니메이션 재생
|
||||
@@ -130,12 +124,12 @@ namespace TON
|
||||
|
||||
if (prevHP > 0 && currentHP <= 0)
|
||||
{
|
||||
_animator.SetBool("Die", true); // 몬스터 죽는 애니메이션 트리거
|
||||
// _animator.SetBool("Die", true); // 몬스터 죽는 애니메이션 트리거
|
||||
Destroy(gameObject); // 몬스터 파괴
|
||||
}
|
||||
else if (prevHP > 0 && currentHP > 0)
|
||||
{
|
||||
_animator.SetBool("Hit", true); // 피격 애니메이션
|
||||
// _animator.SetBool("Hit", true); // 피격 애니메이션
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +154,11 @@ namespace TON
|
||||
if (other.collider.CompareTag("Player"))
|
||||
{
|
||||
_isDetect = true;
|
||||
_animator.SetTrigger("Attack");
|
||||
if (_isDetect)
|
||||
{
|
||||
_isWalking = false;
|
||||
}
|
||||
MonsterAttack(other.gameObject); // 플레이어에게 공격
|
||||
Debug.Log("감지됨");
|
||||
}
|
||||
@@ -168,6 +167,8 @@ namespace TON
|
||||
private void OnCollisionExit2D(Collision2D other)
|
||||
{
|
||||
_isDetect = false;
|
||||
|
||||
_isWalking = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user