コード例 #1
0
    public void Convert(Entity entity, EntityManager dstManager,
                        GameObjectConversionSystem conversionSystem)
    {
        // ensure positive speed
        Debug.Assert(exitSpeed > 0);

        // determine starting movement type
        ExitMovementSystem.MovementComponent type = ExitMovementSystem.MovementComponent.None;
        if (gameObject.GetComponent <BulletMovementProxy>() != null)
        {
            type = ExitMovementSystem.MovementComponent.Simple;
        }
        else if (gameObject.GetComponent <PathMovementProxy>() != null)
        {
            type = ExitMovementSystem.MovementComponent.Path;
        }

        // add a component to track the time
        int timeIdx = TimePassedUtility.AddDefault(entity, dstManager);

        dstManager.AddComponentData(entity, new ExitMovement {
            timeIdx          = timeIdx,
            exitTime         = exitTime,
            exitSpeed        = exitSpeed,
            originalMovement = type
        });
    }
コード例 #2
0
    // Lets you convert the editor data representation to the entity optimal runtime representation
    public void Convert(Entity entity, EntityManager dstManager,
                        GameObjectConversionSystem conversionSystem)
    {
        Assert.IsTrue(period > 0);

        // add a TimePassed component
        int timeIdx        = TimePassedUtility.AddDefault(entity, dstManager);
        int volleyCountIdx = TimePassedUtility.AddDefault(entity, dstManager);

        Entity    bulletEnt = conversionSystem.GetPrimaryEntity(bullet);
        AutoShoot shootData = new AutoShoot
        {
            // The referenced prefab will already be converted due to DeclareReferencedPrefabs.
            // so just look up the entity version in the conversion system
            bullet           = bulletEnt,
            startDelay       = startDelay,
            cooldownDuration = cooldownDuration,
            period           = period,
            pattern          = pattern,
            count            = count,

            sourceOffset = new float3(sourceOffset.x, sourceOffset.y, 0),
            numVolleys   = numVolleys,
            angle        = math.radians(angle),
            aimStyle     = aimStyle,
            centerAngle  = math.radians(centerAngle),

            timeIdx        = timeIdx,
            volleyCountIdx = volleyCountIdx,

            moveStatsIdx   = AutoShootUtility.GetOrAddMovementIdx(movementStats),
            damageStatsIdx = AutoShootUtility.GetOrAddDamageIdx(damageStats)
        };

        DynamicBuffer <AutoShootBuffer> buffer = AutoShootUtility.GetOrAddBuffer(entity, dstManager);

        buffer.Add(new AutoShootBuffer {
            val = shootData
        });
    }
コード例 #3
0
    public void Convert(Entity entity, EntityManager dstManager,
                        GameObjectConversionSystem conversionSystem)
    {
        DynamicBuffer <PathPoint> buffer = dstManager.AddBuffer <PathPoint>(entity);

        foreach (Point p in points)
        {
            buffer.Add(new PathPoint {
                position   = p.position,
                inTangent  = p.inTangent,
                outTangent = p.outTangent
            });
        }

        int timeIdx = TimePassedUtility.AddDefault(entity, dstManager);

        dstManager.AddComponentData(entity, new PathMovement {
            timeIdx   = timeIdx,
            speed     = speed,
            loopIndex = loopIndex
        });
    }