private void PlayDingSound(Notification notification, int count)
    {
        if (!notificationSounds.TryGetValue(notification.Type, out string value))
        {
            value = "Notification";
        }
        if (!timeOfLastNotification.TryGetValue(value, out float value2))
        {
            value2 = 0f;
        }
        float value3 = (Time.time - value2) / soundDecayTime;

        timeOfLastNotification[value] = Time.time;
        string sound;

        if (count > 1)
        {
            sound = GlobalAssets.GetSound(value + "_AddCount", true);
            if (sound == null)
            {
                sound = GlobalAssets.GetSound(value, false);
            }
        }
        else
        {
            sound = GlobalAssets.GetSound(value, false);
        }
        if (notification.playSound)
        {
            EventInstance instance = KFMOD.BeginOneShot(sound, Vector3.zero);
            instance.setParameterValue("timeSinceLast", value3);
            KFMOD.EndOneShot(instance);
        }
    }
    private void TriggerAudio(int old_value)
    {
        SpeedControlScreen instance = SpeedControlScreen.Instance;

        if (old_value != outputValue && (Object)instance != (Object)null && !instance.IsPaused)
        {
            GridArea         visibleArea = GridVisibleArea.GetVisibleArea();
            List <LogicWire> list        = new List <LogicWire>();
            for (int i = 0; i < wires.Count; i++)
            {
                if (visibleArea.Min <= (Vector2)wires[i].transform.GetPosition() && (Vector2)wires[i].transform.GetPosition() <= visibleArea.Max)
                {
                    list.Add(wires[i]);
                }
            }
            if (list.Count > 0)
            {
                int index = Mathf.CeilToInt((float)(list.Count / 2));
                if ((Object)list[index] != (Object)null)
                {
                    Vector3       position  = list[index].transform.GetPosition();
                    EventInstance instance2 = KFMOD.BeginOneShot(GlobalAssets.GetSound("Logic_Circuit_Toggle", false), position);
                    instance2.setParameterValue("wireCount", (float)(wires.Count % 24));
                    instance2.setParameterValue("enabled", (float)outputValue);
                    KFMOD.EndOneShot(instance2);
                }
            }
        }
    }
    protected void PlayCircuitSound(string state)
    {
        string sound = null;

        if (state == "powered")
        {
            sound = Sounds.Instance.BuildingPowerOnMigrated;
        }
        else if (state == "overdraw")
        {
            sound = Sounds.Instance.ElectricGridOverloadMigrated;
        }
        else
        {
            Debug.Log("Invalid state for sound in EnergyConsumer.");
        }
        if (CameraController.Instance.IsAudibleSound(base.transform.GetPosition()))
        {
            if (!lastTimeSoundPlayed.TryGetValue(state, out float value))
            {
                value = 0f;
            }
            float value2 = (Time.time - value) / soundDecayTime;
            FMOD.Studio.EventInstance instance = KFMOD.BeginOneShot(sound, CameraController.Instance.GetVerticallyScaledPosition(base.transform.GetPosition()));
            instance.setParameterValue("timeSinceLast", value2);
            KFMOD.EndOneShot(instance);
            lastTimeSoundPlayed[state] = Time.time;
        }
    }
Exemplo n.º 4
0
    private void PlayTone(int pitch, bool forwards)
    {
        EventInstance instance = KFMOD.BeginOneShot(GlobalAssets.GetSound("WorkChime_tone", false), Vector3.zero);

        instance.setParameterValue("WorkChime_pitch", (float)pitch);
        instance.setParameterValue("WorkChime_start", (float)(forwards ? 1 : 0));
        KFMOD.EndOneShot(instance);
    }
Exemplo n.º 5
0
    public override void PlaySound(AnimEventManager.EventPlayerData behaviour)
    {
        EventInstance instance = KFMOD.BeginOneShot(base.sound, Vector3.zero);

        if (instance.isValid())
        {
            instance.setParameterValue("frame", (float)base.frame);
            KFMOD.EndOneShot(instance);
        }
    }
 public void PlayEndSound()
 {
     if (KInputManager.isFocused && playSounds)
     {
         string text = currentSounds[2];
         if (text != null && text.Length > 0)
         {
             EventInstance instance = KFMOD.BeginOneShot(text, Vector3.zero);
             instance.setParameterValue("sliderValue", value);
             KFMOD.EndOneShot(instance);
         }
     }
 }
Exemplo n.º 7
0
    private void PlayImpactSound(Vector3 pos)
    {
        if (impactSound == null)
        {
            impactSound = "Meteor_Large_Impact";
        }
        loopingSounds.StopSound(flyingSound);
        string sound = GlobalAssets.GetSound(impactSound, false);

        if (CameraController.Instance.IsAudibleSound(pos, sound))
        {
            EventInstance instance = KFMOD.BeginOneShot(sound, pos);
            instance.setParameterValue("userVolume_SFX", KPlayerPrefs.GetFloat("Volume_SFX"));
            KFMOD.EndOneShot(instance);
        }
    }
