Пример #1
0
    private void Click_Catching()
    {
        if (Input.GetMouseButtonDown(0) && (Time.timeScale == 1f))
        {
            Vector2      point = _camera.ScreenToWorldPoint(Input.mousePosition);
            Vector2      dir   = point;
            RaycastHit2D hit   = Physics2D.Raycast(point, Vector2.zero, 100f, NeedLayer);
            if (hit.collider != null)
            {
                if (hit.transform.gameObject.GetComponent <Water>() != null)
                {
                    Water      water = hit.transform.gameObject.GetComponent <Water>();
                    Vector3    pos   = new Vector3(Mathf.Floor(hit.transform.position.x) + 0.5f, Mathf.Floor(hit.transform.position.y) + 0.5f, -0.1f);
                    Quaternion quat  = new Quaternion(0, 0, 0, 0);

                    GameObject go = Instantiate(Hydrolocator, pos, quat, Map_man);
                    go.GetComponent <Hydrolocator>().t_mesh    = go.GetComponentInChildren <TextMesh>();
                    go.GetComponent <Hydrolocator>().cor_x     = Mathf.FloorToInt(go.transform.position.x - 0.5f);
                    go.GetComponent <Hydrolocator>().cor_y     = Mathf.FloorToInt(go.transform.position.y - 0.5f);
                    go.GetComponent <Hydrolocator>().h_updater = Hydrolocator_updater;
                    Level_Info.h_amounts   += -1;
                    water.have_hydrolocator = true;
                    if (water.have_treasure)
                    {
                        Level_Info.tr_ch_amounts += -1;
                        UI_Man.Info_Refresh();
                    }
                    UI_Man.Info_Refresh();
                }
            }
        }
    }