Files
MRCS/Assets/_MrCs/Scripts/Explosions/ShieldExplosion.cs

69 lines
1.6 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using DamageNumbersPro;
using DragonLi.Frame;
using Mirror;
using UnityEngine;
public class ShieldExplosion : Explosion
{
public int hp;
public GameObject[] models;
private void Awake()
{
foreach (var model in models)
{
model.GetComponent<BoxCollider>().enabled = false;
}
}
public override void OnSpawn(TeamType team,float curDurationTime,int id)
{
base.OnSpawn(team,curDurationTime,id);
if(!isServer)
return;
transform.eulerAngles=new Vector3(0,120,0);
GunInfo info = GameManager.Ins.GunInfos[(GunType)type][1];
hp=info.Hp;
int index = 0;
Debug.LogError("初始化");
foreach (var model in models)
{
var shieldModel = model.GetComponent<DamageBox>();
if (shieldModel != null)
{
shieldModel.Init(index,team,hp,isServer);
}
model.SetActive(false);
index++;
}
StartCoroutine(ShowModels());
}
IEnumerator ShowModels()
{
models[0].SetActive(true);
models[1].SetActive(true);
models[2].SetActive(true);
yield return new WaitForSeconds(0.3f);
models[3].SetActive(true);
models[4].SetActive(true);
models[5].SetActive(true);
yield return new WaitForSeconds(0.3f);
models[6].SetActive(true);
models[7].SetActive(true);
models[8].SetActive(true);
}
[Server]
public void HideModel(int index)
{
models[index].transform.localScale=Vector3.zero;
}
public float Health { get; set; }
}