Beispiel #1
0
    // Token: 0x06000887 RID: 2183 RVA: 0x00037394 File Offset: 0x00035794
    public Vector2 GetVecEx(TouchStick.StickPosMode vis)
    {
        float dirCodeAngle = this.angle;
        float num          = this.tilt;

        switch (vis)
        {
        case TouchStick.StickPosMode.FULL_ANALOG:
            return(this.posRaw);

        case TouchStick.StickPosMode.ANALOG_8WAY:
            dirCodeAngle = TouchStick.GetDirCodeAngle(this.dir8way);
            num          = ((this.dir8way == TouchStick.StickDir.NEUTRAL) ? 0f : num);
            break;

        case TouchStick.StickPosMode.ANALOG_4WAY:
            dirCodeAngle = TouchStick.GetDirCodeAngle(this.dir4way);
            num          = ((this.dir4way == TouchStick.StickDir.NEUTRAL) ? 0f : num);
            break;

        case TouchStick.StickPosMode.DIGITAL_8WAY:
            dirCodeAngle = TouchStick.GetDirCodeAngle(this.dir8way);
            num          = (float)((this.dir8way == TouchStick.StickDir.NEUTRAL) ? 0 : 1);
            break;

        case TouchStick.StickPosMode.DIGITAL_4WAY:
            dirCodeAngle = TouchStick.GetDirCodeAngle(this.dir4way);
            num          = (float)((this.dir4way == TouchStick.StickDir.NEUTRAL) ? 0 : 1);
            break;
        }
        return(TouchStick.RotateVec2(new Vector2(0f, 1f), dirCodeAngle) * num);
    }
Beispiel #2
0
    // Token: 0x06000888 RID: 2184 RVA: 0x0003748C File Offset: 0x0003588C
    public Vector3 GetVec3d(bool normalized, float orientByAngle)
    {
        Vector2 pos = (!normalized) ? this.posRaw : this.dirVec;

        if (orientByAngle != 0f)
        {
            pos = TouchStick.RotateVec2(pos, orientByAngle);
        }
        return(new Vector3(pos.x, 0f, pos.y));
    }
Beispiel #3
0
 // Token: 0x060008BB RID: 2235 RVA: 0x000381F8 File Offset: 0x000365F8
 public static TouchStick.StickDir GetDirCodeFromAngle(float ang, bool as8way)
 {
     ang += ((!as8way) ? 45f : 22.5f);
     ang  = TouchStick.NormalizeAnglePositive(ang);
     if (as8way)
     {
         if (ang < 45f)
         {
             return(TouchStick.StickDir.U);
         }
         if (ang < 90f)
         {
             return(TouchStick.StickDir.UR);
         }
         if (ang < 135f)
         {
             return(TouchStick.StickDir.R);
         }
         if (ang < 180f)
         {
             return(TouchStick.StickDir.DR);
         }
         if (ang < 225f)
         {
             return(TouchStick.StickDir.D);
         }
         if (ang < 270f)
         {
             return(TouchStick.StickDir.DL);
         }
         if (ang < 315f)
         {
             return(TouchStick.StickDir.L);
         }
         return(TouchStick.StickDir.UL);
     }
     else
     {
         if (ang < 90f)
         {
             return(TouchStick.StickDir.U);
         }
         if (ang < 180f)
         {
             return(TouchStick.StickDir.R);
         }
         if (ang < 270f)
         {
             return(TouchStick.StickDir.D);
         }
         return(TouchStick.StickDir.L);
     }
 }
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            {
                touchStick = TouchStickManager.Instance.GetComponentInChildren <TouchStick>();

                if (touchStick != null)
                {
                    touchStick.jsContainer.rectTransform.localScale += new Vector3(resizeamount.GetValue(target), resizeamount.GetValue(target), 0);

                    m_RectTransform = touchStick.jsContainer.rectTransform;


                    touchStick.joystick.rectTransform.anchoredPosition = Vector3.zero;
                }
            }
            return(true);
        }
