示例#1
0
        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;
            }
        }
示例#2
0
 public void RegisterOnBeforeFireBullet(AtkComp.BeforeFireBulletCallback callback)
 {
     AtkComp atkComp = Entity.GetComp<AtkComp>();
     if (atkComp != null)
         atkComp.OnBeforeFireBullet += callback;
     else
         Log.Error("RegisterOnBeforeFireBullet failed! SkillComp:", this);
 }
示例#3
0
        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);
        }
示例#4
0
        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;
                }
            }
        }
示例#5
0
 public void UnregisterOnBeforeFireBullet(AtkComp.BeforeFireBulletCallback callback)
 {
     AtkComp atkComp = Entity.GetComp<AtkComp>();
     if (atkComp != null)
         atkComp.OnBeforeFireBullet -= callback;
 }