Exemplo n.º 1
0
        public bool BeginTeleportation(MapObject objectWhichActivatesTransition)
        {
            if (teleportTransitProgress != 0)
            {
                return(false);
            }
            if (!Active)
            {
                return(false);
            }

            teleportTransitProgress             = .0001f;
            this.objectWhichActivatesTransition = objectWhichActivatesTransition;

            if (!string.IsNullOrEmpty(Type.SendParticleName))
            {
                Map.Instance.CreateAutoDeleteParticleSystem(Type.SendParticleName, Position);
            }

            //play teleportation sound
            Dynamic dynamic = objectWhichActivatesTransition as Dynamic;

            if (dynamic != null)
            {
                string soundTeleporationFullPath = RelativePathUtils.ConvertToFullPath(
                    Path.GetDirectoryName(Type.FilePath), Type.SoundTeleportation);
                dynamic.SoundPlay3D(soundTeleporationFullPath, .5f, false);
            }
            else
            {
                SoundPlay3D(Type.SoundTeleportation, .5f, false);
            }

            return(true);
        }
 string ConvertToFullPath(string path)
 {
     if (string.IsNullOrEmpty(FileName))
     {
         return(path);
     }
     return(RelativePathUtils.ConvertToFullPath(Path.GetDirectoryName(FileName), path));
 }
Exemplo n.º 3
0
        public bool Take(Unit unit)
        {
            bool ret = OnTake(unit);

            if (ret)
            {
                string soundTakeFullPath =
                    RelativePathUtils.ConvertToFullPath(Path.GetDirectoryName(Type.FilePath), Type.SoundTake);
                unit.SoundPlay3D(soundTakeFullPath, .5f, true);

                if (EntitySystemWorld.Instance.IsServer())
                {
                    Server_SendSoundPlayTakeToAllClients();
                }

                Die();
            }
            return(ret);
        }
Exemplo n.º 4
0
        public ChooseResourceForm(
            ResourceType resourceType, bool allowChooseNull, Predicate <string> shouldAddDelegate, string currentPath, bool supportRelativePath)
        {
            InitializeComponent();

            this.nullValueNode       = null;
            this.resourceType        = resourceType;
            this.allowChooseNull     = allowChooseNull;
            this.shouldAddDelegate   = shouldAddDelegate;
            this.supportRelativePath = supportRelativePath;
            this.checkBoxAllowRelativePath.Enabled = (supportRelativePath && CurrentHelperDirectoryName != null);
            if (this.checkBoxAllowRelativePath.Enabled)
            {
                this.checkBoxAllowRelativePath.Checked = ChooseResourceForm.allowRelativePath;
            }
            string currentPath2 = RelativePathUtils.ConvertToFullPath(ChooseResourceForm.CurrentHelperDirectoryName, currentPath);

            this.UpdateData(currentPath2);
        }
Exemplo n.º 5
0
        void TickMotorSound()
        {
            bool last_motor_on = motor_on;

            motor_on = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (motor_on != last_motor_on)
            {
                if (!first_tick && Health != 0)
                {
                    if (motor_on)
                    {
                        SoundPlay3D(Type.CONF.SoundOn, .7f, true);
                    }
                    else
                    {
                        SoundPlay3D(Type.CONF.SoundOff, .7f, true);
                    }
                }
            }

            string need_sound_name = null;

            if (motor_on && current_gears != null)
            {
                need_sound_name = current_gears.SoundMotor;
            }

            if (need_sound_name != current_motor_sound_name)
            {
                //change motor sound
                if (motor_sound_channel != null)
                {
                    motor_sound_channel.Stop();
                    motor_sound_channel = null;
                }

                current_motor_sound_name = need_sound_name;

                if (!string.IsNullOrEmpty(need_sound_name))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(
                        RelativePathUtils.ConvertToFullPath(Path.GetDirectoryName(Type.FilePath), need_sound_name),
                        SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        motor_sound_channel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true);
                        motor_sound_channel.Position = Position;
                        switch (Type.SoundRolloffMode)
                        {
                        case DynamicType.SoundRolloffModes.Logarithmic:
                            motor_sound_channel.SetLogarithmicRolloff(Type.SoundMinDistance, Type.SoundMaxDistance,
                                                                      Type.SoundRolloffLogarithmicFactor);
                            break;

                        case DynamicType.SoundRolloffModes.Linear:
                            motor_sound_channel.SetLinearRolloff(Type.SoundMinDistance, Type.SoundMaxDistance);
                            break;
                        }
                        motor_sound_channel.Pause = false;
                    }
                }
            }

            //update motor channel position and pitch
            if (motor_sound_channel != null)
            {
                Range speed_range_abs = current_gears.SpeedRange;
                if (speed_range_abs.Minimum < 0 && speed_range_abs.Maximum < 0)
                {
                    speed_range_abs = new Range(-speed_range_abs.Maximum, -speed_range_abs.Minimum);
                }
                Range pitch_range = current_gears.SoundMotorPitchRange;

                float speed_abs = (PhysicsModel.Bodies[0].LinearVelocity.Length() * 3600.0f / 1000.0f);

                float speed_coef = 0;
                if (speed_range_abs.Size() != 0)
                {
                    speed_coef = (speed_abs - speed_range_abs.Minimum) / speed_range_abs.Size();
                }
                MathFunctions.Clamp(ref speed_coef, 0, 1);

                //update channel
                motor_sound_channel.Pitch    = pitch_range.Minimum + speed_coef * pitch_range.Size();
                motor_sound_channel.Position = Position;
            }
        }