2024-12-02 09:37:47 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class bullet : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
[Header("<22><><EFBFBD>е<EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>㣬<EFBFBD><E3A3AC><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>")]
|
|
|
|
|
public GameObject tagpos;
|
|
|
|
|
[Header("<22><><EFBFBD>е<EFBFBD><D0B5>ٶȣ<D9B6><C8A3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>")]
|
|
|
|
|
public float speed;
|
|
|
|
|
[Header("<22>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>˺<EFBFBD>,<2C><><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD>50")]
|
2024-12-02 23:38:32 +08:00
|
|
|
|
public float changehp=100;
|
|
|
|
|
|
|
|
|
|
public Palye user;
|
|
|
|
|
public DamageType damageType = DamageType.noAttributeDamage;
|
2024-12-02 09:37:47 +08:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
if (tagpos != null)
|
|
|
|
|
{
|
|
|
|
|
move();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Destroy(gameObject); // <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD>겻<EFBFBD><EAB2BB><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Init(GameObject target, float bulletSpeed,float changehp=50)
|
|
|
|
|
{
|
|
|
|
|
this.tagpos = target;
|
|
|
|
|
this.speed = bulletSpeed;
|
|
|
|
|
this.changehp = changehp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void move()
|
|
|
|
|
{
|
|
|
|
|
// <20>ӵ<EFBFBD><D3B5><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD>ƶ<EFBFBD>
|
|
|
|
|
Vector3 direction = (tagpos.transform.position - transform.position).normalized;
|
|
|
|
|
transform.position += direction * speed * Time.deltaTime;
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>dz<EFBFBD><C7B3>ӽ<EFBFBD>Ŀ<EFBFBD>꣬<EFBFBD><EAA3AC>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
2024-12-02 23:38:32 +08:00
|
|
|
|
if (Vector3.Distance(transform.position, tagpos.transform.position) < 10f)
|
2024-12-02 09:37:47 +08:00
|
|
|
|
{
|
|
|
|
|
HitTarget();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// <20>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>
|
|
|
|
|
private void HitTarget()
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD>õ<EFBFBD><C3B5>˵<EFBFBD> changehp <20><><EFBFBD><EFBFBD>
|
|
|
|
|
npcInfo enemy = tagpos.GetComponent<npcInfo>();
|
|
|
|
|
if (enemy != null)
|
|
|
|
|
{
|
2024-12-02 23:38:32 +08:00
|
|
|
|
|
|
|
|
|
enemy.bloodLoss(new object[] { enemy , changehp, damageType, user });
|
2024-12-02 09:37:47 +08:00
|
|
|
|
Debug.Log("<22><><EFBFBD>е<EFBFBD><D0B5><EFBFBD>");
|
2024-12-02 23:38:32 +08:00
|
|
|
|
|
|
|
|
|
//BUff buff = new BUff();
|
|
|
|
|
//buff.timeLeft = 5;
|
|
|
|
|
//buff.executionInterval_max = 0.1f;
|
|
|
|
|
//buff.Funaction = enemy.poisoning;
|
|
|
|
|
//buff.value = new object[] { enemy,user };
|
|
|
|
|
//enemy.buffList.Add(buff);
|
|
|
|
|
|
2024-12-02 09:37:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>
|
2024-12-02 23:38:32 +08:00
|
|
|
|
Destroy(gameObject);
|
|
|
|
|
|
2024-12-02 09:37:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|