void Start() { sceneLoader = GetComponent <SceneLoader>(); sfxManager = SfxManager.instance; gm = GameManager.Instance; }
void Awake() { if (SfxManager.instance == null) { SfxManager.instance = this; } }
// Start is called before the first frame update void Start() { //Check if instance already exists if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); for (int i = 0; i < 50; i++) { var player = new GameObject(); var soundPlayer = new SoundPlayer(player.AddComponent <AudioSource>()); this.players.Add(soundPlayer); soundPlayer.player.playOnAwake = false; player.transform.parent = transform; } for (int i = 0; i < sounds.Length; i++) { this.soundDictionary[sounds[i].type] = sounds[i].sound; } Signals.Get <SfxManagerInitSignal>().Dispatch(); }
void OnTriggerEnter(Collider other) { if (GameState.IsPlaying) { if (gameObject.layer == LayerMask.NameToLayer("Player")) { SphereCollider collider = GetComponent <SphereCollider>(); float radius = collider.radius; radius = radius - 0.5f; if (radius < 0) { collider.enabled = false; } else { collider.radius = radius; } return; } gameObject.layer = LayerMask.NameToLayer("Player"); SfxManager.PlayButterflySfx(); target = other.gameObject.transform; GameState.FlockSize++; } }
void Awake() { sprite = transform.GetChild(0).gameObject; spriteRenderer = sprite.GetComponent <SpriteRenderer>(); animator = sprite.GetComponent <SpriteAnim>(); this.animations = new Dictionary <PlayerAnim, AnimationClip>(); for (int i = 0; i < animHookup.Length; i++) { animations[animHookup[i].ID] = animHookup[i].animation; } this.originalJumpSpeed = this.jumpSpeed; respawnPos = this.transform.position; fsm = new StateMachine <PlayerState>(PlayerState.Air); fsm.Bind(PlayerState.Air, null, Air_Update, null); fsm.Bind(PlayerState.Ground, Ground_Enter, Ground_Update, Ground_Exit); fsm.Bind(PlayerState.Throwing, Throwing_Enter, Throwing_Update, Throwing_Exit); fsm.Bind(PlayerState.Pickup, Pickup_Enter, Pickup_Update, Pickup_Exit); fsm.onChangeState += (newState) => { if (fsm.currentState == PlayerState.Air && newState == PlayerState.Ground) { SfxManager.PlaySoundStatic(SoundType.LAND); } }; currentSpeed = speed; }
void endGamePrompt() { SfxManager.PlaySound("Click"); confirmPrompt.SetActive(true); exitYes.onClick.AddListener(endGame); exitNo.onClick.AddListener(continueGame); }
void OnCollisionEnter(Collision coll) { if (Time.time - m_LastPlaySfxTime < m_SfxIntarvalTime) { return; } if (coll.relativeVelocity.sqrMagnitude < m_HitSfxVelThreshold) { return; } if (m_Rigidbody.velocity.sqrMagnitude < m_HitSfxVelThreshold) { return; } Rigidbody rb = coll.gameObject.GetComponent <Rigidbody>(); if (rb == null) { PlaySfx(coll.gameObject.tag); } else if (m_Rigidbody.velocity.sqrMagnitude >= rb.velocity.sqrMagnitude) { SfxManager.Play(SfxName.Hit); } else { return; } m_LastPlaySfxTime = Time.time; }
// on collision with other cats private void OnTriggerEnter2D(Collider2D collision) { if (!isDead && collision.gameObject.tag == "CatBack") // then kill cat { GameObject deadCat = collision.gameObject.GetComponent <Transform>().parent.gameObject; SfxManager.PlaySound("killCat"); GameManager.getInstance().onSuccessfulKill(deadCat); } // if mouse touches front of cat else if (collision.gameObject.tag == "Cat") // then game over { if (!catIsStunned(collision.gameObject)) { anim.SetTrigger("isDead"); if (!isDead) { StartCoroutine(lagGameOver()); } } else { GameObject deadCat = collision.gameObject.GetComponent <Transform>().parent.gameObject; SfxManager.PlaySound("killCat"); GameManager.getInstance().onSuccessfulKill(deadCat); } } }
private void Awake() { if (Instance == null) { Instance = this; } }
private void FindReferences() { _rigidbody2D = gameObject.GetComponent <Rigidbody2D>(); _scoreManager = FindObjectOfType <ScoreManager>(); _gameManager = FindObjectOfType <GameManager>(); _sfxManager = FindObjectOfType <SfxManager>(); }
IEnumerator MonsterHit() { while (true) { if (codeAccepted == false) { lightParticleIndex++; SfxManager.PlaySfx(Random.Range(27, 33)); CameraShake.ShakeCamera(0.1f, 0.7f); ElevatorLightBurst(lightParticleIndex % 4); if (lightParticleIndex <= 5) { lightControl.CeilingLightOff(lightParticleIndex % 5); } SfxManager.PlaySfx(Random.Range(21, 26)); yield return(new WaitForSeconds(Random.Range(1f, 10f))); } else { break; } } }
private IEnumerator StartSequence() { SfxManager.PlayLoop(0); // Start ambient noise //SfxManager.PlaySfx(14); // Phone ringing yield return(null); //SfxManager.PlaySfx(8); // Intro dialogue }
public static void Tick(float DeltaTime) { AssetManager.Tick(DeltaTime); AudioManager.Tick(DeltaTime); SfxManager.Tick(DeltaTime); UIManager.Tick(DeltaTime); }
private void OnTriggerEnter2D(Collider2D other) { if (requiresSpecificCharacter && !other.gameObject.CompareTag(specificCharacterName)) { return; } if (!isTouching) { //when switch is triggered, faded. //pic.color = new Color(pic.color.r, pic.color.g, pic.color.b, 0.1F); GameManager.Instance.cfp.WatchSomething(goTime, stayTime, objectsToTrigger.ToArray()); SfxManager.PlaySound("switch"); if (ActivateEffect) { ActivateEffect.Play(); } StartCoroutine(ActivateRoutine()); //when switch is triggered, faded. //pic.color = new Color(pic.color.r, pic.color.g, pic.color.b, 0.1F); isTouching = true; light.enabled = flipLight ? false : true; pic.sprite = activated; } }
private void checkJumpPoint(Collider2D collider) { switch (collider.gameObject.tag) { case "JumpPoint": if (!isJumping) { if (mouse != null && mouse.GetComponent <Transform>().position.y > trans.position.y) //jump { rb.AddForce(new Vector2(rb.velocity.x, jumpSpeedY)); isJumping = true; SfxManager.PlaySound("jumpingCat"); } } break; //case "JumpPoint2": // if (!isJumping) // { // if (mouse != null && mouse.GetComponent<Transform>().position.y > trans.position.y) // jump higher // { // rb.AddForce(new Vector2(rb.velocity.x, jumpSpeedY * 1.1f)); // Debug.Log("jumppoint2"); // isJumping = true; // SfxManager.PlaySound("jumpingCat"); // } // } // break; } }
private void OnCollisionEnter2D(Collision2D collision) { // for jump if (isJumping && collision.gameObject.tag == "Ground" && rb.velocity.y <= 0) { rb.velocity = new Vector3(0, 0, 0); isJumping = false; anim.SetBool("isJumping", false); } // if mouse touches bottom of cat if (collision.gameObject.tag == "Cat") // then kill player { if (!catIsStunned(collision.gameObject)) { // game over code anim.SetTrigger("isDead"); if (!isDead) { StartCoroutine(lagGameOver()); } } else { GameObject deadCat = collision.gameObject.GetComponent <Transform>().parent.gameObject; SfxManager.PlaySound("killCat"); GameManager.getInstance().onSuccessfulKill(deadCat); } } }
private void OnTriggerStay2D(Collider2D collision) { if (collision.tag == "Monster" || collision.tag == "Boss") { if (collision.GetComponent <enemyHealth>().currentHealth < 0) { return; } this.GetComponent <Rigidbody2D>().velocity = new Vector3(0, 0, 0); this.GetComponent <Animator>().SetTrigger("Hit"); SfxManager.PlaySound("FireBallHit"); float damage = (float)SaveManager.Instance.gestureDMG[4]; if (!damageShown) { FloatingTextController.CreateFloatingText(damage.ToString(), transform); damageShown = true; } FightManager.currEnemy.gameObject.GetComponent <enemyHealth>().addDamage(damage); //duration of animation StartCoroutine(destroyAfterTime(0.77f)); } }
public void EnterCode(int codeValue) { if (cabinetOpen) { if (waitForCodeCheck == false) { SfxManager.PlaySfx(16); if (passCodeDisplay.text == "---") { passCodeDisplay.text = codeValue.ToString(); } else { passCodeDisplay.text += codeValue; } if (passCodeDisplay.text.Length == 3) { waitForCodeCheck = true; if (numAttempts == 9) { //Play right sound and move elevator numAttempts = 0; } else { StartCoroutine(checkCode(int.Parse(passCodeDisplay.text))); } } } } }
IEnumerator NextLevel() { // TODO async this maybe string sceneName = SceneManager.GetActiveScene().name; GameManager.Instance.cfp.FadeOut(); yield return(new WaitForSeconds(1)); for (int i = 0; i < levels.scenes.Count; i++) { string s = levels.scenes[i]; if (s != sceneName) { continue; } int levelNumber = i + 1; if (PlayerPrefs.GetInt("maxUnlocked", 1) < levelNumber) { PlayerPrefs.SetInt("maxUnlocked", levelNumber); PlayerPrefs.Save(); } SfxManager.PlaySound("win"); SceneManager.LoadScene(levels.scenes[levelNumber], LoadSceneMode.Single); break; } }
public static void Shutdown() { UIManager.Shutdown(); SfxManager.Shutdown(); AudioManager.Shutdown(); AssetManager.Shutdown(); DataManager.Shutdown(); }
private void PreloadAudio(SfxManager sfx, NoteSfxGroup group) { PreloadAudio(sfx, group.Perfect); PreloadAudio(sfx, group.Great); PreloadAudio(sfx, group.Nice); PreloadAudio(sfx, group.Bad); PreloadAudio(sfx, group.Miss); }
// todo: implement animation protected new void Start() { base.Start(); speed = startSpeed; SfxManager.PlaySound("chargingCat"); StartCoroutine(walkToWindup()); }
void Awake() { if (manager) { Destroy(manager.gameObject); } manager = this; }
public void TryToPlayHitSfx(string HitSfx) { if (HitSfxInterval_ <= 0) { SfxManager.PlayNpcSfx(this, true, HitSfx); HitSfxInterval_ = 8; } }
IEnumerator lagGameOver() { isDead = true; yield return(new WaitForSeconds(0.4f)); // delay to play explosion anim SfxManager.PlaySound("gameOverSound"); GameManager.getInstance().gameOver(); }
void Start() { transition = GetComponent <PauseMenuCanvasTransition>(); sceneManager = SceneForestManager.Instance; sfxManager = SfxManager.instance; UnPause(); }
void Awake() { if (!sfxManager) { sfxManager = this; } _audioSources = GetComponents <AudioSource>(); }
// Start is called before the first frame update void Start() { isOpen = value.initialValue; chestClosed.SetActive(!value.initialValue); chestOpened.SetActive(value.initialValue); // connecting to sound effect script sfxMan = FindObjectOfType <SfxManager>(); }
public void OnTriggerExit2D(Collider2D other) { if (other.GetComponent <CharacterMovement>() || other.GetComponent <CharacterMovement_simple>()) { anim.SetTrigger("FadeOut"); SfxManager.PlaySound("tutorialHide"); } }
// Update is called once per frame void Update() { while (totalMoved > distanceBetweenFootsteps) { totalMoved -= distanceBetweenFootsteps; SfxManager.PlaySound("footstep"); } }
// 对象进入场景,在这里初始化各种数据, 资源, 模型等 // 传入数据。 override public void OnEnterWorld() { // todo: 这里会加入数据解析 sfxManager = new SfxManager(this); //AddUniqEventListener<GameObject, Vector3>(Events.OtherEvent.OnMoveTo, OnMoveTo); EventDispatcher.AddEventListener<GameObject, Vector3>(MogoMotor.ON_MOVE_TO, OnMoveTo); CreateModel(); }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
// Use this for initialization void Start() { sfxManager = GameObject.Find("SfxManager").GetComponent<SfxManager>(); socialManager = GameObject.Find("SocialManager").GetComponent<SocialManager>(); gameMode = GameObject.Find("ModeManager").GetComponent<ModeManager>().getSelectedMode(); savingPanel.SetActive(false); timerHolder.SetActive(false); tempoEndPanel.SetActive(false); if (gameMode.Equals(ModeManager.GameMode.CLASSIC)) { bool migrated = PlayerPrefs.GetInt("classicTotalScoreSet", 0) == 1; if (migrated) { totalScore = PlayerPrefs.GetInt("classicTotalScore", 0); } else { totalScore = PlayerPrefs.GetInt("totalScore", 0); PlayerPrefs.SetInt("classicTotalScore", totalScore); int highscore = PlayerPrefs.GetInt("highscore", 0); PlayerPrefs.SetInt("classicHighscore", highscore); PlayerPrefs.SetInt("classicTotalScoreSet", 1); } } else if (gameMode.Equals(ModeManager.GameMode.TEMPO)) { totalScore = PlayerPrefs.GetInt("tempoTotalScore", 0); } else if (gameMode.Equals(ModeManager.GameMode.WILD)) { totalScore = PlayerPrefs.GetInt("wildTotalScore", 0); } showTutorial = PlayerPrefs.GetInt("showTutorial", 1) == 1; tutorialHighlights.SetActive(false); tutorialEnd.SetActive(false); if (!showTutorial) { tutorialPanel.SetActive(false); StartGame(); } }
void Awake() { bgmManager = ScriptableObject.FindObjectOfType<BgmManager>(); sfxManager = ScriptableObject.FindObjectOfType<SfxManager>(); }
// 对象进入场景,在这里初始化各种数据, 资源, 模型等 // 传入数据。 override public void OnEnterWorld() { // todo: 这里会加入数据解析 skillManager = new SkillManager(this); battleManger = new MonsterBattleManager(this, skillManager); sfxManager = new SfxManager(this); //AddUniqEventListener<GameObject, Vector3>(Events.OtherEvent.OnMoveTo, OnMoveTo); EventDispatcher.AddEventListener<GameObject, Vector3>(MogoMotor.ON_MOVE_TO, OnMoveTo); EventDispatcher.AddEventListener(Events.OtherEvent.CallTeammate, OnHelp); //CreateModel(); }
// 对象进入场景,在这里初始化各种数据, 资源, 模型等 // 传入数据。 override public void OnEnterWorld() { // todo: 这里会加入数据解析 buffManager = new BuffManager(this); skillManager = new SkillManager(this); battleManger = new DummyBattleManager(this, skillManager); sfxManager = new SfxManager(this); //AddUniqEventListener<GameObject, Vector3>(Events.OtherEvent.OnMoveTo, OnMoveTo); EventDispatcher.AddEventListener<GameObject, Vector3>(MogoMotor.ON_MOVE_TO, OnMoveTo); EventDispatcher.AddEventListener(Events.OtherEvent.CallTeammate, OnHelp); EventDispatcher.AddEventListener(Events.AIEvent.DummyThink, DummyThink); EventDispatcher.AddEventListener<GameObject>(Events.AIEvent.DummyStiffEnd, DummyStiffEnd); EventDispatcher.AddEventListener(Events.AIEvent.ProcessBossDie, ProcessBossDie); EventDispatcher.AddEventListener<byte, uint>(Events.AIEvent.SomeOneDie, ProcessSomeOneDie);//阵营,eid EventDispatcher.AddEventListener<uint, byte, uint, int>(Events.AIEvent.WarnOtherSpawnPointEntities, ProcessWarnOtherSpawnPointEntities);//eid, AIWarnEvent类型 EventDispatcher.AddEventListener<uint, int, int, int>(Events.GearEvent.Damage, SetDamage); }
public AudioManager() { SfxManager = new SfxManager(); MusicManager = new MusicManager(); }
// 对象进入场景,在这里初始化各种数据, 资源, 模型等 // 传入数据。 override public void OnEnterWorld() { // todo: 这里会加入数据解析 buffManager = new BuffManager(this); skillManager = new SkillManager(this); battleManger = new MercenaryBattleManager(this, skillManager); sfxManager = new SfxManager(this); m_updateCoordTimerID = TimerHeap.AddTimer<bool>(1000, 1000, SyncPos, true); EventDispatcher.AddEventListener<GameObject, Vector3>(MogoMotor.ON_MOVE_TO, OnMoveTo); EventDispatcher.AddEventListener(Events.OtherEvent.CallTeammate, OnHelp); EventDispatcher.AddEventListener(Events.AIEvent.DummyThink, DummyThink); EventDispatcher.AddEventListener<GameObject>(Events.AIEvent.DummyStiffEnd, DummyStiffEnd); EventDispatcher.AddEventListener(Events.AIEvent.ProcessBossDie, ProcessBossDie); EventDispatcher.AddEventListener<byte, uint>(Events.AIEvent.SomeOneDie, ProcessSomeOneDie);//阵营,eid EventDispatcher.AddEventListener<uint, byte, uint, int>(Events.AIEvent.WarnOtherSpawnPointEntities, ProcessWarnOtherSpawnPointEntities);//eid, AIWarnEvent类型 if (MogoWorld.theLittleGuyID == ID) { isLittleGuy = true; } }
void Awake() { if(manager) Destroy(manager.gameObject); manager = this; }
//private void SceneLoaded(int sceneId, bool isInstance) //{ // CreateModel(); //} // 对象进入场景,在这里初始化各种数据, 资源, 模型等 // 传入数据。 override public void OnEnterWorld() { // todo: 这里会加入数据解析 base.OnEnterWorld(); if (ID != MogoWorld.thePlayer.ID) { skillManager = new SkillManager(this); battleManger = new OtherPlayerBattleManager(this, skillManager); } sfxManager = new SfxManager(this); }