Exemplo n.º 1
0
    IEnumerator Start()
    {
        if (clearAll)
        {
            PlayerPrefs.DeleteAll();
            clearAll = false;
        }
        if (ResetAllSettings)
        {
            PlayerPrefs.DeleteAll();
        }
        levelName = GlobalOptions.loadingLevel;
        curTime   = 0;
        GUIcamera = Cameras.GetGUICamera();

        Application.targetFrameRate = 60;

        InitSprites();
        if (GlobalOptions.UnityPro)
        {
            isLoading = true;
            async     = Application.LoadLevelAsync(levelName);
        }
        yield return(async);
    }
Exemplo n.º 2
0
    // Use this for initialization
    protected override void Start()
    {
        base.Start();
        ZoomMap.instance = this;
        swallowTouches   = true;
        init();

        scale           = 1;
        numberOfFingers = 0;
        fingers         = new int[2];
        fingerPos       = new Vector2[2];
        initFingerPos   = new Vector2[2];

        float minScaleX = Screen.width / 2 / perPixel / singleRenderer.bounds.extents.x;
        float minScaleY = Screen.height / 2 / perPixel / singleRenderer.bounds.extents.y;

        minScale = minScaleX < minScaleY?minScaleY:minScaleX;
        if (singleTransform.localScale.x > minScale)
        {
            singleTransform.localScale = new Vector3(minScale, minScale, minScale);
        }

        int padding = -1;

        posLeftTop = new Vector3(padding, GlobalOptions.Vsizey - padding, 1f);
        posLeftTop = GlobalOptions.NormalisePos(posLeftTop);
        posLeftTop = Cameras.GetGUICamera().ScreenToWorldPoint(posLeftTop);

        posRightBottom = new Vector3(GlobalOptions.Vsizex - padding, padding, 1f);
        posRightBottom = GlobalOptions.NormalisePos(posRightBottom);
        posRightBottom = Cameras.GetGUICamera().ScreenToWorldPoint(posRightBottom);
    }
Exemplo n.º 3
0
Arquivo: Money.cs Projeto: Shahabz/crm
    void Start()
    {
        Vector3 pos = new Vector3(GlobalOptions.Vsizex - 15, GlobalOptions.Vsizey - 92, singleTransform.position.z);

        pos = GlobalOptions.NormalisePos(pos);
        pos = Cameras.GetGUICamera().ScreenToWorldPoint(pos);

        singleTransform.position = pos;
    }
Exemplo n.º 4
0
    public override void Awake()
    {
        base.Awake();
        Vector3 pos = new Vector3(GlobalOptions.Vsizex - 15, GlobalOptions.Vsizey - 37, singleTransform.position.z);

        pos = GlobalOptions.NormalisePos(pos);
        pos = Cameras.GetGUICamera().ScreenToWorldPoint(pos);

        singleTransform.position = pos;
    }
Exemplo n.º 5
0
    void Start()
    {
        Vector3 pos = new Vector3(GlobalOptions.Vsizex / 2, GlobalOptions.Vsizey - paddingTop, 1f);

        pos = GlobalOptions.NormalisePos(pos);
        pos = Cameras.GetGUICamera().ScreenToWorldPoint(pos);

        //pos.x = 0f;
        pos.z = 3f;
        singleTransform.position = pos;
    }
Exemplo n.º 6
0
    protected override Vector3 GetOutNotifierPlace(int position)
    {
        Vector3 outPosition;

        outPosition = new Vector3(GlobalOptions.Vsizex / 2, GlobalOptions.Vsizey + 5, -position * Z_INDEX_PER_POSITION);
        outPosition = GlobalOptions.NormalisePos(outPosition);
        outPosition = Cameras.GetGUICamera().ScreenToWorldPoint(outPosition);

        outPosition.y += NOTIFIER_HEIGHT / 2;
        return(outPosition);
    }
Exemplo n.º 7
0
    protected override Vector3 GetInNotifierPlace(int position)
    {
        Vector3 inPostion;

        inPostion = new Vector3(GlobalOptions.Vsizex / 2, GlobalOptions.Vsizey - 15, -position * Z_INDEX_PER_POSITION);
        inPostion = GlobalOptions.NormalisePos(inPostion);
        inPostion = Cameras.GetGUICamera().ScreenToWorldPoint(inPostion);

        inPostion.y -= NOTIFIER_HEIGHT / 2 + NOTIFIER_HEIGHT * position + 0.02f * position;

        return(inPostion);
    }
