예제 #1
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");
            Rift      rift      = entity.GetOrCreate <Rift>("Rift");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main, false, false, null);

            attachable.Enabled.Value = true;
            VoxelAttachable.BindTarget(entity, rift.Position);

            this.SetMain(entity, main);

            PointLight light = entity.GetOrCreate <PointLight>();

            light.Color.Value = new Vector3(1.2f, 1.4f, 1.6f);
            light.Add(new Binding <Vector3>(light.Position, rift.Position));
            light.Add(new Binding <bool>(light.Enabled, () => rift.Type == Rift.Style.In && rift.Enabled, rift.Type, rift.Enabled));
            light.Add(new Binding <float>(light.Attenuation, x => x * 2.0f, rift.CurrentRadius));

            rift.Add(new Binding <Entity.Handle>(rift.Voxel, attachable.AttachedVoxel));
            rift.Add(new Binding <Voxel.Coord>(rift.Coordinate, attachable.Coord));

            entity.Add("Enable", rift.Enable);
            entity.Add("Disable", rift.Disable);
            entity.Add("AttachOffset", attachable.Offset);
            entity.Add("Enabled", rift.Enabled);
            entity.Add("Radius", rift.Radius);
            entity.Add("Style", rift.Type);
        }
예제 #2
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            this.SetMain(entity, main);

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main, true, false);

            attachable.Enabled.Value = true;

            if (!main.EditorEnabled)
            {
                // -1 means we're currently submerged, anything above 0 is the timestamp of the last time we were submerged
                float submerged                  = -1.0f;
                float lastEmit                   = 0.0f;
                Water submergedWater             = null;
                Property <Vector3> coordinatePos = new Property <Vector3>();
                VoxelAttachable.BindTarget(entity, coordinatePos);
                Action check = delegate()
                {
                    Water nowSubmerged = Water.Get(coordinatePos);
                    if (nowSubmerged == null && main.TotalTime - submerged < 1.0f)
                    {
                        Entity ve = attachable.AttachedVoxel.Value.Target;
                        if (ve != null)
                        {
                            Voxel       v   = ve.Get <Voxel>();
                            Voxel.Box   b   = v.GetBox(attachable.Coord);
                            BoundingBox box = new BoundingBox(v.GetRelativePosition(b.X, b.Y, b.Z), v.GetRelativePosition(b.X + b.Width, b.Y + b.Height, b.Z + b.Depth));
                            if (submergedWater != null && main.TotalTime - lastEmit > 0.1f)
                            {
                                Water.SplashParticles(main, box.Transform(v.Transform), v, submergedWater.Position.Value.Y);
                                lastEmit = main.TotalTime;
                            }
                        }
                    }

                    if (nowSubmerged != null)
                    {
                        submerged      = -1.0f;
                        submergedWater = nowSubmerged;
                    }
                    else if (submerged == -1.0f && nowSubmerged == null)
                    {
                        Sound.PostEvent(AK.EVENTS.PLAY_WATER_SPLASH_OUT_BIG, transform.Position);
                        submerged = main.TotalTime;
                    }
                };
                transform.Add(new NotifyBinding(check, coordinatePos));
                entity.Add(new PostInitialization(delegate()
                {
                    submerged = Water.Get(coordinatePos) != null ? -1.0f : -2.0f;
                }));
            }

            entity.Add("AttachOffset", attachable.Offset);
            entity.Add("AttachVector", attachable.Vector);
        }
예제 #3
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            AmbientSound ambientSound = entity.GetOrCreate <AmbientSound>("AmbientSound");

            this.SetMain(entity, main);

            VoxelAttachable.MakeAttachable(entity, main).EditorProperties();
            VoxelAttachable.BindTarget(entity, ambientSound.Position);

            entity.Add("PlayCue", ambientSound.PlayCue);
            entity.Add("StopCue", ambientSound.StopCue);

            entity.Add("Play", ambientSound.Enable);
            entity.Add("Stop", ambientSound.Disable);
            entity.Add("Playing", ambientSound.Enabled);
        }
