Exemplo n.º 1
0
    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>();
        }
    }
Exemplo n.º 2
0
    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));
            });
        }
    }
Exemplo n.º 3
0
 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());
     }
 }
Exemplo n.º 4
0
 // 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();
 }
Exemplo n.º 6
0
    void Start()
    {
        world = GameObject.FindWithTag("Manager").GetComponent <World>();
        ent   = GetComponent <Entity>();
        play  = GetComponent <Player>();

        audioManager = GameObject.FindWithTag("Audio").GetComponent <Audiomanager>();
    }
Exemplo n.º 7
0
 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>();
 }
Exemplo n.º 9
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
         DontDestroyOnLoad(gameObject);
     }
 }
Exemplo n.º 10
0
 private void MakeSingelton()
 {
     if (Instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
 }
Exemplo n.º 11
0
    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>();
        }
    }
Exemplo n.º 12
0
    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);
    }
Exemplo n.º 13
0
    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
    }
Exemplo n.º 14
0
 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;
     }
 }
Exemplo n.º 15
0
    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);
        }
    }
Exemplo n.º 16
0
    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;
    }
Exemplo n.º 17
0
    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;
        }
    }
Exemplo n.º 18
0
    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;
        }
    }
Exemplo n.º 19
0
 private void Awake()
 {
     AM = FindObjectOfType <Audiomanager>();
 }
Exemplo n.º 20
0
 private void Awake()
 {
     GM = FindObjectOfType <GameManager>();
     AM = FindObjectOfType <Audiomanager>();
 }
Exemplo n.º 21
0
 private void Awake()
 {
     _instance = this;
     isMute    = (PlayerPrefs.GetInt("mute", 0) == 0?false:true);
     DoMute();
 }
Exemplo n.º 22
0
 private void Awake()
 {
     audiosingle = this;
 }
Exemplo n.º 23
0
 private void Awake()
 {
     anim         = GetComponent <Animator>();
     AM           = FindObjectOfType <Audiomanager>();
     scoreManager = FindObjectOfType <ScoreManager>();
 }
Exemplo n.º 24
0
    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>();
 }
Exemplo n.º 26
0
 public static void DefeatBoss()
 {
     Audiomanager.FadeOut(VictoryScreenFadeTime);
 }
Exemplo n.º 27
0
 // Use this for initialization
 void Start()
 {
     Instance = this;
     player   = GetComponent <AudioSource>();
 }
Exemplo n.º 28
0
 private void Awake()
 {
     GM = FindObjectOfType <GameManager>();
     AM = FindObjectOfType <Audiomanager>();
     interfaceController = FindObjectOfType <InterfaceController>();
 }