using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityGameFramework.Runtime; /// /// 场景组件 地刺 /// public class SceneEventSunkensLogic : MonoBehaviour { public int hurtHP = 0; public float hurtTime = 2; private float nowTime = 0; private float animTime = 1; private bool isHurt = false; private Animator anim; private Role player; private void Awake() { anim = this.GetComponent(); } // Start is called before the first frame update void Start() { SceneCmptManager.Instance.AddMechanism(this.gameObject); SceneEventSunkens info = this.gameObject.GetComponent(); this.hurtHP = info.hurtHP; this.hurtTime = info.hurtTime; } private void Update() { nowTime += Time.deltaTime; if (nowTime > hurtTime) { nowTime -= hurtTime; Animator anim = this.GetComponent(); anim.Play("running2", 0, 0); } } public void Hurt() { if (!player || player.isDie || !player.IsTeamLeader) { return; } X2Battle.X2BattleManager.Instance.mBulletModel.OnCastSkill( 0, "702002", false, X2Battle.EBulletCastPoint.ECAST_POINT_DEFLUAT, player.mData.UID, false); } public void CloseHurt() { isHurt = false; } public void OnTriggerEnter(Collider collider) { Role role = collider.GetComponent(); if (role != null && role.IsTeamLeader) { player = collider.GetComponent(); SceneCmptManager.Instance.OpenMechanism(this.gameObject); } } public void OnTriggerStay(Collider other) { } public void OnTriggerExit(Collider collider) { Role role = collider.GetComponent(); if (role != null && role.IsTeamLeader) { player = null; } } public void EnableCollider() { } public void OnClickInteractive() { } }