예제 #4
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform transform = entity.GetOrCreate <Transform>("Transform");

            this.SetMain(entity, main);

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            attachable.Enabled.Value = true;

            entity.Add("AttachOffset", attachable.Offset);

            if (!main.EditorEnabled)
            {
                Property <Vector3> soundPosition = new Property <Vector3>();
                VoxelAttachable.BindTarget(entity, soundPosition);
                Sound.AttachTracker(entity, soundPosition);
                AkSoundEngine.PostEvent(AK.EVENTS.PLAY_WHITE_LIGHT, entity);
                SoundKiller.Add(entity, AK.EVENTS.STOP_WHITE_LIGHT);
            }
        }
예제 #5
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Transform     transform = entity.GetOrCreate <Transform>("Transform");
            PlayerTrigger trigger   = entity.GetOrCreate <PlayerTrigger>("PlayerTrigger");

            VoxelAttachable attachable = VoxelAttachable.MakeAttachable(entity, main);

            attachable.Enabled.Value = true;

            this.SetMain(entity, main);

            VoxelAttachable.BindTarget(entity, trigger.Position);

            PointLight light = entity.GetOrCreate <PointLight>();

            light.Add(new Binding <Vector3>(light.Position, trigger.Position));
            light.Color.Value = new Vector3(1.0f, 0.5f, 1.7f);

            Property <float> lightBaseRadius = new Property <float> {
                Value = 10.0f
            };

            Updater updater = new Updater
                              (
                delegate(float dt)
            {
                light.Attenuation.Value = lightBaseRadius.Value * (1.0f + (((float)this.random.NextDouble() - 0.5f) * 0.1f));
            }
                              );

            updater.EnabledInEditMode = true;
            entity.Add(updater);

            SignalTower tower = entity.GetOrCreate <SignalTower>("SignalTower");

            Animation enterAnimation = null;

            trigger.Add(new CommandBinding(trigger.PlayerEntered, delegate()
            {
                if (!string.IsNullOrEmpty(tower.Initial) && (enterAnimation == null || !enterAnimation.Active))
                {
                    enterAnimation = new Animation
                                     (
                        new Animation.FloatMoveTo(lightBaseRadius, 20.0f, 0.25f),
                        new Animation.FloatMoveTo(lightBaseRadius, 10.0f, 0.5f)
                                     );
                    entity.Add(enterAnimation);
                }
            }));

            tower.Add(new CommandBinding(trigger.PlayerEntered, tower.PlayerEnteredRange));
            tower.Add(new CommandBinding(trigger.PlayerExited, tower.PlayerExitedRange));
            tower.Add(new Binding <Entity.Handle>(tower.Player, trigger.Player));

            Sound.AttachTracker(entity, trigger.Position);

            ParticleEmitter distortionEmitter = entity.GetOrCreate <ParticleEmitter>("DistortionEmitter");

            distortionEmitter.Serialize = false;
            distortionEmitter.Add(new Binding <Vector3>(distortionEmitter.Position, trigger.Position));
            distortionEmitter.ParticleType.Value       = "Distortion";
            distortionEmitter.ParticlesPerSecond.Value = 4;
            distortionEmitter.Jitter.Value             = new Vector3(0.5f);

            ParticleEmitter purpleEmitter = entity.GetOrCreate <ParticleEmitter>("PurpleEmitter");

            purpleEmitter.Serialize = false;
            purpleEmitter.Add(new Binding <Vector3>(purpleEmitter.Position, trigger.Position));
            purpleEmitter.ParticleType.Value       = "Purple";
            purpleEmitter.ParticlesPerSecond.Value = 30;
            purpleEmitter.Jitter.Value             = new Vector3(0.5f);

            entity.Add("AttachOffset", attachable.Offset);
            trigger.EditorProperties();
            entity.Add("Initial", tower.Initial);
        }