示例#1
0
        private void OnBeforeBulletHit(Bullet bullet)
        {
            int reboundCount = (int)bullet.GetUserData("reboundCount", 0);
            if (reboundCount >= maxReboundCount)
                return;

            if (reboundCount == 0 && bullet.GetUserData(ConflicMark1) != null)
                return;

            Scene scene = SceneManager.Instance.Scene;
            List<SceneEntity> targetEntities = scene.CollectEntitiesCircle(MapUtils.PositionToLocation(bullet.transform.position), reboundRange, null, CampType.Enemy, true);
            foreach (SceneEntity targetEntity in targetEntities)
            {
                if (targetEntity.UID == bullet.TargetEntityUID)
                    continue;

                Bullet reboundBullet = scene.FireBullet(Entity.UID, targetEntity.UID);
                reboundBullet.SetUserData(ConflicMark1, true);
                reboundBullet.SetUserData("reboundCount", reboundCount + 1);

                SceneEntity sourceEntity = scene.GetEntity(bullet.TargetEntityUID);
                reboundBullet.transform.position = sourceEntity.Position;

                AtkComp atkComp = Entity.GetComp<AtkComp>();
                if (atkComp != null && atkComp.HasOnAfterFireBulletEvent)
                {
                    List<Bullet> bullets = new List<Bullet> { reboundBullet };
                    atkComp.CallOnAfterFireBulletEvent(bullets);
                }
                break;
            }
        }
示例#2
0
        public void RegisterOnBeforeBulletHit(Bullet.BeforeBulletHitCallback callback)
        {
            if (!hasAfterFireBullet)
            {
                hasAfterFireBullet = true;
                RegisterOnAfterFireBullet(OnAfterFireBullet);
            }

            if (beforeBulletHitCallbacks == null)
                beforeBulletHitCallbacks = new List<Bullet.BeforeBulletHitCallback>();

            if (!beforeBulletHitCallbacks.Contains(callback))
                beforeBulletHitCallbacks.Add(callback);
        }
示例#3
0
        public void RegisterOnBulletActivate(Bullet.BulletActivateCallback callback)
        {
            if (!hasAfterFireBullet)
            {
                hasAfterFireBullet = true;
                RegisterOnAfterFireBullet(OnAfterFireBullet);
            }

            if (bulletActivateCallbacks == null)
                bulletActivateCallbacks = new List<Bullet.BulletActivateCallback>();

            if (!bulletActivateCallbacks.Contains(callback))
                bulletActivateCallbacks.Add(callback);
        }