protected virtual void Awake() { if (world == null) { world = GameObject.FindWithTag("Manager").GetComponent <World>(); } if (damagePopup == null) { damagePopup = Resources.Load <GameObject>("Prefabs/DamagePopup"); } t = GetComponent <Transform>(); rend = GetComponent <SpriteRenderer>(); anim = GetComponent <Animator>(); collideCompare = (CollideResult a, CollideResult b) => { float distA = Vector2.SqrMagnitude(Position - a.bb.center); float distB = Vector2.SqrMagnitude(Position - b.bb.center); return(distA < distB ? -1 : 1); }; if (audioManager == null) { audioManager = GameObject.FindWithTag("Audio").GetComponent <Audiomanager>(); } }
private void Awake() { GM = FindObjectOfType <GameManager>(); AM = FindObjectOfType <Audiomanager>(); spawnPoints.AddRange(GameObject.FindGameObjectsWithTag("SpawnPoint")); playerPositions.AddRange(GameObject.FindGameObjectsWithTag("Waypoint")); // Sorts spawnpoints by name if (spawnPoints.Count > 0) { spawnPoints.Sort(delegate(GameObject a, GameObject b) { return((a.name).CompareTo(b.name)); }); } // Sort playerPositions by name if (playerPositions.Count > 0) { playerPositions.Sort(delegate(GameObject a, GameObject b) { return((a.name).CompareTo(b.name)); }); } }
public void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "power") { invisible = false; StartCoroutine(Invisible()); Destroy(other.gameObject); Respawn.SetActive(true); } if (other.gameObject.tag == "Shoes") { playercontroller.jumpforce = 20; StartCoroutine(highJump()); shoes[0].SetActive(true); shoes[1].SetActive(true); } if (other.gameObject.tag == "coin") { cointext.enabled = true; coinpoint += 1; totalcoin += 1; cointext.text = "+" + coinpoint.ToString(); Audiomanager.Playsound("coin"); Destroy(other.gameObject); StartCoroutine(Repeatcoinenable()); } }
// Start is called before the first frame update void Start() { audiomanager = FindObjectOfType <Audiomanager>(); if (audiomanager != null) { } }
private void Awake() { GM = FindObjectOfType <GameManager>(); AM = FindObjectOfType <Audiomanager>(); spawnPoints.AddRange(GameObject.FindGameObjectsWithTag("SpawnPoint")); SortSpawnPoints(); }
void Start() { world = GameObject.FindWithTag("Manager").GetComponent <World>(); ent = GetComponent <Entity>(); play = GetComponent <Player>(); audioManager = GameObject.FindWithTag("Audio").GetComponent <Audiomanager>(); }
private void Awake() { player = GameObject.FindGameObjectWithTag("Player"); wordPosition = GetComponent <WordPosition>(); AM = FindObjectOfType <Audiomanager>(); GM = FindObjectOfType <GameManager>(); wordManager = FindObjectOfType <WordManager>(); preSpawnHandler = FindObjectOfType <PreSpawnHandler>(); }
private void Awake() { AM = FindObjectOfType <Audiomanager>(); GM = FindObjectOfType <GameManager>(); anim = GetComponent <Animator>(); rb = GetComponent <Rigidbody>(); navAgent = GetComponent <NavMeshAgent>(); capsCol = GetComponent <CapsuleCollider>(); boxCol = GetComponent <BoxCollider>(); enemyNav = GetComponent <EnemyNav>(); }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); DontDestroyOnLoad(gameObject); } }
private void MakeSingelton() { if (Instance != null) { Destroy(gameObject); } else { Instance = this; DontDestroyOnLoad(gameObject); } }
private void Awake() { AM = FindObjectOfType <Audiomanager>(); interfaceController = FindObjectOfType <InterfaceController>(); playerBehaviour = FindObjectOfType <PlayerBehaviour>(); screenShake = FindObjectOfType <ScreenShake>(); healthHandler = FindObjectOfType <HealthHandler>(); SetGameMode(); if (gameMode != GameMode.Arcade) { drillModeManager = FindObjectOfType <DrillModeManager>(); } }
public static void SetUpLevel(int levelIndex, GameObject loadingScreen, Slider slider, Text progressText, AudioSource audioSource, float volume = 0) { if (levelIndex > Gamemanager.HighestLevel) { Gamemanager.HighestLevel = levelIndex; } Gamemanager.LoadingScreen = loadingScreen; Gamemanager.Slider = slider; Gamemanager.ProgressText = progressText; Gamemanager.LastLevel = levelIndex; Audiomanager.PlayMusic(audioSource, volume); }
private void Awake() { screenShake = FindObjectOfType <ScreenShake>(); AM = FindObjectOfType <Audiomanager>(); GM = FindObjectOfType <GameManager>(); pauseMenu = FindObjectOfType <PauseMenu>(); joystick = FindObjectOfType <Joystick>(); // Enable mobile controls on Android or IOS #if UNITY_ANDROID || UNITY_IOS joyButtonA = FindObjectsOfType <JoyButton>()[0]; joyButtonX = FindObjectsOfType <JoyButton>()[1]; #endif }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } foreach (Audio a in sound) { a.source = gameObject.AddComponent <AudioSource>(); a.source.clip = a.clip; a.source.volume = a.volume; a.source.pitch = a.pitch; a.source.loop = a.loop; } }
void Start() { playerMovement.moveSpeed = movementSpeed; currentHealth = MaxHealth; timeScore = 0; killScore = 0; shieldScore = 0; audioM = FindObjectOfType <Audiomanager>(); transform.rotation = Quaternion.Euler(Vector3.zero); levelStartTime = Time.timeSinceLevelLoad; for (int i = 0; i < HP; ++i) { var heart = Instantiate(HeartPrefab); heart.transform.parent = healthBar.transform; hearts.Add(heart); } }
private IEnumerator die() { Gamemanager.PlayerDead = true; if (deaths != Gamemanager.DeathCounter) { Gamemanager.DeathCounter++; deaths = Gamemanager.DeathCounter; } GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll; Audiomanager.FadeOut(deathScreenFadeTime); StartCoroutine(UIManager.FadeIn(DeathScreen.GetComponent <SpriteRenderer>(), deathScreenFadeTime)); yield return(new WaitForSeconds(deathScreenFadeTime / 60)); CanRestart = true; }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); foreach (Sound s in sounds) { s.source = gameObject.AddComponent <AudioSource>(); s.source.clip = s.clip; s.source.volume = s.volume; s.source.pitch = s.pitch; s.source.loop = s.loop; } }
private void Awake() { //Singleton if (instance == null) { instance = this; } else { Destroy(gameObject); return; } //Preserve the audiomanager while changing scenes DontDestroyOnLoad(gameObject); foreach (Sound s in sounds) // Atributing the values for the editor { s.source = gameObject.AddComponent <AudioSource>(); s.source.clip = s.clip; s.source.volume = s.volume * masterVolume; s.source.pitch = s.pitch; s.source.loop = s.loop; } }
private void Awake() { AM = FindObjectOfType <Audiomanager>(); }
private void Awake() { GM = FindObjectOfType <GameManager>(); AM = FindObjectOfType <Audiomanager>(); }
private void Awake() { _instance = this; isMute = (PlayerPrefs.GetInt("mute", 0) == 0?false:true); DoMute(); }
private void Awake() { audiosingle = this; }
private void Awake() { anim = GetComponent <Animator>(); AM = FindObjectOfType <Audiomanager>(); scoreManager = FindObjectOfType <ScoreManager>(); }
private void CheckPlayerInput() { PlayerPhysics.MoveDirectionX = 0; PlayerPhysics.MoveDirectionY = 0; if (PlayerController.Health > 0 && !PlayerController.CanExit) { PlayerPhysics.MoveDirectionX = Input.GetAxisRaw("Horizontal"); if (Input.GetKeyDown(KeyCode.LeftShift)) { PlayerController.IsDoged = true; } if (Input.GetKeyUp(KeyCode.LeftShift)) { PlayerController.IsDoged = false; } if (Input.GetKeyDown(KeyCode.I)) { powerShot = StartCoroutine(playerController.EmpoweredShot()); } if (Input.GetKeyUp(KeyCode.I) && !FireEmpowered()) { if (powerShot != null) { PlayerController.PowerShot = false; PlayerController.ShotCount = 0; StopCoroutine(powerShot); } StartCoroutine(playerController.Shoot()); } } if (Input.GetKeyDown(KeyCode.Space)) { PlayerPhysics.Jump(); if (PlayerController.CanExit || PlayerController.CanRestart) { playerController.VictoryScreen.SetActive(false); playerController.DeathScreen.SetActive(false); Gamemanager.RestartGame(); } } if (Input.GetKey(KeyCode.Space) && PlayerPhysics.InWater) { PlayerPhysics.Swim(); } if (Input.GetKeyDown(KeyCode.Escape)) { if (PlayerController.CanExit) { playerController.VictoryScreen.SetActive(false); Gamemanager.LastLevel++; Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel); Gamemanager.ExitLevel(); } else if (PlayerController.CanUnpause) { StartCoroutine(playerController.Unpause()); } else if (PlayerController.Health < 1 && PlayerController.CanRestart) { playerController.DeathScreen.SetActive(false); Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel); Gamemanager.ExitLevel(); } else if (PlayerController.Health > 0 && !PlayerController.CanUnpause) { StartCoroutine(playerController.Pause()); } } if (Input.GetKeyDown(KeyCode.S)) { if (PlayerController.CanUnpause) { playerController.PauseScreen.SetActive(false); Audiomanager.StopMusic(); Gamemanager.SavePlayer(playerController, Gamemanager.LastLevel); Gamemanager.ExitLevel(); } } if (Input.GetKeyDown(KeyCode.E)) { Interact = true; } else if (Input.GetKeyUp(KeyCode.E)) { Interact = false; } if (OnLadder) { PlayerPhysics.MoveDirectionY = Input.GetAxisRaw("Vertical"); } }
private void Awake() { screenShake = FindObjectOfType <ScreenShake>(); AM = FindObjectOfType <Audiomanager>(); }
public static void DefeatBoss() { Audiomanager.FadeOut(VictoryScreenFadeTime); }
// Use this for initialization void Start() { Instance = this; player = GetComponent <AudioSource>(); }
private void Awake() { GM = FindObjectOfType <GameManager>(); AM = FindObjectOfType <Audiomanager>(); interfaceController = FindObjectOfType <InterfaceController>(); }