122 lines
3.1 KiB
C#
122 lines
3.1 KiB
C#
using System;
|
|
using DragonLi.Core;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DG.Tweening;
|
|
using DragonLi.Frame;
|
|
using UnityEngine;
|
|
|
|
public class EnergyPump : MonoBehaviour,IDamagable
|
|
{
|
|
public SphereCollider sphere;
|
|
|
|
public int energyPumpTag;
|
|
|
|
public GameObject txt;
|
|
|
|
[NonSerialized]
|
|
public int HpIndex;
|
|
|
|
|
|
public void ColliderEnergyPump()
|
|
{
|
|
GameManager.Ins.CreateBoss();
|
|
GameManager.Ins.EnergyPumpFillAmount += 0.2f;
|
|
EventDispatcher.TriggerEvent("ChangeEnergyPumpUI", GameManager.Ins.EnergyPumpFillAmount);
|
|
sphere.enabled = false;
|
|
transform.gameObject.SetActive(false);
|
|
Destroy(transform.gameObject);
|
|
}
|
|
|
|
public void ShowLandMask()
|
|
{
|
|
switch (energyPumpTag)
|
|
{
|
|
case 1:
|
|
GameManager.Ins.PlayerUIMessage(1);
|
|
break;
|
|
case 2:
|
|
GameManager.Ins.PlayerUIMessage(2);
|
|
break;
|
|
case 3:
|
|
//GameObject rockfall = GameManager.Ins.GenerateRockfall(new Vector3(6f, 22.3f, 3.26f), new Vector3(-90, 0, 0));
|
|
// CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
|
// {
|
|
// NetworkServer.Destroy(rockfall);
|
|
// }, 5.0f);
|
|
// GameManager.Ins.HudMessage(4);
|
|
break;
|
|
case 4:
|
|
GameManager.Ins.PlayerUIMessage(5);
|
|
break;
|
|
case 5:
|
|
GameManager.Ins.PlayerUIMessage(6);
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
public void Init(int energyPumpTag)
|
|
{
|
|
this.energyPumpTag = energyPumpTag;
|
|
originalPos=transform.localPosition;
|
|
HpIndex = 10;
|
|
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
|
|
{
|
|
Over();
|
|
}, 10f);
|
|
}
|
|
|
|
public void Over()
|
|
{
|
|
if(GameManager.Ins.isGamePlay)
|
|
return;
|
|
GameManager.Ins.isGamePlay = true;
|
|
Debug.Log("过关");
|
|
GameInit.Ins.PlayAudio("2.34道具",transform,true);
|
|
ShowLandMask();
|
|
ColliderEnergyPump();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
txt.transform.parent.GetComponent<Transform>().LookAt(GameInit.Ins.playerCam.transform);
|
|
}
|
|
|
|
public void ApplyDamage(float value, object info, Transform _sender)
|
|
{
|
|
HpIndex--;
|
|
if (HpIndex <= 0)
|
|
{
|
|
Over();
|
|
return;
|
|
}
|
|
|
|
Shake();
|
|
}
|
|
|
|
private Tween shakeTween;
|
|
[Header("Shake Settings")]
|
|
public float duration = 0.3f; // 抖动持续时间
|
|
public float strength = 0.2f; // 抖动强度
|
|
public int vibrato = 20; // 抖动的振动次数
|
|
|
|
private bool isShaking = false;
|
|
private Vector3 originalPos;
|
|
public void Shake()
|
|
{
|
|
if (isShaking) return;
|
|
|
|
isShaking = true;
|
|
|
|
shakeTween = transform.DOShakePosition(duration, strength, vibrato)
|
|
.OnComplete(() =>
|
|
{
|
|
transform.localPosition = originalPos;
|
|
isShaking = false;
|
|
});
|
|
}
|
|
|
|
public float Health { get; set; }
|
|
}
|