Ejemplo n.º 1
0
    private void Awake()
    {
        if (Instance != null)
        {
            Destroy(gameObject);
            return;
        }

        Instance   = this;
        renderData = new RenderSharedComponentData()
        {
            material = numbersSpriteSheet.Material,
            mesh     = numbersSpriteSheet.Mesh,
        };
    }
    public void LaunchArrow(float3 startPos, float scale,
                            ProjectileLaunshSetupComponentData launchData, SpriteSheetAnimationComponentData animaionData,
                            SpriteRendererComponentData spriteData,
                            RenderSharedComponentData renderData, ProjectileCollisionComponentData collisionData,
                            RenderScaleComponentdata renderScale,
                            bool castShadows, CastSpritesShadowComponentData shadowSettings, bool calcShadowShifts)
    {
        var arrow = manager.CreateEntity(arrowArchetype);

        manager.SetComponentData(arrow, new Translation()
        {
            Value = startPos
        });
        manager.SetComponentData(arrow, launchData);
        manager.SetComponentData(arrow, new Scale()
        {
            Value = scale
        });
        manager.SetComponentData(arrow, new Rotation()
        {
            Value = quaternion.identity
        });
        manager.SetComponentData(arrow, spriteData);
        if (animaionData.frameCount > 1)
        {
            manager.AddComponentData(arrow, animaionData);
        }
        manager.SetComponentData(arrow, renderScale);
        manager.SetComponentData(arrow, collisionData);
        manager.SetSharedComponentData(arrow, renderData);

        if (castShadows)
        {
            manager.AddComponentData(arrow, shadowSettings);
            if (calcShadowShifts)
            {
                manager.AddComponentData(arrow, new CastProjectileShadowsTagComponentData()
                {
                    defaultAlpha                   = shadowSettings.color.a,
                    alphaMultiplier                = 0f,
                    scaleMultiplier                = 1,
                    startPositionOffset            = new float2(0, -1),
                    maxYOffsetForLerpScaleAndAlpha = 5f
                });
            }
        }
    }
Ejemplo n.º 3
0
    protected virtual void Start()
    {
        manager   = World.Active.EntityManager;
        archetype = manager.CreateArchetype(
            typeof(Translation),
            typeof(LinearMovementComponentData),
            typeof(VelocityAbsoluteComponentData),
            typeof(SpriteSheetAnimationComponentData),
            typeof(SpriteRendererComponentData),
            typeof(SpriteTintComponentData),
            typeof(Scale),
            typeof(RenderScaleComponentdata),
            typeof(ScaleByPositionComponentData),
            typeof(SquadTagSharedComponentData),
            typeof(SquadComponentData),
            typeof(RenderSharedComponentData),
            typeof(FactionComponentData),
            typeof(CacheByQuadrandSystemTag),
            typeof(ProcessProjectileCollisionTag),
            typeof(AnimationListSharedComponentData),
            typeof(AnimationPauseComponentData),
            typeof(ActionOnAnimationFrameComponentData),
            typeof(DestroyWithHealthComponentData),
            typeof(HealthComponentData),
            typeof(AnimatorStatesComponentData),
            typeof(FlibHorisontalByMoveDirTagComponentData),
            typeof(FlibHorisontalByTargetTagComponentData),
            typeof(ZbyYComponentData),
            typeof(AudioClipComponentData),
            typeof(DeathAudioClipComponentData),
            typeof(CastSpritesShadowComponentData)
            );

        squadTag   = DataToComponentData.ToComponentData(squadData, squadId, squadPosition.position);
        renderData = new RenderSharedComponentData()
        {
            material = animationProvider.Material,
            mesh     = animationProvider.Mesh,
        };
        animationData = new AnimationListSharedComponentData()
        {
            animations = animationProvider.Animations,
            pauses     = animationProvider.PausesData,
            actions    = animationProvider.ActionsData
        };
    }