Exemplo n.º 1
0
            //public void Execute(ref Translation position, [ReadOnly] ref Rotation rotation, [ReadOnly] ref MoveSpeed moveSpeed)
            //{
            //    float3 value = position.Value;
            //    value += deltaTime * moveSpeed.Value * math.forward(rotation.Value);
            //    if (value.z < bottomBound)
            //    {
            //        value.z = topBound;
            //    }
            //    position.Value = value;
            //}

            public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
            {
                NativeArray <Translation> chunkTranslations = chunk.GetNativeArray(TranslationTypeHandle);
                NativeArray <Rotation>    chunkRotations    = chunk.GetNativeArray(RotationTypeHandle);
                NativeArray <MoveSpeed>   chunkMoveSpeeds   = chunk.GetNativeArray(MoveSpeedTypeHandle);

                for (var i = 0; i < chunk.Count; i++)
                {
                    Translation translation = chunkTranslations[i];
                    Rotation    rotation    = chunkRotations[i];
                    MoveSpeed   moveSpeed   = chunkMoveSpeeds[i];
                    float3      value       = translation.Value;
                    value += deltaTime * moveSpeed.Value * new float3(0.0f, 0.0f, 1.0f);//math.forward(rotation.Value);
                    if (value.z == topBound)
                    {
                        value.z = topBound + 1;
                    }
                    chunkTranslations[i] = new Translation
                    {
                        Value = value
                    };
                    chunkRotations[i] = new Rotation
                    {
                        Value = math.mul(math.normalize(rotation.Value), quaternion.AxisAngle(math.up(), moveSpeed.Value * deltaTime))
                    };
                }
            }
Exemplo n.º 2
0
        protected override void OnUpdate()
        {
            for (int i = 0; i < enemies.Length; i++)
            {
                Position  position = enemies.positions[i];
                Rotation  rotation = enemies.rotations[i];
                MoveSpeed speed    = enemies.moveSpeeds[i];

                position.Value += Time.deltaTime * speed.Value * math.forward(rotation.Value);

                if (position.Value.z < GameManager.GM.bottomBound)
                {
                    position.Value.z = GameManager.GM.topBound;
                }

                enemies.positions[i] = position;
            }
        }