Exemplo n.º 8
0
    protected virtual void init()
    {
        GUIcamera = Cameras.GetGUICamera();
        perPixel  = Cameras.GuiCameraPixelPerUnit();

        //TouchDispatcher.sharedTouchDispatcher.addTargetedDelegate(this);
        MakeScaling();
        //у объекта есть отображение
        GetSizePos();
        if (!notTouchObject)
        {
            GetSharedTouchDispatcher();
            sharedTouchDispatcher.addTargetedDelegate(this, touchPriority, swallowTouches);
        }
        InitTouchZone();
        alreadyTouched = false;
    }
Exemplo n.º 9
0
    public override void TouchMoved(Vector2 position, int fingerId)
    {
        int fingerNumber = 0;

        //палец 0
        if (fingerId == fingers[1])
        {
            fingerNumber = 1;
        }

        fingerPos[fingerNumber] = position;

        if (numberOfFingers == 1)
        {
            //двигаем карту влево вправо
            Vector2 moveBy = position - initFingerPos[0];
            initFingerPos[0] = position;

            moveBy.x /= perPixel;
            moveBy.y /= perPixel;

            Vector3 pos = new Vector3(singleTransform.localPosition.x + moveBy.x, singleTransform.localPosition.y + moveBy.y, singleTransform.localPosition.z);
            singleTransform.localPosition = Norm(pos);
        }

        //scale
        if (numberOfFingers == 2)
        {
            float rasst, initrasst;
            float newscale;

            Vector2 gipinit, gip;

            //считаем расстояние
            gipinit = new Vector2(initFingerPos[0].x - initFingerPos[1].x, initFingerPos[0].y - initFingerPos[1].y);
            gip     = new Vector2(fingerPos[1].x - fingerPos[0].x, fingerPos[1].y - fingerPos[0].y);

            Vector2 moveBy    = new Vector2(fingerPos[0].x + gip.x / 2 - singleTransform.localPosition.x, fingerPos[0].y + gip.y / 2 - singleTransform.localPosition.y);
            Vector2 moveByOld = new Vector2(moveBy.x * singleTransform.localScale.x, moveBy.y * singleTransform.localScale.y);

            initrasst = Mathf.Sqrt(gipinit.x * gipinit.x + gipinit.y * gipinit.y);
            rasst     = Mathf.Sqrt(gip.x * gip.x + gip.y * gip.y);

            newscale = (rasst - initrasst) / Screen.width;

            curScale = scale + newscale;


            //scale
            curScale = curScale > maxScale?maxScale:curScale;
            curScale = curScale < minScale?minScale:curScale;

            singleTransform.localScale = new Vector3(curScale, curScale, 1);
            ChangeParticleScales();


            Vector2 moveByNew = new Vector2(moveBy.x * curScale, moveBy.y * curScale);

            moveBy  = moveByOld - moveByNew;
            moveBy /= perPixel;
            //position


            Vector2 centerFingerPrev    = new Vector2(prevFingerPos[0].x - (prevFingerPos[0].x - prevFingerPos[1].x) / 2, prevFingerPos[0].y - (prevFingerPos[0].y - prevFingerPos[1].y) / 2);
            Vector2 centerFingerCurrent = new Vector2(fingerPos[0].x - (fingerPos[0].x - fingerPos[1].x) / 2, fingerPos[0].y - (fingerPos[0].y - fingerPos[1].y) / 2);

            //Debug.Log(centerFingerPrev.x+ " "+ centerFingerPrev.y+ " "+ centerFingerCurrent.x+ " "+ centerFingerCurrent.y);


            Camera guiCamera = Cameras.GetGUICamera();

            Vector3 wordCenterFingerCurrent = guiCamera.ScreenToWorldPoint(new Vector3(centerFingerCurrent.x, centerFingerCurrent.y, 1f));
            //Vector2 smCurrent = curScale*wordCenterFingerCurrent;
            Vector2 smPrevNewCenter = prevScale * wordCenterFingerCurrent;


            Vector3 wordCenterFingerPrev = guiCamera.ScreenToWorldPoint(new Vector3(centerFingerPrev.x, centerFingerPrev.y, 1f));
            Vector2 smPrev = prevScale * wordCenterFingerPrev;
            //Vector2 smPrevNewScale = curScale*wordCenterFingerPrev;

            //Debug.LogWarning(wordCenterFingerPrev.x+ " "+wordCenterFingerPrev.y+ " " +wordCenterFingerCurrent.x+" "+wordCenterFingerCurrent.y);

            //точка в старом масштабе сместилась в место между пальцами.



            Vector3 pos = new Vector3(prevPos.x - smPrev.x + smPrevNewCenter.x,
                                      prevPos.y - smPrev.y + smPrevNewCenter.y,
                                      prevPos.z);

            pos = new Vector3(pos.x - (wordCenterFingerCurrent.x - pos.x) * (curScale - prevScale),
                              pos.y - (wordCenterFingerCurrent.y - pos.y) * (curScale - prevScale),
                              pos.z);

            singleTransform.localPosition = Norm(pos);


            prevScale        = singleTransform.localScale.x;
            prevPos          = singleTransform.localPosition;
            prevFingerPos[0] = fingerPos[0];
            prevFingerPos[1] = fingerPos[1];



            //singleTransform.localPosition=newPos;
            //Debug.Log ("moveByx="+moveBy.x+" moveByy="+moveBy.y+" moveByOld="+moveByOld+" moveByNew="+moveByNew+" curScale="+singleTransform.localScale);
        }
    }
