void Awake() { Instance = this; OldMainSoundVolume = MainSoundVolume; OldMainMusicVolume = MainMusicVolume; if (GameConfig.GetConfigInt(GameConfig.KEY_MusicOnOff) != 0) { MainMusicVolume = 0; } if (GameConfig.GetConfigInt(GameConfig.KEY_SoundOnOff) != 0) { MainSoundVolume = 0; } listener = new GameObject("Listener").transform; listener.parent = transform; listener.gameObject.AddComponent <AudioListener>(); m_MusicSource = listener.gameObject.AddComponent <AudioSource>(); m_AmbSource = listener.gameObject.AddComponent <AudioSource>(); m_SoundSource = listener.gameObject.AddComponent <AudioSource>(); m_AmbSource.panLevel = 0.0f; m_MusicSource.panLevel = 0.0f; m_SoundSource.panLevel = 0.0f; //fadeVolume = 0f; m_MusicSource.volume = fadeVolume * MainMusicVolume; m_AmbSource.volume = MainSoundVolume; uiSounds = GetComponent <SoundSet>(); }
private static void SetHorn(LocoAudioDiesel audio, SoundSet soundSet) { var hornHitSource = audio.hornAudio.transform.Find("train_horn_01_hit").GetComponent <AudioSource>(); AudioUtils.Apply(TrainCarType.LocoDiesel, SoundType.HornHit, soundSet[SoundType.HornHit], hornHitSource); AudioUtils.Apply(TrainCarType.LocoDiesel, SoundType.HornLoop, soundSet[SoundType.HornLoop], audio.hornAudio); }
public void Start(ModManager m) { this.m = m; m.RegisterOnBlockUse(OnUse); m.RegisterOnBlockDelete(OnDelete); SoundSet sounds = new SoundSet() { Walk = new string[] { "walk1", "walk2", "walk3", "walk4" }, Break = new string[] { "destruct" }, Build = new string[] { "build" }, Clone = new string[] { "clone" }, }; m.SetBlockType(155, "Sign", new BlockType() { AllTextures = "Sign", DrawType = DrawType.Ladder, WalkableType = WalkableType.Solid, Sounds = sounds, IsUsable = true, }); m.AddToCreativeInventory("Sign"); m.RegisterOnCommand(OnCommand); m.RegisterOnDialogClick(OnClick); m.RegisterOnLoad(OnLoad); }
public void Start(ModManager manager) { m = manager; SoundSet solidSounds = new SoundSet() { Walk = new string[] { "walk1", "walk2", "walk3", "walk4" }, Break = new string[] { "destruct" }, Build = new string[] { "build" }, Clone = new string[] { "clone" }, }; m.SetBlockType(46, "TNT", new BlockType() { TextureIdTop = "TNTTop", TextureIdBottom = "TNTBottom", TextureIdBack = "TNT", TextureIdFront = "TNT", TextureIdLeft = "TNT", TextureIdRight = "TNT", TextureIdForInventory = "TNT", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, IsUsable = true, }); tnt = m.GetBlockId("TNT"); adminium = m.GetBlockId("Adminium"); m.AddToCreativeInventory("TNT"); m.AddCraftingRecipe("TNT", 1, "GoldBlock", 1); m.RegisterOnBlockUse(UseTnt); m.RegisterPrivilege("use_tnt"); m.RegisterTimer(UpdateTnt, 5); }
public void Apply(Config config, TrainCar car, SoundSet soundSet) { if (Applicable(car)) { rule.Apply(config, car, soundSet); } }
public static void LoadFromSaveManager() { var saved = SaveGameManager.data?.GetJObject(typeof(Registry).FullName); if (saved == null) { return; } foreach (var(guid, soundsObj) in saved) { if (soundsObj is JObject obj) { var soundSet = new SoundSet(); foreach (var(typeStr, soundName) in obj) { if (Config.Config.Active !.sounds.TryGetValue(soundName.Value <string>(), out var soundDefinition)) { soundSet.sounds[Config.Util.ParseEnum <SoundType>(typeStr)] = soundDefinition; } } if (soundSet.sounds.Count > 0) { soundSets[guid] = soundSet; } } } }
private AudioClip InternalPlaySound(Material material, int id) { SoundSet playSoundSet = sound; if (material != null) { SoundSet[] soundSets = null; if (soundSetDir.TryGetValue(material, out soundSets)) { if (id < soundSets.Length) { playSoundSet = soundSets[id]; } } } if (playSoundSet.clips == null || playSoundSet.clips.Length == 0) { return(null); } var clip = playSoundSet.clips[Random.Range(0, playSoundSet.clips.Length)]; if (clip == null) { return(null); } Source.pitch = randomPitch ? Random.Range(1 - randomPitchRange, 1 + randomPitchRange) : 1.0f; Source.clip = clip; Source.PlayDelayed(playDelay); return(clip); }
public void Apply(Config config, TrainCar car, SoundSet soundSet) { foreach (var rule in rules) { rule.Apply(config, car, soundSet); } }
public virtual AudioClip PlayOneShot(SoundSet set) { AudioClip clip = set.RandomClip; PlayOneShot(clip); return(clip); }
public static void Apply(TrainCar car, SoundSet soundSet) { var audio = car.GetComponentInChildren <LocoAudioDiesel>(); SetBell(audio, soundSet); SetEngine(audio, soundSet); SetHorn(audio, soundSet); }
public static void Apply(TrainCar car, CustomLocoAudioSteam audio, SoundSet soundSet) { AudioUtils.Apply( car.carType, SoundType.Whistle, soundSet[SoundType.Whistle], audio.whistleAudio); }
public static void Apply(TrainCar car, SoundSet soundSet) { var audio = car.GetComponentInChildren <LocoAudioSteam>(); AudioUtils.Apply( TrainCarType.LocoSteamHeavy, SoundType.Whistle, soundSet[SoundType.Whistle], audio.whistleAudio); }
public void ResetCharacterWeaponSoundData(WeaponSoundSet weaponSoundSet = null) { if (weaponSoundSet != null) { hitSound = weaponSoundSet.hitSound; attackSound = weaponSoundSet.attackSound; castSound = weaponSoundSet.castSound; useSkillSound = weaponSoundSet.useSkillSound; } }
public void Apply(Config config, TrainCar car, SoundSet soundSet) { var r = UnityEngine.Random.value; var index = Array.FindIndex(Thresholds, t => r <= t); // Main.DebugLog(() => $"weights={string.Join(",",weights)},thresholds={string.Join(",",thresholds)},randomValue={r},index={index}"); if (index >= 0) { rules[index].Apply(config, car, soundSet); } }
protected void InitSettings(SoundSet set) { audioSource.clip = set.clips[Random.Range(0, set.clips.Count)]; audioSource.volume = 1 - set.volume / 100; audioSource.minDistance = set.distMin; audioSource.maxDistance = set.distMax; audioSource.loop = set.loopCount != 1; audioSource.spatialBlend = set.spatialBlend; audioSource.panStereo = Random.Range(set.panMin, set.panMax); audioSource.rolloffMode = set.rolloffMode; }
void TransitionToAudioSnapShot(SoundSet soundSet, float time) { if (soundSet.audioMixerSnapshot != null) { soundSet.audioMixerSnapshot.TransitionTo(time); } else { audioMixerData.standardSnapshot.TransitionTo(time); } }
public void Start(ModManager m) { this.m = m; m.RegisterOnBlockUse(Teleport); m.RegisterOnBlockBuild(AddBlock); m.RegisterOnBlockDelete(DeleteBlock); m.RegisterPrivilege("use_tpblock"); m.RegisterPrivilege("set_tptarget"); m.RegisterPrivilege("get_tpblocks"); m.RegisterPrivilege("reload_tpblocks"); m.RegisterPrivilege("delete_tpblocks"); m.RegisterPrivilege("delete_all_tpblocks"); m.RegisterCommandHelp("use_tpblock", "Allows you to use teleport blocks"); m.RegisterCommandHelp("set_tptarget", "/set_tptarget [blockID] [X] [Y] [Z]"); m.RegisterCommandHelp("get_tpblocks", "Gives you all available teleport blocks"); m.RegisterCommandHelp("reload_tpblocks", "Reloads the list of teleport blocks"); m.RegisterCommandHelp("delete_all_tpblocks", "Deletes ALL teleport blocks and their targets"); m.RegisterOnCommand(SetTarget); m.RegisterOnCommand(GiveBlocks); m.RegisterOnCommand(ReloadTargets); m.RegisterOnCommand(DeleteAll); //m.RegisterOnLoad(LoadTargetPositions); SoundSet solidSounds = new SoundSet() { Walk = new string[] { "walk1", "walk2", "walk3", "walk4" }, Break = new string[] { "destruct" }, Build = new string[] { "build" }, Clone = new string[] { "clone" }, }; Console.WriteLine(consolePrefix + "Registering {0} teleport BlockTypes...", number_of_teleport_blocks); for (int i = 0; i < number_of_teleport_blocks; i++) { m.SetBlockType(blockID_start + i, "Teleport_Block_" + i.ToString(), new BlockType() { AllTextures = "Teleport_" + i.ToString(), DrawType = DrawType.Transparent, WalkableType = WalkableType.Solid, Sounds = solidSounds, IsUsable = true, }); } Console.WriteLine(consolePrefix + "Done."); // Load targets here as RegisterOnLoad is kinda broken... LoadTargetPositions(); Console.WriteLine(consolePrefix + "Loaded Mod Version 1.2"); m.LogServerEvent(consolePrefix + "Loaded Mod Version 1.2"); }
public void PlaySound(SoundSet soundSet) { if (soundSet.audioClip == null || soundSet.audioClip.Length == 0) { return; } effectSoundAudio.clip = soundSet.audioClip[Random.Range(0, soundSet.audioClip.Length)]; // 隨機撥放 if (effectSoundAudio.clip == null) { return; } effectSoundAudio.PlayOneShot(effectSoundAudio.clip); }
/// <summary> /// SEを再生する /// </summary> /// <param name="aFilePath">resources/sound/se/ + aFilePath</param> /// <param name="aAllowOverlap">falseの場合は同じSEを同時に鳴らそうとすると前のSEを停止する</param> public static void playSe(string aFilePath, bool aAllowOverlap = false, float aVolume = 1) { if (mSe == null) { mSe = new Dictionary <string, SoundSet>(); } AudioSource tAudio; MyBehaviour tBehaviour; if (aAllowOverlap) { //同時再生可 tAudio = MyBehaviour.create <AudioSource>(); tAudio.clip = Resources.Load <AudioClip>("sound/se/" + aFilePath); tAudio.name = "SE : " + aFilePath; tAudio.volume = aVolume; tAudio.Play(); tBehaviour = tAudio.gameObject.AddComponent <MyBehaviour>(); tBehaviour.StartCoroutine(deleteSe(tAudio, "")); return; } else { //同時再生不可 if (mSe.ContainsKey(aFilePath)) { //同時再生しようとした SoundSet tPlayedSet = mSe[aFilePath]; tPlayedSet.mSound.clip = Resources.Load <AudioClip>("sound/se/" + aFilePath); tPlayedSet.mSound.time = 0; tPlayedSet.mSound.Play(); return; } else { tAudio = MyBehaviour.create <AudioSource>(); tAudio.clip = Resources.Load <AudioClip>("sound/se/" + aFilePath); tAudio.name = "SE : " + aFilePath; tAudio.volume = aVolume; tAudio.Play(); tBehaviour = tAudio.gameObject.AddComponent <MyBehaviour>(); SoundSet tSet = new SoundSet(); tSet.mSound = tAudio; tSet.mCoroutine = tBehaviour.StartCoroutine(deleteSe(tAudio, aFilePath)); mSe.Add(aFilePath, tSet); GameObject.DontDestroyOnLoad(tAudio); } } }
public void Start(ModManager m) { this.m = m; m.RegisterOnBlockUse(ToggleLight); m.RegisterOnBlockBuild(AddBlock); m.RegisterOnBlockDelete(DeleteBlock); m.RegisterPrivilege("toggle"); m.RegisterPrivilege("toggle_all"); m.RegisterCommandHelp("toggle_all", "/toggle_all [0 / 1]"); m.RegisterCommandHelp("toggle", "Allows you to toggle single light blocks."); m.RegisterOnCommand(ToggleAll); m.RegisterOnLoad(LoadLights); m.RegisterOnSave(SaveLights); m.SetString("en", "Light_Active", "Active Light Block"); m.SetString("en", "Light_Inactive", "Inactive Light Block"); SoundSet solidSounds = new SoundSet() { Walk = new string[] { "walk1", "walk2", "walk3", "walk4" }, Break = new string[] { "destruct" }, Build = new string[] { "build" }, Clone = new string[] { "clone" }, }; m.SetBlockType(254, name_on, new BlockType() { AllTextures = "light_on", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, LightRadius = 10, IsUsable = true, }); m.SetBlockType(255, name_off, new BlockType() { AllTextures = "light_off", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, IsUsable = true, }); light_on = m.GetBlockId(name_on); light_off = m.GetBlockId(name_off); //m.AddToCreativeInventory(name_on); m.AddToCreativeInventory(name_off); m.AddCraftingRecipe2(name_off, 1, "Torch", 3, "IronBlock", 2); }
public static void SetEngine(LocoAudioDiesel audio, SoundSet soundSet) { soundSet.sounds.TryGetValue(SoundType.EngineStartup, out var startup); AudioUtils.Apply(TrainCarType.LocoDiesel, SoundType.EngineStartup, startup, ref audio.engineOnClip); soundSet.sounds.TryGetValue(SoundType.EngineShutdown, out var shutdown); AudioUtils.Apply(TrainCarType.LocoDiesel, SoundType.EngineShutdown, shutdown, ref audio.engineOffClip); EngineFade.SetFadeSettings(audio, new EngineFade.Settings { fadeInStart = startup?.fadeStart ?? 0.15f * audio.engineOnClip.length, fadeOutStart = shutdown?.fadeStart ?? 0.10f * audio.engineOffClip.length, fadeInDuration = startup?.fadeDuration ?? 2f, fadeOutDuration = shutdown?.fadeDuration ?? 1f, }); AudioUtils.Apply(TrainCarType.LocoDiesel, SoundType.EngineLoop, soundSet[SoundType.EngineLoop], audio.engineAudio); AudioUtils.Apply(TrainCarType.LocoDiesel, SoundType.EngineLoadLoop, soundSet[SoundType.EngineLoadLoop], audio.enginePistonAudio); AudioUtils.Apply(TrainCarType.LocoDiesel, SoundType.TractionMotors, soundSet[SoundType.TractionMotors], audio.electricMotorAudio); }
void ChangeSoundSet(int index, bool keepPlaying = false) { if (index >= soundSets.Length) { return; } // stop old soundset StopActiveSoundSet(); if (keepPlaying) { for (int c = 0; c < audioSourceDict[activeSoundSet].GetLength(0); c++) { for (int i = 0; i < audioSourceDict[activeSoundSet].GetLength(1); i++) { for (int v = 0; v < audioSourceDict[activeSoundSet].GetLength(2); v++) { audioSourceDict[soundSets[index]][c, i, v].mute = audioSourceDict[activeSoundSet][c, i, v].mute; } } } } else { // mute old soundset SetAllChannelsInActiveSoundSet(false); } // deactivate old gameobjects DeactivateActiveSoundSetRoot(); // activate new gameobjects ActivateSoundSetRoot(index); // set new soundset as the active soundset activeSoundSet = soundSets[index]; // transition to snapshot TransitionToAudioSnapShot(activeSoundSet, 0); // play new soundset PlayAllFromActiveSoundSet(); }
public static void Apply(TrainCar car, SoundSet soundSet) { Main.DebugLog(() => $"Applying to {car.ID}:\n{soundSet}"); var audio = car.GetComponentInChildren <CustomLocoAudio>(); if (audio == null) { return; } Main.DebugLog(() => $"Found CustomLocoAudio {audio.GetPath()}"); if (audio is CustomLocoAudioDiesel diesel) { CCLDieselAudio.Apply(car, diesel, soundSet); } if (audio is CustomLocoAudioSteam steam) { CCLSteamAudio.Apply(car, steam, soundSet); } }
public void NextSortMode() { int current = (int)sortMode; current++; if (current >= System.Enum.GetNames(typeof(SortMode)).Length) { current = 0; } if (current == (int)SortMode.SearchRelevance && System.String.IsNullOrEmpty(SoundSet.Searchify(searchString))) { current = 0; } sortMode = (SortMode)current; if (current < 2) { lastMode = sortMode; } PlayerPrefs.SetInt("lastSortMode", current); }
public Robot.Robot CreateRobot(ILevel level, TileCoordinates coordinates, FlatDirection direction, RobotAction action) { return(new Robot.Robot( coordinates, direction, m_colour, m_immobile, m_required, action, m_guiColour, m_turnPreference, RobotModel, (m_robotAnimSet != null ? AnimSet.Get(m_robotAnimSet) : null), (m_robotSoundSet != null ? SoundSet.Get(m_robotSoundSet) : null), m_robotLightColour, m_robotLightRadius, Tile.RenderPass, Tile.CastShadows )); }
public Robot(TileCoordinates position, FlatDirection direction, string colour, bool immobile, bool required, RobotAction initialAction, Vector3 guiColour, TurnDirection turnPreference, Model model, AnimSet animations, SoundSet sounds, Vector3?lightColour, float?lightRadius, RenderPass renderPass, bool castShadows) { m_colour = colour; m_immobile = immobile; m_required = required; m_spawnAction = initialAction; m_spawnPosition = position; m_spawnDirection = direction; m_turnPreference = turnPreference; if (lightColour.HasValue && lightRadius.HasValue) { m_lightColour = lightColour.Value; m_light = new PointLight(Vector3.Zero, lightColour.Value, lightRadius.Value); } m_modelInstance = new ModelInstance(model, Matrix4.Identity); m_animations = animations; m_sounds = sounds; m_guiColour = guiColour; m_renderPass = renderPass; m_castShadows = castShadows; }
public void Start(ModManager m) { this.m = m; SoundSet solidSounds = new SoundSet() { Walk = new string[] { "walk1", "walk2", "walk3", "walk4" }, Break = new string[] { "destruct" }, Build = new string[] { "build" }, Clone = new string[] { "clone" }, }; int blockCount = 0; for (int r = 0; r < 16; r += 3) { for (int g = 0; g < 16; g += 3) { for (int b = 0; b < 16; b += 3) { int r32 = r * 17; int g32 = g * 17; int b32 = b * 17; string blockName = string.Format("R{0}G{1}B{2}", r32.ToString(), g32.ToString(), b32.ToString()); m.SetBlockType(blockName, new BlockType() { AllTextures = blockName, DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.AddToCreativeInventory(blockName); blockCount++; } } } System.Console.WriteLine(string.Format("INFO: TooManyColors Mod v1.0 loaded. {0} blocks registered.", blockCount)); }
void Awake() { Instance = this; OldMainSoundVolume = MainSoundVolume; OldMainMusicVolume = MainMusicVolume; if (GameConfig.GetConfigInt(GameConfig.KEY_MusicOnOff) != 0) MainMusicVolume = 0; if (GameConfig.GetConfigInt(GameConfig.KEY_SoundOnOff) != 0) MainSoundVolume = 0; listener = new GameObject("Listener").transform; listener.parent = transform; listener.gameObject.AddComponent<AudioListener>(); m_MusicSource = listener.gameObject.AddComponent<AudioSource>(); m_AmbSource = listener.gameObject.AddComponent<AudioSource>(); m_SoundSource = listener.gameObject.AddComponent<AudioSource>(); m_AmbSource.panLevel = 0.0f; m_MusicSource.panLevel = 0.0f; m_SoundSource.panLevel = 0.0f; //fadeVolume = 0f; m_MusicSource.volume = fadeVolume * MainMusicVolume; m_AmbSource.volume = MainSoundVolume; uiSounds = GetComponent<SoundSet>(); }
public void SetDefaultSounds(SoundSet defaultSounds) { this.defaultSounds = defaultSounds; }
public void Start(ModManager manager) { m = manager; m.RegisterOnBlockBuild(OnBuild); m.RegisterOnBlockDelete(OnDelete); m.RegisterOnBlockUse(OnUse); m.SetString("en", "DoorBottomClosed", "Closed Door"); m.SetString("en", "DoorTopClosed", "Closed Door"); m.SetString("en", "DoorBottomOpen", "Open Door"); m.SetString("en", "DoorTopOpen", "Open Door"); SoundSet sounds = new SoundSet() { Walk = new string[] { "walk1", "walk2", "walk3", "walk4" }, Break = new string[] { "destruct" }, Build = new string[] { "build" }, Clone = new string[] { "clone" }, }; m.SetBlockType(126, "DoorBottomClosed", new BlockType() { AllTextures = "DoorBottom", DrawType = DrawType.ClosedDoor, WalkableType = WalkableType.Solid, Sounds = sounds, IsUsable = true, }); m.SetBlockType(127, "DoorTopClosed", new BlockType() { AllTextures = "DoorTop", DrawType = DrawType.ClosedDoor, WalkableType = WalkableType.Solid, Sounds = sounds, IsUsable = true, WhenPlayerPlacesGetsConvertedTo = 126, }); m.SetBlockType(128, "DoorBottomOpen", new BlockType() { AllTextures = "DoorBottom", DrawType = DrawType.OpenDoorLeft, WalkableType = WalkableType.Empty, Sounds = sounds, IsUsable = true, WhenPlayerPlacesGetsConvertedTo = 126, }); m.SetBlockType(129, "DoorTopOpen", new BlockType() { AllTextures = "DoorTop", DrawType = DrawType.OpenDoorLeft, WalkableType = WalkableType.Empty, Sounds = sounds, IsUsable = true, WhenPlayerPlacesGetsConvertedTo = 126, }); m.AddToCreativeInventory("DoorBottomClosed"); m.AddCraftingRecipe("DoorBottomClosed", 1, "OakWood", 2); m.AddCraftingRecipe("DoorBottomClosed", 1, "BirchWood", 2); m.AddCraftingRecipe("DoorBottomClosed", 1, "SpruceWood", 2); DoorBottomClosed = m.GetBlockId("DoorBottomClosed"); DoorTopClosed = m.GetBlockId("DoorTopClosed"); DoorBottomOpen = m.GetBlockId("DoorBottomOpen"); DoorTopOpen = m.GetBlockId("DoorTopOpen"); }
public void OnPhraseSelectGUI() { GUIF.Button(new Rect(Screen.width * 0.01f, Screen.height * 0.01f, Screen.width * 0.4f, Screen.height * 0.075f), "Back", () => { Application.LoadLevel("default"); menuState = MenuState.ListingSets; searchString = ""; scrollPos = new Vector2(); scrollFling = 0.0f; }); string str; switch (mode) { case PlayMode.AlwaysInstant: str = "Always Play"; break; case PlayMode.Override: str = "Override Playing"; break; case PlayMode.Queue: str = "Queue"; break; case PlayMode.Spam: str = "Spam"; break; default: str = "Error"; break; } GUIF.Button(new Rect(Screen.width * 0.59f, Screen.height * 0.01f, Screen.width * 0.4f, Screen.height * 0.075f), str, () => { NextMode(); }); Rect scrollArea = new Rect(Screen.width * 0.01f, Screen.height * 0.2f, Screen.width * 0.98f, Screen.height * 0.73f); float lineHeight = GUI.skin.button.LineSize() * 1.33f; Rect brush = new Rect(Screen.width * 0.01f, Screen.height * 0.1f, Screen.width * 0.93f, lineHeight); GUI.Label(brush.Left(0.2f), "Search"); searchString = GUI.TextField(brush.Right(0.8f), searchString); GUIF.Button(new Rect(Screen.width * 0.94f, Screen.height * 0.1f, Screen.width * 0.05f, lineHeight), "X", () => { searchString = ""; }); brush = brush.Move(0.0f, 1.0f); brush.width = Screen.width * 0.98f; switch (sortMode) { case SortMode.Alphabetic: str = "Alphabetic"; break; case SortMode.MostPlayed: str = "Most Played"; break; case SortMode.SearchRelevance: str = "Relevance"; break; default: str = "Error"; break; } GUIF.Button(brush, "Sort by: " + str, () => { NextSortMode(); scrollPos = new Vector2(); scrollFling = 0.0f; if (System.String.IsNullOrEmpty(SoundSet.Searchify(searchString))) { currentSet.Sort(); } else { searchResults.Sort((Phrase phrase1, Phrase phrase2) => { if (sortMode == SortMode.Alphabetic) { return(phrase1.name.ToUpper().CompareTo(phrase2.name.ToUpper())); } else if (sortMode == SortMode.MostPlayed) { return(phrase2.timesPlayed - phrase1.timesPlayed); } else if (sortMode == SortMode.SearchRelevance) { return(SoundSet.ComparePhrasesBySearchRelevance(phrase1.name.ToUpper(), phrase2.name.ToUpper(), SoundSet.Searchify(searchString))); } else { return(0); } }); } }); brush = new Rect(0.0f, 0.0f, scrollArea.width - 24, lineHeight); System.Func <Rect, string, System.Action, bool> buttonFunc; if (mode == PlayMode.Spam) { buttonFunc = GUIF.RepeatButton; } else { buttonFunc = GUIF.Button; } if (!System.String.IsNullOrEmpty(SoundSet.Searchify(searchString))) { scrollPos = GUI.BeginScrollView(scrollArea, scrollPos, new Rect(0, 0, Screen.width * 0.9f - 24, lineHeight * 1.05f * searchResults.Count)); { brush.y = (int)(scrollPos.y / (brush.height * 1.05f)) * (brush.height * 1.05f); for (int i = (int)Mathf.Max(scrollPos.y / (brush.height * 1.05f), 0); scrollPos.y >= ((i - 1) * brush.height * 1.05f) - scrollArea.height && i < searchResults.Count; i++) { Phrase phrase = searchResults[i]; str = phrase.name; if (phrase.clips.Count > 1) { str += " (" + phrase.clips.Count + ")"; } buttonFunc(brush, str, () => { if (!scrolling) { switch (mode) { case PlayMode.Queue: clipQueue.Enqueue(phrase.clips.Choose <AudioClip>()); break; case PlayMode.AlwaysInstant: case PlayMode.Spam: PlaySound(phrase.clips.Choose <AudioClip>()); break; case PlayMode.Override: if (currentSound != null) { currentSound.Stop(); } PlaySound(phrase.clips.Choose <AudioClip>()); break; } } }); brush = brush.Move(0.0f, 1.05f); } } GUI.EndScrollView(); } else { scrollPos = GUI.BeginScrollView(scrollArea, scrollPos, new Rect(0, 0, Screen.width * 0.9f - 24, lineHeight * 1.05f * currentSet.phrases.Count)); { brush.y = (int)(scrollPos.y / (brush.height * 1.05f)) * (brush.height * 1.05f); for (int i = (int)Mathf.Max(scrollPos.y / (brush.height * 1.05f), 0); scrollPos.y >= ((i - 1) * brush.height * 1.05f) - scrollArea.height && i < currentSet.phrases.Count; i++) { Phrase phrase = currentSet.phrases[i]; str = phrase.name; if (phrase.clips.Count > 1) { str += " (" + phrase.clips.Count + ")"; } buttonFunc(brush, str, () => { switch (mode) { case PlayMode.Queue: clipQueue.Enqueue(phrase.clips.Choose <AudioClip>()); break; case PlayMode.AlwaysInstant: case PlayMode.Spam: PlaySound(phrase.clips.Choose <AudioClip>()); break; case PlayMode.Override: if (currentSound != null) { currentSound.Stop(); } PlaySound(phrase.clips.Choose <AudioClip>()); break; } phrase.timesPlayed += 1; }); brush = brush.Move(0.0f, 1.05f); } } GUI.EndScrollView(); } buttonFunc(new Rect(scrollArea.x, Screen.height * 0.95f, scrollArea.width, lineHeight), "[Random]", () => { List <Phrase> set; if (System.String.IsNullOrEmpty(SoundSet.Searchify(searchString))) { set = currentSet.phrases; } else { set = searchResults; } if (set.Count > 0) { Phrase phrase = set.Choose <Phrase>(); switch (mode) { case PlayMode.Queue: clipQueue.Enqueue(phrase.clips.Choose <AudioClip>()); break; case PlayMode.AlwaysInstant: case PlayMode.Spam: PlaySound(phrase.clips.Choose <AudioClip>()); break; case PlayMode.Override: if (currentSound != null) { currentSound.Stop(); } PlaySound(phrase.clips.Choose <AudioClip>()); break; } phrase.timesPlayed += 1; } }); }
public bool StopSound(SoundSet.ClipType type) { if (soundSet == null) { return false; } SoundSet.ClipPlayType playType; AudioClip clip = soundSet.GetClip (type, out playType); if (clip) { if (playType == SoundSet.ClipPlayType.OneShot) { return true; } if (audioSource.clip == clip) { audioSource.Stop (); return true; } } return false; }
public void Start(ModManager manager) { m = manager; //Timer for season changes m.RegisterTimer(UpdateSeasons, 1); //Initialize sounds noSound = new SoundSet(); solidSounds = new SoundSet() { Walk = new string[] { "walk1", "walk2", "walk3", "walk4" }, Break = new string[] { "destruct" }, Build = new string[] { "build" }, Clone = new string[] { "clone" }, }; snowSounds = new SoundSet() { Walk = new string[] { "walksnow1", "walksnow2", "walksnow3", "walksnow4" }, Break = new string[] { "destruct" }, Build = new string[] { "build" }, Clone = new string[] { "clone" }, }; m.SetDefaultSounds(solidSounds); #region Block types m.SetBlockType(0, "Empty", new BlockType() { DrawType = DrawType.Empty, WalkableType = WalkableType.Empty, Sounds = noSound, }); m.SetBlockType(1, "Stone", new BlockType() { AllTextures = "Stone", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(2, "Grass", new BlockType() { TextureIdTop = "Grass", SideTextures = "GrassSide", TextureIdForInventory = "GrassSide", TextureIdBottom = "Dirt", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, WhenPlayerPlacesGetsConvertedTo = 3, }); m.SetBlockType(3, "Dirt", new BlockType() { AllTextures = "Dirt", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(4, "Cobblestone", new BlockType() { AllTextures = "Cobblestone", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(5, "OakWood", new BlockType() { AllTextures = "OakWood", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(6, "OakSapling", new BlockType() { AllTextures = "OakSapling", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(7, "Adminium", new BlockType() { AllTextures = "Adminium", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(8, "Water", new BlockType() { AllTextures = "Water", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = noSound, }); m.SetBlockType(9, "StationaryWater", new BlockType() { AllTextures = "Water", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = noSound, }); m.SetBlockType(10, "Lava", new BlockType() { AllTextures = "Lava", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = noSound, LightRadius = 15, DamageToPlayer = 2, }); m.SetBlockType(11, "StationaryLava", new BlockType() { AllTextures = "Lava", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = noSound, LightRadius = 15, DamageToPlayer = 2, }); m.SetBlockType(12, "Sand", new BlockType() { AllTextures = "Sand", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(13, "Gravel", new BlockType() { AllTextures = "Gravel", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(14, "GoldOre", new BlockType() { AllTextures = "GoldOre", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(15, "IronOre", new BlockType() { AllTextures = "IronOre", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(16, "CoalOre", new BlockType() { AllTextures = "CoalOre", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(17, "OakTreeTrunk", new BlockType() { TopBottomTextures = "OakTreeTrunkTopBottom", SideTextures = "OakTreeTrunk", TextureIdForInventory = "OakTreeTrunk", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(18, "OakLeaves", new BlockType() { AllTextures = "OakLeaves", DrawType = DrawType.Transparent, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(19, "Sponge", new BlockType() { AllTextures = "Sponge", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(20, "Glass", new BlockType() { AllTextures = "Glass", DrawType = DrawType.Transparent, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(21, "RedCloth", new BlockType() { AllTextures = "RedCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(22, "OrangeCloth", new BlockType() { AllTextures = "OrangeCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(23, "YellowCloth", new BlockType() { AllTextures = "YellowCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(24, "LightGreenCloth", new BlockType() { AllTextures = "LightGreenCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(25, "GreenCloth", new BlockType() { AllTextures = "GreenCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(26, "AquaGreenCloth", new BlockType() { AllTextures = "AquaGreenCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(27, "CyanCloth", new BlockType() { AllTextures = "CyanCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(28, "BlueCloth", new BlockType() { AllTextures = "BlueCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(29, "PurpleCloth", new BlockType() { AllTextures = "PurpleCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(30, "IndigoCloth", new BlockType() { AllTextures = "IndigoCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(31, "VioletCloth", new BlockType() { AllTextures = "VioletCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(32, "MagentaCloth", new BlockType() { AllTextures = "MagentaCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(33, "PinkCloth", new BlockType() { AllTextures = "PinkCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(34, "BlackCloth", new BlockType() { AllTextures = "BlackCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(35, "GrayCloth", new BlockType() { AllTextures = "GrayCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(36, "WhiteCloth", new BlockType() { AllTextures = "WhiteCloth", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(37, "YellowFlowerDecorations", new BlockType() { AllTextures = "YellowFlowerDecorations", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(38, "RedRoseDecorations", new BlockType() { AllTextures = "RedRoseDecorations", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(39, "RedMushroom", new BlockType() { AllTextures = "RedMushroom", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(40, "BrownMushroom", new BlockType() { AllTextures = "BrownMushroom", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(41, "GoldBlock", new BlockType() { AllTextures = "GoldBlock", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(42, "IronBlock", new BlockType() { AllTextures = "IronBlock", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(43, "DoubleStair", new BlockType() { TopBottomTextures = "Stair", SideTextures = "DoubleStairSide", TextureIdForInventory = "DoubleStairSide", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(44, "Stair", new BlockType() { TopBottomTextures = "Stair", SideTextures = "StairSide", TextureIdForInventory = "StairInventory", DrawType = DrawType.HalfHeight, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(45, "Brick", new BlockType() { AllTextures = "Brick", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(47, "Bookcase", new BlockType() { TopBottomTextures = "OakWood", SideTextures = "Bookcase", TextureIdForInventory = "Bookcase", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(48, "MossyCobblestone", new BlockType() { AllTextures = "MossyCobblestone", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(49, "Obsidian", new BlockType() { AllTextures = "Obsidian", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(50, "Torch", new BlockType() { TextureIdTop = "TorchTop", TextureIdBottom = "Torch", SideTextures = "Torch", TextureIdForInventory = "Torch", LightRadius = 15, DrawType = DrawType.Torch, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(51, "Clay", new BlockType() { AllTextures = "Clay", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(52, "Marble", new BlockType() { AllTextures = "Marble", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(53, "Granite", new BlockType() { AllTextures = "Granite", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(54, "RedSand", new BlockType() { AllTextures = "RedSand", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(55, "Sandstone", new BlockType() { AllTextures = "Sandstone", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(56, "RedSandstone", new BlockType() { AllTextures = "RedSandstone", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(57, "Cactus", new BlockType() { TopBottomTextures = "CactusTopBottom", SideTextures = "CactusSide", TextureIdForInventory = "CactusSide", DrawType = DrawType.Cactus, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(58, "DeadPlant", new BlockType() { AllTextures = "DeadPlant", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(59, "GrassPlant", new BlockType() { AllTextures = "GrassPlant", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(60, "BirchTreeTrunk", new BlockType() { TopBottomTextures = "BirchTreeTrunkTopBottom", SideTextures = "BirchTreeTrunk", TextureIdForInventory = "BirchTreeTrunk", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(61, "BirchLeaves", new BlockType() { AllTextures = "BirchLeaves", DrawType = DrawType.Transparent, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(62, "BirchSapling", new BlockType() { AllTextures = "BirchSapling", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(63, "BirchWood", new BlockType() { AllTextures = "BirchWood", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(64, "SpruceTreeTrunk", new BlockType() { TopBottomTextures = "SpruceTreeTrunkTopBottom", SideTextures = "SpruceTreeTrunk", TextureIdForInventory = "SpruceTreeTrunk", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(65, "SpruceLeaves", new BlockType() { AllTextures = "SpruceLeaves", DrawType = DrawType.Transparent, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(66, "SpruceSapling", new BlockType() { AllTextures = "SpruceSapling", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(67, "SpruceWood", new BlockType() { AllTextures = "SpruceWood", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(68, "HalfCobblestone", new BlockType() { TopBottomTextures = "Cobblestone", SideTextures = "CobblestoneHalf", TextureIdForInventory = "CobblestoneHalfInventory", DrawType = DrawType.HalfHeight, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(69, "HalfMossyCobblestone", new BlockType() { TopBottomTextures = "MossyCobblestone", SideTextures = "MossyCobblestoneHalf", TextureIdForInventory = "MossyCobblestoneHalfInventory", DrawType = DrawType.HalfHeight, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(70, "HalfOakWood", new BlockType() { TopBottomTextures = "OakWood", SideTextures = "OakWoodHalf", TextureIdForInventory = "OakWoodHalfInventory", DrawType = DrawType.HalfHeight, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(71, "HalfBirchWood", new BlockType() { TopBottomTextures = "BirchWood", SideTextures = "BirchWoodHalf", TextureIdForInventory = "BirchWoodHalfInventory", DrawType = DrawType.HalfHeight, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(72, "HalfSpruceWood", new BlockType() { TopBottomTextures = "SpruceWood", SideTextures = "SpruceWoodHalf", TextureIdForInventory = "SpruceWoodHalfInventory", DrawType = DrawType.HalfHeight, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(73, "HalfBrick", new BlockType() { TopBottomTextures = "Brick", SideTextures = "BrickHalf", TextureIdForInventory = "BrickHalfInventory", DrawType = DrawType.HalfHeight, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(74, "HalfSandBrick", new BlockType() { TopBottomTextures = "SandBrick", SideTextures = "SandBrickHalf", TextureIdForInventory = "SandBrickHalfInventory", DrawType = DrawType.HalfHeight, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(75, "Bog", new BlockType() { AllTextures = "Bog", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, WalkSpeed = 0.5f, }); m.SetBlockType(100, "BrushedMetal", new BlockType() { AllTextures = "BrushedMetal", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(101, "ChemicalGreen", new BlockType() { AllTextures = "ChemicalGreen", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(102, "Salt", new BlockType() { AllTextures = "Salt", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(103, "Roof", new BlockType() { AllTextures = "Roof", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(104, "Camouflage", new BlockType() { AllTextures = "Camouflage", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(105, "DirtForFarming", new BlockType() { AllTextures = "DirtForFarming", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(106, "Apples", new BlockType() { AllTextures = "Apples", DrawType = DrawType.Transparent, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(107, "Hay", new BlockType() { AllTextures = "Hay", DrawType = DrawType.Transparent, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(108, "Crops1", new BlockType() { AllTextures = "Crops1", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(109, "Crops2", new BlockType() { AllTextures = "Crops2", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(110, "Crops3", new BlockType() { AllTextures = "Crops3", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(111, "Crops4", new BlockType() { AllTextures = "Crops4", DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(112, "CraftingTable", new BlockType() { TopBottomTextures = "CraftingTableTopBottom", SideTextures = "CraftingTableSide", TextureIdForInventory = "CraftingTableTopBottom", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, IsUsable = true, }); m.SetBlockType(113, "Minecart", new BlockType() { AllTextures = "Minecart", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(114, "Trampoline", new BlockType() { AllTextures = "Trampoline", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(115, "FillStart", new BlockType() { AllTextures = "FillStart", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(116, "Cuboid", new BlockType() { AllTextures = "FillEnd", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(117, "FillArea", new BlockType() { AllTextures = "FillArea", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = solidSounds, }); m.SetBlockType(118, "Water0", new BlockType() { AllTextures = "Water", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = solidSounds, }); m.SetBlockType(119, "Water1", new BlockType() { AllTextures = "Water", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = solidSounds, }); m.SetBlockType(120, "Water2", new BlockType() { AllTextures = "Water", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = solidSounds, }); m.SetBlockType(121, "Water3", new BlockType() { AllTextures = "Water", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = solidSounds, }); m.SetBlockType(122, "Water4", new BlockType() { AllTextures = "Water", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = solidSounds, }); m.SetBlockType(123, "Water5", new BlockType() { AllTextures = "Water", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = solidSounds, }); m.SetBlockType(124, "Water6", new BlockType() { AllTextures = "Water", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = solidSounds, }); m.SetBlockType(125, "Water7", new BlockType() { AllTextures = "Water", DrawType = DrawType.Fluid, WalkableType = WalkableType.Fluid, Sounds = solidSounds, }); m.SetBlockType(130, "GrassTrap", new BlockType() { TextureIdTop = "Grass", SideTextures = "GrassSide", TextureIdForInventory = "GrassSide", TextureIdBottom = "Dirt", DrawType = DrawType.Solid, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(131, "GoldCoin", new BlockType() { AllTextures = "GoldCoin", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(132, "GoldBar", new BlockType() { TopBottomTextures = "GoldBarTopBottom", SideTextures = "GoldBarSide", TextureIdForInventory = "GoldBarInvetory", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, LightRadius = 5, }); m.SetBlockType(133, "SilverOre", new BlockType() { AllTextures = "SilverOre", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(135, "SilverCoin", new BlockType() { AllTextures = "SilverCoin", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(140, "DirtBrick", new BlockType() { AllTextures = "DirtBrick", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(141, "LuxuryRoof", new BlockType() { AllTextures = "LuxuryRoof", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(142, "SandBrick", new BlockType() { AllTextures = "SandBrick", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(143, "FakeBookcase", new BlockType() { TopBottomTextures = "OakWood", SideTextures = "Bookcase", TextureIdForInventory = "Bookcase", DrawType = DrawType.Solid, WalkableType = WalkableType.Empty, Sounds = solidSounds, }); m.SetBlockType(144, "WoodDesk", new BlockType() { TextureIdTop = "WoodBlock", TextureIdBottom = "Empty", SideTextures = "GlassDeskSide", TextureIdForInventory = "WoodBlock", DrawType = DrawType.Transparent, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(145, "GlassDesk", new BlockType() { TextureIdTop = "Glass", TextureIdBottom = "Empty", SideTextures = "GlassDeskSide", TextureIdForInventory = "GlassDeskSide", DrawType = DrawType.Transparent, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(146, "Mosaik", new BlockType() { AllTextures = "Mosaik", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(147, "Asphalt", new BlockType() { AllTextures = "Asphalt", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(148, "Cake", new BlockType() { TextureIdTop = "CakeTop", TextureIdBottom = "Gray", SideTextures = "CakeSide", TextureIdForInventory = "CakeTop", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(149, "Fire", new BlockType() { AllTextures = "Fire", LightRadius = 15, DrawType = DrawType.Plant, WalkableType = WalkableType.Empty, Sounds = solidSounds, DamageToPlayer = 2, }); m.SetBlockType(150, "Fence", new BlockType() { AllTextures = "Fence", DrawType = DrawType.Fence, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(151, "Compass", new BlockType() { AllTextures = "Compass", TextureIdForInventory = "CompassInventory", DrawType = DrawType.Plant, WalkableType = WalkableType.Solid, Sounds = solidSounds, }); m.SetBlockType(152, "Ladder", new BlockType() { AllTextures = "Ladder", DrawType = DrawType.Ladder, WalkableType = WalkableType.Fluid, Sounds = solidSounds, }); m.SetBlockType(153, "EmptyHand", new BlockType() { AllTextures = "YellowThing", DrawType = DrawType.Torch, WalkableType = WalkableType.Empty, Sounds = noSound, }); for (int i = 0; i < 64; i++) { m.SetBlockType(176 + i, "Rail" + i.ToString(), new BlockType() { TextureIdTop = "Rail" + i.ToString(), TextureIdBottom = "Cobblestone", SideTextures = "Cobblestone", TextureIdForInventory = "Rail" + i.ToString(), DrawType = DrawType.Transparent, WalkableType = WalkableType.Solid, Sounds = solidSounds, Rail = i, }); } m.SetBlockType(241, "RedCarpet", new BlockType() { AllTextures = "RedCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(242, "OrangeCarpet", new BlockType() { AllTextures = "OrangeCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(243, "YellowCarpet", new BlockType() { AllTextures = "YellowCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(244, "LightGreenCarpet", new BlockType() { AllTextures = "LightGreenCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(245, "GreenCarpet", new BlockType() { AllTextures = "GreenCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(246, "AquaGreenCarpet", new BlockType() { AllTextures = "AquaGreenCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(247, "CyanCarpet", new BlockType() { AllTextures = "CyanCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(248, "BlueCarpet", new BlockType() { AllTextures = "BlueCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(249, "PurpleCarpet", new BlockType() { AllTextures = "PurpleCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(250, "IndigoCarpet", new BlockType() { AllTextures = "IndigoCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(251, "VioletCarpet", new BlockType() { AllTextures = "VioletCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(252, "MagentaCarpet", new BlockType() { AllTextures = "MagentaCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(253, "PinkCarpet", new BlockType() { AllTextures = "PinkCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(254, "BlackCarpet", new BlockType() { AllTextures = "BlackCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(255, "GrayCarpet", new BlockType() { AllTextures = "GrayCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); m.SetBlockType(256, "WhiteCarpet", new BlockType() { AllTextures = "WhiteCloth", DrawType = DrawType.Flat, WalkableType = WalkableType.Empty, Sounds = solidSounds }); #endregion #region Creative inventory m.AddToCreativeInventory("Stone"); m.AddToCreativeInventory("Dirt"); m.AddToCreativeInventory("Cobblestone"); m.AddToCreativeInventory("OakWood"); m.AddToCreativeInventory("OakSapling"); //m.AddToCreativeInventory("Adminium"); m.AddToCreativeInventory("Water"); m.AddToCreativeInventory("Lava"); m.AddToCreativeInventory("Sand"); m.AddToCreativeInventory("Gravel"); m.AddToCreativeInventory("GoldOre"); m.AddToCreativeInventory("IronOre"); m.AddToCreativeInventory("CoalOre"); m.AddToCreativeInventory("OakTreeTrunk"); m.AddToCreativeInventory("OakLeaves"); m.AddToCreativeInventory("Sponge"); m.AddToCreativeInventory("Glass"); m.AddToCreativeInventory("RedCloth"); m.AddToCreativeInventory("OrangeCloth"); m.AddToCreativeInventory("YellowCloth"); m.AddToCreativeInventory("LightGreenCloth"); m.AddToCreativeInventory("GreenCloth"); m.AddToCreativeInventory("AquaGreenCloth"); m.AddToCreativeInventory("CyanCloth"); m.AddToCreativeInventory("BlueCloth"); m.AddToCreativeInventory("PurpleCloth"); m.AddToCreativeInventory("IndigoCloth"); m.AddToCreativeInventory("VioletCloth"); m.AddToCreativeInventory("MagentaCloth"); m.AddToCreativeInventory("PinkCloth"); m.AddToCreativeInventory("BlackCloth"); m.AddToCreativeInventory("GrayCloth"); m.AddToCreativeInventory("WhiteCloth"); m.AddToCreativeInventory("RedCarpet"); m.AddToCreativeInventory("OrangeCarpet"); m.AddToCreativeInventory("YellowCarpet"); m.AddToCreativeInventory("LightGreenCarpet"); m.AddToCreativeInventory("GreenCarpet"); m.AddToCreativeInventory("AquaGreenCarpet"); m.AddToCreativeInventory("CyanCarpet"); m.AddToCreativeInventory("BlueCarpet"); m.AddToCreativeInventory("PurpleCarpet"); m.AddToCreativeInventory("IndigoCarpet"); m.AddToCreativeInventory("VioletCarpet"); m.AddToCreativeInventory("MagentaCarpet"); m.AddToCreativeInventory("PinkCarpet"); m.AddToCreativeInventory("BlackCarpet"); m.AddToCreativeInventory("GrayCarpet"); m.AddToCreativeInventory("WhiteCarpet"); m.AddToCreativeInventory("YellowFlowerDecorations"); m.AddToCreativeInventory("RedRoseDecorations"); m.AddToCreativeInventory("RedMushroom"); m.AddToCreativeInventory("BrownMushroom"); m.AddToCreativeInventory("GoldBlock"); m.AddToCreativeInventory("IronBlock"); m.AddToCreativeInventory("DoubleStair"); m.AddToCreativeInventory("Stair"); m.AddToCreativeInventory("Brick"); m.AddToCreativeInventory("Bookcase"); m.AddToCreativeInventory("MossyCobblestone"); m.AddToCreativeInventory("Obsidian"); m.AddToCreativeInventory("Torch"); m.AddToCreativeInventory("BrushedMetal"); m.AddToCreativeInventory("ChemicalGreen"); m.AddToCreativeInventory("Salt"); m.AddToCreativeInventory("Roof"); m.AddToCreativeInventory("Camouflage"); m.AddToCreativeInventory("DirtForFarming"); m.AddToCreativeInventory("Apples"); m.AddToCreativeInventory("Hay"); m.AddToCreativeInventory("Crops1"); m.AddToCreativeInventory("CraftingTable"); m.AddToCreativeInventory("Trampoline"); m.AddToCreativeInventory("FillStart"); m.AddToCreativeInventory("Cuboid"); m.AddToCreativeInventory("FillArea"); m.AddToCreativeInventory("GrassTrap"); m.AddToCreativeInventory("GoldCoin"); m.AddToCreativeInventory("GoldBar"); m.AddToCreativeInventory("SilverOre"); m.AddToCreativeInventory("SilverCoin"); m.AddToCreativeInventory("DirtBrick"); m.AddToCreativeInventory("LuxuryRoof"); m.AddToCreativeInventory("SandBrick"); m.AddToCreativeInventory("FakeBookcase"); m.AddToCreativeInventory("WoodDesk"); m.AddToCreativeInventory("GlassDesk"); m.AddToCreativeInventory("Mosaik"); m.AddToCreativeInventory("Asphalt"); m.AddToCreativeInventory("Cake"); m.AddToCreativeInventory("Fire"); m.AddToCreativeInventory("Fence"); m.AddToCreativeInventory("Compass"); m.AddToCreativeInventory("Ladder"); m.AddToCreativeInventory("Rail3"); m.AddToCreativeInventory("Rail60"); m.AddToCreativeInventory("Clay"); m.AddToCreativeInventory("Marble"); m.AddToCreativeInventory("Granite"); m.AddToCreativeInventory("Sandstone"); m.AddToCreativeInventory("RedSand"); m.AddToCreativeInventory("RedSandstone"); m.AddToCreativeInventory("Cactus"); m.AddToCreativeInventory("DeadPlant"); m.AddToCreativeInventory("GrassPlant"); m.AddToCreativeInventory("BirchTreeTrunk"); m.AddToCreativeInventory("BirchLeaves"); m.AddToCreativeInventory("BirchSapling"); m.AddToCreativeInventory("BirchWood"); m.AddToCreativeInventory("SpruceTreeTrunk"); m.AddToCreativeInventory("SpruceLeaves"); m.AddToCreativeInventory("SpruceSapling"); m.AddToCreativeInventory("SpruceWood"); m.AddToCreativeInventory("HalfCobblestone"); m.AddToCreativeInventory("HalfMossyCobblestone"); m.AddToCreativeInventory("HalfOakWood"); m.AddToCreativeInventory("HalfBirchWood"); m.AddToCreativeInventory("HalfSpruceWood"); m.AddToCreativeInventory("HalfBrick"); m.AddToCreativeInventory("HalfSandBrick"); m.AddToCreativeInventory("Bog"); #endregion #region Start inventory m.AddToStartInventory("Torch", 6); m.AddToStartInventory("Crops1", 1); m.AddToStartInventory("CraftingTable", 6); m.AddToStartInventory("GoldCoin", 2); m.AddToStartInventory("GoldBar", 5); m.AddToStartInventory("SilverCoin", 1); m.AddToStartInventory("Compass", 1); #endregion }
public void Start(ModManager m) { SoundSet solidSounds = new SoundSet() { Walk = new string[] { "walk1", "walk2", "walk3", "walk4" }, Break = new string[] { "destruct" }, Build = new string[] { "build" }, Clone = new string[] { "clone" }, Shoot = new string[] { }, ShootEnd = new string[] { "M1GarandGun-SoundBible.com-1519788442", "M1GarandGun-SoundBible.com-15197884422" }, Reload = new string[] { "shotgun-reload-old_school-RA_The_Sun_God-580332022" }, }; SoundSet grenadesounds = new SoundSet() { Shoot = new string[] { "grenadestart" }, ShootEnd = new string[] {"grenadethrow" }, Reload = solidSounds.Reload, }; m.SetBlockType(154, "Pistol", new BlockType() { AllTextures = "Pistol", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, handimage = "pistolhand.png", IsPistol = true, AimRadius = 15, Recoil = 0.04f, Delay = 0.5f, WalkSpeedWhenUsed = 1f, IronSightsEnabled = true, IronSightsMoveSpeed = 1f, IronSightsImage = "pistolhandsights.png", IronSightsAimRadius = 15, IronSightsFov = 0.8f, AmmoMagazine = 12, AmmoTotal = 120, ReloadDelay = 2, ExplosionRange = 0.2f, ExplosionTime = 0.2f, DamageBody = 15, DamageHead = 50, }); m.SetBlockType(155, "SubmachineGun", new BlockType() { AllTextures = "SubmachineGun", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, handimage = "submachinegunhand.png", IsPistol = true, AimRadius = 20, Recoil = 0.04f, Delay = 0.1f, WalkSpeedWhenUsed = 1f, IronSightsEnabled = true, IronSightsMoveSpeed = 1f, IronSightsImage = "submachinegunhandsights.png", IronSightsAimRadius = 20, IronSightsFov = 0.8f, AmmoMagazine = 30, AmmoTotal = 120, ReloadDelay = 2, ExplosionRange = 0.2f, ExplosionTime = 0.2f, DamageBody = 15, DamageHead = 40, }); m.SetBlockType(156, "Shotgun", new BlockType() { AllTextures = "Shotgun", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, handimage = "shotgunhand.png", IsPistol = true, AimRadius = 50, Recoil = 0.08f, Delay = 1f, BulletsPerShot = 6, WalkSpeedWhenUsed = 1f, IronSightsEnabled = true, IronSightsMoveSpeed = 1f, IronSightsImage = "shotgunhandsights.png", IronSightsAimRadius = 50, IronSightsFov = 0.8f, AmmoMagazine = 30, AmmoTotal = 120, ReloadDelay = 2, ExplosionRange = 0.2f, ExplosionTime = 0.2f, DamageBody = 35, DamageHead = 60, }); m.SetBlockType(157, "Rifle", new BlockType() { AllTextures = "Rifle", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = solidSounds, handimage = "riflehand.png", IsPistol = true, AimRadius = 20, Recoil = 0.04f, Delay = 2f, WalkSpeedWhenUsed = 1f, IronSightsEnabled = true, IronSightsMoveSpeed = 0.4f, IronSightsImage = "riflehandsights.png", IronSightsAimRadius = 10, IronSightsFov = 0.5f, AmmoMagazine = 6, AmmoTotal = 48, ReloadDelay = 2, ExplosionRange = 0.2f, ExplosionTime = 0.2f, DamageBody = 35, DamageHead = 100, }); m.SetBlockType(158, "MedicalKit", new BlockType() { AllTextures = "MedicalKit", DrawType = DrawType.Transparent, WalkableType = WalkableType.Empty, Sounds = solidSounds, handimage = null, IsPistol = false, WalkSpeedWhenUsed = 1f, }); m.SetBlockType(159, "AmmoPack", new BlockType() { TextureIdTop = "AmmoTop", TextureIdBack = "AmmoPack", TextureIdFront = "AmmoPack", TextureIdLeft = "AmmoPack", TextureIdRight = "AmmoPack", TextureIdForInventory = "AmmoPack", TextureIdBottom = "AmmoTop", DrawType = DrawType.Transparent, WalkableType = WalkableType.Empty, Sounds = solidSounds, handimage = null, IsPistol = false, WalkSpeedWhenUsed = 1f, }); m.SetBlockType(160, "Grenade", new BlockType() { AllTextures = "Grenade", DrawType = DrawType.Solid, WalkableType = WalkableType.Solid, Sounds = grenadesounds, handimage = "grenadehand.png", IsPistol = true, AimRadius = 20, Recoil = 0.04f, Delay = 0.5f, WalkSpeedWhenUsed = 1f, IronSightsEnabled = false, IronSightsMoveSpeed = 0.4f, IronSightsImage = "grenadehand.png", IronSightsAimRadius = 10, IronSightsFov = 0.5f, AmmoMagazine = 6, AmmoTotal = 6, ReloadDelay = 2, ExplosionRange = 10f, ExplosionTime = 1f, ProjectileSpeed = 25f, ProjectileBounce = true, DamageBody = 200, PistolType = PistolType.Grenade, }); }
void Awake() { instance = this; m_SoundSet = gameObject.GetComponent<SoundSet>(); }
public bool PlaySound(SoundSet.ClipType type) { if (soundSet == null) { return false; } SoundSet.ClipPlayType playType; AudioClip clip = soundSet.GetClip (type, out playType); if (clip) { if (playType == SoundSet.ClipPlayType.OneShot) { //audioSource.PlayOneShot (clip); AudioSource.PlayClipAtPoint (clip, transform.position, 0.6f); return true; } audioSource.clip = clip; audioSource.Play (); return true; } return false; }
public void AssociateSounds(SoundSet sounds) { Sounds = sounds; }