Commit 79f8b032 authored by 15김민규's avatar 15김민규

Merge branch 'enemy'

# Conflicts:
#	Assets/Scripts/Characters/Enemy/Enemy.cs
parents 517ee9bc 12de29b2
...@@ -141,19 +141,19 @@ Rigidbody2D: ...@@ -141,19 +141,19 @@ Rigidbody2D:
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1346522711063220} m_GameObject: {fileID: 1346522711063220}
m_BodyType: 1 m_BodyType: 0
m_Simulated: 1 m_Simulated: 1
m_UseFullKinematicContacts: 0 m_UseFullKinematicContacts: 0
m_UseAutoMass: 0 m_UseAutoMass: 0
m_Mass: 1 m_Mass: 1
m_LinearDrag: 0 m_LinearDrag: 0
m_AngularDrag: 0.05 m_AngularDrag: 50
m_GravityScale: 1 m_GravityScale: 0
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Interpolate: 0 m_Interpolate: 1
m_SleepingMode: 1 m_SleepingMode: 1
m_CollisionDetection: 0 m_CollisionDetection: 1
m_Constraints: 3 m_Constraints: 0
--- !u!61 &61019308264186112 --- !u!61 &61019308264186112
BoxCollider2D: BoxCollider2D:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
......
...@@ -630,7 +630,12 @@ Prefab: ...@@ -630,7 +630,12 @@ Prefab:
- target: {fileID: 114402380471012178, guid: 3d077a5f727dd1e4780e9265ed26e036, - target: {fileID: 114402380471012178, guid: 3d077a5f727dd1e4780e9265ed26e036,
type: 2} type: 2}
propertyPath: debuffTime.Array.data[2] propertyPath: debuffTime.Array.data[2]
value: 3 value: 0
objectReference: {fileID: 0}
- target: {fileID: 114402380471012178, guid: 3d077a5f727dd1e4780e9265ed26e036,
type: 2}
propertyPath: knockBackMultiplier
value: 100
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3d077a5f727dd1e4780e9265ed26e036, type: 2} m_SourcePrefab: {fileID: 100100000, guid: 3d077a5f727dd1e4780e9265ed26e036, type: 2}
...@@ -770,9 +775,10 @@ Prefab: ...@@ -770,9 +775,10 @@ Prefab:
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 17 value: 17
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1346522711063220, guid: e4298313f9e94c44fb057542ec7ad273, type: 2} - target: {fileID: 50573848117970958, guid: e4298313f9e94c44fb057542ec7ad273,
propertyPath: m_IsActive type: 2}
value: 1 propertyPath: m_AngularDrag
value: 50
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e4298313f9e94c44fb057542ec7ad273, type: 2} m_SourcePrefab: {fileID: 100100000, guid: e4298313f9e94c44fb057542ec7ad273, type: 2}
...@@ -943,12 +949,46 @@ Prefab: ...@@ -943,12 +949,46 @@ Prefab:
- target: {fileID: 224071041299093070, guid: e6794ab8e2e4c6340a23b382e9497cbb, - target: {fileID: 224071041299093070, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2} type: 2}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 4 value: 5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 224804297962416264, guid: e6794ab8e2e4c6340a23b382e9497cbb, - target: {fileID: 224804297962416264, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2} type: 2}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 5 value: 7
objectReference: {fileID: 0}
- target: {fileID: 224612213790397690, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 224851610276147026, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -675
objectReference: {fileID: 0}
- target: {fileID: 224612213790397690, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -580
objectReference: {fileID: 0}
- target: {fileID: 224293546598734980, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -487
objectReference: {fileID: 0}
- target: {fileID: 224071041299093070, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -440
objectReference: {fileID: 0}
- target: {fileID: 224804297962416264, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -394
objectReference: {fileID: 0}
- target: {fileID: 1083421967201116, guid: e6794ab8e2e4c6340a23b382e9497cbb, type: 2}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e6794ab8e2e4c6340a23b382e9497cbb, type: 2} m_SourcePrefab: {fileID: 100100000, guid: e6794ab8e2e4c6340a23b382e9497cbb, type: 2}
...@@ -1036,7 +1076,7 @@ RectTransform: ...@@ -1036,7 +1076,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 131, y: -605} m_AnchoredPosition: {x: 131, y: -628}
m_SizeDelta: {x: 200, y: 50} m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1204443556 --- !u!114 &1204443556
...@@ -1594,6 +1634,10 @@ Prefab: ...@@ -1594,6 +1634,10 @@ Prefab:
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4242738345506188, guid: 29d5569197813594db51adf0d061bc36, type: 2}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 29d5569197813594db51adf0d061bc36, type: 2} m_SourcePrefab: {fileID: 100100000, guid: 29d5569197813594db51adf0d061bc36, type: 2}
m_IsPrefabAsset: 0 m_IsPrefabAsset: 0
......
...@@ -23,8 +23,11 @@ public class ArcherIdle : StateMachineBehaviour ...@@ -23,8 +23,11 @@ public class ArcherIdle : StateMachineBehaviour
patrolSpeed = enemy.patrolSpeed; patrolSpeed = enemy.patrolSpeed;
enemy.ChangeDir_noOption(NumeratedDir.Left); enemy.ChangeDir_noOption(NumeratedDir.Left);
if (patrolRange > 0)
{
enemy.ChangeVelocityX_noOption(enemy.MoveDir * patrolSpeed); enemy.ChangeVelocityX_noOption(enemy.MoveDir * patrolSpeed);
} }
}
// OnStateUpdate is called on each Update frame between OnStateEnter and O nStateExit callbacks // OnStateUpdate is called on each Update frame between OnStateEnter and O nStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
...@@ -34,7 +37,7 @@ public class ArcherIdle : StateMachineBehaviour ...@@ -34,7 +37,7 @@ public class ArcherIdle : StateMachineBehaviour
animator.SetTrigger("TrackTrigger"); animator.SetTrigger("TrackTrigger");
return; return;
} }
if (!enemy.MovementLock) if (!enemy.MovementLock && patrolRange > 0)
{ {
float span = animatorRoot.position.x - origin.x; float span = animatorRoot.position.x - origin.x;
......
...@@ -21,8 +21,10 @@ public class EnemyMeleeIdle : StateMachineBehaviour { ...@@ -21,8 +21,10 @@ public class EnemyMeleeIdle : StateMachineBehaviour {
patrolSpeed = enemy.patrolSpeed; patrolSpeed = enemy.patrolSpeed;
enemy.ChangeDir_noOption(NumeratedDir.Left); enemy.ChangeDir_noOption(NumeratedDir.Left);
if (enemy.patrolRange > 0) {
enemy.ChangeVelocityX_noOption(enemy.MoveDir * patrolSpeed); enemy.ChangeVelocityX_noOption(enemy.MoveDir * patrolSpeed);
} }
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
...@@ -31,7 +33,7 @@ public class EnemyMeleeIdle : StateMachineBehaviour { ...@@ -31,7 +33,7 @@ public class EnemyMeleeIdle : StateMachineBehaviour {
animator.SetTrigger("TrackTrigger"); animator.SetTrigger("TrackTrigger");
return; return;
} }
if (!enemy.MovementLock) if (!enemy.MovementLock && patrolRange > 0)
{ {
float span = animatorRoot.position.x - origin.x; float span = animatorRoot.position.x - origin.x;
......
...@@ -3,7 +3,7 @@ using System.Collections; ...@@ -3,7 +3,7 @@ using System.Collections;
using UnityEngine; using UnityEngine;
using Random = UnityEngine.Random; using Random = UnityEngine.Random;
public abstract class Enemy : MonoBehaviour { public class Enemy : MonoBehaviour {
// data // data
...@@ -12,8 +12,8 @@ public abstract class Enemy : MonoBehaviour { ...@@ -12,8 +12,8 @@ public abstract class Enemy : MonoBehaviour {
[SerializeField] [SerializeField]
DebuffState[] debuffState; DebuffState[] debuffState;
float fireDuration = 0.0f; float fireDuration = 0.0f;
protected abstract IEnumerator OnIce(float duration); protected virtual IEnumerator OnIce(float duration) { yield return 0; }
protected abstract IEnumerator OnStun(float duration); protected virtual IEnumerator OnStun(float duration) { yield return 0; }
// protected abstract IEnumerator OnBlind(float duration); // protected abstract IEnumerator OnBlind(float duration);
// protected abstract IEnumerator OnCharm(float duration); // protected abstract IEnumerator OnCharm(float duration);
...@@ -41,7 +41,7 @@ public abstract class Enemy : MonoBehaviour { ...@@ -41,7 +41,7 @@ public abstract class Enemy : MonoBehaviour {
public bool Invisible { get; protected set; } public bool Invisible { get; protected set; }
public bool KnockbackLock { get; protected set; } public bool KnockbackLock { get; protected set; }
public float PlayerDistance { get; protected set; } public float PlayerDistance { get; protected set; }
protected abstract IEnumerator Knockback(float knockbackDist, float knockbackTime); protected virtual IEnumerator Knockback(float knockbackDist, float knockbackTime) { yield return 0; }
// drop item // drop item
private int[] dropTable; private int[] dropTable;
...@@ -73,7 +73,7 @@ public abstract class Enemy : MonoBehaviour { ...@@ -73,7 +73,7 @@ public abstract class Enemy : MonoBehaviour {
{ {
currHealth = maxHealth; currHealth = maxHealth;
Invisible = MovementLock = KnockbackLock = false; Invisible = MovementLock = KnockbackLock = false;
dropTable = enemyManager.DropTableByID[monsterID]; if (enemyManager.DropTableByID.ContainsKey(monsterID)) { dropTable = enemyManager.DropTableByID[monsterID]; }
PlayerDistance = Vector2.Distance(enemyManager.Player.transform.position, transform.parent.position); PlayerDistance = Vector2.Distance(enemyManager.Player.transform.position, transform.parent.position);
} }
...@@ -85,26 +85,12 @@ public abstract class Enemy : MonoBehaviour { ...@@ -85,26 +85,12 @@ public abstract class Enemy : MonoBehaviour {
// When damaged // When damaged
// - Calculate value & Arrange information // - Calculate value & Arrange information
public void GetDamaged(PlayerAttackInfo attack) public virtual void GetDamaged(PlayerAttackInfo attack)
{ {
string objectName = gameObject.transform.parent.name; if (Invisible) { return; }
float prevHealth = currHealth; float prevHealth = currHealth;
currHealth -= attack.damage; currHealth -= attack.damage;
if (objectName == "NotDyingScarecrow(Clone)")
{
if (currHealth <= 0)
{
prevHealth = maxHealth;
currHealth = maxHealth;
return;
}
if (currHealth < prevHealth)
animator.SetTrigger("DamagedTrigger");
}
else
{
if (currHealth <= 0) if (currHealth <= 0)
{ {
Invisible = true; Invisible = true;
...@@ -113,13 +99,7 @@ public abstract class Enemy : MonoBehaviour { ...@@ -113,13 +99,7 @@ public abstract class Enemy : MonoBehaviour {
GetComponent<SpriteRenderer>().color = Color.white; GetComponent<SpriteRenderer>().color = Color.white;
return; return;
} }
if (objectName == "DyingScarecrow(Clone)")
{
if (currHealth < prevHealth)
animator.SetTrigger("DamagedTrigger");
}
else
{
DebuffApply(attack.debuffTime); DebuffApply(attack.debuffTime);
float knockbackDist = attack.damage * attack.knockBackMultiplier / weight; float knockbackDist = attack.damage * attack.knockBackMultiplier / weight;
...@@ -145,11 +125,10 @@ public abstract class Enemy : MonoBehaviour { ...@@ -145,11 +125,10 @@ public abstract class Enemy : MonoBehaviour {
} }
animator.SetTrigger("TrackTrigger"); animator.SetTrigger("TrackTrigger");
} }
}
}
public void GetDamaged(float damage) public void GetDamaged(float damage)
{ {
if (Invisible) { return; }
float prevHealth = currHealth; float prevHealth = currHealth;
currHealth -= damage; currHealth -= damage;
if (currHealth <= 0) if (currHealth <= 0)
...@@ -294,7 +273,11 @@ public abstract class Enemy : MonoBehaviour { ...@@ -294,7 +273,11 @@ public abstract class Enemy : MonoBehaviour {
StopAllCoroutines(); StopAllCoroutines();
enemyManager.EnemyDeadCount++; // 다른 enemy로 인해 소환되는 enemy가 추가될 경우 여기를 건드려야 함 enemyManager.EnemyDeadCount++; // 다른 enemy로 인해 소환되는 enemy가 추가될 경우 여기를 건드려야 함
currHealth = maxHealth;
Invisible = false;
// Drop 아이템 결정. 인덱스 별 아이템은 맨 밑에 서술 // Drop 아이템 결정. 인덱스 별 아이템은 맨 밑에 서술
if (dropTable == null) { return; }
float denominator = dropTable[dropTable.Length - 1]; float denominator = dropTable[dropTable.Length - 1];
float numerator = Random.Range(0, denominator); float numerator = Random.Range(0, denominator);
int indexOfItem = 0; int indexOfItem = 0;
...@@ -330,10 +313,6 @@ public abstract class Enemy : MonoBehaviour { ...@@ -330,10 +313,6 @@ public abstract class Enemy : MonoBehaviour {
{ {
inventoryManager.AddonInstantiate((ItemQuality)(indexOfItem - 12), transform.parent.position, EnemyManager.dropObjStrength); inventoryManager.AddonInstantiate((ItemQuality)(indexOfItem - 12), transform.parent.position, EnemyManager.dropObjStrength);
} }
currHealth = maxHealth;
Invisible = false;
return;
} }
public void aaa() public void aaa()
......
...@@ -42,7 +42,7 @@ public class EnemyAir : Enemy { ...@@ -42,7 +42,7 @@ public class EnemyAir : Enemy {
private void ChangeAngleZ(float val, bool[] lockArray) private void ChangeAngleZ(float val, bool[] lockArray)
{ {
foreach (var Lock in lockArray) { if (Lock) return; } foreach (var Lock in lockArray) { if (Lock) { return; } }
Vector3 tempAngle = transform.parent.eulerAngles; Vector3 tempAngle = transform.parent.eulerAngles;
tempAngle.z = val; tempAngle.z = val;
transform.parent.eulerAngles = tempAngle; transform.parent.eulerAngles = tempAngle;
...@@ -50,7 +50,7 @@ public class EnemyAir : Enemy { ...@@ -50,7 +50,7 @@ public class EnemyAir : Enemy {
private void ChangeVelocityXY(Vector2 val, bool[] lockArray) private void ChangeVelocityXY(Vector2 val, bool[] lockArray)
{ {
foreach (var Lock in lockArray) { if (Lock) return; } foreach (var Lock in lockArray) { if (Lock) { return; } }
Vector3 tempVelocity = transform.parent.gameObject.GetComponent<Rigidbody2D>().velocity; Vector3 tempVelocity = transform.parent.gameObject.GetComponent<Rigidbody2D>().velocity;
tempVelocity.x = val.x; tempVelocity.x = val.x;
tempVelocity.y = val.y; tempVelocity.y = val.y;
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Scarecrow : Enemy {
public bool neverDie;
public override void GetDamaged(PlayerAttackInfo attack)
{
if (Invisible) { return; }
float prevHealth = currHealth;
currHealth -= attack.damage;
if (currHealth <= 0)
{
if (neverDie)
{
currHealth = maxHealth;
}
else
{
Invisible = true;
animator.SetTrigger("DeadTrigger");
return;
}
}
animator.SetTrigger("DamagedTrigger");
}
}
fileFormatVersion: 2
guid: bf69b9b0b3af3664e89e16eab14c1b0c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -56,6 +56,7 @@ public class EnemyManager : Singleton<EnemyManager> ...@@ -56,6 +56,7 @@ public class EnemyManager : Singleton<EnemyManager>
Transform enemySpots = MapManager.currentRoom.roomInGame.transform.Find("enemy spot"); Transform enemySpots = MapManager.currentRoom.roomInGame.transform.Find("enemy spot");
foreach(Transform enemySpot in enemySpots) foreach(Transform enemySpot in enemySpots)
{ {
if (!enemySpot.gameObject.activeSelf) { continue; }
GameObject enemy = enemySpot.gameObject.GetComponent<enemySpot>().enemyPrefab; GameObject enemy = enemySpot.gameObject.GetComponent<enemySpot>().enemyPrefab;
foreach(Transform location in enemySpot) foreach(Transform location in enemySpot)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment