Beispiel #1
0
    void OnSpawnLauncherDrag(EntityCommonSpawnLaunch launcher, PointerEventData dat)
    {
        if (mCurSpawnLauncherReady != launcher)
        {
            return;
        }

        Vector2 pos        = dat.pointerPressRaycast.worldPosition;
        Vector2 pointerPos = pointer.position;

        mLastDir  = pos - pointerPos;
        mLastDist = mLastDir.magnitude;
        if (mLastDist > 0f)
        {
            mLastDir /= mLastDist;
        }

        bool valid = Vector2.Angle(Vector2.up, mLastDir) <= launchAngleLimit && mLastDist >= launchRadiusMin;

        SetPointerActive(valid);

        if (valid)
        {
            pointer.position = dat.pointerPressRaycast.worldPosition;
        }
    }
Beispiel #2
0
    void OnSpawnLauncherDragEnd(EntityCommonSpawnLaunch launcher, PointerEventData dat)
    {
        if (mCurSpawnLauncherReady != launcher)
        {
            return;
        }

        //launch
        if (mIsPointerActive)
        {
            SetPointerActive(false);

            mCurSpawnLauncherReady.Launch(mLastDir, GetLaunchForce());
        }

        mCurSpawnLauncherReady = null;
    }
Beispiel #3
0
 void OnSpawnLauncherDragBegin(EntityCommonSpawnLaunch launcher, PointerEventData dat)
 {
     mCurSpawnLauncherReady = launcher;
 }