756 lines
24 KiB
C#
756 lines
24 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using DG.Tweening;
|
||
using DragonLi.Core;
|
||
using DragonLi.Frame;
|
||
using UnityEngine;
|
||
using UnityEngine.AI;
|
||
|
||
public class DropShip : Enemy
|
||
{
|
||
public float oneAttackInterval;
|
||
public GameObject player;
|
||
public Transform[] enemyPos;
|
||
public Vector3 startPos;
|
||
|
||
public GameObject bigXl;//大招蓄力特效
|
||
public GameObject mzObj;//瞄准特效
|
||
public GameObject damagableObj;//受伤特效
|
||
|
||
public GameObject[] tailGas;//飞机尾气
|
||
|
||
private bool _isShow;
|
||
|
||
private bool idle;
|
||
|
||
public GameObject[] damageEffects; // 存储所有受伤特效对象
|
||
|
||
public override void Init()
|
||
{
|
||
base.Init();
|
||
idle = true;
|
||
_isShow = true;
|
||
bigXl.SetActive(false);
|
||
mzObj.SetActive(false);
|
||
damagableObj.SetActive(false);
|
||
player = GameManager.Ins.player;
|
||
foreach (var item in components)
|
||
{
|
||
item.Stop();
|
||
}
|
||
components[^1].boxCollider.enabled = false;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(false);
|
||
}
|
||
bloodSlider.gameObject.SetActive(false);
|
||
enemyState = EnemyState.Show;
|
||
|
||
GameInit.Ins.PlayAudio("1.8", GameInit.Ins.self.transform, true);
|
||
|
||
// 初始化受伤特效
|
||
foreach (var effect in damageEffects)
|
||
{
|
||
if (effect != null) effect.SetActive(false);
|
||
}
|
||
}
|
||
|
||
public override void Attack()
|
||
{
|
||
base.Attack();
|
||
components[0].Play();
|
||
components[1].Play();
|
||
}
|
||
|
||
public override void StopAttack()
|
||
{
|
||
base.StopAttack();
|
||
foreach (var item in components)
|
||
{
|
||
item.Stop();
|
||
}
|
||
}
|
||
|
||
public override void OneAttackMode()
|
||
{
|
||
base.OneAttackMode();
|
||
components[0].Stop();
|
||
components[1].Stop();
|
||
if (components[2].isDead && components[3].isDead)
|
||
{
|
||
Fly();
|
||
}
|
||
else if (!components[2].isDead && components[3].isDead)
|
||
{
|
||
StartCoroutine(ShootOneAttackMode(2, Fly));
|
||
}
|
||
else if (components[2].isDead && !components[3].isDead)
|
||
{
|
||
StartCoroutine(ShootOneAttackMode(3, Fly));
|
||
}
|
||
else
|
||
{
|
||
StartCoroutine(ShootOneAttackMode(2));
|
||
StartCoroutine(ShootOneAttackMode(3, Fly));
|
||
}
|
||
|
||
}
|
||
|
||
public override void TwoAttackMode()
|
||
{
|
||
base.TwoAttackMode();
|
||
ShowEnemy();
|
||
}
|
||
|
||
public void ShowEnemy()
|
||
{
|
||
|
||
for (int i = 0; i < enemyPos.Length; i++)
|
||
{
|
||
Vector3 curEnemyPos = new Vector3(enemyPos[i].position.x, 0, enemyPos[i].position.z);
|
||
GameManager.Ins.CreateCallEnemyEffect(curEnemyPos);
|
||
}
|
||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||
{
|
||
for (int i = 0; i < enemyPos.Length; i++)
|
||
{
|
||
Vector3 curEnemyPos = new Vector3(enemyPos[i].position.x, 0, enemyPos[i].position.z);
|
||
GameManager.Ins.CreateEnemy(1, curEnemyPos, Vector3.zero, false);
|
||
}
|
||
}, 2f);
|
||
}
|
||
|
||
public override void ThreeAttackMode()
|
||
{
|
||
// base.ThreeAttackMode();
|
||
// components[^1].StopQteAttack();
|
||
}
|
||
|
||
private IEnumerator ShootOneAttackMode(int curIndex, Action cb = null)
|
||
{
|
||
// 一开始就把玩家位置记下来,避免中途玩家移动影响最终目标
|
||
Vector3 playerTarget = player.transform.position;
|
||
// 保持导弹发射高度(此处假设你希望在 y=0 平面)
|
||
playerTarget = new Vector3(playerTarget.x, 0f, playerTarget.z);
|
||
|
||
// 获取起点
|
||
Vector3 startPos = components[curIndex].showPos.position;
|
||
// 方向与总距离
|
||
Vector3 dir = (playerTarget - startPos).normalized;
|
||
float totalDist = Vector3.Distance(startPos, playerTarget);
|
||
|
||
// 要分几段发射(用户想要“递进”n 次就填 n)
|
||
int segmentCount = 4;
|
||
// 每段的长度
|
||
float step = totalDist / segmentCount;
|
||
|
||
for (int i = 1; i <= segmentCount; i++)
|
||
{
|
||
Vector3 targetPos;
|
||
if (i < segmentCount)
|
||
{
|
||
// 普通段落,按起点 + dir*i*step
|
||
targetPos = startPos + dir * (step * i);
|
||
}
|
||
else
|
||
{
|
||
// 最后一段,直接用预先算好的玩家位置
|
||
targetPos = playerTarget;
|
||
}
|
||
targetPos = new Vector3(targetPos.x, 0f, targetPos.z);
|
||
Debug.Log($"发射第 {i} 发导弹,目标点 = {targetPos}");
|
||
components[curIndex].EnemyShoot(targetPos);
|
||
GameInit.Ins.PlayAudio("2.3导弹发射", transform, false);
|
||
yield return new WaitForSeconds(oneAttackInterval);
|
||
}
|
||
|
||
// 全部发射完毕后回调
|
||
cb?.Invoke();
|
||
}
|
||
|
||
|
||
public override void Show()
|
||
{
|
||
base.Show();
|
||
isAttack = false;
|
||
isShield = true;
|
||
shieldObj.SetActive(true);
|
||
startPos = transform.position;
|
||
float endValue = 10;
|
||
if (GameInit.Ins.gamePlace == GamePlace.HangZhouLongHuTianJie)
|
||
endValue = 35f;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Yangzhou_Hanjiang_TansuoZhongxin_wai)
|
||
endValue = 16f;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Guangzhou_Panyv_Zhanting)
|
||
endValue = -7f;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Anhui_Wuhu_Guanwei)
|
||
endValue = 13f;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Zhejiang_Jinhua_KeJiGuan)
|
||
endValue = 17f;
|
||
if (GameInit.Ins.gamePlace == GamePlace.ShanDong_Langfang_QingzhouTaihuacheng)
|
||
endValue = 20f;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Shandong_Jining_Shangchang_nei)
|
||
endValue = 7f;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Nanjing_Qixia_Yaohuamen_Jindiguangchang_nei)
|
||
endValue = 10f;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Henan_Xinzheng_Shuanghudadao_Longhujinyicheng)
|
||
endValue = -14.62f;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Yunnan_Lincang_Linxiang_Hengji)
|
||
endValue = -5.7f;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Gansu_Jinchang_Jinchuan_Shijiguangchang_Shiwai)
|
||
endValue = 1.47f;
|
||
if (GameInit.Ins.gamePlace == GamePlace.Company1Floor)
|
||
{
|
||
transform.DOMove(new Vector3(7f, transform.position.y, 12f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Jilin_Tonghua_Liuhe)
|
||
{
|
||
transform.DOMove(new Vector3(-9.45f, transform.position.y, 12.4f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Hunan_Jishou_Qianzhou_Tianhong)
|
||
{
|
||
transform.DOMove(new Vector3(-3.42f, transform.position.y, -6.34f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.HangZhouLongHuTianJie || GameInit.Ins.gamePlace == GamePlace.Guangzhou_Panyv_Zhanting)
|
||
{
|
||
transform.DOMoveX(endValue, 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Hubei_Xiangyang_Kejiguan)
|
||
{
|
||
transform.DOMove(new Vector3(-8.12f, transform.position.y, -3.71f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Zhejiang_Shaoxing_Shengzhou_WuyueGuangchang)
|
||
{
|
||
transform.DOMove(new Vector3(3.29f, transform.position.y, 5.91f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Gansu_Longnan_Shicheng_Dongsheng)
|
||
{
|
||
transform.DOMove(new Vector3(-6.44f, transform.position.y, 8.73f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Shandong_Heze_Yuncheng_Gefuli)
|
||
{
|
||
transform.DOMove(new Vector3(-20.21f, transform.position.y, -3.18f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Wulanhaote_Ouya_Shangchang)
|
||
{
|
||
transform.DOMove(new Vector3(-0.55f, 5f, 1.7f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Wulanhaote_Wanda_Shangchang)
|
||
{
|
||
transform.DOMove(new Vector3(-3.15f, 5f, -2.22f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Hunan_Hengyang_Zhuhui_Dongzhoudao)
|
||
{
|
||
transform.DOMove(new Vector3(4.7f, 5f, -3.72f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Hunan_Hengyang_Zhuhui_Dongzhoudao_nei)
|
||
{
|
||
transform.DOMove(new Vector3(0.5f, 5f, 12.71f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
|
||
if (GameInit.Ins.gamePlace == GamePlace.Yunnan_Mile_Jinchen_Shidaiguangchang)
|
||
{
|
||
transform.DOMove(new Vector3(0.65f, 5f, 12f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Xinjiang_Yili_Yining_Wanrong)
|
||
{
|
||
transform.DOMove(new Vector3(1.19f, 5f, -5.23f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Guangxi_Guilin_Gongcheng_Shijixincheng)
|
||
{
|
||
transform.DOMove(new Vector3(-9.3f, 5f, 15.5f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Guangdong_Shenzhen_Guangming_Wanda)
|
||
{
|
||
transform.DOMove(new Vector3(11.37f, 5f, -1.32f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Liaoning_AnShan_Lishan_Dayuecheng)
|
||
{
|
||
transform.DOMove(new Vector3(-9.39f, 5f, 14.6f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Hebei_Tangshan_Qianan_Tianyuangu)
|
||
{
|
||
transform.DOMove(new Vector3(8.17f, 5f, -2.49f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Zhejiang_Hangzhou_Linping_Yintaicheng)
|
||
{
|
||
transform.DOMove(new Vector3(4.73f, 5f, 4.85f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
|
||
if (GameInit.Ins.gamePlace == GamePlace.Gansu_Jinchang_Jinchuan_Shijiguangchang)
|
||
{
|
||
transform.DOMove(new Vector3(-7.03f, 5f, 8.06f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
//if (GameInit.Ins.gamePlace == GamePlace.Gansu_Jinchang_Jinchuan_Shijiguangchang_Shiwai)
|
||
//{
|
||
// transform.DOMove(new Vector3(-5.63f, 5f, 0.47f), 4).OnComplete(() =>
|
||
// {
|
||
// isAttack = true;
|
||
// foreach (var item in tailGas)
|
||
// {
|
||
// item.SetActive(true);
|
||
// }
|
||
// bloodSlider.gameObject.SetActive(true);
|
||
// isShield = false;
|
||
// shieldObj.SetActive(false);
|
||
// _isShow = false;
|
||
// });
|
||
//}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Henan_Xinxiang_Wandaguangchang)
|
||
{
|
||
transform.DOMove(new Vector3(6.16f, 5f, -13.05f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Zhejiang_Hangzhou_Linping_Yintaicheng_Shinei)
|
||
{
|
||
transform.DOMove(new Vector3(0f, 5f, 11.5f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
if (GameInit.Ins.gamePlace == GamePlace.Guangdong_Guangzhou_Yanghaiyan)
|
||
{
|
||
transform.DOMove(new Vector3(5.34f, 5f, 7.57f), 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
else
|
||
{
|
||
transform.DOMoveZ(endValue, 4).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
bloodSlider.gameObject.SetActive(true);
|
||
isShield = false;
|
||
shieldObj.SetActive(false);
|
||
_isShow = false;
|
||
});
|
||
}
|
||
}
|
||
|
||
public override void Show2()
|
||
{
|
||
base.Show2();
|
||
isAttack = false;
|
||
//shieldObj.SetActive(true);
|
||
//isShield = true;
|
||
if (GameInit.Ins.gamePlace == GamePlace.HangZhouLongHuTianJie)
|
||
{
|
||
transform.DOMove(transform.position + new Vector3(-15, -2, 0), 3).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
});
|
||
}
|
||
else
|
||
{
|
||
transform.DOMove(transform.position + new Vector3(0, -2, 0), 3).OnComplete(() =>
|
||
{
|
||
isAttack = true;
|
||
});
|
||
}
|
||
}
|
||
public void Fly()
|
||
{
|
||
isShield = true;
|
||
AnimatorComponent.SetBool("fly", true);
|
||
GameInit.Ins.PlayAudio("2.11冲刺", transform, false);
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(false);
|
||
}
|
||
MonoSingleton<CoroutineTaskManager>.Instance.WaitSecondTodo(() =>
|
||
{
|
||
isShield = false;
|
||
StopFly();
|
||
}, 3f);
|
||
}
|
||
|
||
public void StopFly()
|
||
{
|
||
foreach (var item in tailGas)
|
||
{
|
||
item.SetActive(true);
|
||
}
|
||
AnimatorComponent.SetBool("fly", false);
|
||
userSillIng = false;
|
||
|
||
//停止飞行后进入待机状态
|
||
SetIdle(true);
|
||
}
|
||
|
||
public override void Dead()
|
||
{
|
||
var pos = transform.position;
|
||
if (GameInit.Ins.gamePlace == GamePlace.ShanDong_Langfang_QingzhouTaihuacheng)
|
||
pos = new Vector3(16.6f, 0, 16.2f);
|
||
if (!isDead)
|
||
GameManager.Ins.CurLevelWin(pos);
|
||
base.Dead();
|
||
|
||
//死亡时取消待机状态
|
||
SetIdle(false);
|
||
|
||
base.Dead();
|
||
}
|
||
|
||
public override void StartQteAttack()
|
||
{
|
||
bigXl.SetActive(true);
|
||
mzObj.SetActive(true);
|
||
components[^1].StatQteAttack();
|
||
shieldObj.SetActive(false);
|
||
isShield = false;
|
||
}
|
||
|
||
public override void BossQteAttack()
|
||
{
|
||
base.BossQteAttack();
|
||
components[^1].QteAttack();
|
||
StopQteAttack();
|
||
}
|
||
|
||
public override void StopQteAttack()
|
||
{
|
||
base.StopQteAttack();
|
||
bigXl.SetActive(false);
|
||
mzObj.SetActive(false);
|
||
components[^1].StopQteAttack();
|
||
shieldObj.SetActive(false);
|
||
isShield = false;
|
||
}
|
||
|
||
public override void ChangeHp(float value, object info, Transform _sender)
|
||
{
|
||
base.ChangeHp(value, info, _sender);
|
||
|
||
// 显示受伤特效(随机选择一个)
|
||
//ShowRandomDamageEffect();
|
||
|
||
damagableObj.SetActive(health / maxHealth <= 0.5f);
|
||
}
|
||
|
||
//显示随机受伤特效
|
||
private void ShowRandomDamageEffect()
|
||
{
|
||
if (damageEffects == null || damageEffects.Length == 0) return;
|
||
|
||
// 随机选择一个受伤特效
|
||
int randomIndex = UnityEngine.Random.Range(0, damageEffects.Length);
|
||
GameObject effect = damageEffects[randomIndex];
|
||
|
||
if (effect != null && !effect.activeSelf)
|
||
{
|
||
effect.SetActive(true);
|
||
|
||
//2秒后自动隐藏特效
|
||
StartCoroutine(HideDamageEffect(effect, 2f));
|
||
}
|
||
}
|
||
|
||
//隐藏受伤特效
|
||
private IEnumerator HideDamageEffect(GameObject effect, float delay)
|
||
{
|
||
yield return new WaitForSeconds(delay);
|
||
|
||
if (effect != null)
|
||
{
|
||
effect.SetActive(false);
|
||
}
|
||
}
|
||
|
||
private float enemyTime = 60f;
|
||
private float curEnemyTime;
|
||
public override void Update()
|
||
{
|
||
base.Update();
|
||
|
||
//检查待机状态
|
||
if (!_isShow && !isAttack && !userSillIng && !AnimatorComponent.GetBool("fly") && !idle)
|
||
{
|
||
SetIdle(true);
|
||
}
|
||
else if (idle && (isAttack || userSillIng || AnimatorComponent.GetBool("fly")))
|
||
{
|
||
SetIdle(false);
|
||
}
|
||
|
||
if (_isShow) return;
|
||
// 平滑朝向玩家
|
||
Vector3 targetDir = GameManager.Ins.player.transform.position - transform.position;
|
||
targetDir.y = 0f;
|
||
|
||
if (targetDir != Vector3.zero)
|
||
{
|
||
Quaternion targetRotation = Quaternion.LookRotation(targetDir);
|
||
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 2f);
|
||
}
|
||
|
||
curEnemyTime -= Time.deltaTime;
|
||
if (curEnemyTime <= 0)
|
||
{
|
||
if (GameManager.Ins.GetCurEnemyListCount() <= 5)
|
||
{
|
||
ShowEnemy();
|
||
}
|
||
curEnemyTime = enemyTime;
|
||
}
|
||
}
|
||
private void SetIdle(bool state)
|
||
{
|
||
idle = state;
|
||
AnimatorComponent.SetBool("idle", idle);
|
||
Debug.Log("敌人已进入待机状态");
|
||
}
|
||
|
||
} |