Exemplo n.º 8
0
    private void TriggerAudio(int new_value)
    {
        LogicCircuitNetwork networkForCell = Game.Instance.logicCircuitManager.GetNetworkForCell(cell);
        SpeedControlScreen  instance       = SpeedControlScreen.Instance;

        if (networkForCell != null && new_value != value && (UnityEngine.Object)instance != (UnityEngine.Object)null && !instance.IsPaused && (!KPlayerPrefs.HasKey(AudioOptionsScreen.AlwaysPlayAutomation) || KPlayerPrefs.GetInt(AudioOptionsScreen.AlwaysPlayAutomation) == 1 || !(OverlayScreen.Instance.GetMode() != OverlayModes.Logic.ID)))
        {
            string name = "Logic_Building_Toggle";
            if (CameraController.Instance.IsAudibleSound(Grid.CellToPosCCC(cell, Grid.SceneLayer.BuildingFront)))
            {
                EventInstance instance2 = KFMOD.BeginOneShot(GlobalAssets.GetSound(name, false), Grid.CellToPos(cell));
                instance2.setParameterValue("wireCount", (float)(networkForCell.Wires.Count % 24));
                instance2.setParameterValue("enabled", (float)new_value);
                KFMOD.EndOneShot(instance2);
            }
        }
    }
 public void PlayMoveSound(MoveSource moveSource)
 {
     if (KInputManager.isFocused && playSounds)
     {
         float num = Time.unscaledTime - lastMoveTime;
         if (!(num < movePlayRate))
         {
             if (moveSource != MoveSource.MouseDrag)
             {
                 playedBoundaryBump = false;
             }
             float  num2 = Mathf.InverseLerp(base.minValue, base.maxValue, value);
             string text = null;
             if (num2 == 1f && lastMoveValue == 1f)
             {
                 if (!playedBoundaryBump)
                 {
                     text = currentSounds[4];
                     playedBoundaryBump = true;
                 }
             }
             else if (num2 == 0f && lastMoveValue == 0f)
             {
                 if (!playedBoundaryBump)
                 {
                     text = currentSounds[3];
                     playedBoundaryBump = true;
                 }
             }
             else if (num2 >= 0f && num2 <= 1f)
             {
                 text = currentSounds[1];
                 playedBoundaryBump = false;
             }
             if (text != null && text.Length > 0)
             {
                 lastMoveTime  = Time.unscaledTime;
                 lastMoveValue = num2;
                 EventInstance instance = KFMOD.BeginOneShot(text, Vector3.zero);
                 instance.setParameterValue("sliderValue", num2);
                 instance.setParameterValue("timeSinceLast", num);
                 KFMOD.EndOneShot(instance);
             }
         }
     }
 }
Exemplo n.º 10
0
	private void OnLanded(object data)
	{
		if (!((UnityEngine.Object)CameraController.Instance == (UnityEngine.Object)null))
		{
			Vector3 position = base.transform.GetPosition();
			Vector2I vector2I = Grid.PosToXY(position);
			if (vector2I.x < 0 || Grid.WidthInCells <= vector2I.x || vector2I.y < 0 || Grid.HeightInCells <= vector2I.y)
			{
				this.DeleteObject();
			}
			else
			{
				Vector2 vector = (Vector2)data;
				float sqrMagnitude = vector.sqrMagnitude;
				if (!(sqrMagnitude <= 0.2f) && !SpeedControlScreen.Instance.IsPaused)
				{
					Element element = primaryElement.Element;
					if (element.substance != null)
					{
						string text = element.substance.GetOreBumpSound();
						if (text == null)
						{
							text = (element.HasTag(GameTags.RefinedMetal) ? "RefinedMetal" : ((!element.HasTag(GameTags.Metal)) ? "Rock" : "RawMetal"));
						}
						text = ((!(element.tag.ToString() == "Creature") || base.gameObject.HasTag(GameTags.Seed)) ? ("Ore_bump_" + text) : "Bodyfall_rock");
						string sound = GlobalAssets.GetSound(text, true);
						sound = ((sound == null) ? GlobalAssets.GetSound("Ore_bump_rock", false) : sound);
						if (CameraController.Instance.IsAudibleSound(base.transform.GetPosition(), sound))
						{
							int num = Grid.PosToCell(position);
							bool isLiquid = Grid.Element[num].IsLiquid;
							float value = 0f;
							if (isLiquid)
							{
								value = SoundUtil.GetLiquidDepth(num);
							}
							FMOD.Studio.EventInstance instance = KFMOD.BeginOneShot(sound, CameraController.Instance.GetVerticallyScaledPosition(base.transform.GetPosition()));
							instance.setParameterValue("velocity", vector.magnitude);
							instance.setParameterValue("liquidDepth", value);
							KFMOD.EndOneShot(instance);
						}
					}
				}
			}
		}
	}
