Beispiel #1
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);
                    }
                }
            }
        }
    }