private void OnBeforeFireBullet(AtkComp atkComp, List<Bullet> bullets) { if (bullets.Count == 0) return; Bullet originBullet = bullets[0]; if (originBullet.GetUserData(ConflicMark1) != null) return; Scene scene = SceneManager.Instance.Scene; int targetCount = 1; foreach (SceneEntity targetEntity in atkComp.TargetEntities) { if (targetCount >= maxAttackCount) break; if (targetEntity.UID == originBullet.TargetEntityUID) continue; Bullet bullet = scene.FireBullet(originBullet.FromEntityUID, targetEntity.UID); bullet.SetUserData(ConflicMark1, true); bullets.Add(bullet); targetCount += 1; } }
public void RegisterOnBeforeFireBullet(AtkComp.BeforeFireBulletCallback callback) { AtkComp atkComp = Entity.GetComp<AtkComp>(); if (atkComp != null) atkComp.OnBeforeFireBullet += callback; else Log.Error("RegisterOnBeforeFireBullet failed! SkillComp:", this); }
public override void Init(ResourceLoader loader, EntitySetting template) { base.Init(loader, template); AtkComp = AddComp<AtkComp>(); TowerEntitySetting setting = (TowerEntitySetting)template; AttrComp.AtkBase = setting.Atk; AttrComp.AtkSpeedBase = setting.AtkSpeed; AttrComp.AtkRangeBase = setting.AtkRange; AttrComp.AtkTypes.AddRange(setting.AtkTypeArr); }
private void OnAfterFireBullet(AtkComp atkComp, List<Bullet> bullets) { foreach (Bullet bullet in bullets) { if (beforeBulletHitCallbacks != null) { foreach (var callback in beforeBulletHitCallbacks) bullet.OnBeforeBulletHit += callback; } if (afterBulletHitCallbacks != null) { foreach (var callback in afterBulletHitCallbacks) bullet.OnAfterBulletHit += callback; } if (bulletActivateCallbacks != null) { foreach (var callback in bulletActivateCallbacks) bullet.OnBulletActivate += callback; } } }
public void UnregisterOnBeforeFireBullet(AtkComp.BeforeFireBulletCallback callback) { AtkComp atkComp = Entity.GetComp<AtkComp>(); if (atkComp != null) atkComp.OnBeforeFireBullet -= callback; }