예제 #1
0
        private void Test()
        {
            if (!mTestWithKey)
            {
                return;
            }

            if (JCS_Input.GetKey(mFirstAnimKey))
            {
                DoAnimation(0, true);
            }

            if (JCS_Input.GetKey(mSecondAnimKey))
            {
                DoAnimation(1, false);
            }

            if (JCS_Input.GetKey(mThirdAnimKey))
            {
                DoAnimation(2, true);
            }

            if (JCS_Input.GetKey(mPlayOneShotAnimKey))
            {
                PlayOneShot(0);
            }
        }
예제 #2
0
        /// <summary>
        /// Process the input of this camera.
        /// </summary>
        private void InputCamera()
        {
#if (UNITY_EDITOR || UNITY_STANDALONE)
            if (JCS_Input.GetKeyDown(mResetKeyCode))
            {
                ResetCamera();
            }

            if (JCS_Input.GetKeyDown(mUpKey))
            {
                UpCamera();
            }
            else if (JCS_Input.GetKeyDown(mDownKey))
            {
                DownCamera();
            }

            if (JCS_Input.GetKey(mRotateAroundLeft))
            {
                RotateAroundLeft();
            }
            else if (JCS_Input.GetKey(mRotateAroundRight))
            {
                RotateAroundRight();
            }
#endif
        }
예제 #3
0
 private void Test()
 {
     if (JCS_Input.GetKey(KeyCode.Y))
     {
         DoShake();
     }
 }
