Commit e7a1ad84 authored by 15김민규's avatar 15김민규

거미 구현 끝. Prefabs/enemy/spider 쓰셈. 넉백 디버프 부딪히고 잠깐 멈칫까지 구현

parent 7b447510
......@@ -8,6 +8,12 @@ AnimatorController:
m_Name: Air
serializedVersion: 5
m_AnimatorParameters:
- m_Name: IdleTrigger
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: TrackTrigger
m_Type: 9
m_DefaultFloat: 0
......@@ -79,7 +85,10 @@ AnimatorStateTransition:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: DeadTrigger
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102308230915380642}
m_Solo: 0
......@@ -100,7 +109,10 @@ AnimatorStateTransition:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: IdleTrigger
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102026995191012766}
m_Solo: 0
......@@ -110,7 +122,7 @@ AnimatorStateTransition:
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 1
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
......@@ -121,7 +133,10 @@ AnimatorStateTransition:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: DisableStunTrigger
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102281897657207296}
m_Solo: 0
......@@ -142,7 +157,10 @@ AnimatorStateTransition:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: DamagedTrigger
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102673918059962672}
m_Solo: 0
......@@ -163,7 +181,10 @@ AnimatorStateTransition:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: TrackTrigger
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102281897657207296}
m_Solo: 0
......@@ -173,7 +194,7 @@ AnimatorStateTransition:
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0
m_HasExitTime: 1
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
......@@ -205,18 +226,21 @@ AnimatorStateTransition:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_Conditions: []
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: StunnedTrigger
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102983908728061620}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 0.75
m_ExitTime: 0
m_HasExitTime: 0
m_HasFixedDuration: 1
m_HasFixedDuration: 0
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
......@@ -293,7 +317,7 @@ AnimatorState:
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400000, guid: e38ac228fc296204b80018c3350e6b3d, type: 2}
m_Motion: {fileID: 7400000, guid: a18ed8217cce17348a342f01a47efb4f, type: 2}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
......@@ -367,13 +391,13 @@ AnimatorStateMachine:
m_Position: {x: 96, y: 264, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102673918059962672}
m_Position: {x: 216, y: 360, z: 0}
m_Position: {x: -12, y: 360, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102308230915380642}
m_Position: {x: 384, y: 468, z: 0}
m_Position: {x: 324, y: 468, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102983908728061620}
m_Position: {x: -12, y: 360, z: 0}
m_Position: {x: 216, y: 360, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions:
- {fileID: 1101602240264659518}
......
......@@ -163,7 +163,7 @@ AnimationClip:
m_GenerateMotionCurves: 0
m_Events:
- time: 0
functionName: ChangeVelocityX
functionName: ChangeVelocityX_noOption
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
......
......@@ -109,7 +109,7 @@ AnimationClip:
m_GenerateMotionCurves: 0
m_Events:
- time: 0
functionName: ChangeVelocityX
functionName: ChangeVelocityX_noOption
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Spider Dead
serializedVersion: 6
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves: []
m_PPtrCurves:
- curve:
- time: 0
value: {fileID: 21300000, guid: 3f4a1ae9be64d9f46b0fd7fbffeb58a4, type: 3}
- time: 0.16666667
value: {fileID: 21300000, guid: 3f4a1ae9be64d9f46b0fd7fbffeb58a4, type: 3}
- time: 0.33333334
value: {fileID: 21300000, guid: 3f4a1ae9be64d9f46b0fd7fbffeb58a4, type: 3}
attribute: m_Sprite
path:
classID: 212
script: {fileID: 0}
m_SampleRate: 60
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 0
script: {fileID: 0}
typeID: 212
customType: 23
isPPtrCurve: 1
pptrCurveMapping:
- {fileID: 21300000, guid: 3f4a1ae9be64d9f46b0fd7fbffeb58a4, type: 3}
- {fileID: 21300000, guid: 3f4a1ae9be64d9f46b0fd7fbffeb58a4, type: 3}
- {fileID: 21300000, guid: 3f4a1ae9be64d9f46b0fd7fbffeb58a4, type: 3}
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0.35000002
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 1
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves: []
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_GenerateMotionCurves: 0
m_Events:
- time: 0
functionName: ChangeVelocityXY_zero
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 0
messageOptions: 0
- time: 0.33333334
functionName: DeadEvent
data:
objectReferenceParameter: {fileID: 0}
floatParameter: 0
intParameter: 0
messageOptions: 0
fileFormatVersion: 2
guid: a18ed8217cce17348a342f01a47efb4f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:
......@@ -323,6 +323,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
damage: 4
damageOnce: 1
--- !u!114 &114851997656688694
MonoBehaviour:
m_ObjectHideFlags: 1
......
......@@ -27,7 +27,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!1 &1822069857481414
GameObject:
m_ObjectHideFlags: 0
......@@ -233,7 +233,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 908a1b16b9926f747807d321c5ecc8af, type: 3}
m_Name:
m_EditorClassIdentifier:
damage: 2
damage: 0
isBumpAttack: 1
--- !u!114 &114337624805266014
MonoBehaviour:
m_ObjectHideFlags: 1
......@@ -271,6 +272,7 @@ MonoBehaviour:
trackSpeed: 1.5
knockbackPercentage:
- 0.5
MovementLock: 0
--- !u!212 &212993065858080250
SpriteRenderer:
m_ObjectHideFlags: 1
......
......@@ -770,6 +770,10 @@ Prefab:
propertyPath: m_RootOrder
value: 17
objectReference: {fileID: 0}
- target: {fileID: 1346522711063220, guid: e4298313f9e94c44fb057542ec7ad273, type: 2}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e4298313f9e94c44fb057542ec7ad273, type: 2}
m_IsPrefabAsset: 0
......@@ -1173,10 +1177,6 @@ Prefab:
propertyPath: m_RootOrder
value: 16
objectReference: {fileID: 0}
- target: {fileID: 1636491341446076, guid: a164c147037e89448820f7387c724c42, type: 2}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a164c147037e89448820f7387c724c42, type: 2}
m_IsPrefabAsset: 0
......
......@@ -9,6 +9,7 @@ public class EnemyAirIdle : StateMachineBehaviour {
Vector2 origin;
Transform animatorRoot;
EnemyAir enemy;
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
origin = animator.transform.position;
......@@ -24,6 +25,7 @@ public class EnemyAirIdle : StateMachineBehaviour {
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
if (enemy.PlayerDistance < noticeRange)
{
animator.ResetTrigger("IdleTrigger");
animator.SetTrigger("TrackTrigger");
return;
}
......
......@@ -4,25 +4,39 @@ using UnityEngine;
public class EnemyAirTrack : StateMachineBehaviour {
float trackSpeed;
float trackRange;
float angle;
GameObject player;
Transform animatorRoot;
EnemyAir enemy;
Vector2 direction;
int maxFrame = 10;
int frameCount;
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
animatorRoot = animator.transform.parent;
enemy = animator.GetComponent<EnemyAir>();
player = EnemyManager.Instance.Player;
trackSpeed = enemy.trackSpeed;
frameCount = 0;
SetDirection();
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
if (enemy.PlayerDistance > enemy.noticeRange)
{
animator.ResetTrigger("TrackTrigger");
animator.SetTrigger("IdleTrigger");
enemy.ChangeVelocityXY_noOption(Vector2.zero);
return;
}
SetDirection();
Vector2 vel = direction * trackSpeed;
Vector2 vel = direction.normalized * trackSpeed;
enemy.ChangeVelocityXY_noOption(vel);
}
......@@ -44,7 +58,7 @@ public class EnemyAirTrack : StateMachineBehaviour {
private void SetDirection()
{
direction = player.transform.position - animatorRoot.position;
float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
enemy.ChangeAngleZ_noOption(angle - 90.0f);
}
}
......@@ -4,13 +4,33 @@ using UnityEngine;
public class DamageToPlayer : MonoBehaviour {
public int damage;
public bool isBumpAttack;
// enum debuff
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("Player"))
if (collision.CompareTag("Player") && !isBumpAttack)
{
EnemyAttackInfo attack = new EnemyAttackInfo(damage, 1f, 0, null, null);
collision.gameObject.GetComponent<PlayerAttack>().TakeDamage(attack);
}
}
private void OnTriggerStay2D(Collider2D collision)
{
if (collision.CompareTag("Player") && isBumpAttack && transform.parent.gameObject.GetComponent<Enemy>().bumpable)
{
EnemyAttackInfo attack = new EnemyAttackInfo(damage, 1f, 0, null, null);
collision.gameObject.GetComponent<PlayerAttack>().TakeDamage(attack);
transform.parent.gameObject.GetComponent<EnemyAir>().bumped = true;
transform.parent.gameObject.GetComponent<EnemyAir>().bumpable = false;
}
}
private void OnTriggerExit2D(Collider2D collision)
{
if (collision.CompareTag("Player") && isBumpAttack)
{
transform.parent.gameObject.GetComponent<Enemy>().bumped = false;
}
}
}
......@@ -9,6 +9,7 @@ public abstract class Enemy : MonoBehaviour {
// debuff
readonly float[] immunity_time = new float[(int)EnemyDebuffCase.END_POINTER] { 0.0f, 3.0f, 6.0f, 6.0f, 6.0f };
[SerializeField]
DebuffState[] debuffState;
float fireDuration = 0.0f;
protected abstract IEnumerator OnIce(float duration);
......@@ -36,8 +37,8 @@ public abstract class Enemy : MonoBehaviour {
// for movement
protected Animator animator;
protected float stunnedAnimLength;
public bool MovementLock;
public bool Invisible { get; protected set; }
public bool MovementLock { get; protected set; }
public bool KnockbackLock { get; protected set; }
public float PlayerDistance { get; protected set; }
protected abstract IEnumerator Knockback(float knockbackDist, float knockbackTime);
......@@ -45,7 +46,11 @@ public abstract class Enemy : MonoBehaviour {
// drop item
private int[] dropTable;
// method
// for bumping attack
public bool bumped = false;
public bool bumpable = true;
// method
// Standard method
protected virtual void Awake()
{
......
......@@ -3,19 +3,26 @@ using System.Collections.Generic;
using UnityEngine;
public class EnemyAir : Enemy {
protected override IEnumerator OnIce(float duration)
{
throw new System.NotImplementedException();
}
protected override IEnumerator OnStun(float duration)
protected override void Start()
{
throw new System.NotImplementedException();
base.Start();
StartCoroutine(BumpCheck());
}
protected override IEnumerator Knockback(float knockbackDist, float knockbackTime)
protected override void FixedUpdate()
{
throw new System.NotImplementedException();
base.FixedUpdate();
if (bumpable)
{
MovementLock = false;
}
else
{
ChangeVelocityXY_zero();
MovementLock = true;
}
}
public void ChangeAngleZ_noOption(float val)
......@@ -23,6 +30,11 @@ public class EnemyAir : Enemy {
ChangeAngleZ(val, new bool[] { MovementLock, KnockbackLock });
}
public void ChangeVelocityXY_zero() // 망할 유니티 애니메이션 이벤트 Vec2를 parameter로 받는 함수를 못집어넣음
{
ChangeVelocityXY(Vector2.zero, new bool[] { MovementLock, KnockbackLock });
}
public void ChangeVelocityXY_noOption(Vector2 val)
{
ChangeVelocityXY(val, new bool[] { MovementLock, KnockbackLock });
......@@ -44,4 +56,49 @@ public class EnemyAir : Enemy {
tempVelocity.y = val.y;
transform.parent.gameObject.GetComponent<Rigidbody2D>().velocity = tempVelocity;
}
protected override IEnumerator OnIce(float duration)
{
ChangeVelocityXY(Vector2.zero, new bool[] { });
KnockbackLock = true;
animator.SetTrigger("StunnedTrigger");
animator.speed = stunnedAnimLength / duration;
yield return new WaitForSeconds(duration);
OffDebuff(EnemyDebuffCase.Ice);
}
protected override IEnumerator OnStun(float duration)
{
ChangeVelocityXY(Vector2.zero, new bool[] { });
animator.SetTrigger("StunnedTrigger");
animator.speed = stunnedAnimLength / duration;
yield return new WaitForSeconds(duration);
OffDebuff(EnemyDebuffCase.Stun);
yield return null;
}
// - Knockback coroutine
protected override IEnumerator Knockback(float knockbackDist, float knockbackTime)
{
MovementLock = true;
bool[] lockArray = new bool[] { false, KnockbackLock };
Vector2 knockbackDir = (transform.parent.position - enemyManager.Player.transform.position).normalized;
Vector2 knockbackVelocity = (knockbackDist / knockbackTime) * knockbackDir;
ChangeAngleZ(Mathf.Atan2(knockbackDir.y, knockbackDir.x) * -1, new bool[] { MovementLock, KnockbackLock });
ChangeVelocityXY(knockbackVelocity, lockArray);
yield return new WaitForSeconds(knockbackTime);
MovementLock = false;
ChangeVelocityXY(Vector2.zero, new bool[] { MovementLock, KnockbackLock });
}
IEnumerator BumpCheck()
{
while (true)
{
if (!bumpable) { bumpable = true; }
yield return new WaitForSeconds(1.0f);
}
}
}
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