Exemple #1
0
        public static Particle Create(EParticles particleType, Vector3 location, Vector3 force)
        {
            Particle particle = EntityFactory.Create <Particle>(string.Format("{0}Particle", particleType.ToString()));

            particle.AddComponent <TransformComponent>().Init(location);

            PhysicsComponent physics = particle.AddComponent <PhysicsComponent>();

            physics.Init(BodyType.Dynamic, 0.94f, 0.5f);
            physics.ApplyForce(force, true);

            SpriteComponent   sprite  = particle.AddComponent <SpriteComponent>();
            LightingComponent light   = particle.AddComponent <LightingComponent>();
            DespawnComponent  despawn = particle.AddComponent <DespawnComponent>();

            switch (particleType)
            {
            case EParticles.Spark:
                float lifeTime = SeedManager.Get().NextRandF(2.0f, 5.0f);

                sprite.Init(CollisionManager.Get().PointTexture);
                sprite.Scale = new Vector2(SeedManager.Get().NextRandF(5, 15), SeedManager.Get().NextRandF(5, 15));
                sprite.AddColorFunction(x => { return(Color.Lerp(new Color(0.99f, 1.0f, 0.78f), new Color(1.0f, 0.0f, 0.0f), x)); });
                sprite.AddOpacityFunction(x => { return(1.0f - x / lifeTime); });

                light.Init(AssetManager.Get().Find <Texture2D>(ELightAssets.CircleLight), Vector2.Zero, new Vector2(0.4f, 0.4f));
                light.AddColorFunction(x => { return(Color.Lerp(new Color(0.99f, 1.0f, 0.78f), new Color(1.0f, 0.0f, 0.0f), x)); });
                light.AddBrightnessFunction(x => { return(1.0f - x / lifeTime); });

                despawn.AddTimeTrigger(x => x > lifeTime);
                break;
            }

            return(particle);
        }
Exemple #2
0
 public void SetTarget(Components.Component component, Coocoo3D.Core.Coocoo3DMain _appBody)
 {
     lightingComponent = (LightingComponent)component;
     appBody           = _appBody;
     _cacheColor       = lightingComponent.Color;
     if (lightingComponent.LightingType == LightingType.Directional)
     {
         radio1.IsChecked = true;
     }
     else if (lightingComponent.LightingType == LightingType.Point)
     {
         radio2.IsChecked = true;
     }
 }
Exemple #3
0
        public Task <IPreparedEffect> PrepareEffectAsync(EnvironmentElement element, string descriptor, PlaybackOptions options)
        {
            if (element is null)
            {
                throw new ArgumentNullException(nameof(element));
            }

            LightingComponent lighting = element.Lighting;

            if (lighting == null)
            {
                return(Task.FromResult <IPreparedEffect> (null));
            }

            return(Task.FromResult <IPreparedEffect> (null));
        }
Exemple #4
0
 public void Preprocess()
 {
     lightings.Sort();
     for (int i = 0; i < entities.Count; i++)
     {
         MMD3DEntity entity = entities[i];
         entity.rendererComponent.position = entity.Position;
         entity.rendererComponent.rotation = entity.Rotation;
         rendererComponents.Add(entity.rendererComponent);
     }
     for (int i = 0; i < gameObjects.Count; i++)
     {
         GameObject        gameObject        = gameObjects[i];
         LightingComponent lightingComponent = gameObject.GetComponent <LightingComponent>();
         if (lightingComponent != null)
         {
             lightingComponent.Position = gameObject.Position;
             lightingComponent.Rotation = gameObject.Rotation;
             lightings.Add(lightingComponent.GetLightingData());
         }
     }
 }