Beispiel #5
0
    // Token: 0x06000889 RID: 2185 RVA: 0x000374DC File Offset: 0x000358DC
    public Vector3 GetVec3d(TouchStick.Vec3DMode vecMode, bool normalized, float orientByAngle)
    {
        Vector2 pos = (!normalized) ? this.posRaw : this.dirVec;

        if (orientByAngle != 0f)
        {
            pos = TouchStick.RotateVec2(pos, orientByAngle);
        }
        if (vecMode == TouchStick.Vec3DMode.XY)
        {
            return(new Vector3(pos.x, pos.y, 0f));
        }
        if (vecMode != TouchStick.Vec3DMode.XZ)
        {
            return(Vector3.zero);
        }
        return(new Vector3(pos.x, 0f, pos.y));
    }
    //private int uiDisable;

    private void Start()
    {
        PlayerPrefs.SetFloat(mushroomdirection, 0);
        //            // get the transform of the main camera
        //            if (Camera.main != null)
        //            {
        //                m_Cam = Camera.main.transform;
        //            }
        //            else
        //            {
        //                Debug.LogWarning(
        //                    "Warning: no main camera found. Third person character needs a Camera tagged \"MainCamera\", for camera-relative controls.");
        //                // we use self-relative controls in this case, which probably isn't what the user wants, but hey, we warned them!
        //            }

        // get the third person character ( this should never be null due to require component )
        m_Character = GetComponent <ThirdPersonCharacter>();

        walkStick = this.ctrl.GetStick(STICK_WALK);
    }
    private void TouchController()
    {
        if (this.ctrl)
        {
            TouchStick
                walkStick   = this.ctrl.GetStick(STICK_WALK),
                rotateStick = this.ctrl.GetStick(STICK_ROTATE);
            if (IsClick())
            {
                return;
            }

            if (walkStick.Pressed() && false == walkStick.disableGui)
            {
                var playerController = PlayerController.Instance;
                playerController.EnableMove();
                Vector3 PremoveXZ = walkStick.GetVec3d(true, 0);
                playerController.TouchMove(PremoveXZ.x, PremoveXZ.z);
            }

            else if (rotateStick.Pressed() && false == rotateStick.disableGui)
            {
                if (null == CameraController.Instance.cameraController)
                {
                    return;
                }

                Vector3 PreroateXZ = rotateStick.GetVec3d(true, 0);
                CameraController.Instance.cameraController.RotateCamera(PreroateXZ.x, PreroateXZ.z);
            }
            else
            {
                PlayerController.Instance.DisableMove();
            }
        }
    }
