void Start()
 {
     audio  = GameObject.FindObjectOfType <AudioAdmin>();
     _Mat   = transform.parent.GetComponent <Renderer>();
     _MatD  = door.GetComponent <Renderer>();
     _color = new Color(
         Random.Range(0f, 1f),
         Random.Range(0f, 1f),
         Random.Range(0f, 1f)
         );
     _Mat.material.color  = _color;
     _MatD.material.color = _color;
 }
    // Start is called before the first frame update
    void Start()
    {
        _resetButton = GetComponent <Button>();
        _resetButton.image.gameObject.SetActive(false);
        _resetButton.onClick.AddListener(TaskOnClick);

        _audio = FindObjectOfType <AudioAdmin>();
        if (_audio == null)
        {
            Debug.LogError("Audio script could not be found.");
        }
        _sceneAdmin = FindObjectOfType <SceneLoader>();
        if (_sceneAdmin == null)
        {
            Debug.LogError("Could not find Scene Loader");
        }
    }
 private 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.loop   = s.loop;
     }
 }
    // Use this for initialization
    void Start()
    {
        anim           = GetComponent <Animator>();
        _StartPosision = transform.position;

        _playerController = GetComponent <CharacterController>();
        #region Get Reset Scene Script
        _ResetButtonScript = _ResetButton.GetComponent <Reset_Scene_Script>();
        if (_ResetButtonScript == null)
        {
            Debug.LogError("No se encontró el script del botón");
        }
        #endregion

        audio = GameObject.FindObjectOfType <AudioAdmin>();
        if (audio == null)
        {
            Debug.LogError("No se encontro Audio");
        }

        ShowScore();
    }
Пример #5
0
    // Use this for initialization
    void Start()
    {
        #region initialize Player
        _initialSpeed        = 5f;
        _speed               = _initialSpeed;
        _runningSpeed        = 10f;
        _playerController    = GetComponent <CharacterController>();    //Obtener el Controlador
        _currentJumps        = 0;
        _StartPosition       = transform.position;
        totalClientsToAttend = 10;
        _isTriggeredHelper   = false;
        #endregion

        _modelAnim = GetComponentInChildren <Animator>();

        #region initialize Camera
        _zoom = -5f;
        _playerCamera.transform.localPosition = new Vector3(0, 0, _zoom);
        _playerCamera.LookAt(_focusPoint);
        #endregion


        #region initialize UI

        foodNumber      = 0;
        moneyEarned     = 0;
        lifeRemaining   = 3;
        attendedClients = 0;

        ShowScore();
        _WinLoseText.gameObject.SetActive(false);
        _BackgroundImage.enabled = false;
        #endregion

        #region Get Reset Scene Script
        _ResetButtonScript = _ResetButton.GetComponent <Reset_Scene_Script>();
        if (_ResetButtonScript == null)
        {
            Debug.LogError("Button Script Missing");
        }
        #endregion

        #region Puntaje
        _maxPuntaje = GameObject.FindGameObjectsWithTag("Food").Length;
        #endregion

        #region Audio
        _audio = FindObjectOfType <AudioAdmin>();
        if (_audio == null)
        {
            Debug.LogError("Audio script could not be found.");
        }
        #endregion

        #region SpawnObjects
        enemiesSpawnObj = FindObjectOfType <SpawnObjects>();
        if (enemiesSpawnObj == null)
        {
            Debug.LogError("'Enemies SpawnObjects' could not be found.");
        }
        clientsSpawnObj = FindObjectOfType <ClientSpawner>();
        if (clientsSpawnObj == null)
        {
            Debug.LogError("'Clients SpawnObjects' could not be found");
        }
        collectablesSpawnerObj = FindObjectsOfType <InfiniteSpawner>();
        if (collectablesSpawnerObj == null)
        {
            Debug.LogError("'Infinite Spawners' could not be found");
        }
        #endregion

        #region PlayerLife
        maxHealth            = 100;
        health               = maxHealth;
        healthBar.fillAmount = health / maxHealth;
        InvokeRepeating("EnergyLoss", 1, 1);
        #endregion
    }