void Awake () { jod = GetComponent<JamoDrum> (); jodkey = GetComponent<JamoDrumKeyVersion> (); launcher = GetComponent<SingleLauncher> (); platform = GameObject.Find("TracingPanel") .GetComponent<TracingPanel>(); spawn = GameObject.FindGameObjectWithTag("SpawnController") .GetComponent<SpawnMarbles>(); soundManager = GameObject.Find ("SoundManager") .GetComponent<SoundManagerScript>(); if (launcher.key) { jodkey.AddHitEvent(HitHandler); jodkey.AddSpinEvent(SpinHandler); } else { jod.AddHitEvent(HitHandler); jod.AddSpinEvent(SpinHandler); } stateStartAction = () => { stateTimer = 0f; heroTapSum = 0; heroSpinSum = 0; }; }
void Awake () { spawn = GetComponent<SpawnMarbles> (); health = GameObject.Find ("VillainHealth") .GetComponent<VillainHealth>(); soundManager = GameObject.Find ("SoundManager") .GetComponent<SoundManagerScript>(); explosion = GameObject.Find ("ExplosionController") .GetComponent<ExplosionController>(); }
void Awake () { controller = GameObject.Find ("GameController") .GetComponent<GameController> (); soundManager = GameObject.Find ("SoundManager") .GetComponent<SoundManagerScript> (); hpUI = GameObject.Find ("HPStuff") .GetComponentInChildren<DragonHP> (); maxHealth = health; }
// Use this for initialization void Start () { beating = false; soundManager = GameObject.Find ("SoundManager") .GetComponent<SoundManagerScript> (); balls = GameObject.Find ("SpawnController") .GetComponent<SpawnMarbles> ().ballChain; gameController = GameObject.Find ("GameController") .GetComponent<GameController> (); }
void Awake(){ if (instance != null && instance != this) { Destroy (gameObject); } else { instance = this; } DontDestroyOnLoad (gameObject); }
void Awake() { if (soundManagerInstance != null && soundManagerInstance != this) { Destroy(this.gameObject); return; } else { soundManagerInstance = this; } DontDestroyOnLoad(this.gameObject); }
private void OnMouseUp() { Scene currentScene = SceneManager.GetActiveScene(); string sceneName = currentScene.name; // if put in incorrect posistion - CAT if (sceneName == "CatExercise") { if (Mathf.Abs(transform.position.x - cat[0].position.x) <= 0.5f && Mathf.Abs(transform.position.y - cat[0].position.y) <= 0.5f || Mathf.Abs(transform.position.x - cat[1].position.x) <= 0.5f && Mathf.Abs(transform.position.y - cat[1].position.y) <= 0.5f || Mathf.Abs(transform.position.x - cat[2].position.x) <= 0.5f && Mathf.Abs(transform.position.y - cat[2].position.y) <= 0.5f) { Destroy(this.gameObject); SoundManagerScript.playErrorSound(); } else { transform.position = new Vector2(initialPosition.x, initialPosition.y); } } // DOG if (sceneName == "DogExercise") { // if put in incorrect posistion if (Mathf.Abs(transform.position.x - dog[0].position.x) <= 0.5f && Mathf.Abs(transform.position.y - dog[0].position.y) <= 0.5f || Mathf.Abs(transform.position.x - dog[1].position.x) <= 0.5f && Mathf.Abs(transform.position.y - dog[1].position.y) <= 0.5f || Mathf.Abs(transform.position.x - dog[2].position.x) <= 0.5f && Mathf.Abs(transform.position.y - dog[2].position.y) <= 0.5f) { Destroy(this.gameObject); SoundManagerScript.playErrorSound(); } else { transform.position = new Vector2(initialPosition.x, initialPosition.y); } } else { transform.position = new Vector2(initialPosition.x, initialPosition.y); } }
public void Move(float move, bool jump) { //only control the player if grounded or airControl is turned on if ((m_Grounded || m_AirControl) && knockBackCount <= 0) { // Move the character by finding the target velocity Vector3 targetVelocity = new Vector2(move * 10f, m_Rigidbody2D.velocity.y); // And then smoothing it out and applying it to the character m_Rigidbody2D.velocity = Vector3.SmoothDamp(m_Rigidbody2D.velocity, targetVelocity, ref m_Velocity, m_MovementSmoothing); // If the input is moving the player right and the player is facing left... if (move > 0 && !m_FacingRight) { // ... flip the player. Flip(); } // Otherwise if the input is moving the player left and the player is facing right... else if (move < 0 && m_FacingRight) { // ... flip the player. Flip(); } } else { // If player was knocked back if (knockBackFromRight) { m_Rigidbody2D.velocity = new Vector2(-knockBack, knockBack); } else { m_Rigidbody2D.velocity = new Vector2(knockBack, knockBack); } knockBackCount -= Time.deltaTime; } // If the player should jump... if (m_Grounded && jump) { // Play jump sound SoundManagerScript.PlaySound("Jump"); // Add a vertical force to the player. m_Grounded = false; m_Rigidbody2D.AddForce(new Vector2(0f, m_JumpForce)); } }
private void DoubleJump(Vector3 wishDir) { if (canDJump) { SoundManagerScript.PlaySound("djump"); float tempJumpForce = jumpForce; //Calculate upwards float upSpeed = rb.velocity.y; if (upSpeed < 0) { upSpeed = 0; } else if (upSpeed < dJumpBaseSpd) { upSpeed = dJumpBaseSpd; tempJumpForce = 0; } //Calculate sideways Vector3 jumpVector = Vector3.zero; Vector2 force = Vector2.zero; wishDir = wishDir.normalized; Vector3 spid = new Vector3(rb.velocity.x, 0, rb.velocity.z); if (spid.magnitude < airTargetSpeed) { jumpVector = wishDir * dashForce; jumpVector -= spid; } else if (Vector3.Dot(spid.normalized, wishDir) > -0.4f) { jumpVector = wishDir * dashForce; force = ClampedAdditionVector(new Vector2(rb.velocity.x, rb.velocity.z), new Vector2(jumpVector.x, jumpVector.z)); jumpVector.x = force.x; jumpVector.z = force.y; } else { jumpVector = wishDir * spid.magnitude; } //Apply Jump jumpVector.y = tempJumpForce; rb.velocity = new Vector3(rb.velocity.x, upSpeed, rb.velocity.z); rb.AddForce(jumpVector, ForceMode.Impulse); canDJump = false; } }
private void Update() { // Debug.Log(Health); HealthBar.SetHealth(Health); if (Health <= 0) { LostLevel.SetActive(true); Time.timeScale = 0f; Health = 100; SoundManagerScript.PlaySound("stinger_lose"); //animator.SetTrigger("Death"); //DestroyGameObject(); return; } //white dizzzy logic }
private void ActivateAssistant() { AssistantHelp ah = GameObject.Find("MainGameLogic").GetComponent <AssistantHelp>(); if (!ah.activated) { DisplayMessageOnScreen("Assistente Monetario Ativado"); ah.activated = true; SoundManagerScript.PlaySound("happy"); } else { DisplayMessageOnScreen("Assistente Monetario Desactivado"); ah.activated = false; SoundManagerScript.PlaySound("sad"); } }
IEnumerator Countdown(int seconds) { int count = seconds; while (count > 0) { yield return(new WaitForSeconds(1)); if (count != 1) { countDownText.text = (count - 1).ToString(); SoundManagerScript.playSecondSound(); } count--; } StartGame(); }
IEnumerator Pickup(Collider player) { stats = player.GetComponent <PlayerMovement>(); if (isBoosted == false) { isBoosted = true; SoundManagerScript.PlaySound("PowerUp"); stats.speed *= multiplier; StartCoroutine(FromTo(60f, 75f, 0.2f, false)); yield return(new WaitForSeconds(duration)); isBoosted = false; SoundManagerScript.PlaySound("PowerDown"); StartCoroutine(FromTo(stats.speed, stats.speed / multiplier, 0.7f, true)); StartCoroutine(FromTo(75f, 60f, 0.7f, false)); } }
public void DisplayNextSentence() { if (talk.Count == 0) { EndDialogue(); return; } DialogueSpecial temp = talk.Dequeue(); person.text = temp.name; character = person.text; string s = temp.sentence; StopAllCoroutines(); SoundManagerScript.StopSound(); StartCoroutine(TypeSentence(s, character)); }
public void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player") { SoundManagerScript.PlaySound("SFX/GetHit"); HealthScript.health -= 10f; //isDead = true; } if (collision.gameObject.tag == "Bullet") { bossHealth -= 10; // if (bossHealth <= 0) //{ // boss1IsDead = true; //} } }
private void Spit() { Vector2 direction; spitTimer += Time.deltaTime; if (spitTimer >= spitInterval) { direction = player.transform.position - transform.position; direction.Normalize(); SoundManagerScript.PlaySound("ThrowWBC"); Instantiate(spit, spitPoint.transform.position, spitPoint.transform.rotation); spitTimer = 0; } }
void OnTriggerEnter2D(Collider2D other) { if (other.tag == "FallDetector") { gameLevelManager.Respawn(); } if (other.tag == "Checkpoint") { respawnPoint = other.transform.position; } if (other.tag == "ArenaTriggers") { if (movingToRight) { fixMove = true; rigidBody.velocity = new Vector2((movement * speed) / -1, rigidBody.velocity.y); } else if (movingToLeft) { fixMove = true; rigidBody.velocity = new Vector2((movement * speed) / -1, rigidBody.velocity.y); } } if (other.gameObject.tag == "Coin") { money++; SoundManagerScript.PlaySound("coin"); } if (other.gameObject.tag == "Characters") { isNearCharacter = true; } if (other.gameObject.name == "Goofy") { isNearGoofy = true; } if (other.gameObject.name == "Motor_oil") { SoundManagerScript.PlaySound("questitem"); hasMotorOil = true; } if (other.gameObject.name == "Bus_Stop") { nearBusStop = true; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Virus") && collision.gameObject.GetComponent <VirusBehavior>().isDamaging()) { mainController.PlayHitEffects(); if (shield > 0) { SoundManagerScript.PlaySound("TakeDamage"); shield--; } else { mainController.LowerLives(); mainController.PlayDamageEffects(); } } }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; } coin = Resources.Load <AudioClip>("coin"); draw = Resources.Load <AudioClip>("draw"); attack = Resources.Load <AudioClip>("attack"); audioSrc = GetComponent <AudioSource>(); }
public void ResetProgress() { SoundManagerScript.PlaySound("button"); PlayerPrefs.DeleteAll(); instruction11.SetActive(false); instruction1.SetActive(true); button1.interactable = false; image1.enabled = true; button2.interactable = false; image2.enabled = true; hs1.GetComponent <TextMeshProUGUI>().SetText("0"); hs2.GetComponent <TextMeshProUGUI>().SetText("0"); hs3.GetComponent <TextMeshProUGUI>().SetText("0"); ButtonSettings.releasedLevelStatic = 1; ResetUI.SetActive(true); StartCoroutine(LateCall()); }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Player") { SoundManagerScript.PlaySound("SFX/GetHit"); Destroy(gameObject); HealthScript.health -= 10; } if (collision.gameObject.tag == "Barrier") { Destroy(gameObject); } if (collision.gameObject.tag == "Bullet") { Destroy(gameObject); } }
void UpdateValue() { Debug.LogFormat("Updating value of diffSlider to {0}", diffSlider.value); if (diffSlider.value == 1) { SoundManagerScript.PlayOneShot("Kid_Laugh"); } else if (diffSlider.value == 2) { SoundManagerScript.PlayOneShot("Laughter"); } else if (diffSlider.value == 3) { SoundManagerScript.PlayOneShot("Maniac"); } }
// Use this for initialization void Start() { //HSDM_Script = GameObject.FindGameObjectWithTag("High Score Display Manager").GetComponent<HighScoreDisplayManagerScript>(); SoundManager_Script = GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManagerScript> (); //Original sprite before click playGamePanel.SetActive(false); topScorePanel.SetActive(false); creditsPanel.SetActive(false); Time.timeScale = 1.0f; CheckDifficultyLock(); //Sounds manager Mute button work around and starting back ground music SoundManager_Script.GetMuteButton(); SoundManager_Script.Play_BG_loop("bg1"); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag("Player")) { if (LivesUI.lives >= 10) { ; } else { LivesUI.lives += 5; SoundManagerScript.PlaySound("HealthUp"); //SpawnPowerup(); Destroy(this.gameObject); } } }
/** * Checks for each objective in the objectives array to see if the player has come within 1 unit of that object, * signifying that the player has collected or completed that object. The objective's hasCompleted boolean will * be set to true. */ void CheckObjectives() { Transform player = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform>(); foreach (Objective o in objectives) { if (Vector2.Distance(o.objective.transform.position, player.position) < 1) { o.hasCompleted = true; if (o.objective.activeSelf) { SoundManagerScript.PlaySound("money"); } o.objective.SetActive(false); } } }
IEnumerator coroutineA() { int i = 3; while (i >= 1) { cont.text = i.ToString(); i--; yield return(new WaitForSeconds(1.0f)); } cont.fontSize = 900; cont.text = "GOO!!"; SoundManagerScript.PlaySound("go"); yield return(new WaitForSeconds(1.0f)); cont.enabled = false; }
private void OnTriggerEnter(Collider collider) { if (collider.gameObject == Ball && Ball.GetComponent <Ball_Script>().follow == false) { lives--; SoundManagerScript.PlaySoundFX("ball_destroyed"); Ball.GetComponent <Ball_Script>().Respawn(); } if (collider.gameObject.transform.IsChildOf(GameObject.Find("PowerUps").transform)) { collider.gameObject.GetComponent <PowerUp_Script>().start = false; collider.gameObject.GetComponent <PowerUp_Script>().GetComponent <MeshRenderer>().enabled = false; collider.gameObject.GetComponent <PowerUp_Script>().GetComponent <BoxCollider>().enabled = false; collider.gameObject.GetComponent <PowerUp_Script>().transform.position = collider.gameObject.GetComponent <PowerUp_Script>().pos; } }
protected override void OnMouseUp() { pressed = false; if (sceneName == "SecretaryExercise") { transform.position = ReplaceBlocks(transform.position.x, transform.position.y, initialPosition.x, initialPosition.y, 4.391f, 3.119f); } else if (sceneName == "ArtemisExercise") { if (Mathf.Abs(transform.position.x - targetBlock[0].position.x) <= 0.5f && Mathf.Abs(transform.position.y - targetBlock[0].position.y) <= 0.5f || Mathf.Abs(transform.position.x - targetBlock[1].position.x) <= 0.5f && Mathf.Abs(transform.position.y - targetBlock[1].position.y) <= 0.5f || Mathf.Abs(transform.position.x - targetBlock[2].position.x) <= 0.5f && Mathf.Abs(transform.position.y - targetBlock[2].position.y) <= 0.5f || Mathf.Abs(transform.position.x - targetBlock[3].position.x) <= 0.5f && Mathf.Abs(transform.position.y - targetBlock[3].position.y) <= 0.5f) { this.gameObject.SetActive(false); destroyed = true; SoundManagerScript.playErrorSound(); if (sceneName == "ArtemisExercise") { fairyAnimator.runtimeAnimatorController = Resources.Load("fairy disappointed 1") as RuntimeAnimatorController; } } else { transform.position = new Vector2(initialPosition.x, initialPosition.y); SpriteChangeTest.rend.sprite = SpriteChangeTest.fairy01; } } else { transform.position = new Vector2(initialPosition.x, initialPosition.y); } // doubleclick if (Input.GetMouseButtonUp(0)) clickCounter += 1; if (clickCounter == 1 && coroutineAllowed) { firstClickTime = Time.time; StartCoroutine(DoubleClickDetection()); } }
private void OnCollisionEnter2D(Collision2D collision) { GameObject player = GameObject.Find("Player"); PlayersMovement playersMovement = player.GetComponent <PlayersMovement>(); if (collision.collider.gameObject.CompareTag("PickUp")) { Destroy(collision.collider.gameObject); SoundManagerScript.PlaySound("slurp"); transform.localScale += new Vector3(.03F, .03F, 0); GameManager.gameManager.consumePerson(); print("People = " + GameManager.gameManager.getPeopleConsumed()); playersMovement.jumpForce = 120f + playersMovement.jumpForce; playersMovement.Speed = .2f + playersMovement.Speed; } }
public void ability() // cd: 10f { if (!cooldowns[1]) { SoundManagerScript.PlaySound("Skill"); RaycastHit2D[] ultHits = Physics2D.CircleCastAll(wielder.position, 4.0f, Vector2.zero); foreach (RaycastHit2D hit in ultHits) { if (hit.transform.CompareTag("Enemy")) { hit.transform.GetComponent <Enemy>().takeDamage(damage + 2); } } SpawnAndDestroy(hitbox, 0.25f); StartCoroutine(FadeTo(1, 10, 1, cooldownImageAbility)); } }
private void Reset() { Vector3 playerPosition = GameObject.FindGameObjectWithTag("Player").transform.position; transform.position = playerPosition + new Vector3(0, 0.5f, 0); float dirX = Random.Range(-5.0f, 5.0f); float dirY = Random.Range(2.0f, 5.0f); direcao = new Vector3(dirX, dirY).normalized; gm.vidas--; SoundManagerScript.PlaySound("death"); if (gm.vidas < 0) { gm.ChangeState(GameManager.GameState.ENDGAME); } }
void OnTriggerEnter2D(Collider2D hitInfo) { if (hitInfo.CompareTag("Enemy")) { SoundManagerScript.PlaySound("ShotFired1"); Enemy target = hitInfo.GetComponent <Enemy>(); target.TakeDamage(damage); Instantiate(impactEffect, transform.position, transform.rotation); Destroy(gameObject); } else if (!hitInfo.CompareTag("Range")) { Instantiate(impactEffect, transform.position, transform.rotation); Destroy(gameObject); } }
private void Atack() { if (atackCD > 0) { return; } atackCD = 1.2f; PerformAction("Atack"); foreach (var enemy in FindObjectsOfType <Enemigo>()) { if (Vector3.Distance(transform.position, enemy.transform.position) <= 2) { enemy.getHit(stats.GetAtack()); SoundManagerScript.PlaySound("SwordAttack"); } } }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Platform") || collision.gameObject.CompareTag("Trigger") || collision.gameObject.CompareTag("Bubble") || collision.gameObject.CompareTag("Lock1")) { //Debug.Log("Reflect"); reflectedBullet = true; SoundManagerScript.PlaySound("Reflect"); var speed = lastVelocity.magnitude + 0.5f; var direction = Vector3.Reflect(lastVelocity.normalized, collision.contacts[0].normal); //Debug.Log(direction); rigidBody.velocity = direction * speed; } else { //reflectedBullet = false; } }
//Unity calls this function when our pickup touches any other object //If the player touches the pickup object, it will disappear and the player's score will go up private void OnCollisionEnter2D(Collision2D collision) { //Check if the thing we touched was the Player Player playerScript = collision.collider.GetComponent <Player>(); //If the thing we touched has the player script, that means it IS the player, so.... if (playerScript) { //We hit the player! SoundManagerScript.PlaySound("coinSound"); //Add to the score based on our value scoreObject.AddScore(timepieceValue); //Destroy the gameObject that this script is attached to (the coin) Destroy(gameObject); } }
/// <summary> /// Méthode permettant de diminuer ou d'augmenter les points de vie du Personnage /// </summary> /// <param name="dmg">nb de points de vie a ajouter (valeur négative pour enlever)</param> /// /// <returns> true si tué sinon false</returns> public bool takeDamageHeal(int dmg) { health += dmg; if (health <= 0) { health = 0; healthMax = 0; for (int k = 0; k < hand.Count; k++) { GameObject.Find("GameManager").GetComponent <GameManager>().Disc(hand[k]); } hand.Clear(); List <GameObject> Personnages = GameObject.Find("GameManager").GetComponent <GameManager>().Personnages; for (int i = 0; i < Personnages.Count; i++) { if (Personnages[i].GetComponent <ThisPersonnage>().GetPersonnage().GetHealth() == 0) { if (Personnages[i].GetComponent <ThisPersonnage>().GetPersonnage().GetRole() == "Sheriff") { GameObject.Find("GameManager").GetComponent <GameManager>().nbSheriff--; Debug.Log(GameObject.Find("GameManager").GetComponent <GameManager>().nbSheriff); } else if (Personnages[i].GetComponent <ThisPersonnage>().GetPersonnage().GetRole() == "Hors La Loi") { GameObject.Find("GameManager").GetComponent <GameManager>().nbHorsLaLoi--; Debug.Log(GameObject.Find("GameManager").GetComponent <GameManager>().nbHorsLaLoi); } Personnages.RemoveAt(i); } } } if (health > healthMax) { health = healthMax; } if (health == 0 && !isDead) { isDead = true; SoundManagerScript.PlaySound("Oof"); } return(isDead); }
void Awake () { soundManager = GameObject.Find ("SoundManager") .GetComponent<SoundManagerScript> (); }
/** * Awake function */ void Awake() { if (Singleton == null) // Not instantiated yet Singleton = this; else if (Singleton != this) // Can only have one Destroy(gameObject); DontDestroyOnLoad(gameObject); // Persist this object }
void Awake() { if (instance != null) Debug.LogError("Only one plox"); instance = this; }
void Awake () { soundManager = GameObject.Find ("SoundManager") .GetComponent<SoundManagerScript> (); explosion = GameObject.Find ("ExplosionController") .GetComponent<ExplosionController>(); }
// Use this for initialization void Start () { NM = GameObject.FindGameObjectWithTag("NoteManager").GetComponent<NoteManager>(); //SMS = GameObject.FindGameObjectWithTag ("SoundManager").GetComponent<SoundManagerScript> (); SMS = SoundManagerScript.Instance; if(noteName == "MiddleC"){ currentNote = note.MiddleC; Yposition = -1.5f; } if(noteName == "CSharp"){ currentNote = note.CSharp; Yposition = -1.5f; } if(noteName == "D"){ currentNote = note.D; Yposition = -1.25f; } if(noteName == "DSharp"){ currentNote = note.DSharp; Yposition = -1.25f; } if(noteName == "E"){ currentNote = note.E; Yposition = -1f; } if(noteName == "F"){ currentNote = note.F; Yposition = -0.75f; } if(noteName == "FSharp"){ currentNote = note.FSharp; Yposition = -0.75f; } if(noteName == "G"){ currentNote = note.G; Yposition = -0.5f; } if(noteName == "GSharp"){ currentNote = note.GSharp; Yposition = -0.5f; } if(noteName == "A"){ currentNote = note.A; Yposition = -0.25f; } if(noteName == "ASharp"){ currentNote = note.ASharp; Yposition = -0.25f; } if(noteName == "B"){ currentNote = note.B; Yposition = 0f; } if(noteName == "HighC"){ currentNote = note.HighC; Yposition = 0.25f; } if(noteName == "HighCSharp"){ currentNote = note.HighCSharp; Yposition = 0.25f; } if(noteName == "HighD"){ currentNote = note.HighD; Yposition = 0.5f; } if(noteName == "HighDSharp"){ currentNote = note.HighDSharp; Yposition = 0.5f; } if(noteName == "HighE"){ currentNote = note.HighE; Yposition = 0.75f; } if(noteName == "HighF"){ currentNote = note.HighF; Yposition = 1f; } this.gameObject.transform.position = new Vector3(transform.position.x, Yposition, transform.position.z); }