Beispiel #8
0
    // ----------------
    public void ControlByTouch()
    {
        if (this.touchCtrl == null)
        {
            return;
        }

        // Get controls' references...

        TouchStick stickWalk  = this.touchCtrl.GetStick(DemoFppGameCS.STICK_WALK);
        TouchZone  zoneAim    = this.touchCtrl.GetZone(DemoFppGameCS.ZONE_AIM);
        TouchZone  zoneFire   = this.touchCtrl.GetZone(DemoFppGameCS.ZONE_FIRE);
        TouchZone  zoneZoom   = this.touchCtrl.GetZone(DemoFppGameCS.ZONE_ZOOM);
        TouchZone  zoneReload = this.touchCtrl.GetZone(DemoFppGameCS.ZONE_RELOAD);


        // If Walk stick is pressed...

        if (stickWalk.Pressed())
        {
            // ... use it's unnormalized direction vector to control walking.

            Vector2 moveVec = stickWalk.GetVec();

            this.SetWalkSpeed(moveVec.y, moveVec.x);
        }

        // Stop walking when stick is released...
        else
        {
            this.SetWalkSpeed(0, 0);
        }


        // Firing...
        // Set weapons trigger by getting the Fire zone pressed state
        // (include mid-frame press)

        this.SetTriggerState(zoneFire.UniPressed(true, false));


        // Reload on Reload zone press (including mid-frame press and release situations).

        if (zoneReload.JustUniPressed(true, true))
        {
            this.ReloadWeapon();
        }


        // Toggle zoom mode, when tapped on zoom-zone...

        if (zoneZoom.JustTapped())
        {
            this.zoomActive = !this.zoomActive;
        }

        // Zoom dragging...

        if (this.zoomActive &&
            zoneZoom.UniPressed(false, false))
        {
            // Store inital zoom factor...

            if (!this.isZoomDragging)
            {
                this.isZoomDragging = true;
                this.zoomFactorRaw  = this.zoomFactor;
            }

            // Change zoom factor by RAW vertical unified-touch drag delta
            // queried in centimeters and scaled...

            this.zoomFactorRaw += (this.zoomFactorPerCm *
                                   zoneZoom.GetUniDragDelta(TouchCoordSys.SCREEN_CM, true).y);

            this.zoomFactor = Mathf.Clamp(this.zoomFactorRaw, 0, 1);
        }
        else
        {
            this.isZoomDragging = false;
        }



        // Aim, when either aim or fire zone if pressed by at least one finger
        // (ignoring mid-frame presses and releases)...

        if (zoneAim.UniPressed(false, false) ||
            zoneFire.UniPressed(false, false))
        {
            // If just started aiming, store initial aim angles...

            if (!this.isAiming)
            {
                this.isAiming   = true;
                this.aimVertRaw = this.aimVert;
                this.aimHorzRaw = this.aimHorz;
            }

            // Get aim delta adding aim-zone and fire-zone's
            // unified-touch RAW drag deltas in centimeters...

            Vector2 aimDelta =
                zoneAim.GetUniDragDelta(TouchCoordSys.SCREEN_CM, true) +
                zoneFire.GetUniDragDelta(TouchCoordSys.SCREEN_CM, true);


            // Apply aim-sensitivity and speed...

            aimDelta *= Mathf.Lerp(0.1f, 1.0f, this.aimSensitivity);

            aimDelta.x *= this.horzAimSpeed;
            aimDelta.y *= this.vertAimSpeed;

            // Add calculated delta to current our raw, non-clamped aim angles
            // and pass them to Aim() function.
            // By keeping separate, non-clamped angles we prevent that
            // uncomfortable effect when dragging past the limit and back again.

            this.aimHorzRaw += aimDelta.x;
            this.aimVertRaw += aimDelta.y;

            //
            this.Aim(this.aimHorzRaw, this.aimVertRaw);
        }
        else
        {
            this.isAiming = false;
        }

        // When double tapped the aim zone - level horizonal aim angle...

        if (zoneAim.JustDoubleTapped())
        {
            this.Aim(this.aimHorz, 0);
        }
    }
// ----------------
    private void Update()
    {
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            DemoSwipeMenuCS.LoadMenuScene();
            return;
        }

        // Manually poll and update the controller...

        this.ctrl.PollController();
        this.ctrl.UpdateController();


        // Control and update the player controller...

        if (this.player != null)
        {
            this.player.ControlByTouch(this.ctrl, this);
            this.player.UpdateChara();
        }



        // Popup box update...

        if (this.popupBox != null)
        {
            if (!this.popupBox.IsVisible())
            {
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    this.popupBox.Show(INSTRUCTIONS_TITLE, INSTRUCTIONS_TEXT,
                                       INSTRUCTIONS_BUTTON_TEXT);
                }
            }
            else
            {
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    this.popupBox.Hide();
                }
            }
        }



        // Control camera...

        TouchZone  zoneScreen = this.ctrl.GetZone(ZONE_SCREEN);
        TouchStick stickWalk  = this.ctrl.GetStick(STICK_WALK);



        // If screen is pressed by two fingers (excluding mid-frame press and release).

        if (zoneScreen.MultiPressed(false, true))
        {
            if (!this.isMultiTouching)
            {
                // If we just started multi-touch, store initial zoom factor.

                this.pinchStartZoom  = this.camZoom;
                this.isMultiTouching = true;

                // Cancel stick's touch if it's shared with our catch-all zone...

                zoneScreen.TakeoverTouches(stickWalk);
            }


            // If pinching is active...

            if (zoneScreen.Pinched())
            {
                // Get pinch distance delta in centimeters (screen-size independence!),
                // then add it to our non-clamped state variable...

                this.pinchStartZoom += this.zoomFactorPerCm *
                                       zoneScreen.GetPinchDistDelta(TouchCoordSys.SCREEN_CM);

                // ... and pass it to proper function when zoom factor will be clamped.

                this.SetZoom(this.pinchStartZoom);
            }
        }

        // If less than two fingers are touching the zone...
        else
        {
            this.isMultiTouching = false;
        }



        // Update camera...

        this.camZoom           = Mathf.Clamp01(this.camZoom);
        this.camZoomForDisplay = Mathf.SmoothDamp(this.camZoomForDisplay, this.camZoom,
                                                  ref this.camZoomVel, this.camSmoothingTime);



        // Place camera...

        this.PlaceCamera();
    }
