using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityGameFramework.Runtime; /// /// 场景组件 炸弹 /// 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(); 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(); if(r && !isCountDown) { Animator anim = this.GetComponent(); anim.Play("warning", 0, 0); isCountDown = true; SceneCmptManager.Instance.OpenMechanism(this.gameObject); } } public void Bomb() { isLive = false; Animator anim = this.GetComponent(); anim.Play("destroy"); SceneEventBombEntryLogic bombEntry = this.transform.Find("zha dan").GetComponent(); List 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() { } }