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:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1346522711063220}
m_BodyType: 1
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 1
m_AngularDrag: 50
m_GravityScale: 0
m_Material: {fileID: 0}
m_Interpolate: 0
m_Interpolate: 1
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 3
m_CollisionDetection: 1
m_Constraints: 0
--- !u!61 &61019308264186112
BoxCollider2D:
m_ObjectHideFlags: 1
......
......@@ -630,7 +630,12 @@ Prefab:
- target: {fileID: 114402380471012178, guid: 3d077a5f727dd1e4780e9265ed26e036,
type: 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}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3d077a5f727dd1e4780e9265ed26e036, type: 2}
......@@ -770,9 +775,10 @@ Prefab:
propertyPath: m_RootOrder
value: 17
objectReference: {fileID: 0}
- target: {fileID: 1346522711063220, guid: e4298313f9e94c44fb057542ec7ad273, type: 2}
propertyPath: m_IsActive
value: 1
- target: {fileID: 50573848117970958, guid: e4298313f9e94c44fb057542ec7ad273,
type: 2}
propertyPath: m_AngularDrag
value: 50
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e4298313f9e94c44fb057542ec7ad273, type: 2}
......@@ -943,12 +949,46 @@ Prefab:
- target: {fileID: 224071041299093070, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2}
propertyPath: m_RootOrder
value: 4
value: 5
objectReference: {fileID: 0}
- target: {fileID: 224804297962416264, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2}
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}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e6794ab8e2e4c6340a23b382e9497cbb, type: 2}
......@@ -1036,7 +1076,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {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_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1204443556
......@@ -1594,6 +1634,10 @@ Prefab:
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4242738345506188, guid: 29d5569197813594db51adf0d061bc36, type: 2}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 29d5569197813594db51adf0d061bc36, type: 2}
m_IsPrefabAsset: 0
......
......@@ -23,7 +23,10 @@ public class ArcherIdle : StateMachineBehaviour
patrolSpeed = enemy.patrolSpeed;
enemy.ChangeDir_noOption(NumeratedDir.Left);
enemy.ChangeVelocityX_noOption(enemy.MoveDir * patrolSpeed);
if (patrolRange > 0)
{
enemy.ChangeVelocityX_noOption(enemy.MoveDir * patrolSpeed);
}
}
// OnStateUpdate is called on each Update frame between OnStateEnter and O nStateExit callbacks
......@@ -34,7 +37,7 @@ public class ArcherIdle : StateMachineBehaviour
animator.SetTrigger("TrackTrigger");
return;
}
if (!enemy.MovementLock)
if (!enemy.MovementLock && patrolRange > 0)
{
float span = animatorRoot.position.x - origin.x;
......
......@@ -21,7 +21,9 @@ public class EnemyMeleeIdle : StateMachineBehaviour {
patrolSpeed = enemy.patrolSpeed;
enemy.ChangeDir_noOption(NumeratedDir.Left);
enemy.ChangeVelocityX_noOption(enemy.MoveDir * patrolSpeed);
if (enemy.patrolRange > 0) {
enemy.ChangeVelocityX_noOption(enemy.MoveDir * patrolSpeed);
}
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
......@@ -31,7 +33,7 @@ public class EnemyMeleeIdle : StateMachineBehaviour {
animator.SetTrigger("TrackTrigger");
return;
}
if (!enemy.MovementLock)
if (!enemy.MovementLock && patrolRange > 0)
{
float span = animatorRoot.position.x - origin.x;
......
......@@ -3,7 +3,7 @@ using System.Collections;
using UnityEngine;
using Random = UnityEngine.Random;
public abstract class Enemy : MonoBehaviour {
public class Enemy : MonoBehaviour {
// data
......@@ -12,8 +12,8 @@ public abstract class Enemy : MonoBehaviour {
[SerializeField]
DebuffState[] debuffState;
float fireDuration = 0.0f;
protected abstract IEnumerator OnIce(float duration);
protected abstract IEnumerator OnStun(float duration);
protected virtual IEnumerator OnIce(float duration) { yield return 0; }
protected virtual IEnumerator OnStun(float duration) { yield return 0; }
// protected abstract IEnumerator OnBlind(float duration);
// protected abstract IEnumerator OnCharm(float duration);
......@@ -41,7 +41,7 @@ public abstract class Enemy : MonoBehaviour {
public bool Invisible { get; protected set; }
public bool KnockbackLock { 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
private int[] dropTable;
......@@ -73,7 +73,7 @@ public abstract class Enemy : MonoBehaviour {
{
currHealth = maxHealth;
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);
}
......@@ -85,71 +85,50 @@ public abstract class Enemy : MonoBehaviour {
// When damaged
// - 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;
currHealth -= attack.damage;
if (objectName == "NotDyingScarecrow(Clone)")
if (currHealth <= 0)
{
if (currHealth <= 0)
{
prevHealth = maxHealth;
currHealth = maxHealth;
return;
}
if (currHealth < prevHealth)
animator.SetTrigger("DamagedTrigger");
Invisible = true;
animator.SetTrigger("DeadTrigger");
StopCoroutine("OnFire");
GetComponent<SpriteRenderer>().color = Color.white;
return;
}
DebuffApply(attack.debuffTime);
else
float knockbackDist = attack.damage * attack.knockBackMultiplier / weight;
float knockbackTime = (knockbackDist >= 0.5f) ? 0.5f : knockbackDist;
if (MovementLock) // 넉백이 진행 중
{
if (currHealth <= 0)
{
Invisible = true;
animator.SetTrigger("DeadTrigger");
StopCoroutine("OnFire");
GetComponent<SpriteRenderer>().color = Color.white;
return;
}
if (objectName == "DyingScarecrow(Clone)")
{
if (currHealth < prevHealth)
animator.SetTrigger("DamagedTrigger");
}
else
StopCoroutine("Knockback");
}
StartCoroutine(Knockback(knockbackDist, knockbackTime));
float currHealthPercentage = currHealth / maxHealth;
float prevHealthPercentage = prevHealth / maxHealth;
foreach (float percentage in knockbackPercentage)
{
if (currHealthPercentage > percentage) { break; }
if (prevHealthPercentage > percentage)
{
DebuffApply(attack.debuffTime);
float knockbackDist = attack.damage * attack.knockBackMultiplier / weight;
float knockbackTime = (knockbackDist >= 0.5f) ? 0.5f : knockbackDist;
if (MovementLock) // 넉백이 진행 중
{
StopCoroutine("Knockback");
}
StartCoroutine(Knockback(knockbackDist, knockbackTime));
float currHealthPercentage = currHealth / maxHealth;
float prevHealthPercentage = prevHealth / maxHealth;
foreach (float percentage in knockbackPercentage)
{
if (currHealthPercentage > percentage) { break; }
if (prevHealthPercentage > percentage)
{
animator.SetTrigger("DamagedTrigger");
break;
}
}
animator.SetTrigger("TrackTrigger");
animator.SetTrigger("DamagedTrigger");
break;
}
}
animator.SetTrigger("TrackTrigger");
}
public void GetDamaged(float damage)
{
if (Invisible) { return; }
float prevHealth = currHealth;
currHealth -= damage;
if (currHealth <= 0)
......@@ -294,7 +273,11 @@ public abstract class Enemy : MonoBehaviour {
StopAllCoroutines();
enemyManager.EnemyDeadCount++; // 다른 enemy로 인해 소환되는 enemy가 추가될 경우 여기를 건드려야 함
currHealth = maxHealth;
Invisible = false;
// Drop 아이템 결정. 인덱스 별 아이템은 맨 밑에 서술
if (dropTable == null) { return; }
float denominator = dropTable[dropTable.Length - 1];
float numerator = Random.Range(0, denominator);
int indexOfItem = 0;
......@@ -330,10 +313,6 @@ public abstract class Enemy : MonoBehaviour {
{
inventoryManager.AddonInstantiate((ItemQuality)(indexOfItem - 12), transform.parent.position, EnemyManager.dropObjStrength);
}
currHealth = maxHealth;
Invisible = false;
return;
}
public void aaa()
......
......@@ -42,7 +42,7 @@ public class EnemyAir : Enemy {
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;
tempAngle.z = val;
transform.parent.eulerAngles = tempAngle;
......@@ -50,7 +50,7 @@ public class EnemyAir : Enemy {
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;
tempVelocity.x = val.x;
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>
Transform enemySpots = MapManager.currentRoom.roomInGame.transform.Find("enemy spot");
foreach(Transform enemySpot in enemySpots)
{
if (!enemySpot.gameObject.activeSelf) { continue; }
GameObject enemy = enemySpot.gameObject.GetComponent<enemySpot>().enemyPrefab;
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