Commit 3a7a09f4 authored by 15김민규's avatar 15김민규

죽었을 때 아이템 드랍. 일단 전부 활로.

parent c0e7fe7f
...@@ -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
...@@ -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,7 +201,7 @@ MonoBehaviour: ...@@ -201,7 +201,7 @@ 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
......
...@@ -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
......
...@@ -43,19 +43,25 @@ public class Enemy : MonoBehaviour { ...@@ -43,19 +43,25 @@ public class Enemy : MonoBehaviour {
private Animator animator; 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>(); animator = GetComponent<Animator>();
} }
private void Start() private void Start()
{ {
this.currHealth = maxHealth; this.currHealth = maxHealth;
dropTable = enemyManager.dropTableByID[monsterID];
} }
private void Update() private void Update()
...@@ -67,13 +73,34 @@ public class Enemy : MonoBehaviour { ...@@ -67,13 +73,34 @@ public class Enemy : MonoBehaviour {
public void GetDamaged(float damage) { public void GetDamaged(float damage) {
currHealth -= damage; currHealth -= damage;
if(currHealth <= 0) { if(currHealth <= 0) {
gameObject.SetActive(false); processDeath();
return; return;
} }
animator.SetFloat("knockbackDistance", damage / this.weight); animator.SetFloat("knockbackDistance", damage / this.weight);
animator.SetTrigger("DamagedTrigger"); 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