Commit 539e6417 authored by 18류지석's avatar 18류지석

Merge branch 'enemy' into item

parents ce128779 3a7a09f4
...@@ -13,25 +13,31 @@ AnimatorController: ...@@ -13,25 +13,31 @@ AnimatorController:
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 9100000} m_Controller: {fileID: 0}
- m_Name: AttackTrigger - m_Name: AttackTrigger
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 9100000} m_Controller: {fileID: 0}
- m_Name: DamagedTrigger - m_Name: DamagedTrigger
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 9100000} m_Controller: {fileID: 0}
- m_Name: DeadTrigger - m_Name: DeadTrigger
m_Type: 9 m_Type: 9
m_DefaultFloat: 0 m_DefaultFloat: 0
m_DefaultInt: 0 m_DefaultInt: 0
m_DefaultBool: 0 m_DefaultBool: 0
m_Controller: {fileID: 9100000} m_Controller: {fileID: 0}
- m_Name: knockbackDistance
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers: m_AnimatorLayers:
- serializedVersion: 5 - serializedVersion: 5
m_Name: Base Layer m_Name: Base Layer
......
...@@ -21,7 +21,7 @@ GameObject: ...@@ -21,7 +21,7 @@ GameObject:
- component: {fileID: 4015301101001556} - component: {fileID: 4015301101001556}
- component: {fileID: 212540714587432698} - component: {fileID: 212540714587432698}
- component: {fileID: 95413729269184064} - component: {fileID: 95413729269184064}
- component: {fileID: 114138317320723260} - component: {fileID: 114118738857420128}
m_Layer: 0 m_Layer: 0
m_Name: Body m_Name: Body
m_TagString: Untagged m_TagString: Untagged
...@@ -71,7 +71,7 @@ Transform: ...@@ -71,7 +71,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1225288737757304} m_GameObject: {fileID: 1225288737757304}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.15799999, y: 0.40100002, z: 0} m_LocalPosition: {x: -0.234, y: 0.621, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 4140258981397796} - {fileID: 4140258981397796}
...@@ -98,7 +98,7 @@ Transform: ...@@ -98,7 +98,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000} m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1636491341446076} m_GameObject: {fileID: 1636491341446076}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 6.876, y: 1.034, z: -0.1645136} m_LocalPosition: {x: 6.01, y: 2.009, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: m_Children:
- {fileID: 4015301101001556} - {fileID: 4015301101001556}
...@@ -133,11 +133,11 @@ BoxCollider2D: ...@@ -133,11 +133,11 @@ BoxCollider2D:
m_GameObject: {fileID: 1636491341446076} m_GameObject: {fileID: 1636491341446076}
m_Enabled: 1 m_Enabled: 1
m_Density: 1 m_Density: 1
m_Material: {fileID: 0} m_Material: {fileID: 6200000, guid: 90e689a435f304c469db49daef28ed89, type: 2}
m_IsTrigger: 0 m_IsTrigger: 0
m_UsedByEffector: 0 m_UsedByEffector: 0
m_UsedByComposite: 0 m_UsedByComposite: 0
m_Offset: {x: 0.08, y: 0.325} m_Offset: {x: -0.020877361, y: 0.5497493}
m_SpriteTilingProperty: m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0} border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0} pivot: {x: 0, y: 0}
...@@ -148,7 +148,7 @@ BoxCollider2D: ...@@ -148,7 +148,7 @@ BoxCollider2D:
adaptiveTiling: 0 adaptiveTiling: 0
m_AutoTiling: 0 m_AutoTiling: 0
serializedVersion: 2 serializedVersion: 2
m_Size: {x: 0.55, y: 1.1} m_Size: {x: 0.5978651, y: 1.1179954}
m_EdgeRadius: 0 m_EdgeRadius: 0
--- !u!61 &61362187134790794 --- !u!61 &61362187134790794
BoxCollider2D: BoxCollider2D:
...@@ -193,7 +193,7 @@ Animator: ...@@ -193,7 +193,7 @@ Animator:
m_HasTransformHierarchy: 1 m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1 m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0 m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &114138317320723260 --- !u!114 &114118738857420128
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
...@@ -201,12 +201,12 @@ MonoBehaviour: ...@@ -201,12 +201,12 @@ MonoBehaviour:
m_GameObject: {fileID: 1225288737757304} m_GameObject: {fileID: 1225288737757304}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f12bf401d26646a488bc32ca7e3845be, type: 3} m_Script: {fileID: 11500000, guid: 2d73d07fdab522c4aa045e1cb6a92e8c, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
monsterID: 101 monsterID: 101
maxHealth: 5 maxHealth: 5
weight: 3 weight: 1
patrolRange: 2 patrolRange: 2
noticeRange: 2 noticeRange: 2
attackRange: 1 attackRange: 1
......
fileFormatVersion: 2
guid: c7a987df794900341bf68b8263f6e205
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
...@@ -757,6 +757,86 @@ Prefab: ...@@ -757,6 +757,86 @@ Prefab:
propertyPath: dropTableData propertyPath: dropTableData
value: value:
objectReference: {fileID: 4900000, guid: 6216895c658a2af40890a4446cc10a8c, type: 3} objectReference: {fileID: 4900000, guid: 6216895c658a2af40890a4446cc10a8c, type: 3}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[1]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[2]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[3]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[4]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[5]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[6]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[7]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[8]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[9]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[10]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[11]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[12]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[13]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[14]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[15]
value: Bow
objectReference: {fileID: 0}
- target: {fileID: 114768470604838176, guid: 54c1a7b414e41724197333a9e17dd49b,
type: 2}
propertyPath: dropItemList.Array.data[0]
value: Bow
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 54c1a7b414e41724197333a9e17dd49b, type: 2} m_SourcePrefab: {fileID: 100100000, guid: 54c1a7b414e41724197333a9e17dd49b, type: 2}
m_IsPrefabAsset: 0 m_IsPrefabAsset: 0
...@@ -1090,7 +1170,7 @@ Prefab: ...@@ -1090,7 +1170,7 @@ Prefab:
- target: {fileID: 114685218848006942, guid: e6794ab8e2e4c6340a23b382e9497cbb, - target: {fileID: 114685218848006942, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2} type: 2}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: UpgradeStage value: SummonEnemy
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 224008356030171754, guid: e6794ab8e2e4c6340a23b382e9497cbb, - target: {fileID: 224008356030171754, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2} type: 2}
...@@ -1117,6 +1197,11 @@ Prefab: ...@@ -1117,6 +1197,11 @@ Prefab:
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 9 value: 9
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 224667404527337120, guid: e6794ab8e2e4c6340a23b382e9497cbb,
type: 2}
propertyPath: m_RootOrder
value: 10
objectReference: {fileID: 0}
m_RemovedComponents: [] m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: e6794ab8e2e4c6340a23b382e9497cbb, type: 2} m_SourcePrefab: {fileID: 100100000, guid: e6794ab8e2e4c6340a23b382e9497cbb, type: 2}
m_IsPrefabAsset: 0 m_IsPrefabAsset: 0
...@@ -1240,15 +1325,15 @@ Prefab: ...@@ -1240,15 +1325,15 @@ Prefab:
m_Modifications: m_Modifications:
- target: {fileID: 4639192263818050, guid: a164c147037e89448820f7387c724c42, type: 2} - target: {fileID: 4639192263818050, guid: a164c147037e89448820f7387c724c42, type: 2}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
value: 6.876 value: 6.01
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4639192263818050, guid: a164c147037e89448820f7387c724c42, type: 2} - target: {fileID: 4639192263818050, guid: a164c147037e89448820f7387c724c42, type: 2}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: 1.034 value: 2.009
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4639192263818050, guid: a164c147037e89448820f7387c724c42, type: 2} - target: {fileID: 4639192263818050, guid: a164c147037e89448820f7387c724c42, type: 2}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
value: -0.1645136 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 4639192263818050, guid: a164c147037e89448820f7387c724c42, type: 2} - target: {fileID: 4639192263818050, guid: a164c147037e89448820f7387c724c42, type: 2}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
......
This diff is collapsed.
fileFormatVersion: 2
guid: 7f2a5cd3b45ab364a9b2e39e41de53e2
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
...@@ -6,8 +6,11 @@ public class Damaged : StateMachineBehaviour { ...@@ -6,8 +6,11 @@ public class Damaged : StateMachineBehaviour {
RuntimeAnimatorController ac; RuntimeAnimatorController ac;
float knockbackTime; float knockbackTime;
float knockbackSpeed;
float knockbackDir; // 1: right \ -1: left
Vector3 leftsideAngle = new Vector3(0, 0, 0); Vector3 leftsideAngle = new Vector3(0, 0, 0);
Vector3 rightsideAngle = new Vector3(0, 180, 0); Vector3 rightsideAngle = new Vector3(0, 180, 0);
Transform pivotTransform;
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state // 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) { override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
...@@ -19,15 +22,20 @@ public class Damaged : StateMachineBehaviour { ...@@ -19,15 +22,20 @@ public class Damaged : StateMachineBehaviour {
knockbackTime = clip.length; knockbackTime = clip.length;
} }
} }
knockbackSpeed = animator.GetFloat("knockbackDistance") / knockbackTime;
Transform playerTransform = EnemyManager.Instance.player.transform; Transform playerTransform = EnemyManager.Instance.player.transform;
Transform pivotTransform = animator.transform.parent; pivotTransform = animator.transform.parent;
pivotTransform.eulerAngles = (playerTransform.position.x - pivotTransform.position.x < 0) ? leftsideAngle : rightsideAngle; pivotTransform.eulerAngles = (playerTransform.position.x - pivotTransform.position.x < 0) ? leftsideAngle : rightsideAngle;
} knockbackDir = (playerTransform.position.x - pivotTransform.position.x < 0) ? 1 : -1;
}
// 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) {
Vector2 currPosition = pivotTransform.position;
} Vector2 movingDistance = new Vector2(knockbackSpeed * Time.deltaTime, 0) * knockbackDir;
pivotTransform.gameObject.GetComponent<Rigidbody2D>().MovePosition(currPosition + movingDistance);
}
// OnStateExit is called when a transition ends and the state machine finishes evaluating this state // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
//override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { //override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
......
...@@ -40,21 +40,28 @@ public class Enemy : MonoBehaviour { ...@@ -40,21 +40,28 @@ public class Enemy : MonoBehaviour {
// for animation // for animation
[HideInInspector] [HideInInspector]
public float playerDistance; public float playerDistance;
private Animator animator;
// drop item // drop item
private InventoryManager inventoryManager;
private int[] dropTable;
// for test
public GameObject droppedItem;
public Item item;
// method // method
// Standard Method // Standard Method
private void Awake() private void Awake()
{ {
enemyManager = EnemyManager.Instance; enemyManager = EnemyManager.Instance;
inventoryManager = GameObject.Find("InventoryManager").GetComponent<InventoryManager>();
animator = GetComponent<Animator>();
} }
private void Start() private void Start()
{ {
this.currHealth = maxHealth; this.currHealth = maxHealth;
playerDistance = Vector2.Distance(enemyManager.player.transform.position, transform.parent.position); dropTable = enemyManager.dropTableByID[monsterID];
} }
private void Update() private void Update()
...@@ -66,10 +73,32 @@ public class Enemy : MonoBehaviour { ...@@ -66,10 +73,32 @@ public class Enemy : MonoBehaviour {
public void GetDamaged(PlayerAttackInfo attack) { public void GetDamaged(PlayerAttackInfo attack) {
currHealth -= attack.damage; currHealth -= attack.damage;
if(currHealth <= 0) { if(currHealth <= 0) {
gameObject.SetActive(false); processDeath();
return; return;
} }
gameObject.GetComponent<Animator>().SetTrigger("DamagedTrigger"); animator.SetFloat("knockbackDistance", damage / this.weight);
animator.SetTrigger("DamagedTrigger");
}
private void processDeath()
{
float denominator = dropTable[dropTable.Length - 1];
float numerator = Random.Range(0, denominator);
int indexOfItem = 0;
for (int i = 0; i < dropTable.Length; i++)
{
if(numerator <= dropTable[i])
{
indexOfItem = i;
break;
}
}
inventoryManager.ItemInstantiate(enemyManager.dropItemList[indexOfItem], transform.parent.position);
gameObject.SetActive(false);
// animator.SetTrigger("DeadTrigger");
return;
} }
IEnumerator DebuffCase(EnemyDebuffed sCase) IEnumerator DebuffCase(EnemyDebuffed sCase)
......
...@@ -17,7 +17,7 @@ public class EnemyManager : Singleton<EnemyManager> ...@@ -17,7 +17,7 @@ public class EnemyManager : Singleton<EnemyManager>
// data of drop item // data of drop item
public TextAsset dropTableData; public TextAsset dropTableData;
public Dictionary<int, int[]> dropTableByID = new Dictionary<int, int[]>(); public Dictionary<int, int[]> dropTableByID = new Dictionary<int, int[]>();
public GameObject[] dropItemList; // insert drop item here(on right order) public string[] dropItemList; // insert drop item here(on right order)
// enemy prefab // enemy prefab
public GameObject[] enemyPrefab; public GameObject[] enemyPrefab;
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyMelee : Enemy {
}
fileFormatVersion: 2
guid: f12bf401d26646a488bc32ca7e3845be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
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