Beispiel #1
0
    void UnlockFieldsRecurs(int a_x, int a_y)
    {
        if (a_x < 0 || a_x >= m_initialData.m_width || a_y < 0 || a_y >= m_initialData.m_height)
        {
            return;
        }

        MapField checkedField = m_fields[a_x, a_y];

        if (checkedField.IsOpen || checkedField.Ellement.IsMine)
        {
            return;
        }

        checkedField.Action();

        if (checkedField.IsEmpty)
        {
            for (int i = -1; i < 2; ++i)
            {
                for (int j = -1; j < 2; ++j)
                {
                    UnlockFieldsRecurs(a_x + i, a_y + j);
                }
            }
        }
    }
Beispiel #2
0
    void OnTouchEnd(Vector2 touchPos, bool a_isALternative)
    {
        var testPos = Camera.main.ScreenToWorldPoint(touchPos);

        Debug.Log($"pos.x = {touchPos.x}, pos.y = {touchPos.y}, testPos.x = {testPos.x}, testPos.y = {testPos.y} ");
        //bool isLongTouch = (Time.unscaledTime - m_touchTimeStamp) > m_timeForLongTouch;
        RaycastHit2D hit2D = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(touchPos), Vector2.zero);

        if (hit2D)
        {
            MapField field = hit2D.transform.GetComponent <MapField>();
            if (field)
            {
                Debug.Log("Object found");
                if (a_isALternative)
                {
                    field.AlternativeAction();
                }
                else
                {
                    if (field.Ellement.IsMine)
                    {
                        field.Action();
                        Debug.Log("You lose");
                        //m_map.CreateMap();
                        return;
                    }
                    else
                    {
                        m_map.UnlockFields(field);
                    }
                }
            }
        }
    }