Beispiel #10
0
    // Token: 0x060008C1 RID: 2241 RVA: 0x00038580 File Offset: 0x00036980
    private void SetInternalPos(Vector2 pos)
    {
        this.pollPos = pos;
        if (this.disableX)
        {
            pos.x = 0f;
        }
        if (this.disableY)
        {
            pos.y = 0f;
        }
        float   num        = Mathf.Clamp01(pos.magnitude);
        Vector2 normalized = this.dirVec;
        float   num2       = this.safeAngle;

        if (num > 0.01f)
        {
            normalized = pos.normalized;
            num2       = Mathf.Atan2(normalized.x, normalized.y) * 57.29578f;
        }
        if (num > ((this.dir8way != TouchStick.StickDir.NEUTRAL) ? this.joy.stickDigitalLeaveThresh : this.joy.stickDigitalEnterThresh))
        {
            if (this.dir8wayLastNonNeutral == TouchStick.StickDir.NEUTRAL)
            {
                this.dir4way = TouchStick.GetDirCodeFromAngle(num2, false);
                this.dir8way = TouchStick.GetDirCodeFromAngle(num2, true);
            }
            else if (num > this.joy.stickDigitalEnterThresh)
            {
                float dirCodeAngle = TouchStick.GetDirCodeAngle(this.dir8wayLastNonNeutral);
                if (Mathf.Abs(Mathf.DeltaAngle(dirCodeAngle, num2)) > 22.5f + this.joy.stickMagnetAngleMargin)
                {
                    this.dir8way = TouchStick.GetDirCodeFromAngle(num2, true);
                }
                else
                {
                    this.dir8way = this.dir8wayLastNonNeutral;
                }
                float dirCodeAngle2 = TouchStick.GetDirCodeAngle(this.dir4wayLastNonNeutral);
                if (Mathf.Abs(Mathf.DeltaAngle(dirCodeAngle2, num2)) > 45f + this.joy.stickMagnetAngleMargin)
                {
                    this.dir4way = TouchStick.GetDirCodeFromAngle(num2, false);
                }
                else
                {
                    this.dir4way = this.dir4wayLastNonNeutral;
                }
            }
        }
        else
        {
            this.dir4way = TouchStick.StickDir.NEUTRAL;
            this.dir8way = TouchStick.StickDir.NEUTRAL;
        }
        if (this.dir4way != TouchStick.StickDir.NEUTRAL)
        {
            this.dir4wayLastNonNeutral = this.dir4way;
        }
        if (this.dir8way != TouchStick.StickDir.NEUTRAL)
        {
            this.dir8wayLastNonNeutral = this.dir8way;
        }
        this.tilt      = num;
        this.angle     = num2;
        this.safeAngle = num2;
        this.posRaw    = normalized * num;
        this.dirVec    = normalized;
    }
Beispiel #11
0
    // ---------------
    void Update()
    {
        // If the game is paused...

        if ((this.popupBox != null) && this.popupBox.IsVisible())
        {
            if (Input.GetKeyUp(KeyCode.Escape))
            {
                this.popupBox.End();
            }

            // Unpause...

            if (this.popupBox.IsComplete())
            {
                this.popupBox.Hide();

                // Enable controller...

                this.ctrl.EnableController();

                // Unpause the player...

                this.player.OnUnpause();
            }
        }

        // When not paused...
        else
        {
            // Return to Main menu...

            if (Input.GetKeyUp(KeyCode.Escape))
            {
                DemoSwipeMenuCS.LoadMenuScene();
                return;
            }


            // Handle input...

            if (this.ctrl)
            {
                // Get stick and zone references by IDs...

                TouchStick
                    walkStick = this.ctrl.GetStick(STICK_WALK),
                    fireStick = this.ctrl.GetStick(STICK_FIRE);
                TouchZone
                //screenZone	= this.ctrl.GetZone(ZONE_SCREEN),
                    pauseZone = this.ctrl.GetZone(ZONE_PAUSE);


                // If the PAUSE zone (or SPACEBAR) is released, show info box...

                if (pauseZone.JustUniReleased() || Input.GetKeyUp(KeyCode.Space))
                {
                    // Show popup box...

                    this.popupBox.Show(INFO_TITLE, INFO_BODY, INFO_BUTTON_TEXT);

                    // Disable controller to stop it from reacting to touch input...

                    this.ctrl.DisableController();

                    // Pause the game...

                    this.player.OnPause();
                }

                else
                {
                    // Walk when left stick is pressed...

                    if (walkStick.Pressed())
                    {
                        // Use stick's normalized XZ vector and tilt to move...

                        this.player.Move(walkStick.GetVec3d(true, 0), walkStick.GetTilt());
                    }

                    // Stop when stick is released...

                    else
                    {
                        this.player.Move(Vector3.zero, 0);
                    }


                    // Shoot when right stick is pressed...

                    if (fireStick.Pressed())
                    {
                        this.player.SetTriggerState(true);

                        // Get target angle and stick's tilt to determinate turning speed.

                        this.player.Aim(fireStick.GetAngle(), fireStick.GetTilt());
                    }

                    // ...or stop shooting and aiming when right stick is released.

                    else
                    {
                        this.player.SetTriggerState(false);
                        this.player.Aim(0, 0);
                    }
                }
            }
        }


        // Update character...

        this.player.UpdateChara();


        // Update camera...

        if (this.cam != null)
        {
            Transform camTf = this.cam.transform;
            camTf.position = this.player.transform.position + this.camOfs;
        }
    }