Exemplo n.º 11
0
 // Based on Ksliders sounds
 // Minor bug: the pitch is a little too high
 public void PlayMoveSound()
 {
     if (KInputManager.isFocused)
     {
         float timeSinceLast = Time.unscaledTime - lastMoveTime;
         if (!(timeSinceLast < movePlayRate))
         {
             float  inverseLerpValue = Mathf.InverseLerp(slider.minValue, slider.maxValue, slider.value);
             string sound_path       = null;
             if (inverseLerpValue == 1f && lastMoveValue == 1f)
             {
                 if (!playedBoundaryBump)
                 {
                     sound_path         = UISoundHelper.SliderBoundaryHigh;
                     playedBoundaryBump = true;
                 }
             }
             else
             {
                 if (inverseLerpValue == 0f && lastMoveValue == 0f)
                 {
                     if (!playedBoundaryBump)
                     {
                         sound_path         = UISoundHelper.SliderBoundaryLow;
                         playedBoundaryBump = true;
                     }
                 }
                 else if (inverseLerpValue >= 0f && inverseLerpValue <= 1f)
                 {
                     sound_path         = UISoundHelper.SliderMove;
                     playedBoundaryBump = false;
                 }
             }
             if (sound_path != null && sound_path.Length > 0)
             {
                 lastMoveTime  = Time.unscaledTime;
                 lastMoveValue = inverseLerpValue;
                 FMOD.Studio.EventInstance ev = KFMOD.BeginOneShot(sound_path, Vector3.zero, 1f);
                 ev.setParameterValue("sliderValue", inverseLerpValue);
                 ev.setParameterValue("timeSinceLast", timeSinceLast);
                 KFMOD.EndOneShot(ev);
             }
         }
     }
 }
Exemplo n.º 12
0
    public static void PlayPriorityConfirmSound(PrioritySetting priority)
    {
        EventInstance instance = KFMOD.BeginOneShot(GlobalAssets.GetSound("Priority_Tool_Confirm", false), Vector3.zero);

        if (instance.isValid())
        {
            float num = 0f;
            if (priority.priority_class >= PriorityClass.high)
            {
                num += 10f;
            }
            if (priority.priority_class >= PriorityClass.topPriority)
            {
                num = num;
            }
            num += (float)priority.priority_value;
            instance.setParameterValue("priority", num);
            KFMOD.EndOneShot(instance);
        }
    }
Exemplo n.º 13
0
        public void ShowExplosion(Comet comet)
        {
            var    position = comet.transform.GetPosition();
            string sound    = GlobalAssets.GetSound(comet.impactSound);

            if (CameraController.Instance.IsAudibleSound(position, sound))
            {
                EventInstance instance = KFMOD.BeginOneShot(sound, position);
                instance.setParameterByName("userVolume_SFX", KPlayerPrefs.GetFloat("Volume_SFX"));
                KFMOD.EndOneShot(instance);
            }
            var fx_position = position;

            fx_position.z = Grid.GetLayerZ(Grid.SceneLayer.FXFront2);
            var cell = Grid.PosToCell(fx_position);

            if (SafeCell(cell))
            {
                Game.Instance.SpawnFX(comet.explosionEffectHash, fx_position, 0f);
            }
        }
Exemplo n.º 14
0
    public override void OnScroll(PointerEventData data)
    {
        if (base.vertical && allowVerticalScrollWheel)
        {
            float   num         = scrollVelocity;
            Vector2 scrollDelta = data.scrollDelta;
            scrollVelocity = num + scrollDelta.y * verticalScrollInertiaScale;
        }
        else if (base.horizontal && allowHorizontalScrollWheel)
        {
            float   num2         = scrollVelocity;
            Vector2 scrollDelta2 = data.scrollDelta;
            scrollVelocity = num2 - scrollDelta2.y * horizontalScrollInertiaScale;
        }
        Vector2 scrollDelta3 = data.scrollDelta;

        if (Mathf.Abs(scrollDelta3.y) > 0.2f)
        {
            EventInstance instance           = KFMOD.BeginOneShot(currentSounds[SoundType.OnMouseScroll], Vector3.zero);
            float         boundsExceedAmount = GetBoundsExceedAmount();
            instance.setParameterValue("scrollbarPosition", boundsExceedAmount);
            KFMOD.EndOneShot(instance);
        }
    }