예제 #1
0
    void Start()
    {
        _score          = 0;
        scoreLabel.text = _score.ToString();

        settingsPopUp.Close();
    }
예제 #2
0
 void Update()
 {
     // enables or disables mouse lock and visibility also pauses game if mouse is visible
     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         if (Cursor.visible == true)
         {
             Cursor.lockState = CursorLockMode.Locked;
             Cursor.visible   = false;
             Time.timeScale   = 1f;
             settingsPopUp.Close();
         }
         else
         {
             Cursor.lockState = CursorLockMode.None;
             Cursor.visible   = true;
             Time.timeScale   = 0f;
             settingsPopUp.Open();
         }
     }
     // enables shooing only if game isnt paused
     if (Time.timeScale != 0)
     {
         if ((Input.GetKeyDown(KeyCode.RightControl)) && (!EventSystem.current.IsPointerOverGameObject()))
         {
             // this creates a vector with the coridnates of the rays origin
             Vector3 point = new Vector3(_camera.pixelWidth / 2, _camera.pixelHeight / 2, 0);
             muzzleFlash.Play();
             gunShot.Play();
             // creates ray object with origin cordinates
             Ray ray = _camera.ScreenPointToRay(point);
             // pases the ray and a new object with type RaycastHit
             if (Physics.Raycast(ray, out RaycastHit hit))
             {
                 // this retrieves the object the ray hit
                 GameObject     hitObject  = hit.transform.gameObject;
                 ReactiveTarget target     = hitObject.GetComponent <ReactiveTarget>();
                 GameObject     enemy      = hit.transform.gameObject;
                 WanderingAI    lifeStatus = enemy.GetComponent <WanderingAI>();
                 // this checks if the target is a person though the get component method and if it is
                 // it returns a hit and if not it creates a sphere in the debug console.
                 // get component returns null if the component isnt there.
                 if ((target != null) && (lifeStatus.getAlive()))
                 {
                     target.ReactToHit();
                     Messenger.Broadcast(GameEvent.ENEMY_HIT);
                 }
                 else
                 {
                     // starts the coroutine kicking control to it
                     StartCoroutine(SphereIndicator(hit.point));
                 }
             }
         }
     }
 }
예제 #3
0
 //All popups initialized to "Close" at the start of the game.
 void Start()
 {
     settingsPopup.Close();
 }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     settingsPopup.Close(); // Закрываем всплывающее окно в момент начала игры
 }
예제 #5
0
 //All popups initialized to "Close" at the start of the game.
 void Start()
 {
     //Debug.Log(countResearch);
     settingsPopup.Close();
 }