public void ChargingLoop(string atk) { if (chargingAudio == null) { chargingAudio = AudioManagerMk2.Instance.PlaySound(AudioSourceType.Game, BattleManagerScript.Instance.AudioProfile.SpecialAttackChargingLoop, AudioBus.MediumPriority, transform, true); } SetAnimation(atk + "_Charging", true); }
void RestoreBullet() { if (bulletSoundSource != null) { bulletSoundSource.ResetSource(); } bulletSoundSource = null; //PS.GetComponent<DisableParticleScript>().ResetParticle(); CancelInvoke("RestoreBullet"); StopAllCoroutines(); gameObject.SetActive(false); }
private void FlagLoadedForClip(AudioClip clip) { source = AudioSourceManager.CreateSource(clip, DJStand.Map); source.TargetVolume = volume; source.Area = DJStand.FloorBounds; source.Source.pitch = Settings.GameSpeedAffectsMusic ? Find.TickManager.TickRateMultiplier : Find.TickManager.Paused ? 0f : 1f; source.Source.Play(); source.IsPlaying = () => source?.Source != null && !removed; if (!registered) { UnityHook.OnPauseChange += UnityHook_OnPauseChange; registered = true; } }
//Set ste special attack public void SpecialAttack(ScriptableObjectAttackBase atkType) { nextAttack = atkType; CameraManagerScript.Instance.CameraShake(CameraShakeType.Powerfulattack); if (chargingAudio != null) { AudioManagerMk2.Instance.PlaySound(AudioSourceType.Game, BattleManagerScript.Instance.AudioProfile.SpecialAttackChargingRelease, AudioBus.LowPriority, transform); chargingAudio.ResetSource(); chargingAudio = null; } SetAnimation(nextAttack.PrefixAnim + "_AtkToIdle"); ParticleManagerScript.Instance.FireParticlesInPosition(nextAttack.Particles.CastActivationPS, CharInfo.CharacterID, AttackParticlePhaseTypes.CastActivation, transform.position, UMS.Side, nextAttack.AttackInput); }
ManagedAudioSource GetFreeSource(AudioBus priority, AudioSourceType sourceType) { ManagedAudioSource source = sources.Where(r => !r.gameObject.activeInHierarchy && r.type == sourceType).FirstOrDefault(); if (source == null) { source = sources.Where(r => r.bus < priority && r.type == sourceType).FirstOrDefault(); } if (source == null) { source = sources.Where(r => !r.gameObject.activeInHierarchy && r.bus != AudioBus.Music).FirstOrDefault(); source.type = sourceType; } if (source == null) { Debug.LogError("Insufficient Sources"); } return(source); }
public ManagedAudioSource PlaySound(AudioSourceType sourceType, AudioClipInfoClass clipInfo, AudioBus priority, Transform sourceOrigin = null, bool loop = false) { if (ClipPlayedThisFrame(clipInfo.Clip)) { return(null); } ManagedAudioSource source = GetFreeSource(priority, sourceType); source.gameObject.SetActive(true); if (sourceOrigin != null) { source.SetParent(sourceOrigin); } source.SetAudioClipInfo(clipInfo); source.bus = priority; source.PlaySound(loop); AddClipPlayedLastFrame(clipInfo.Clip); UpdateActiveAudioVolumes(); return(source); }
public IEnumerator ChildExplosion(List <Vector2Int> bet, Vector2Int basePos) { float timer = 0; BaseCharacter target; bulletSoundSource = null; while (timer < ChildrenExplosionDelay) { timer += Time.fixedDeltaTime; yield return(new WaitForFixedUpdate()); while (!VFXTestMode && (BattleManagerScript.Instance.CurrentBattleState != BattleState.Battle && BattleManagerScript.Instance.CurrentBattleState != BattleState.End)) { yield return(new WaitForFixedUpdate()); } } for (int i = 0; i < bet.Count; i++) { if (GridManagerScript.Instance.isPosOnField(Side == SideType.LeftSide ? basePos + bet[i] : basePos - bet[i])) { if (!VFXTestMode) { target = BattleManagerScript.Instance.GetCharInPos(Side == SideType.LeftSide ? basePos + bet[i] : basePos - bet[i]); MakeDamage(target, (CharInfo.DamageStats.BaseDamage * (AtkType == AttackAnimType.Weak_Atk ? CharInfo.RapidAttack.DamageMultiplier.x : CharInfo.PowerfulAttac.DamageMultiplier.x)) * 0.3f); } AudioManagerMk2.Instance.PlaySound(AudioSourceType.Game, attackAudioType.Impact, AudioBus.HighPriority, GridManagerScript.Instance.GetBattleTile(Side == SideType.LeftSide ? basePos + bet[i] : basePos - bet[i]).transform); FireEffectParticles(GridManagerScript.Instance.GetBattleTile(Side == SideType.LeftSide ? basePos + bet[i] : basePos - bet[i]).transform.position); } else { /* Vector3 dest = new Vector3(bet[i].y * GridManagerScript.Instance.GetWorldDistanceBetweenTiles() * (-1), * bet[i].x * GridManagerScript.Instance.GetWorldDistanceBetweenTiles() * (-1), 0); * FireEffectParticles(GridManagerScript.Instance.GetBattleTile(basePos).transform.position + dest, i == bet.Count - 1 ? true : false);*/ } } }
//Move the bullet on a determinated tile using the BulletInfo.Trajectory public IEnumerator MoveToTile() { if (attackAudioType.Loop.clip != null) { bulletSoundSource = AudioManagerMk2.Instance.PlaySound(AudioSourceType.Game, attackAudioType.Loop, AudioBus.LowPriority, transform, true); } vfx = GetComponentInChildren <VFXBulletSpeedController>(); if (vfx != null) { vfx.BulletTargetTime = CharInfo.SpeedStats.BulletSpeed; vfx.ApplyTargetTime(); } BulletTarget(); //setup the base offset for the movement Vector3 offset = transform.position; //Timer used to set up the coroutine float timer = 0; //Destination position Vector3 destination = bts.transform.position + new Vector3(Side == SideType.LeftSide ? 0.2f : -0.2f, 0, 0); float bulletDuration = (CharInfo.SpeedStats.BulletSpeed / 12) * (bts.Pos.y - StartingTile.y); //Duration of the particles PSTimeGroup pstg = PS.GetComponent <PSTimeGroup>(); if (pstg != null) { pstg.UpdatePSTime(bulletDuration + 2); } else { } //float Duration = Vector3.Distance(transform.position, destination) / CharInfo.BulletSpeed; Vector3 res; isMoving = true; float ti = 0; while (isMoving) { yield return(new WaitForFixedUpdate()); if (BattleManagerScript.Instance.CurrentBattleState == BattleState.Intro) { isMoving = false; } //In case the game ended or in pause I will block the movement while (!VFXTestMode && (BattleManagerScript.Instance.CurrentBattleState != BattleState.Battle && BattleManagerScript.Instance.CurrentBattleState != BattleState.FungusPuppets && BattleManagerScript.Instance.CurrentBattleState != BattleState.End)) { yield return(new WaitForFixedUpdate()); } //Calutation for next world position of the bullet res = Vector3.Lerp(offset, destination, timer); res.y = Trajectory_Y.Evaluate(timer) + res.y; res.z = Trajectory_Z.Evaluate(timer) + res.z; transform.position = res; timer += Time.fixedDeltaTime / bulletDuration; ti += Time.fixedDeltaTime; //if timer ended the bullet fire the Effect if (timer > 1) { isMoving = false; //StartCoroutine(ChildExplosion(BulletEffectTiles.Where(r=> r != Vector2Int.zero).ToList())); FireEffectParticles(bts.transform.position);//BulletEffectTiles.Count == 1 ? true : false } } EndBullet(0.5f); }
public override void Init() { string path = Def.Get <string>("filePath"); float volume = Def.Get("volume", 1f); bool mute = Def.Get("mute", false); if (volume <= 0f) { mute = true; } // Resolve the file path. ModContentPack mcp = Def.modContentPack; if (mcp == null) { string[] split = path.Split('/'); split[0] = split[0].ToLowerInvariant(); Core.Warn($"Video program def '{Def.defName}' has been added by a patch operation. Attempting to resolve filepath..."); var found = LoadedModManager.RunningModsListForReading.FirstOrFallback(mod => mod.PackageId.ToLowerInvariant() == split[0]); if (found == null) { Core.Error($"Failed to resolve mod folder path from id '{split[0]}'. See below for how to solve this issue."); Core.Error("If you mod's package ID is 'my.mod.name' and your video file is in 'MyModFolder/Videos/Video.bwcv' then the correct filePath would be 'my.mod.name/Videos/Video.bwcv'"); Remove(); return; } Core.Warn("Successfully resolved file path."); mcp = found; } path = Path.Combine(mcp.RootDir, path); player = GetParentObject().AddComponent <VideoPlayer>(); player.renderMode = VideoRenderMode.APIOnly; player.audioOutputMode = mute ? VideoAudioOutputMode.None : VideoAudioOutputMode.AudioSource; if (!mute) { audioContainer = AudioSourceManager.CreateSource(null, DJStand.Map); audioContainer.TargetVolume = volume; audioContainer.Area = DJStand.FloorBounds; audioContainer.IsPlaying = () => player != null && !removed; player.SetTargetAudioSource(0, audioContainer.Source); string msg = "DSC.NowPlaying".Translate(Def.Get("credits", "Unknown")); Messages.Message(msg, MessageTypeDefOf.PositiveEvent); } player.isLooping = false; player.sendFrameReadyEvents = true; player.playbackSpeed = Settings.GameSpeedAffectsMusic ? Find.TickManager.TickRateMultiplier : Find.TickManager.Paused ? 0f : 1f; player.loopPointReached += OnVideoReachEnd; player.frameReady += Player_frameReady; player.errorReceived += Player_errorReceived; OnPauseChange(Find.TickManager.Paused); player.url = path; if (!isSubscribed) { UnityHook.OnPauseChange += OnPauseChange; } }