168 lines
4.0 KiB
C#
168 lines
4.0 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using DG.Tweening;
|
||
using DragonLi.Core;
|
||
using UnityEngine;
|
||
|
||
public class OctopusBoss : Enemy
|
||
{
|
||
public Tentacle[] tentacles;
|
||
public Transform[] teleportPoints;
|
||
|
||
public Transform sprayRoot; // 喷射旋转节点(嘴巴)
|
||
public GameObject sprayEx; // 喷射特效(带 Trigger)
|
||
public float sprayDuration = 5f;
|
||
public float sprayAngle = 40f;
|
||
public float sprayRotateSpeed = 1f; // 插值用
|
||
|
||
|
||
[Header("Cooldown")]
|
||
public float skill1Cooldown = 6f;
|
||
public float skill2Cooldown = 30f;
|
||
public float teleportCooldown = 12f;
|
||
|
||
[HideInInspector] public float skill1Timer;
|
||
[HideInInspector] public float skill2Timer;
|
||
[HideInInspector] public float teleportTimer;
|
||
|
||
[Header("Spike")]
|
||
public int spikeTriggerIndex = 4; // 100%→80→60→40→20
|
||
|
||
|
||
private void Start()
|
||
{
|
||
foreach (var item in tentacles)
|
||
{
|
||
item.SetData(Data);
|
||
}
|
||
sprayEx.SetActive(false);
|
||
teleportPoints = GameInit.Ins.allBossPos;
|
||
}
|
||
|
||
public override void Update()
|
||
{
|
||
base.Update();
|
||
if (enemyState != EnemyState.Show && enemyState != EnemyState.Dead)
|
||
{
|
||
skill1Timer += Time.deltaTime;
|
||
skill2Timer += Time.deltaTime;
|
||
teleportTimer += Time.deltaTime;
|
||
}
|
||
}
|
||
|
||
public List<Tentacle> GetAliveTentacles()
|
||
{
|
||
List<Tentacle> list = new();
|
||
foreach (var t in tentacles)
|
||
if (t != null && !t.isDead)
|
||
list.Add(t);
|
||
return list;
|
||
}
|
||
|
||
public void ResetSkill1() => skill1Timer = 0;
|
||
public void ResetSkill2() => skill2Timer = 0;
|
||
public void ResetTeleport() => teleportTimer = 0;
|
||
|
||
public override void Show()
|
||
{
|
||
base.Show();
|
||
GameManager.Ins.CreateEnemySkillTip(transform.position.ReflectVectorXOZ(),3.5f);
|
||
transform.position = new Vector3(0, -8, 0);
|
||
transform.DOMoveY(0, 4f).OnComplete(() =>
|
||
{
|
||
isShowEnd = true;
|
||
enemyState = EnemyState.Idle;
|
||
foreach (var item in tentacles)
|
||
{
|
||
item.EndShow();
|
||
}
|
||
});
|
||
}
|
||
|
||
public override void ChangeHp(float value, object info, Transform _sender)
|
||
{
|
||
if(enemyState== EnemyState.Show)
|
||
return;
|
||
base.ChangeHp(value, info, _sender);
|
||
}
|
||
|
||
public override void Dead()
|
||
{
|
||
base.Dead();
|
||
GameManager.Ins.PlaySound3D("1.46",transform);
|
||
foreach (var item in GetAliveTentacles())
|
||
{
|
||
item.Dead();
|
||
}
|
||
}
|
||
|
||
public ClipQuadProvider dissolve;
|
||
public Transform clipQuad;
|
||
public float dissolveDuration = 2f;
|
||
|
||
IEnumerator DeathDissolve()
|
||
{
|
||
// 1️⃣ 停止行为
|
||
behaviourTree.enabled = false;
|
||
ColliderComponent.enabled = false;
|
||
|
||
// 2️⃣ 从下往上消散
|
||
Vector3 startPos = clipQuad.position + Vector3.down * 2f;
|
||
Vector3 endPos = clipQuad.position + Vector3.up * 2f;
|
||
|
||
clipQuad.position = startPos;
|
||
|
||
float t = 0;
|
||
while (t < 1f)
|
||
{
|
||
t += Time.deltaTime / dissolveDuration;
|
||
clipQuad.position = Vector3.Lerp(startPos, endPos, t);
|
||
yield return null;
|
||
}
|
||
|
||
// 3️⃣ 完全消失
|
||
SpawnEnergyGather();
|
||
|
||
Destroy(gameObject);
|
||
}
|
||
|
||
void SpawnEnergyGather()
|
||
{
|
||
//Instantiate(energyFxPrefab, transform.position, Quaternion.identity);
|
||
|
||
//StartCoroutine(SpawnNewBoss());
|
||
}
|
||
|
||
IEnumerator SpawnNewBoss()
|
||
{
|
||
yield return new WaitForSeconds(2f);
|
||
|
||
// var newBoss = Instantiate(bossPrefab, transform.position, transform.rotation);
|
||
// newBoss.PlayAppearDissolve();
|
||
}
|
||
|
||
public void PlayAppearDissolve()
|
||
{
|
||
StartCoroutine(AppearDissolve());
|
||
}
|
||
|
||
IEnumerator AppearDissolve()
|
||
{
|
||
Vector3 startPos = clipQuad.position + Vector3.up * 2f;
|
||
Vector3 endPos = clipQuad.position + Vector3.down * 2f;
|
||
|
||
clipQuad.position = startPos;
|
||
|
||
float t = 0;
|
||
while (t < 1f)
|
||
{
|
||
t += Time.deltaTime / dissolveDuration;
|
||
clipQuad.position = Vector3.Lerp(startPos, endPos, t);
|
||
yield return null;
|
||
}
|
||
}
|
||
}
|
||
|
||
|