Bomb
This commit is contained in:
parent
5855906c9c
commit
de60c392d0
@ -386,6 +386,10 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: Crystal_Sml_A_01
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 100000, guid: d638cc32d98ca2b458e7d672e6b5d561, type: 3}
|
||||
propertyPath: m_TagString
|
||||
value: ore
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 400000, guid: d638cc32d98ca2b458e7d672e6b5d561, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 3
|
||||
@ -1070,6 +1074,10 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: Crystal_Sml_B_01 (1)
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 100000, guid: 152fa45dabcbb324aa494574f578e2b5, type: 3}
|
||||
propertyPath: m_TagString
|
||||
value: ore
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 400000, guid: 152fa45dabcbb324aa494574f578e2b5, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 4
|
||||
@ -1307,6 +1315,10 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: Crystal_Sml_B_01
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 100000, guid: 152fa45dabcbb324aa494574f578e2b5, type: 3}
|
||||
propertyPath: m_TagString
|
||||
value: ore
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 400000, guid: 152fa45dabcbb324aa494574f578e2b5, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 2
|
||||
@ -1423,6 +1435,10 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: Crystal_Sml_A_01 (1)
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 100000, guid: d638cc32d98ca2b458e7d672e6b5d561, type: 3}
|
||||
propertyPath: m_TagString
|
||||
value: ore
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 400000, guid: d638cc32d98ca2b458e7d672e6b5d561, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 5
|
||||
|
37
Assets/scripts/Bomb.cs
Normal file
37
Assets/scripts/Bomb.cs
Normal file
@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Bomb : MonoBehaviour
|
||||
{
|
||||
public int harm;
|
||||
public GameObject bomb;
|
||||
public float explosionRadius = 5f; // 爆炸半径
|
||||
public float maxDamage = 100f; // 最大伤害
|
||||
|
||||
void Explode()
|
||||
{
|
||||
// 获取爆炸范围内的所有目标
|
||||
Collider[] colliders = Physics.OverlapSphere(transform.position, explosionRadius);
|
||||
|
||||
foreach (Collider collider in colliders)
|
||||
{
|
||||
// 计算与目标的距离
|
||||
float distance = Vector3.Distance(transform.position, collider.transform.position);
|
||||
|
||||
// 计算伤害值,距离越远伤害越小
|
||||
float damage = Mathf.Lerp(maxDamage, 0, distance / explosionRadius);
|
||||
|
||||
//具体伤害
|
||||
|
||||
}
|
||||
}
|
||||
void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("Player"))
|
||||
{
|
||||
Explode();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
Assets/scripts/Bomb.cs.meta
Normal file
11
Assets/scripts/Bomb.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02340cc575ba4a043948bf3a6cb7d863
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user