Ejemplo n.º 1
0
        protected override void OnUpdate()
        {
            EndSimulationEntityCommandBufferSystem endSimECBSystem = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();

            EntityCommandBuffer.ParallelWriter parallelWriter = endSimECBSystem.CreateCommandBuffer().AsParallelWriter();
            Random random = new Random((uint)Environment.TickCount);

            Entities.ForEach((Entity entity, int entityInQueryIndex, in StressTestCommand cmd) =>
            {
                for (int i = 0; i < cmd.Count; i++)
                {
                    Entity obj = parallelWriter.Instantiate(entityInQueryIndex, cmd.Prefab);

                    float3 moveStart      = random.NextFloat3Direction() * cmd.StartMoveRadius;
                    float3 moveEnd        = random.NextFloat3Direction() * cmd.EndMoveRadius;
                    EaseDesc moveEaseDesc = new EaseDesc(cmd.MoveEaseType, cmd.MoveEaseExponent);
                    Tween.Move(parallelWriter, entityInQueryIndex, obj, moveStart, moveEnd, cmd.MoveDuration, moveEaseDesc, cmd.MoveIsPingPong, cmd.MoveLoopCount);

                    quaternion rotateEnd    = quaternion.AxisAngle(random.NextFloat3Direction(), random.NextFloat(cmd.MinRotateDegree, cmd.MaxRotateDegree));
                    EaseDesc rotateEaseDesc = new EaseDesc(cmd.RotateEaseType, cmd.RotateEaseExponent);
                    Tween.Rotate(parallelWriter, entityInQueryIndex, obj, quaternion.identity, rotateEnd, cmd.RotateDuration, rotateEaseDesc, cmd.RotateIsPingPong, cmd.RotateLoopCount);

                    float3 scaleStart      = new float3(random.NextFloat(cmd.MinStartScale, cmd.MaxStartScale));
                    float3 scaleEnd        = new float3(random.NextFloat(cmd.MinEndScale, cmd.MaxEndScale));
                    EaseDesc scaleEaseDesc = new EaseDesc(cmd.ScaleEaseType, cmd.ScaleEaseExponent);
                    Tween.Scale(parallelWriter, entityInQueryIndex, obj, scaleStart, scaleEnd, cmd.ScaleDuration, scaleEaseDesc, cmd.ScaleIsPingPong, cmd.ScaleLoopCount);
                }

                parallelWriter.RemoveComponent <StressTestCommand>(entityInQueryIndex, entity);
            }).ScheduleParallel();

            endSimECBSystem.AddJobHandleForProducer(Dependency);
        }
Ejemplo n.º 2
0
        public static void Move(
            EntityCommandBuffer commandBuffer,
            Entity entity,
            float3 start,
            float3 end,
            float duration,
            EaseDesc easeDesc = default,
            bool isPingPong   = false,
            int loopCount     = 1,
            float startDelay  = 0.0f)
        {
            if (!CheckParams(easeDesc.Exponent, loopCount))
            {
                return;
            }

            TweenParams tweenParams = new TweenParams(duration, easeDesc.Type, easeDesc.Exponent, isPingPong, loopCount, startDelay);

            commandBuffer.AddComponent(entity, new TweenTranslationCommand(tweenParams, start, end));
        }
Ejemplo n.º 3
0
        public static void Tint(
            EntityManager entityManager,
            Entity entity,
            float4 start,
            float4 end,
            float duration,
            EaseDesc easeDesc = default,
            bool isPingPong   = false,
            int loopCount     = 1,
            float startDelay  = 0.0f)
        {
            if (!CheckParams(easeDesc.Exponent, loopCount))
            {
                return;
            }

            TweenParams tweenParams = new TweenParams(duration, easeDesc.Type, easeDesc.Exponent, isPingPong, loopCount, startDelay);

            entityManager.AddComponentData(entity, new TweenTintCommand(tweenParams, start, end));
        }
Ejemplo n.º 4
0
        public static void Scale(
            EntityCommandBuffer.ParallelWriter parallelWriter,
            int sortKey,
            Entity entity,
            float3 start,
            float3 end,
            float duration,
            EaseDesc easeDesc = default,
            bool isPingPong   = false,
            int loopCount     = 1,
            float startDelay  = 0.0f)
        {
            if (!CheckParams(easeDesc.Exponent, loopCount))
            {
                return;
            }

            TweenParams tweenParams = new TweenParams(duration, easeDesc.Type, easeDesc.Exponent, isPingPong, loopCount, startDelay);

            parallelWriter.AddComponent(sortKey, entity, new TweenScaleCommand(tweenParams, start, end));
        }