Beispiel #12
0
    // ----------------------
    // Update()
    // ----------------------

    void Update()
    {
        if (this.ctrl != null)
        {
            // ----------------------
            // Stick and Zone Variables
            // ----------------------

            TouchStick walkStick  = this.ctrl.GetStick(STICK_WALK);
            TouchZone  actionZone = this.ctrl.GetZone(ZONE_ACTION);
            TouchZone  screenZone = this.ctrl.GetZone(ZONE_SCREEN);


            // ----------------------
            // Input Handling Code
            // ----------------------

            // ----------------
            // Stick 'Walk'...
            // ----------------

            if (walkStick.Pressed())
            {
                Vector2             walkVec      = walkStick.GetVec();
                float               walkTilt     = walkStick.GetTilt();
                float               walkAngle    = walkStick.GetAngle();
                TouchStick.StickDir walkDir      = walkStick.GetDigitalDir(true);
                Vector3             walkWorldVec = walkStick.GetVec3d(false, 0);

                // Your code here.
            }

            // ----------------
            // Zone 'Action'...
            // ----------------

            if (actionZone.JustUniPressed())
            {
                Vector2 actionPressStartPos = actionZone.GetUniStartPos(TouchCoordSys.SCREEN_PX);
            }

            // Uni-touch pressed...

            if (actionZone.UniPressed())
            {
                float   actionUniDur          = actionZone.GetMultiTouchDuration();
                Vector2 actionUniPos          = actionZone.GetMultiPos();
                Vector2 actionUniDragDelta    = actionZone.GetMultiDragDelta();
                Vector2 actionUniRawDrawDelta = actionZone.GetMultiDragDelta(true);
            }


            // Uni-Touch Just Released

            if (actionZone.JustUniReleased())
            {
                Vector2 actionUniRelStartPos = actionZone.GetReleasedUniStartPos();
                Vector2 actionUniRelEndPos   = actionZone.GetReleasedUniEndPos();
                int     actionUniRelStartBox = TouchZone.GetBoxPortion(2, 2, actionZone.GetReleasedUniStartPos(TouchCoordSys.SCREEN_NORMALIZED));
                int     actionUniRelEndBox   = TouchZone.GetBoxPortion(2, 2, actionZone.GetReleasedUniEndPos(TouchCoordSys.SCREEN_NORMALIZED));

                Vector2 actionUniRelDragVel = actionZone.GetReleasedUniDragVel();
                Vector2 actionUniRelDragVec = actionZone.GetReleasedUniDragVec();
            }


            // ----------------
            // Zone 'SCREEN'...
            // ----------------

            if (screenZone.JustMultiPressed())
            {
                Vector2 screenMultiPressStartPos = screenZone.GetMultiStartPos(TouchCoordSys.SCREEN_PX);
            }

            if (screenZone.JustUniPressed())
            {
                Vector2 screenPressStartPos = screenZone.GetUniStartPos(TouchCoordSys.SCREEN_PX);
            }

            // Multi-Pressed...

            if (screenZone.MultiPressed())
            {
                float   screenMultiDur          = screenZone.GetMultiTouchDuration();
                Vector2 screenMultiPos          = screenZone.GetMultiPos();
                Vector2 screenMultiDragDelta    = screenZone.GetMultiDragDelta();
                Vector2 screenMultiRawDrawDelta = screenZone.GetMultiDragDelta(true);


                // Multi-touch drag...

                if (screenZone.JustMultiDragged())
                {
                }

                if (screenZone.MultiDragged())
                {
                }

                // Just Twisted...

                if (screenZone.JustTwisted())
                {
                }

                // Twisted...

                if (screenZone.Twisted())
                {
                    float screenTwistDelta = screenZone.GetTwistDelta();
                    float screenTwistTotal = screenZone.GetTotalTwist();
                }

                // Just Pinched...

                if (screenZone.JustPinched())
                {
                }

                // Pinched...

                if (screenZone.Pinched())
                {
                    float screenPinchRelScale = screenZone.GetPinchRelativeScale();
                    float screenPinchAbsScale = screenZone.GetPinchScale();
                    float screenFingerDist    = screenZone.GetPinchDist();
                }
            }

            // Uni-touch pressed...

            if (screenZone.UniPressed())
            {
                float   screenUniDur          = screenZone.GetMultiTouchDuration();
                Vector2 screenUniPos          = screenZone.GetMultiPos();
                Vector2 screenUniDragDelta    = screenZone.GetMultiDragDelta();
                Vector2 screenUniRawDrawDelta = screenZone.GetMultiDragDelta(true);


                // Just Uni-touch dragged...

                if (screenZone.JustUniDragged())
                {
                }

                // Uni-Touch drag...

                if (screenZone.UniDragged())
                {
                }
            }


            // Multi-Touch Just Released

            if (screenZone.JustMultiReleased())
            {
                Vector2 screenMultiRelStartPos = screenZone.GetReleasedMultiStartPos();
                Vector2 screenMultiRelEndPos   = screenZone.GetReleasedMultiEndPos();
                int     screenMultiRelStartBox = TouchZone.GetBoxPortion(2, 2, screenZone.GetReleasedMultiStartPos(TouchCoordSys.SCREEN_NORMALIZED));
                int     screenMultiRelEndBox   = TouchZone.GetBoxPortion(2, 2, screenZone.GetReleasedMultiEndPos(TouchCoordSys.SCREEN_NORMALIZED));

                Vector2 screenMultiRelDragVel = screenZone.GetReleasedMultiDragVel();
                Vector2 screenMultiRelDragVec = screenZone.GetReleasedMultiDragVec();

                // Released multi-touch was dragged...

                if (screenZone.ReleasedMultiDragged())
                {
                }

                // Released multi-touch was twisted...

                if (screenZone.ReleasedTwisted())
                {
                    float screenRelTwistAngle = screenZone.GetReleasedTwistAngle();
                    float screenRelTwistVel   = screenZone.GetReleasedTwistVel();
                }

                // Released multi-touch was pinched...

                if (screenZone.ReleasedPinched())
                {
                    float screenRelPinchStartDist = screenZone.GetReleasedPinchStartDist();
                    float screenRelPinchEndDist   = screenZone.GetReleasedPinchEndDist();
                    float screenRelPinchScale     = screenZone.GetReleasedPinchScale();
                }
            }


            // Uni-Touch Just Released

            if (screenZone.JustUniReleased())
            {
                Vector2 screenUniRelStartPos = screenZone.GetReleasedUniStartPos();
                Vector2 screenUniRelEndPos   = screenZone.GetReleasedUniEndPos();
                int     screenUniRelStartBox = TouchZone.GetBoxPortion(2, 2, screenZone.GetReleasedUniStartPos(TouchCoordSys.SCREEN_NORMALIZED));
                int     screenUniRelEndBox   = TouchZone.GetBoxPortion(2, 2, screenZone.GetReleasedUniEndPos(TouchCoordSys.SCREEN_NORMALIZED));

                Vector2 screenUniRelDragVel = screenZone.GetReleasedUniDragVel();
                Vector2 screenUniRelDragVec = screenZone.GetReleasedUniDragVec();


                // Released uni-touch was dragged...

                if (screenZone.ReleasedUniDragged())
                {
                }
            }


            // Double multi-finger tap...

            if (screenZone.JustMultiDoubleTapped())
            {
                Vector2 screenMultiDblTapPos = screenZone.GetMultiTapPos();
            }
            else

            // Simple multi-finger tap...

            if (screenZone.JustMultiTapped())
            {
                Vector2 screenMultiTapPos = screenZone.GetMultiTapPos();
            }
            else

            // Double one-finger tap...

            if (screenZone.JustDoubleTapped())
            {
                Vector2 screenDblTapPos = screenZone.GetTapPos();
            }
            else

            // Simple one-finger tap...

            if (screenZone.JustTapped())
            {
                Vector2 screenTapPos = screenZone.GetTapPos();
            }
        }
    }
    public void EnableroatateStick()
    {
        TouchStick rotateStick = this.ctrl.GetStick(STICK_ROTATE);

        rotateStick.disableGui = false;
    }
    public void EnablewalkStick()
    {
        TouchStick walkStick = this.ctrl.GetStick(STICK_WALK);

        walkStick.disableGui = false;
    }
        // ----------------
        public ControlParams(TouchControllerCodeTemplateGenerator cfg, 
			TouchZone zone, int id)
        {
            this.cfg		= cfg;
            this.zone 		= zone;
            this.stick		= null;
            this.constVal 	= id;
            this.srcName	= zone.name;
            this.varName	= "";
            this.constName	= "";
            this.prefix		= "";

            this.GenNames();
        }
