12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityGameFramework.Runtime;
- /// <summary>
- /// 场景组件 炸弹
- /// </summary>
- public class SceneEventBombLogic : MonoBehaviour
- {
- public string skillId = "6010012";
- public float countdown = 3;
- private bool isCountDown = false;
- private bool isLive = true;
- private void Awake()
- {
- SceneCmptManager.Instance.AddMechanism(this.gameObject);
- }
- // Start is called before the first frame update
- void Start()
- {
- SceneEventBomb info = this.gameObject.GetComponent<SceneEventBomb>();
- this.skillId = info.skillId;
- this.countdown = info.countdown;
- }
- public void Update()
- {
- if(!isLive)
- {
- return;
- }
- if(isCountDown)
- {
- countdown -= Time.deltaTime;
- if(countdown <= 0)
- {
- Bomb();
-
- }
- }
- }
- public void OnTriggerEnter(Collider collider)
- {
- Role r = collider.GetComponent<Role>();
- if(r && !isCountDown)
- {
- Animator anim = this.GetComponent<Animator>();
- anim.Play("warning", 0, 0);
- isCountDown = true;
- SceneCmptManager.Instance.OpenMechanism(this.gameObject);
- }
- }
- public void Bomb()
- {
- isLive = false;
- Animator anim = this.GetComponent<Animator>();
- anim.Play("destroy");
- SceneEventBombEntryLogic bombEntry = this.transform.Find("zha dan").GetComponent<SceneEventBombEntryLogic>();
- List<Role> roleList = bombEntry.GetEntryRoleList();
- foreach(var item in roleList)
- {
- if (!item || item.isDie)
- {
- continue;
- }
- X2Battle.X2BattleManager.Instance.mBulletModel.OnCastSkill(
- 0, skillId,
- false, X2Battle.EBulletCastPoint.ECAST_POINT_DEFLUAT, item.mData.UID, false);
- }
-
- }
- public void EnableCollider()
- {
- }
- public void OnClickInteractive()
- {
-
- }
- }
|