Esempio n. 1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var entities = query.ToEntityArray(Allocator.TempJob);

            if (entities.Length == 0)
            {
                entities.Dispose();
                return(inputDeps);
            }

            for (var i = 0; i < entities.Length; i++)
            {
                var job = new ResolveAbilityJob
                {
                    EntityCommandBuffer      = barrier.CreateCommandBuffer().ToConcurrent(),
                    PostResolveCardArchetype = postResolveCardArchetype
                };
                inputDeps = job.Schedule(this, inputDeps);
                barrier.AddJobHandleForProducer(inputDeps);
            }

            entities.Dispose();
            return(inputDeps);


            return(inputDeps);
        }
Esempio n. 2
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var data = query.ToComponentDataArray <ResolveAbilityFortifyData>(Allocator.TempJob);

            if (data.Length == 0)
            {
                data.Dispose();
                return(inputDeps);
            }

            for (var i = 0; i < data.Length; i++)
            {
                var targetEntity = data[i].TargetEntity;
                if (EntityManager.HasComponent <StatData>(targetEntity))
                {
                    var job = new ResolveAbilityJob()
                    {
                        EntityCommandBuffer      = barrier.CreateCommandBuffer().ToConcurrent(),
                        InitialStatValue         = 5,
                        PostResolveCardArchetype = postResolveCardArchetype
                    };
                    inputDeps = job.Schedule(this, inputDeps);
                    barrier.AddJobHandleForProducer(inputDeps);
                }
            }
            data.Dispose();

            return(inputDeps);
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var resolveData = resolveQuery.ToComponentDataArray <ResolveAbilityBloodPaktData>(Allocator.TempJob);

            if (resolveData.Length == 0)
            {
                resolveData.Dispose();
                return(inputDeps);
            }

            var playerData     = playerQuery.ToComponentDataArray <PlayerData>(Allocator.TempJob);
            var playerEntities = playerQuery.ToEntityArray(Allocator.TempJob);

            for (var i = 0; i < playerData.Length; i++)
            {
                var targetEntity = resolveData[i].TargetMonster;
                if (EntityManager.HasComponent <MonsterData>(targetEntity) &&
                    EntityManager.HasComponent <StatData>(targetEntity))
                {
                    var playerHp    = playerData[0].Hp;
                    var playerCoins = playerData[0].Coins;
                    var monsterHp   = EntityManager.GetComponentData <StatData>(targetEntity).Value;
                    var job         = new ResolveAbilityJob
                    {
                        EntityCommandBuffer     = barrier.CreateCommandBuffer().ToConcurrent(),
                        PlayerHp                = playerHp,
                        PlayerCoins             = playerCoins,
                        MonsterHp               = monsterHp,
                        PlayerEntity            = playerEntities[0],
                        PostresolveCardArhetype = postResolveCardArchetype
                    };
                    inputDeps = job.Schedule(this, inputDeps);
                    barrier.AddJobHandleForProducer(inputDeps);
                }
            }

            playerEntities.Dispose();
            playerData.Dispose();
            resolveData.Dispose();

            return(inputDeps);
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var resolveEntities = resolveQuery.ToEntityArray(Allocator.TempJob);

            if (resolveEntities.Length == 0)
            {
                resolveEntities.Dispose();
                return(inputDeps);
            }

            var playerData     = playerQuery.ToComponentDataArray <PlayerData>(Allocator.TempJob);
            var playerEntities = playerQuery.ToEntityArray(Allocator.TempJob);

            for (var i = 0; i < playerData.Length; i++)
            {
                int playerHp    = playerData[0].Hp;
                int playerCoins = playerData[0].Coins;
                playerHp += 5;
                if (playerHp >= GameplayConstants.MaxPlayerHp)
                {
                    GameplayConstants.MaxPlayerHp = playerHp;
                }

                var job = new ResolveAbilityJob
                {
                    EntityCommandBuffer      = barrier.CreateCommandBuffer().ToConcurrent(),
                    PlayerHP                 = playerHp,
                    PlayerCoins              = playerCoins,
                    PostResolveCardArchetype = postResolveCardArchetype,
                    PlayerEntity             = playerEntities[0]
                };

                inputDeps = job.Schedule(this, inputDeps);
                barrier.AddJobHandleForProducer(inputDeps);
            }

            playerEntities.Dispose();
            playerData.Dispose();
            resolveEntities.Dispose();
            return(inputDeps);
        }