Exemplo n.º 10
0
    // Use this for initialization
    public override void Awake()
    {
        base.Awake();
        if (top && bottom || right && left)
        {
            Debug.LogError("check " + gameObject.name);
        }
        if (top && left)
        {
            Vector3 pos = new Vector3(paddingLeft, GlobalOptions.Vsizey - paddingTop, singleTransform.position.z);
            pos = GlobalOptions.NormalisePos(pos);
            pos = Cameras.GetGUICamera().ScreenToWorldPoint(pos);

            pos.x += singleRenderer.bounds.extents.x;
            pos.y -= singleRenderer.bounds.extents.y;

            singleTransform.position = pos;
            return;
        }
        if (top && right)
        {
            Vector3 pos = new Vector3(GlobalOptions.Vsizex - paddingRight, GlobalOptions.Vsizey - paddingTop, singleTransform.position.z);
            pos = GlobalOptions.NormalisePos(pos);
            pos = Cameras.GetGUICamera().ScreenToWorldPoint(pos);

            pos.x -= singleRenderer.bounds.extents.x;
            pos.y -= singleRenderer.bounds.extents.y;

            singleTransform.position = pos;
            return;
        }
        if (bottom && left)
        {
            Vector3 pos = new Vector3(paddingLeft, paddingBottom, singleTransform.position.z);
            pos = GlobalOptions.NormalisePos(pos);
            pos = Cameras.GetGUICamera().ScreenToWorldPoint(pos);

            pos.x += singleRenderer.bounds.extents.x;
            pos.y += singleRenderer.bounds.extents.y;

            singleTransform.position = pos;
            return;
        }
        if (bottom && right)
        {
            Vector3 pos = new Vector3(GlobalOptions.Vsizex - paddingRight, paddingBottom, singleTransform.position.z);
            pos = GlobalOptions.NormalisePos(pos);
            pos = Cameras.GetGUICamera().ScreenToWorldPoint(pos);

            pos.x -= singleRenderer.bounds.extents.x;
            pos.y += singleRenderer.bounds.extents.y;

            singleTransform.position = pos;
            return;
        }

        if (left)
        {
            Vector3 pos = new Vector3(paddingLeft, 0f, singleTransform.position.z);
            pos = GlobalOptions.NormalisePos(pos);
            pos = Cameras.GetGUICamera().ScreenToWorldPoint(pos);

            pos.x += singleRenderer.bounds.extents.x;
            pos.y  = 0f;

            singleTransform.position = pos;
            return;
        }

        if (right)
        {
            Vector3 pos = new Vector3(GlobalOptions.Vsizex - paddingRight, 0f, singleTransform.position.z);
            pos = GlobalOptions.NormalisePos(pos);
            pos = Cameras.GetGUICamera().ScreenToWorldPoint(pos);

            pos.x -= singleRenderer.bounds.extents.x;
            pos.y  = 0f;

            singleTransform.position = pos;
            return;
        }

        if (top)
        {
            Vector3 pos = new Vector3(0f, GlobalOptions.Vsizey - paddingTop, singleTransform.position.z);
            pos = GlobalOptions.NormalisePos(pos);
            pos = Cameras.GetGUICamera().ScreenToWorldPoint(pos);

            pos.x  = 0f;
            pos.y -= singleRenderer.bounds.extents.y;

            singleTransform.position = pos;
            return;
        }

        if (bottom)
        {
            Vector3 pos = new Vector3(0f, paddingBottom, singleTransform.position.z);
            pos = GlobalOptions.NormalisePos(pos);
            pos = Cameras.GetGUICamera().ScreenToWorldPoint(pos);

            pos.x  = 0f;
            pos.y += singleRenderer.bounds.extents.y;

            singleTransform.position = pos;
            return;
        }
    }