Beispiel #16
0
        // EXECUTABLE: ----------------------------------------------------------------------------

        public override bool InstantExecute(GameObject target, IAction[] actions, int index)
        {
            {
                touchStick = TouchStickManager.Instance.GetComponentInChildren <TouchStick>();
                if (touchStick != null)
                {
                    m_RectTransform = touchStick.jsContainer.rectTransform;
                }

                if (resized == true)
                {
                    if (touchStick != null)
                    {
                        touchStick.jsContainer.rectTransform.localScale += new Vector3(resizeamount.GetValue(target), resizeamount.GetValue(target), 0);
                        tswidth = (m_RectTransform.rect.width * (resizeamount.GetValue(target) + 1));
                    }
                }
                else
                {
                    if (touchStick != null)
                    {
                        touchStick.jsContainer.rectTransform.localScale += new Vector3(0, 0, 0);
                        tswidth = (m_RectTransform.rect.width * (0 + 1));
                    }
                }

                if (touchStick != null)
                {
                    switch (this.stickPostion)
                    {
                    case STICKPOSITION.BottomLeft:
                        touchStick.jsContainer.rectTransform.anchoredPosition     = new Vector3(0, 0);
                        GameCreator.Camera.CameraMotorTypeAdventure.MOBILE_RECT   = new Rect(0.5f, 0.0f, 0.5f, 1.0f);
                        GameCreator.Camera.CameraMotorTypeFirstPerson.MOBILE_RECT = new Rect(0.5f, 0.0f, 0.5f, 1.0f);

                        break;

                    case STICKPOSITION.TopLeft:
                        touchStick.jsContainer.rectTransform.anchoredPosition     = new Vector3(0, Screen.height - (tswidth));
                        GameCreator.Camera.CameraMotorTypeAdventure.MOBILE_RECT   = new Rect(0.5f, 0.0f, 0.5f, 1.0f);
                        GameCreator.Camera.CameraMotorTypeFirstPerson.MOBILE_RECT = new Rect(0.5f, 0.0f, 0.5f, 1.0f);

                        break;

                    case STICKPOSITION.TopRight:
                        touchStick.jsContainer.rectTransform.anchoredPosition     = new Vector3(Screen.width - (+tswidth), Screen.height - (tswidth));
                        GameCreator.Camera.CameraMotorTypeAdventure.MOBILE_RECT   = new Rect(0.0f, 0.0f, 0.5f, 1.0f);
                        GameCreator.Camera.CameraMotorTypeFirstPerson.MOBILE_RECT = new Rect(0.0f, 0.0f, 0.5f, 1.0f);
                        break;

                    case STICKPOSITION.BottomRight:
                        touchStick.jsContainer.rectTransform.anchoredPosition     = new Vector3(Screen.width - (tswidth), 0);
                        GameCreator.Camera.CameraMotorTypeAdventure.MOBILE_RECT   = new Rect(0.0f, 0.0f, 0.5f, 1.0f);
                        GameCreator.Camera.CameraMotorTypeFirstPerson.MOBILE_RECT = new Rect(0.0f, 0.0f, 0.5f, 1.0f);


                        break;
                    }



                    touchStick.joystick.rectTransform.anchoredPosition = Vector3.zero;
                }
            }
            return(true);
        }
