Cute_demon_attacks/meng_yao/Assets/script/A_Fight/Huo.cs

57 lines
1.8 KiB
C#
Raw Normal View History

2024-12-20 17:40:13 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Huo : MonoBehaviour
{
2024-12-20 18:02:18 +08:00
public enemy Crole; // <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѫ
2024-12-20 17:40:13 +08:00
public Bullet bullet; // <20>ӵ<EFBFBD><D3B5>ű<EFBFBD>
private float lastDamageTime = 0; // <20><>һ<EFBFBD>ο<EFBFBD>Ѫ<EFBFBD><D1AA>ʱ<EFBFBD><CAB1>
private float lastDamageAllTime = 0; // <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
[Header("<22><><EFBFBD>տ<EFBFBD>Ѫ<EFBFBD><D1AA><EFBFBD><EFBFBD>")]
public float attackTime; // <20><>Ѫ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ʱ<EFBFBD><CAB1>
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>")]
public float attackAllTime = 3; // <20><>Ѫ<EFBFBD>ij<EFBFBD><C4B3><EFBFBD>ʱ<EFBFBD><CAB1>
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧʱ<CAA7><CAB1>")]
2024-12-20 18:02:18 +08:00
public float lifeTime = 3f; // <20><><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD>ʱ<EFBFBD>䣬Ĭ<E4A3AC><C4AC> 5 <20><>
2024-12-20 17:40:13 +08:00
private float spawnTime; // <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD>ʱ<EFBFBD><CAB1>
void Start()
{
2024-12-24 17:40:42 +08:00
//Debug.Log("-------------------------");
2024-12-20 17:40:13 +08:00
spawnTime = Time.time; // <20><>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
2024-12-20 18:02:18 +08:00
Crole = transform.parent.GetComponent<enemy>();
2024-12-20 17:40:13 +08:00
}
void Update()
{
// <20>ж<EFBFBD><D0B6>Ƿ񳬹<C7B7><F1B3ACB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
if (Time.time - spawnTime > lifeTime)
{
Destroy(gameObject); // <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
return; // ֱ<>ӷ<EFBFBD><D3B7>أ<EFBFBD><D8A3><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>к<EFBFBD><D0BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD>
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յľ<D5B5><C4BE><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><CBBA>Ŀ۳<C4BF><DBB3><EFBFBD>
if (Crole != null && bullet != null)
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>տ<EFBFBD>Ѫ<EFBFBD><D1AA><EFBFBD><EFBFBD>
if (Time.time - lastDamageAllTime > attackAllTime || lastDamageAllTime == 0)
{
if (Time.time - lastDamageTime > attackTime || attackTime == 0)
{
// ִ<><D6B4><EFBFBD>˺<EFBFBD><CBBA>߼<EFBFBD>
2024-12-23 16:58:00 +08:00
//Crole.bloodLoss(new object[] { Crole, bullet.role.DamageCreate(), bullet.attackObj.damageTyp, bullet.role });
//Debug.Log("<22><><EFBFBD>տ<EFBFBD>Ѫ");
2024-12-20 17:40:13 +08:00
lastDamageTime = Time.time;
}
lastDamageAllTime = Time.time;
}
}
}
}