Ejemplo n.º 1
0
    /// <summary>
    /// Middle of the screen is the crosshair, sets the target point and updates raycasthit using raycasts
    /// </summary>
    void Update()
    {
        RaycastHit hit;
        // layer mask for bullet holes
        int layerMask = 1 << 8;

        layerMask = ~layerMask;
        Physics.Raycast(transform.position, transform.TransformDirection(Vector3.up), out hit, Mathf.Infinity,
                        layerMask);
        if (hit.collider != null)
        {
            MyUiManager.SetTextUpR(hit.collider.gameObject.name);
        }
        if (hit.transform != null)
        {
            gunTargetPosition = hit.point;
            Vector3 pos = _camera.WorldToScreenPoint(gunTargetPosition);
            crosshair.position = new Vector3(pos.x, pos.y, 0);
        }
        else
        {
            // if target is skybox, raycast doesn't register so we set target as a long distance away from camera
            gunTargetPosition  = transform.position + transform.TransformDirection(Vector3.up) * 500f;
            crosshair.position = _camera.WorldToScreenPoint(gunTargetPosition);
        }
        _playable.SetGunTargetPosition(gunTargetPosition);
        _playable.SetGunTargetRaycastHit(hit);
    }
Ejemplo n.º 2
0
    private void Update()
    {
        if (spawner == null)
        {
            spawner = GameObject.Find("spawnPlane");
        }
        else
        {
            if (!started)
            {
                canStartSpawnRoutine = true;
            }
        }
        if (canStartSpawnRoutine)
        {
            StartCoroutine(Spawn(spawnRate));
            canStartSpawnRoutine = false;
            started = true;
        }

        if (started)
        {
            if (nbEnemiesKilled >= nbEnemiesToKill)
            {
                SceneManager.LoadScene("End");
            }
            MyUiManager.SetTextUpR(ToTimeString(timeSinceSpawn));
            MyUiManager.SetTextCenter(nbEnemiesKilled.ToString());
        }
    }
Ejemplo n.º 3
0
 public static MyUiManager GetInstance()
 {
     if (instance == null)
     {
         instance = new MyUiManager();
     }
     return(instance);
 }
Ejemplo n.º 4
0
 void Awake()
 {
     Debug.Assert(FindObjectsOfType <MyUiManager>().Length == 1);
     if (instance == null)
     {
         instance = this;
     }
 }
    /// <summary>
    /// Computes and print player speed
    /// </summary>
    /// <returns></returns>
    private IEnumerator UpdateVelocity()
    {
        while (true)
        {
            var oldPosition = transform.position;
            yield return(new WaitForSeconds(0.1f));

            var diffPosition = transform.position - oldPosition;
            var speed        = Math.Abs(diffPosition.x) + Math.Abs(diffPosition.y) + Math.Abs(diffPosition.z);
            MyUiManager.SetTextUpL(speed.ToString());
        }
    }
Ejemplo n.º 6
0
    private IEnumerator Loading()
    {
        var t   = Time.time;
        var img = transform.Find("bottom/Image").GetComponent <Image>();

        img.fillAmount = 0;
        while (true)
        {
            yield return(new WaitForSeconds(0.02f));

            img.fillAmount = (Time.time - t) / 3;
            if (Time.time - t > 3)
            {
                MyUiManager.GetInstance().OffPanel();
                //MyUiManager.GetInstance().PushPanel(MyUiType.MainPanel);
                break;
            }
        }
    }
Ejemplo n.º 7
0
 public void Close()
 {
     MyUiManager.GetInstance().OffPanel();
 }
Ejemplo n.º 8
0
 // Start is called before the first frame update
 void Start()
 {
     MyUiManager.GetInstance().PushPanel(MyUiType.FirstPanel);
 }
Ejemplo n.º 9
0
 // Start is called before the first frame update
 void Start()
 {
     uiManager = MyUiManager.GetInstance();
 }
Ejemplo n.º 10
0
 // Start is called before the first frame update
 void Start()
 {
     uiManager = MyUiManager.GetInstance();
     //MyUiManager.GetInstance().PushPanel(MyUiType.ThirdInfoPanel);
 }