예제 #4
0
        private void HandleFacing()
        {
            if (mLookPoint == null)
            {
                return;
            }

            JCS_Camera cam = JCS_Camera.main;

            Vector3 newPos    = this.transform.localPosition;
            Vector3 direction = Vector3.zero;

            if (JCS_Input.GetKey(mUpKey))
            {
                direction = cam.transform.forward;
            }
            else if (JCS_Input.GetKey(mDownKey))
            {
                direction = -cam.transform.forward;
            }

            if (JCS_Input.GetKey(mRightKey))
            {
                direction += cam.transform.right;
            }
            else if (JCS_Input.GetKey(mLeftKey))
            {
                direction += -cam.transform.right;
            }

            mLookPoint.localPosition = newPos + direction * mLookDistance;
        }
        protected override void FixedUpdate()
        {
            base.FixedUpdate();

            if (JCS_Input.GetKeyDown(KeyCode.H))
            {
                JCS_SceneManager.instance.LoadScene("JCS_SideScrollerDemo");
            }


            if (mIndex == 0)
            {
                if (JCS_Input.GetKey(KeyCode.UpArrow))
                {
                    GoUp();
                }
                else if (JCS_Input.GetKey(KeyCode.DownArrow))
                {
                    GoDown();
                }

                else if (JCS_Input.GetKey(KeyCode.RightArrow))
                {
                    GoRight();
                }
                else if (JCS_Input.GetKey(KeyCode.LeftArrow))
                {
                    GoLeft();
                }
                else
                {
                    Idle();
                }
            }

            if (mIndex == 1)
            {
                if (JCS_Input.GetKey(KeyCode.W))
                {
                    GoUp();
                }
                else if (JCS_Input.GetKey(KeyCode.S))
                {
                    GoDown();
                }

                else if (JCS_Input.GetKey(KeyCode.D))
                {
                    GoRight();
                }
                else if (JCS_Input.GetKey(KeyCode.A))
                {
                    GoLeft();
                }
                else
                {
                    Idle();
                }
            }
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private bool CheckClimbDirection()
        {
            // no climbing object, no climbing!
            if (m2DClimbingObject == null)
            {
                return(false);
            }

            if (m2DClimbingObject.IsOpTopOfLeanPlatform(this) && !JCS_Input.GetKey(mClimbDownKey))
            {
                return(false);
            }

            // when is in air, character can climb what ever
            if (!isGrounded())
            {
                return(true);
            }

            JCS_ClimbMoveType keyInput = JCS_ClimbMoveType.IDLE;

            // process input
            if (JCS_Input.GetKey(this.ClimbUpKey))
            {
                keyInput = JCS_ClimbMoveType.MOVE_UP;
            }
            else if (JCS_Input.GetKey(this.mClimbDownKey))
            {
                keyInput = JCS_ClimbMoveType.MOVE_DOWN;
            }


            switch (keyInput)
            {
            case JCS_ClimbMoveType.IDLE: return(true);

            case JCS_ClimbMoveType.MOVE_UP:
            {
                if (this.transform.position.y < this.m2DClimbingObject.transform.position.y)
                {
                    return(true);
                }
            }
            break;

            case JCS_ClimbMoveType.MOVE_DOWN:
            {
                if (this.transform.position.y > this.m2DClimbingObject.transform.position.y)
                {
                    return(true);
                }
            }
            break;
            }

            return(false);
        }
예제 #7
0
        //----------------------
        // Protected Functions

        //----------------------
        // Private Functions

        /// <summary>
        ///
        /// </summary>
        private void ProcessInput()
        {
            if (!mOverrideAction)
            {
                if (!mAction &&
                    JCS_Input.GetKey(mKeyCode))
                {
                    // display animation
                    SpawnAttackAnimation();

                    // display sound
                    SpawnSwignSound();

                    mAction = true;
                }

                if (mAfterDelay)
                {
                    mActionTimer += Time.deltaTime;

                    if (mActTime < mActionTimer)
                    {
                        // close trigger
                        EndAttack();

                        // reset timer
                        mActionTimer = 0;

                        // can do the next shoot
                        mAction = false;

                        // exit delay process
                        mAfterDelay = false;
                    }
                }

                if (mAction && !mAfterDelay)
                {
                    mActionTimer += Time.deltaTime;

                    if (mTimeToActTime < mActionTimer)
                    {
                        // active trigger
                        Attack();

                        // start after delay timer.
                        mAfterDelay = true;

                        // reset timer for "mAfterDelay" Trigger.
                        mActionTimer = 0;
                    }
                }
            }
        }
예제 #8
0
 private void Test()
 {
     if (JCS_Input.GetKey(mDeltaToA))
     {
         UpdateScore(mDeltaValueA);
     }
     if (JCS_Input.GetKey(mDeltaToB))
     {
         UpdateScore(mDeltaValueB);
     }
 }
예제 #9
0
        private void Test()
        {
            if (!mTestWithKey)
            {
                return;
            }

            if (JCS_Input.GetKey(mDoShakeEffectKey))
            {
                DoShake();
            }
        }
예제 #10
0
        protected virtual void OnTriggerStay(Collider other)
        {
            if (mAutoPickColliderTouched)
            {
                // picked
                Pick(other);
                return;
            }

            if (JCS_Input.GetKey(mPickKey))
            {
                Pick(other);
            }
        }
예제 #11
0
        /// <summary>
        /// Check if the player down jumping.
        /// </summary>
        /// <returns></returns>
        public bool IsDownJump()
        {
            if (!mCanDownJump)
            {
                return(false);
            }

            if (JCS_Input.GetKey(JumpKey) && JCS_Input.GetKey(DownKey))
            {
                return(true);
            }

            return(false);
        }
예제 #12
0
        private void Test()
        {
            if (!mTestWithKey)
            {
                return;
            }

            if (JCS_Input.GetKey(mDeltaToA))
            {
                UpdateScore(mDeltaValueA);
            }
            if (JCS_Input.GetKey(mDeltaToB))
            {
                UpdateScore(mDeltaValueB);
            }
        }
예제 #13
0
        protected override void PlayerInput()
        {
            if (JCS_Input.GetKey(mUpKey) || JCS_Input.GetKey(mDownKey) ||
                JCS_Input.GetKey(mLeftKey) || JCS_Input.GetKey(mRightKey))
            {
                mVelocity.z = mMoveSpeed;
            }
            else
            {
                mVelocity.z = 0;
            }

            if (JCS_Input.GetKeyDown(KeyCode.Space))
            {
                mVelocity.y = mJumpForce;
            }
        }
예제 #14
0
        //========================================
        //      Self-Define
        //------------------------------
        //----------------------
        // Public Functions

        /// <summary>
        ///
        /// </summary>
        public void DoPortal(JCS_3DPortalType type, JCS_Player player)
        {
            switch (type)
            {
            case JCS_3DPortalType.SCENE_PORTAL:
            {
                if (!mAutoTrigger)
                {
                    if (JCS_Input.GetKey(mKeyToTrigger))
                    {
                        JCS_SceneManager.instance.LoadScene(mSceneName);
                    }
                }
                else
                {
                    // auto do the action
                    JCS_SceneManager.instance.LoadScene(mSceneName);
                }
            }
            break;

            case JCS_3DPortalType.TRANSFER_PORTAL:
            {
                if (!mAutoTrigger)
                {
                    if (JCS_Input.GetKeyDown(mKeyToTrigger))
                    {
                        if (mTargetPortal != null)
                        {
                            player.transform.position = mTargetPortal.position;
                        }
                    }
                }
                else
                {
                    // auto do the action
                    if (mTargetPortal != null)
                    {
                        player.transform.position = mTargetPortal.position;
                    }
                }
            }
            break;
            }
        }
예제 #15
0
        /// <summary>
        /// Handle skill prevent the skill go to fast.
        /// </summary>
        private void ProcessInput()
        {
            if (!mAction)
            {
                if (JCS_Input.GetKey(mKeyCode))
                {
                    mAction = true;
                }
            }

            if (mAfterDelay)
            {
                mActionTimer += Time.deltaTime;

                if (mActiveTime < mActionTimer)
                {
                    // reset timer
                    mActionTimer = 0;

                    // can do the next shoot
                    mAction = false;

                    // exit delay process
                    mAfterDelay = false;
                }
            }

            if (mAction && !mAfterDelay)
            {
                mActionTimer += Time.deltaTime;

                if (mTimeToActive < mActionTimer)
                {
                    // Do shooting effect
                    ActiveSkill();

                    // start after delay timer.
                    mAfterDelay = true;

                    // reset timer for "mAfterDelay" Trigger.
                    mActionTimer = 0;
                }
            }
        }
예제 #16
0
        private void Test()
        {
            float speed = 2;

            // Test..
            if (JCS_Input.GetKey(mRightKey))
            {
                VelX = speed;
            }
            else if (JCS_Input.GetKey(mLeftKey))
            {
                VelX = -speed;
            }
            else
            {
                VelX = 0;
            }

            if (JCS_Input.GetKey(mJumpKey))
            {
                Jump();
            }
        }
예제 #17
0
        /// <summary>
        /// Play input's design.
        /// </summary>
        protected virtual void PlayerInput()
        {
            if (JCS_Input.GetKey(KeyCode.RightArrow))
            {
                mVelocity.x = mMoveSpeed;
            }
            else if (JCS_Input.GetKey(KeyCode.LeftArrow))
            {
                mVelocity.x = -mMoveSpeed;
            }
            else
            {
                mVelocity.x = 0;
            }

            if (JCS_Input.GetKey(KeyCode.UpArrow))
            {
                mVelocity.z = mMoveSpeed;
            }
            else if (JCS_Input.GetKey(KeyCode.DownArrow))
            {
                mVelocity.z = -mMoveSpeed;
            }
            else
            {
                mVelocity.z = 0;
            }

            if (JCS_Input.GetKey(KeyCode.L))
            {
                this.transform.Rotate(Vector3.up * mRotateSpeed * Time.deltaTime);
            }
            else if (JCS_Input.GetKey(KeyCode.J))
            {
                this.transform.Rotate(Vector3.up * -mRotateSpeed * Time.deltaTime);
            }
        }
예제 #18
0
        /// <summary>
        /// Process the user input.
        /// </summary>
        private void ProcessInput()
        {
            if (!mAction)
            {
                if (JCS_Input.GetMouseByAction(mKeyAct, mMouseButton))
                {
                    mAction = true;
                }

                if (JCS_Input.GetKey(mShootKeyCode))
                {
                    mAction = true;
                }
            }

            if (mAfterDelay)
            {
                mActionTimer += Time.deltaTime;

                if (mTimeDelayAfterShoot < mActionTimer)
                {
                    // reset timer
                    mActionTimer = 0;

                    // can do the next shoot
                    mAction = false;

                    // exit delay process
                    mAfterDelay = false;
                }
            }

            if (mAction && !mAfterDelay)
            {
                mActionTimer += Time.deltaTime;

                if (mTimeBeforeShoot < mActionTimer)
                {
                    // do call back
                    mShootCallback.Invoke();


                    // check able to shoot before shoot.
                    if (mCheckAbleToShoot.Invoke())
                    {
                        // Do shooting effect
                        for (int count = 0;
                             count < mShootCount;
                             ++count)
                        {
                            Shoot();
                        }
                    }

                    // start after delay timer.
                    mAfterDelay = true;

                    // reset timer for "mAfterDelay" Trigger.
                    mActionTimer = 0;
                }
            }
        }
예제 #19
0
        /// <summary>
        /// While character are climbing.
        /// </summary>
        private void CharacterClimbing()
        {
            mJumpCount = 0;

            if (!mStartClimbing)
            {
                if (!mAutoClimb)
                {
                    if (!GetCharacterAnimator().IsInState((int)JCS_LiveObjectState.STAND) &&
                        !GetCharacterAnimator().IsInState((int)JCS_LiveObjectState.JUMP) &&
                        !GetCharacterAnimator().IsInState((int)JCS_LiveObjectState.WALK))
                    {
                        ExitClimbing(0);
                        return;
                    }
                }

                if (m2DClimbingObject == null)
                {
                    ExitClimbing(0);
                    return;
                }

                mStartClimbing = true;
            }

            if (CanLadder)
            {
                Ladder();
            }
            else if (CanRope)
            {
                Rope();
            }
            else
            {
                ExitClimbing(0);
                return;
            }

            // while climbing zero jump count.
            mJumpCount = 0;

            mClimbMoveType = JCS_ClimbMoveType.IDLE;

            if (mAutoClimb)
            {
                mClimbMoveType = mAutoClimbDirection;
            }
            else
            {
                // process input
                if (JCS_Input.GetKey(this.ClimbUpKey))
                {
                    mClimbMoveType = JCS_ClimbMoveType.MOVE_UP;
                }
                else if (JCS_Input.GetKey(this.mClimbDownKey))
                {
                    mClimbMoveType = JCS_ClimbMoveType.MOVE_DOWN;
                }
                else
                {
                    mClimbMoveType = JCS_ClimbMoveType.IDLE;
                    GetCharacterAnimator().StopAnimationInFrame();
                }
            }

            bool climbing = false;

            // process velocity
            switch (mClimbMoveType)
            {
            case JCS_ClimbMoveType.IDLE:
                this.mVelocity.y = 0;
                break;

            case JCS_ClimbMoveType.MOVE_UP:
                this.mVelocity.y = MoveSpeed;
                climbing         = true;
                break;

            case JCS_ClimbMoveType.MOVE_DOWN:
                this.mVelocity.y = -MoveSpeed;
                climbing         = true;
                break;
            }

            if (climbing)
            {
                if (m2DClimbingObject == null)
                {
                    ExitClimbing(0);
                    return;
                }

                // let x axis the same as ladder x axis.
                Vector3 newPos = this.transform.position;
                newPos.x = m2DClimbingObject.transform.position.x;
                this.transform.position = newPos;

                // start the animation agian
                GetCharacterAnimator().PlayAnimationInFrame();
            }
            else
            {
                if (JCS_Input.GetKey(this.JumpKey) ||
                    JCS_Input.GetKey(this.JumpKey))
                {
                    if (JCS_Input.GetKey(this.LeftKey) ||
                        JCS_Input.GetKey(this.RightKey))
                    {
                        ExitClimbing();
                        mExitingClimbing = true;
                    }
                }
            }

            if (isGrounded())
            {
                ExitClimbing(0);
            }
        }
예제 #20
0
        private void Test()
        {
            if (!mTestWithKey)
            {
                return;
            }

            if (JCS_Input.GetKey(KeyCode.F1))
            {
                SwitchState(JCS_CursorCustomizeType.NORMAL_SELECT);
            }
            if (JCS_Input.GetKey(KeyCode.F2))
            {
                SwitchState(JCS_CursorCustomizeType.HELP_SELECT);
            }
            if (JCS_Input.GetKey(KeyCode.F3))
            {
                SwitchState(JCS_CursorCustomizeType.WORKING_IN_BACKGROUND);
            }
            if (JCS_Input.GetKey(KeyCode.F4))
            {
                SwitchState(JCS_CursorCustomizeType.BUSY);
            }
            if (JCS_Input.GetKey(KeyCode.F5))
            {
                SwitchState(JCS_CursorCustomizeType.PRECISION_SELECT);
            }
            if (JCS_Input.GetKey(KeyCode.F6))
            {
                SwitchState(JCS_CursorCustomizeType.TEXT_SELECT);
            }
            if (JCS_Input.GetKey(KeyCode.F7))
            {
                SwitchState(JCS_CursorCustomizeType.HANDWRITING);
            }
            if (JCS_Input.GetKey(KeyCode.F8))
            {
                SwitchState(JCS_CursorCustomizeType.UNAVAILABLE);
            }
            if (JCS_Input.GetKey(KeyCode.F9))
            {
                SwitchState(JCS_CursorCustomizeType.VERTICAL_RESIZE);
            }
            if (JCS_Input.GetKey(KeyCode.F10))
            {
                SwitchState(JCS_CursorCustomizeType.HORIZONTAL_RESIZE);
            }
            if (JCS_Input.GetKey(KeyCode.F11))
            {
                SwitchState(JCS_CursorCustomizeType.DIAGONAL_RESIZE_1);
            }
            if (JCS_Input.GetKey(KeyCode.F12))
            {
                SwitchState(JCS_CursorCustomizeType.DIAGONAL_RESIZE_2);
            }
            if (JCS_Input.GetKey(KeyCode.F13))
            {
                SwitchState(JCS_CursorCustomizeType.MOVE);
            }
            if (JCS_Input.GetKey(KeyCode.F14))
            {
                SwitchState(JCS_CursorCustomizeType.ALTERNATE_SELECT);
            }
            if (JCS_Input.GetKey(KeyCode.F15))
            {
                SwitchState(JCS_CursorCustomizeType.LINK_SELECT);
            }
        }
예제 #21
0
        /// <summary>
        /// Process/Handle the inputs from the user.
        /// </summary>
        private void ProcessInput()
        {
            if (!mAction)
            {
                if (JCS_Input.GetKey(mShootAction.ShootKeyCode) ||
                    JCS_Input.GetMouseByAction(mShootAction.KeyAct, mShootAction.MouseButton))
                {
                    // find the target
                    switch (mShootAction.GetTrackType())
                    {
                    case JCS_ShootAction.TrackType.CLOSEST:
                        mDetectedObject = mShootAction.GetDetectAreaAction().FindTheClosest();
                        break;

                    case JCS_ShootAction.TrackType.FURTHEST:
                        mDetectedObject = mShootAction.GetDetectAreaAction().FindTheFurthest();
                        break;
                    }

                    mAction = true;
                }
            }

            if (mAfterDelay)
            {
                mActionTimer += Time.deltaTime;

                if (mTimeDelayAfterShoot < mActionTimer)
                {
                    // reset timer
                    mActionTimer = 0;

                    // can do the next shoot
                    mAction = false;

                    // exit delay process
                    mAfterDelay = false;
                }
            }

            if (mAction && !mAfterDelay)
            {
                mActionTimer += Time.deltaTime;

                if (mTimeBeforeShoot < mActionTimer)
                {
                    if (mShootAction.GetShootCallback() != null)
                    {
                        // do call back
                        mShootAction.GetShootCallback().Invoke();
                    }

                    // Do shooting effect
                    Shoots(mHit, this.transform.position);

                    // start after delay timer.
                    mAfterDelay = true;

                    // reset timer for "mAfterDelay" Trigger.
                    mActionTimer = 0;
                }
            }
        }