Exemple #1
0
 public override void Awake()
 {
     base.Awake();
     Sound.AttachTracker(this.Entity, this.Position);
     this.particles         = ParticleSystem.Get(this.main, "Rift");
     this.EnabledInEditMode = false;
     this.EnabledWhenPaused = false;
     this.Add(new CommandBinding(this.Enable, (Action)this.go));
     rifts.Add(this);
 }
Exemple #2
0
        public override void Awake()
        {
            base.Awake();

            Sound.AttachTracker(this.Entity, this.Position);

            this.Entity.CannotSuspendByDistance = !this.Is3D;
            this.Entity.Add(new NotifyBinding(delegate()
            {
                this.Entity.CannotSuspendByDistance = !this.Is3D;
            }, this.Is3D));

            this.Play.Action = this.play;
            this.Add(new CommandBinding(this.Disable, (Action)this.stop));
            this.Add(new CommandBinding(this.OnSuspended, (Action)this.stop));
        }
Exemple #3
0
        public override void Awake()
        {
            base.Awake();
            this.EnabledWhenPaused = true;

            this.Add(new NotifyBinding(main.AlphaDrawablesModified, this.DrawOrder));

            this.Add(new SetBinding <bool>(this.CannotSuspendByDistance, delegate(bool value)
            {
                this.Entity.CannotSuspendByDistance = value;
            }));

            this.Add(new NotifyBinding(delegate() { this.needResize = true; }, this.main.ScreenSize));

            Action removeFluid = delegate()
            {
                if (this.Fluid.Space != null)
                {
                    this.main.Space.Remove(this.Fluid);
                }
                AkSoundEngine.PostEvent(AK.EVENTS.STOP_WATER_LOOP, this.Entity);
            };

            Action addFluid = delegate()
            {
                if (this.Fluid.Space == null && this.Enabled && !this.Suspended)
                {
                    this.main.Space.Add(this.Fluid);
                    if (!this.main.EditorEnabled)
                    {
                        AkSoundEngine.PostEvent(AK.EVENTS.PLAY_WATER_LOOP, this.Entity);
                    }
                }
            };

            this.Add(new CommandBinding(this.OnSuspended, removeFluid));
            this.Add(new CommandBinding(this.Disable, removeFluid));
            this.Add(new CommandBinding(this.OnResumed, addFluid));
            this.Add(new CommandBinding(this.Enable, addFluid));

            this.camera = new Camera();
            this.main.AddComponent(this.camera);
            this.parameters = new RenderParameters
            {
                Camera           = this.camera,
                Technique        = Technique.Clip,
                ReverseCullOrder = true,
            };

            this.Add(new SetBinding <Vector3>(this.Color, delegate(Vector3 value)
            {
                this.effect.Parameters["Color"].SetValue(value);
            }));

            this.Add(new SetBinding <Vector2>(this.Scale, delegate(Vector2 value)
            {
                this.effect.Parameters["Scale"].SetValue(value);
                this.updatePhysics();
            }));

            this.Add(new SetBinding <Vector3>(this.UnderwaterColor, delegate(Vector3 value)
            {
                this.effect.Parameters["UnderwaterColor"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.Fresnel, delegate(float value)
            {
                this.effect.Parameters["Fresnel"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.Speed, delegate(float value)
            {
                this.effect.Parameters["Speed"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.RippleDensity, delegate(float value)
            {
                this.effect.Parameters["RippleDensity"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.Distortion, delegate(float value)
            {
                this.effect.Parameters["Distortion"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.Brightness, delegate(float value)
            {
                this.effect.Parameters["Brightness"].SetValue(value);
            }));

            this.Add(new SetBinding <float>(this.Refraction, delegate(float value)
            {
                this.effect.Parameters["Refraction"].SetValue(value);
            }));

            this.Add(new SetBinding <Vector3>(this.Position, delegate(Vector3 value)
            {
                this.effect.Parameters["Position"].SetValue(this.Position);
                if (this.CannotSuspendByDistance)
                {
                    Water.BigWaterHeight.Value = value.Y;
                }
                this.updatePhysics();
            }));

            this.Add(new SetBinding <float>(this.Depth, delegate(float value)
            {
                this.updatePhysics();
            }));

            instances.Add(this);

            this.Add(new Binding <Vector3>(this.soundPosition,
                                           delegate(Vector3 pos)
            {
                BoundingBox box = this.Fluid.BoundingBox;
                pos.X           = Math.Max(box.Min.X, Math.Min(pos.X, box.Max.X));
                pos.Y           = this.Position.Value.Y;
                pos.Z           = Math.Max(box.Min.Z, Math.Min(pos.Z, box.Max.Z));
                return(pos);
            }, this.main.Camera.Position));
            Sound.AttachTracker(this.Entity, this.soundPosition);

            if (!this.main.EditorEnabled && this.Enabled && !this.Suspended)
            {
                AkSoundEngine.PostEvent(AK.EVENTS.PLAY_WATER_LOOP, this.Entity);
            }
        }