Beispiel #17
0
 // Token: 0x060008B0 RID: 2224 RVA: 0x00038084 File Offset: 0x00036484
 public Rect GetHatDisplayRect(bool applyScale)
 {
     return(TouchController.GetCenRect(this.posPx + TouchStick.InternalToScreenPos(this.displayPos) * this.radPx * this.hatMoveScale, 2f * this.radPx * ((!applyScale) ? 1f : this.animHatScale.cur)));
 }
Beispiel #18
0
// --------------------
    public void ControlByTouch(TouchController ctrl, DemoRpgGameCS game)
    {
        TouchStick
            stickWalk = ctrl.GetStick(DemoRpgGameCS.STICK_WALK);
        TouchZone
            zoneScreen = ctrl.GetZone(DemoRpgGameCS.ZONE_SCREEN),
            zoneAction = ctrl.GetZone(DemoRpgGameCS.ZONE_ACTION),
            zoneFire   = ctrl.GetZone(DemoRpgGameCS.ZONE_FIRE);



        // Get stick's normalized direction in world space relative to camera's angle...

        Vector3 moveWorldDir = stickWalk.GetVec3d(TouchStick.Vec3DMode.XZ, true, game.camOrbitalAngle);


        // Get stick's angle in world space by adding it to camera's angle..

        float stickWorldAngle = stickWalk.GetAngle() + game.camOrbitalAngle;


        // Get walking speed from stick's current tilt...

        float speed = stickWalk.GetTilt();


        // Get gun's trigger state by checking Fire zone's state (including mid-frame press)

        bool gunTriggerState = zoneFire.UniPressed(true, false);


        // Check if Action should be performed - either by pressing the Action button or
        // by tapping on the right side of the screen...

        bool performAction =
            zoneAction.JustUniPressed(true, true) ||
            zoneScreen.JustTapped();



        if ((this.charaState == CharaState.IDLE) ||
            (this.charaState == CharaState.WALK) ||
            (this.charaState == CharaState.RUN))
        {
            if (speed > this.walkStickThreshold)
            {
                float moveSpeed = 0;

                // Walk...

                if (speed < this.runStickThreshold)
                {
                    moveSpeed = this.walkSpeed;

                    if (this.charaState != CharaState.WALK)
                    {
                        this.StartWalking();
                    }

                    // Set animation speed...

                    this.charaAnim[this.ANIM_WALK_F].speed = this.walkAnimSpeed;
                }

                // Run!

                else
                {
                    moveSpeed = this.runSpeed;

                    if (this.charaState != CharaState.RUN)
                    {
                        this.StartRunning();
                    }

                    // Set animation speed...

                    this.charaAnim[this.ANIM_RUN_F].speed = this.runAnimSpeed;
                }



                // Update player's angle...

                this.angle = DampAngle(this.angle, stickWorldAngle, this.angleSmoothingTime, this.turnMaxSpeed, Time.deltaTime);

                // Move player's collider...

                this.charaCtrl.Move(moveWorldDir * moveSpeed * Time.deltaTime);
            }

            else if ((this.charaState == CharaState.WALK) || (this.charaState == CharaState.RUN))
            {
                // Stop...

                this.StartIdle();
            }


            // Perform Action...

            if (performAction)
            {
                this.PerformUseAction();
            }
        }


        // Every other state than USE...

        if (this.charaState != CharaState.USE)
        {
            if (this.gun != null)
            {
                this.gun.SetTriggerState(gunTriggerState);
            }

            if (performAction)
            {
                this.PerformUseAction();
            }
        }

        // USE state updates...

        else
        {
            if (this.gun != null)
            {
                this.gun.SetTriggerState(false);
            }

            this.useElapsed += Time.deltaTime;
            if (this.useElapsed > this.useAnimDuration)
            {
                this.StartIdle();
            }
        }
    }