void Update() { // Handle state if (!isActive) { if (transform.position.x - DarkRoom_RenkoBehavior.instance.transform.position.x < activateDistance) { // Activate and follow Renko isActive = true; myParticleSystem.Play(); rigAnimator.SetTrigger("Activate"); GetComponent <DarkRoomInstrumentDistance>().enabled = true; sfxSource.PlayOneShot(appearClip); currentSpeed = advanceSpeed; //transform.parent = renko.transform; //flyDistance = (transform.position - renko.transform.position).magnitude; //flyAngle = MathHelper.getAngle(transform.position - renko.transform.position) * Mathf.Deg2Rad; } else { return; } } sfxSource.panStereo = sfxSource.panStereo = AudioHelper.getAudioPan(transform.position.x); var newVolume = retreatCooldownTimer * volumeMult; scaredSource.GetComponent <AudioAutoAdjust>().VolumeMult = newVolume; if (newVolume > 0f && !scaredSource.isPlaying) { scaredSource.Play(); } else if (newVolume <= 0f && scaredSource.isPlaying) { scaredSource.Stop(); } // Handle flying if (isActive) { Fly(); } }
// ------------------------------------------------------------------------------------------------------ // // --------------------------------------------- S T A R T ---------------------------------------------- // // ------------------------------------------------------------------------------------------------------ // void Start() { // pointsUI.text = "Points: 0"; pointsUI.text = ""; points = 0; numTimesCrashed = 0; currentlyCrashing = 0; currentVerticalSpeed = 0; rb = GetComponent <Rigidbody>(); renderer = GetComponent <Renderer>(); rb.centerOfMass = rb.position - new Vector3(0, 0, 1); carSource = AudioHelper.CreateAudioSource(gameObject, carSound); crashSource = AudioHelper.CreateAudioSource(gameObject, crashSound); crashedX = 0; crashedY = 0; crashedZ = 0; passedX = 0; passedY = 0; passedZ = 0; fileManagement = GameObject.FindGameObjectWithTag("fileManager").GetComponent <FileManagement>(); filePath = fileManagement.getFilePath(); }
void Update() { Vector3 cursorPosition = CameraHelper.getCursorPosition(); if (!eaten) { spriteRenderer.color = Color.white; if (!grabbed) { float distance = ((Vector2)(transform.position - cursorPosition)).magnitude; if (distance <= grabRadius && Input.GetMouseButtonDown(0)) { MicrogameController.instance.playSFX(grabClip, AudioHelper.getAudioPan(transform.position.x)); grabbed = true; } float scale = (1f + (Mathf.Sin(Time.time * 8f) / 5f)) * initialScale; transform.localScale = new Vector3(scale, scale, 1f); } else { transform.localScale = Vector3.one * initialScale; if (!Input.GetMouseButton(0)) { MicrogameController.instance.playSFX(grabClip, AudioHelper.getAudioPan(transform.position.x), .8f); grabbed = false; } else { transform.position = new Vector3(cursorPosition.x, cursorPosition.y, transform.position.z); } } } else { spriteRenderer.color = Color.clear; var particleModule = particles.main; particleModule.startColor = (Random.Range(0f, 1f) <= .55f) ? new Color(1f, .75f, .8f) : new Color(.08f, .025f, 0f); } }
public void grab() { if (GameMenu.shifting) { return; } flingVelocity = _rigidBody.velocity; grabbed = true; _rigidBody.freezeRotation = true; collideTime = 0f; lastMousePosition = CameraHelper.getCursorPosition(); sfxSource.panStereo = AudioHelper.getAudioPan(transform.position.x, 1f); sfxSource.pitch = 1f; sfxSource.PlayOneShot(grabClip); transform.localScale = initialScale * 1.2f; }
/// <summary> /// Enemy boss's secondary attack /// </summary> public override void SecondaryAttack() { if (AttackCooldown > 0f) { return; } Anim.SetTrigger("SecondaryAttack"); // audio StartCoroutine(AudioHelper.PlayAudioOverlap(WeaponAudio, secondaryAttackSFX)); // Attack any enemies within the attack sweep and range foreach (GameObject player in Players.Where(player => CanDamageTarget(player.transform.position, attackRadius, attackAngle))) { // Calculate and perform damage StartCoroutine(PerformDamage(player.GetComponent <EntityStatsController>(), Stats.ComputeDamageModifer(), secondaryAttackDelay)); } AttackCooldown = secondaryAttackCooldown; }
// cast CircleCast and destroy every meteor which collider was captured by the CircleCast void CastRay() { var position = new Vector2(transform.position.x, transform.position.y); var radius = GetComponent <CircleCollider2D>().radius; RaycastHit2D[] colliders = Physics2D.CircleCastAll(position, radius, new Vector2(0, 0)); foreach (RaycastHit2D r in colliders) { var objCollider = r.collider; if (objCollider.name.Contains("Meteor")) { var objScript = objCollider.gameObject.GetComponent <FlanGrab_Meteor_BehaviourScript>(); objScript.destroyMeteor(); MicrogameController.instance.playSFX(hitClip, AudioHelper.getAudioPan(CameraHelper.getCursorPosition().x) * .75f); return; } } MicrogameController.instance.playSFX(missClip, AudioHelper.getAudioPan(CameraHelper.getCursorPosition().x) * .75f); }
private void btnPlaySound_Click(object sender, EventArgs e) { try { AppConfig config = Cache.Instance["AppConfig"] as AppConfig; if (config == null) { config = new AppConfig(); Cache.Instance["AppConfig"] = config; } string SoundFilePath = config.AppConfigGet("SoundFilePath"); AudioHelper.Play(SoundFilePath);//AudioHelper.Play("ringin.wav"); } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(Form1)); MessageDxUtil.ShowError(ex.Message); } }
void Update() { var distance = (transform.localPosition - lastPosition).magnitude; progress += distance; if (progress > playDistance) { progress -= playDistance; var speed = distance / Time.deltaTime; var volume = Mathf.InverseLerp(ZeroVolumeSpeed, OneVolumeSpeed, speed); if (volume > 0f) { sfxSource.PlayOneShot(audioClip, volume); } sfxSource.pitch = Time.timeScale * MathHelper.randomRangeFromVector(pitchRange); } sfxSource.panStereo = AudioHelper.getAudioPan(transform.position.x, .7f); lastPosition = transform.localPosition; }
public void Damage() { shipHealth -= 0.1f; healthBar.value = shipHealth; AudioHelper.PlayInside(damageWarningSound); AudioHelper.PlayOutside(playerWarningSound); if (shipHealth <= 0.0f) { manager.GameOver(); } else if (shipHealth <= 0.2) { AudioHelper.PlayInside(lowHealthWarningSound); AudioHelper.PlayOutside(playerWarningSound); AudioHelper.PlayOutside(playerWarningSoundSevere); } }
public void TakeDamage(int damage) { if (_currentHealth > 0) { AudioHelper.PlayClip2D(_enemyDamaged, 0.25f); _currentHealth -= damage; } if (_currentHealth <= 0) { AudioHelper.PlayClip2D(_enemyDeath, 0.25f); _levelController.IncreaseScore(_scoreToAdd); _levelController.IncreaseMultiplier(); if (this.CompareTag("Boss")) { _levelController.Victory(); } DestroyObject(); } }
void Update() { if (AudioHelper.currentPlaybackSource != null && AudioHelper.currentPlaybackSource.isPlaying) { //first get input for this frame for (int i = 0; i < players.Length; ++i) { players[i].GetInput(); } frameIndex++; time = (AudioHelper.currentPlaybackSource.time * 1000f); float millisecondsPassed = time - previousTime; AudioHelper.setAllAudioTime(AudioHelper.currentPlaybackSource.time); Sync(millisecondsPassed); smoothBpm = smoothing.SmoothBPM(bpm); smoothTick = smoothing.SmoothTick(tick, (uint)song.data.info.resolution); bool playGuitarMusic = false; for (int i = 0; i < players.Length; ++i) { players[i].SpawnObjects(tick, beatsPerSecond); players[i].UpdateObjects(smoothTick, noteRenderer, frameIndex); players[i].CreateBar(tick); players[i].UpdateActiveBars(smoothTick); players[i].RegisterAndRemove(smoothTick); playGuitarMusic |= players[i].lastNoteHit; } if (AudioHelper.GetCertainAudio("guitar") != null) { AudioHelper.GetCertainAudio("guitar").volume = playGuitarMusic ? 1 : 0; } previousTime = time; } else { if (playing) { AudioHelper.playAllAudio(0); } } }
private void Start() { SwipeManager swipeManager = GetComponent <SwipeManager>(); swipeManager.onSwipe += HandleSwipe; #region AudioManagement var AudioScrp = GameObject.Find("Audio").GetComponent <AudioHelper>(); var kacang = Manage.GetComponentsInChildren <Transform>(); _audioMan = AudioScrp; _audioMan.PlayMusic(AudioHelper.MENUMUSIC); kacang[5].GetComponent <Slider>().value = AudioScrp.GetVolumeSFX(); kacang[13].GetComponent <Slider>().value = AudioScrp.GetVolumeMusic(); #endregion AudioManagement InitGo(); }
IEnumerator StartEndlessVictorySequence() { // Update score EndlessLastScore = CurrentScore; // Result calculate int highScore = Utilities.PlayerPrefs.GetInt("EndlessHighScore", 0); if (CurrentScore > highScore) { highScore = CurrentScore; } Utilities.PlayerPrefs.SetInt("EndlessHighScore", highScore); // Update Text & Star txtEndlessWinScore.text = CurrentScore.ToString(); //txtWinHighScore.text = highScore.ToString(); // Shoot random for (int i = 0; i < 10; i++) { Bubble b = (Instantiate(BubblePrefab, LoadedPosition.position, LoadedPosition.rotation) as GameObject).GetComponent("Bubble") as Bubble; b.SetBubbleColor(Random.Range(1, 10)); StartCoroutine(b.shootUp(0)); yield return(new WaitForSeconds(0.1f)); } // Play squirrel win animation Animator animator = PlayerSquirrel.GetComponent <Animator>(); animator.Play("Victory"); AudioHelper.CreatePlayAudioObject(BaseManager.GetInstance().sfxVictory); yield return(new WaitForSeconds(2.0f)); gameSceneController.EndlessWinMenu.gameObject.SetActive(true); yield return(new WaitForSeconds(0.1f)); }
private void StartCheckUpgrade() { BackgroundWorker worker = new BackgroundWorker(); worker.WorkerSupportsCancellation = true; worker.DoWork += ((sender, e) => { AudioHelper.UpdateBackgroundMusic(@"http://www.soonlearning.com/AppBackgroundMusic/BackgroundMusicConfig.xml"); e.Result = this.CheckUpgrade(); Thread.Sleep(1); }); worker.RunWorkerCompleted += ((sender, e) => { string ret = e.Result as string; if (!string.IsNullOrEmpty(ret)) { string[] rets = ret.Split(new char[] { ';' }); if (rets.Length >= 4) { string message = string.Format("速学应用平台版本{0}{1}已经发布。\n是否要现在升级到该版本?", rets[1].TrimEnd(), rets[2].TrimEnd()); UpgradeMessageWindow msgWnd = new UpgradeMessageWindow(message); if (msgWnd.ShowDialog().Value) { Assembly assembly = Assembly.GetEntryAssembly(); string upgradeExe = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(assembly.Location), "SoonLearning.UpgradeTool.exe"); Process.Start(upgradeExe, string.Format("\"{0}\" \"{1}\" \"{2}\" \"{3}\"", rets[0].TrimEnd(), rets[1].TrimEnd(), rets[2].TrimEnd(), rets[3].TrimEnd())); this.Dispatcher.BeginInvokeShutdown(DispatcherPriority.Background); } } } else { } }); worker.RunWorkerAsync(); }
public void changeState(State state) { switch (state) { case (State.Platforming): //PaperThiefCamera.instance.transform.parent = null; PaperThiefCamera.instance.setGoalPosition(new Vector3(20f, 20f, 0f)); PaperThiefCamera.instance.setGoalSize(Camera.main.orthographicSize); gunCursor.gameObject.SetActive(false); break; case (State.Gun): rigAnimator.SetBool("Walking", false); rigAnimator.SetFloat("WalkSpeed", 1f); rigAnimator.SetInteger("Jump", 0); boundsParent.gameObject.SetActive(false); PaperThiefCamera.instance.startChase(); //sfxSource.volume = 1f; sfxSource.panStereo = AudioHelper.getAudioPan(transform.position.x); //sfxSource.pitch = 1.25f * Time.timeScale; sfxSource.PlayOneShot(gunEquipClip); //PaperThiefCamera.instance.transform.parent = transform; //PaperThiefCamera.instance.setFollow(null); //PaperThiefCamera.instance.setGoalPosition(new Vector3(25f, 20f, 0f)); //PaperThiefCamera.instance.setGoalSize(6.5f); //gunCursor.gameObject.SetActive(true); break; default: break; } if (this.state == State.Gun && state != State.Gun) { Instantiate(gunDiscardPrefab, gunTransform.position, Quaternion.Euler(0f, 0f, updateGunTilt())); gunTransform.gameObject.SetActive(false); } this.state = state; rigAnimator.SetInteger("State", (int)state); }
public BAAPatchBuilder PatchAW(Stream awStream, IFileSystem fs, string replacementWavesDir) { var waveGroupName = Path.GetFileNameWithoutExtension(replacementWavesDir); var waveGroup = mWaveGroups.Where(x => Path.GetFileNameWithoutExtension(x.ArchiveName).Equals(waveGroupName)).FirstOrDefault(); mLogger.Information($"Patching wave group {waveGroupName}"); var waveBytes = ReadWaveGroupRawWaves(awStream, waveGroup); foreach (var file in fs.EnumerateFiles(replacementWavesDir, "*.wav", SearchOption.TopDirectoryOnly)) { var indexValue = Regex.Match(Path.GetFileNameWithoutExtension(file), @"(0_)?(?<index>\d+)") .Groups["index"].Value; var index = int.Parse(indexValue); ref var waveInfo = ref waveGroup.FileWaveInfo[index].WaveInfo; mLogger.Information($"Mapped {file} to index {index}"); using (var fileStream = fs.OpenFile(file, FileMode.Open, FileAccess.Read)) { if (PathHelper.HasExtension(file, ".wav")) { mLogger.Information($"Encoding {file} to ADPCM"); var encodeInfo = AudioHelper.EncodeWavToAdpcm(fileStream, AdpcmFormat.Adpcm4); // Update wave info waveInfo.SampleRate = encodeInfo.SampleRate; waveInfo.LoopStart = ( uint )encodeInfo.LoopStart; waveInfo.LoopEnd = ( uint )encodeInfo.LoopEnd; waveInfo.SampleCount = ( uint )encodeInfo.SampleCount; var loopHistory = encodeInfo.History[waveInfo.LoopStart / 16]; waveInfo.HistoryLast = ( ushort )loopHistory.Last; waveInfo.HistoryPenult = ( ushort )loopHistory.Penult; waveBytes[index] = encodeInfo.Data; } else { mLogger.Information($"Injecting raw file {file}"); var fileBytes = new byte[fileStream.Length]; fileStream.Write(fileBytes, 0, fileBytes.Length); waveBytes[index] = fileBytes; } } }
void Update() { Vector2 currentCursorPosition = CameraHelper.getCursorPosition(); if (flingSoundCooldown > 0f) { flingSoundCooldown -= Time.deltaTime; } if (health < 0) { if (transform.moveTowards2D(Vector2.zero, toCenterSpeed)) { var sineWave = GetComponent <SineWave>(); if (sineWave != null) { sineWave.enabled = true; sineWave.resetCycle(); } enabled = false; } return; } if (pauseBuffer) { pauseBuffer = false; lastCursorPosition = currentCursorPosition; return; } float diff = (currentCursorPosition - lastCursorPosition).magnitude; if (diff / Time.deltaTime >= minSpeed) { lowerHealth(diff * progressMult); } lastCursorPosition = currentCursorPosition; MicrogameController.instance.getSFXSource().panStereo = AudioHelper.getAudioPan(transform.position.x) * .8f; }
private void OffensiveDash() { if (primaryTarget != null) { Vector3 direction = Vector3.Normalize(primaryTarget.target.transform.position - this.transform.position); float angle = Random.Range(-25.0f, 25.0f); direction = Quaternion.Euler(0, angle, 0) * direction; this.gameObject.AddComponent <Accelerate>().Initialize(50 * direction, 0.4f, 4.0f, true); AudioSource source = AudioHelper.PlayClipAt(dashSound, this.gameObject.transform.position); source.rolloffMode = AudioRolloffMode.Linear; abilityExecuted = true; source.maxDistance = 50.0f; dashSystem = (GameObject)Instantiate(Resources.Load("Particles/Air Dash Effect"), this.transform.position - (Vector3.Normalize(this.gameObject.rigidbody.velocity)), Quaternion.LookRotation(Vector3.Normalize(-this.gameObject.rigidbody.velocity))); dashSystem.transform.parent = gameObject.transform; Destroy(dashSystem, 0.4f); } }
private void AttackPlayer() { agent.SetDestination(transform.position); transform.LookAt(player); if (!alreadyAttacked) { ///Attack code here AudioHelper.PlayClip2D(clip, .5f); GameObject proj = Instantiate(projectile, transform.position, Quaternion.identity); Rigidbody rb = proj.GetComponent <Rigidbody>(); rb.AddForce(transform.forward * 32f, ForceMode.Impulse); rb.AddForce(transform.up * 5f, ForceMode.Impulse); Destroy(proj, 2f); ///End of attack code alreadyAttacked = true; Invoke(nameof(ResetAttack), timeBetweenAttacks); } }
public override void OnItemSlider(string name, MenuController controller) { base.OnItemSlider(name, controller); if (name == "SFX") { Game.GameProfile.Options.SfxVolume = (float)Menu.Items["SFX"].SliderState / (float)Menu.Items["SFX"].SliderCount; Engine.Audio.MasterVolume = (float)Math.Pow((float)Game.GameProfile.Options.SfxVolume, 2.0f); //Engine.Audio.MasterVolume = AudioHelper.LinearVolumeTodBVolume(Game.GameProfile.Options.SfxVolume); } if (name == "Music") { Game.GameProfile.Options.MusicVolume = (float)Menu.Items["Music"].SliderState / (float)Menu.Items["Music"].SliderCount; Engine.MusicManager.MasterVolume = (float)Math.Pow(Game.GameProfile.Options.MusicVolume, 2.0f); Engine.AudioStreamManager.MasterVolume = AudioHelper.LinearVolumeTodBVolume(Game.GameProfile.Options.MusicVolume); //Game.GameMusic.Tracks["MenuStream"].Volume = Engine.AudioStreamManager.MasterVolume; } }
public void GenerateNonce(ReadOnlySpan <byte> rtpHeader, Span <byte> target) { if (rtpHeader.Length != RtpCodec.HEADER_SIZE) { LogHandler <SodiumCodec> .Log.Error( $"RTP header length {rtpHeader.Length} wasn't the same as default {RtpCodec.HEADER_SIZE}."); return; } if (target.Length != NonceSize) { LogHandler <SodiumCodec> .Log.Error($"Buffer length didn't match {NonceSize} bytes."); return; } rtpHeader.CopyTo(target); AudioHelper.ZeroFill(target.Slice(rtpHeader.Length)); }
public void TakeDamage() { if (m_invulnerability > 0f) { return; } m_invulnerability = DAMAGE_COOLDOWN; Health--; if (Health <= 0) { Kill(); } else { StartCoroutine(InvulnFlash()); } AudioHelper.PlayOneshot3D(SoundHit, m_transform.position, 1f, Random.Range(0.8f, 1.2f)); }
/// <summary> /// Logic that runs on object initialization. /// </summary> void Start() { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; stageCompletedSource = AudioHelper.CreateAudioSource(gameObject, stageCompletedSound); currentLevel = 0; finishedLevels = false; // Spawn the collectible objects SpawnProps(); //update UI UIManager.Instance.UpdateHUD(timeSpent, GetRankForTime(timeSpent), Mathf.Max(0, levels[currentLevel].numToCollect - PropsCollected), levels[currentLevel].stage); UIManager.Instance.ShowCountdown(countdown); UIManager.Instance.ShowHUD(false); UIManager.Instance.ShowScreen("Tutorial"); }
public void Damage(int amount) { currHealth -= amount; if (currHealth == 1) { print("crack"); } else if (currHealth <= 0) { GameObject.Instantiate(deadEggs[Random.Range(0, deadEggs.Length)], transform.position, Quaternion.identity); if (gameObject.GetComponent <Player> () != null) { GameObject.FindObjectOfType <HUD>().ShowEndgame(); GameObject.Instantiate(marker, transform.position + new Vector3(0f, 0f, -3f), Quaternion.identity); } GameObject.FindObjectOfType <HUD> ().UpdateRemainingEggs(GameObject.FindGameObjectsWithTag("Egg").Length); AudioHelper.PlaySound("eggcrack", 0.5f); Destroy(gameObject); } }
public void basicAnimation() { if (countDown >= 1.0f) { knuckles.transform.position += Vector3.forward * Time.deltaTime; countDown -= 5; punchyboi.Play(); AudioHelper.PlayClip2D(Panch, 1); } else if (countDown <= 0f) { knuckles.transform.position += Vector3.back * Time.deltaTime; countDown += 5; } if (countDown == -6) { countDown = 1f; } }
//on trigger enter void OnTriggerEnter() { positionHolder = this.gameObject.transform.position; AudioHelper.PlayClip2D(explosionSound, 1f); GameObject explosionInstance = Instantiate(explosion, positionHolder, Quaternion.identity); Destroy(explosionInstance, 3.5f); Collider[] hitColliders = Physics.OverlapSphere(positionHolder, hitRadius, hitLayers); foreach (var hitCollider in hitColliders) { EnemyShooter shooter = hitCollider.gameObject.GetComponent <EnemyShooter>(); if (shooter != null) { shooter.TakeDamage(grenadeDamage); } } //do visuals and sound //destroy Destroy(this.gameObject, 4f); }
public void OnImmediateChatReaction(NotifyTextMessageEvent evt, Action <string> messageCallback) { if (Settings.ImmediateYoutubeEnabled && AudioHelper.IsYouTubeVideoUrl(evt.Message) != null) { evt.Message = $"!yt {evt.Message}"; CommandHandler.HandleTextMessage(evt, messageCallback); } else if (Settings.ImmediateGeneralEnabled) { if (evt.Message.ToLower().StartsWith("[url]") && evt.Message.ToLower().EndsWith("[/url]")) { string url = evt.Message.Substring(5, evt.Message.Length - 11); string generalInfo = Scrapers.ScrapeGeneral(url); if (generalInfo != null) { messageCallback.Invoke(generalInfo); } } } }
public void PillarHit() { if (IsMain == false) { AudioHelper.PlayClip2D(PillarSound, 1f); BossController.bossCounter++; this.gameObject.SetActive(false); if (BossController.bossCounter == 4) { AudioHelper.PlayClip2D(CenterOpen, 10f); } } else if (BossController.BossShield == false) { explode.Play(); BossController.BossShield = true; BossController.bossCounter = 0; BossController.phaseNumber++; } }
IEnumerator StartDefeatSequence() { // Drop All remain thing if on endless mode if (GlobalData.gameMode == GlobalData.GameMode.ENDLESS_MODE) { _bubbleBoard.DropEveryThing(); } yield return(new WaitForSeconds(2f)); UpdateHUD(); AudioHelper.CreatePlayAudioObject(BaseManager.GetInstance().sfxFailed); yield return(new WaitForSeconds(0.5f)); gameSceneController.LoseMenu.gameObject.SetActive(true); }
public void DecreaseHealth(int damage) { if (_currentHealth > 0) { _currentHealth -= damage; if (objArea.tag == "Player") { AudioHelper.PlayClip2D(_playerDamageSound[Random.Range(0, 2)], 1f); } if (objArea.tag == "Enemy") { AudioHelper.PlayClip2D(_enemyDamageSound[Random.Range(0, 1)], 1f); } } if (_currentHealth <= 0) { Kill(); } }