Esempio n. 1
0
    void runJumping()
    {
        if (rb.velocity.y >= Physics.gravity.y * (1.0f / 60.0f))
        {
            motion.crossFade(msJump, 0.2f);
        }
        else
        {
            motion.crossFade(msFall, 0.2f);
        }


        if (ls.sqrmag > 0.0f)
        {
            var m = new MoveUtilityUnit(ref ls);


            // 立ち姿・移動ともに常に直立
            lookAtDirectionUpright(m.hdir);
        }


        if (/*msJump.time > 0.5f &&*/ grounder.isGround)
        {
            state.changeTo(run);
        }
        else if (GamePad._l1 && msJump.time < 0.2f)
        {
            rb.AddForce(stance.direction * 50.0f + Vector3.down * 200.0f, ForceMode.Impulse);

            state.changeTo(avoidance);
        }
    }
Esempio n. 2
0
    void falling()
    {
        //if( rb.velocity.y > 0.0f )
        if (rb.velocity.y >= Physics.gravity.y * (1.0f / 60.0f))
        {
            motion.crossFade(msJump, 0.2f);
        }
        else
        {
            motion.crossFade(msFall, 0.2f);
        }


        if (ls.sqrmag > 0.0f)
        {
            var m = new MoveUtilityUnit(ref ls);


            //if( !move.isOver ) move.setSpeedRate( 0.0f );


            // 立ち姿・移動ともに常に直立
            lookAtForwardUpright(m.hdir);
        }
        else
        {
            //move.setSpeedRate( 0.0f );
        }


        if (grounder.isGround)
        {
            state.changeTo(walk);
        }

        if (GamePad._l3)
        {
            state.changeTo(crawl);
        }

        /*if( GamePad._l2 )
         * {
         *
         *      state.changeTo( wire );
         *
         * }*/
    }
Esempio n. 3
0
    void shootingWire()
    {
        /*if( !isWireShot )
         * {
         *
         *      var pos = playerShoot.tfMuzzle.position;
         *
         *      var rot = playerShoot.tfMuzzle.rotation;
         *
         *
         *      wireTemplate.emit( pos, rot, 1.0f, this );
         *
         *      hitter.reactions.sound.PlayOneShot( wireTemplate.emitSound );
         *
         *
         *      isWireShot = true;
         *
         * }*/


        if (ls.sqrmag > 0.0f)
        {
            var m = new MoveUtilityUnit(ref ls);


            //moveSpeed.inc( 60.0f * GM.t.delta, m.mag );// 最大ダメージ 30 だと 0.5 秒のストッピングとなる
            //moveSpeed.set( m.mag );


            // 立ち姿・移動ともに常に直立
            lookAtForwardUpright(m.hdir);


            //rb.AddForce( stance.direction * a, ForceMode.Force );
        }


        //state.changeTo( walk );
    }
Esempio n. 4
0
    void rollingover()
    {
        if (msRoll.time >= msRoll.length)
        {
            state.changeTo(walk);
        }
        else if (wall.isTouchWall)
        {
            state.changeTo(walk);
        }
        else if (GamePad._l1 && grounder.isGround)          // ムリな連続回避はスタミナを減らすが、モーションをキャンセルできる。
        {
            var m = new MoveUtilityUnit(ref ls);


            // 進行方向を向いて、立ち姿は直立だが、移動だけ接地面に沿う
            lookAtDirectionStandOnGround(m.hdir);


            if (ls.sqrmag > 0.6f * 0.6f)
            {
                state.changeTo(avoidance);

                isSmallDash = true;
            }
        }
        else
        {
            return;
        }



        stance.setSpeed(1.0f, move.speedRate01);
        //if( grounder.isGround ) rb.velocity = Vector3.zero;
    }
Esempio n. 5
0
    void walking()
    {
        if (ls.sqrmag > 0.0f)
        {
            var m = new MoveUtilityUnit(ref ls);


            //move.inc( 60.0f, m.mag );// 最大ダメージ 30 だと 0.5 秒のストッピングとなる
            //moveSpeed.set( m.mag );
            move.setRepairTime(moveThresholds.walk);
            stance.setSpeed(m.mag, move.speedRate01);


            // 立ち姿は直立だが、移動だけ接地面に沿う
            lookAtForwardStandOnGround(m.hdir);


            if (move.isMovable)
            {
                //ragdoll.switchToAnimation();//
                motion.blend2D(msWalkSide, msWalkStance, ls.stick, 1.0f, move.speedRate01 * stance.moveRate * 0.5f, 0.1f);
                //motion.crossFade( msNowWalk, 0.1f );
            }


            output.loudness = 1.0f + m.mag;
        }
        else
        {
            if (stance.moveDistancePerSec > 1.2f)
            {
                motion.crossFade(msJump, 0.2f);
            }
            else
            {
                if (GamePad.l1)
                {
                    motion.crossFade(msKneesit, 0.3f);
                }
                else                                                                      //
                {
                    motion.crossFade(msStandStance, 0.2f);
                }
            }

            msJump.time = 0.0f;



            //moveSpeed.inc( 0.0f, 0.0f );
            //move.velocity = 0.0f;// 止まればダメージは回復する(が静止状態)
            move.setRepairTime(moveThresholds.stand);
            stance.setSpeedZero();


            // 立ち姿は直立だが、移動だけ接地面に沿う
            lookAtForwardStandOnGround();


            output.loudness = 1.0f;
        }


        if (GamePad._l3)
        {
            state.changeTo(crawl);
        }
        else
        {
            if (GamePad._l1 && grounder.isGround)
            {
                //if( ls.sqrmag > 0.6f * 0.6f )
                if (ls.sqrmag > 0.1f * 0.1f)
                {
                    if (checkOverBarrier())
                    {
                        state.changeTo(overBarrier);
                    }
                    else
                    {
                        //move.setSpeedRate( 2.0f );

                        state.changeTo(avoidance);
                    }
                }

                /*else if( ls.sqrmag < 0.1f * 0.1f )
                 * {
                 *      changeToJumpMode( 200.0f );
                 * }
                 */
            }
            else if (!dashButton.over(true) && GamePad.l1_ && grounder.isGround) //
            {                                                                    //
                changeToJumpMode(200.0f);                                        //
            }                                                                    //
            else if (!grounder.isGround)
            {
                changeToFallMode();
            }
        }

        /*if( GamePad._l2 )
         * {
         *
         *      state.changeTo( wire );
         *
         * }*/
    }
Esempio n. 6
0
    void running()
    {
        var stickRate = 0.0f;


        if (ls.sqrmag > 0.0f)
        {
            var m = new MoveUtilityUnit(ref ls);


            // 立ち姿は直立だが、移動だけ接地面に沿う
            lookAtDirectionStandOnGround(m.hdir);



            msWalkStance.speed = stance.moveDistancePerSec * (1.0f / 5.0f);              //moveSpeed * ( 1.0f / 5.0f );

            stickRate = m.mag;



            if (stance.moveDistancePerSec > 0.4f)
            {
                motion.crossFade(msWalkStance, 0.2f);
            }
            else
            {
                motion.crossFade(msStandStance, 0.3f);
            }
        }
        else
        {
            if (stance.moveDistancePerSec > 1.2f)
            {
                motion.crossFade(msJump, 0.2f);
            }
            else
            {
                motion.crossFade(msStandStance, 0.3f);
            }

            msJump.time = 0.0f;
        }



        stance.setSpeed(stickRate, move.speedRate01 * runSpeed);



        if (!GamePad.l1 & rb.velocity.magnitude < 1.4f & ls.sqrmag < 0.1f * 0.1f)
        {
            state.changeTo(walk);
        }
        else if (GamePad._l3)
        {
            state.changeTo(crawl);

            rb.AddForce(stance.direction * stance.speedRate * 80.0f, ForceMode.Impulse);
        }
        else if (grounder.isGround)
        {
            if (GamePad._l1)
            {
                if (ls.sqrmag > 0.6f * 0.6f)
                {
                    if (checkOverBarrier())
                    {
                        state.changeTo(overBarrier);
                    }
                    else
                    {
                        state.changeTo(avoidance);
                    }
                }

                /*else if( ls.sqrmag < 0.1f * 0.1f )
                 * {
                 *      changeToJumpMode( 200.0f );
                 * }*/
            }

            /*else if( GamePad.l1_ & dashButton.over(true) & ls.sqrmag < 0.1f * 0.1f )
             * {
             *      changeToJumpMode( 200.0f );
             * }*/
        }
        else
        {
            changeToFallMode();
        }


        output.loudness = stance.speedRate;
    }
Esempio n. 7
0
    void crawling()
    {
        if (GamePad.r1)
        {
            motionUpperBody.fadeIn(msNowWaponUpperStance, 0.1f);
        }
        else
        {
            motionUpperBody.fadeOut(0.2f);
        }

        {
            if (!GamePad.r1 & ls.sqrmag > 0.0f)
            {
                var m = new MoveUtilityUnit(ref ls);


                ////move.inc( 10.0f, m.mag * 0.33f );
                //moveSpeed.set( mag * (1.0f / 3.0f) );
                move.setRepairTime(moveThresholds.stand);
                stance.setSpeed(m.mag * 0.33f, move.speedRate01);


                // 立ち姿・移動ともに接地面に沿う
                lookAtForwardFitOnGround(m.hdir);


                motion.blend1D(msCrawlMove, ls.stick.y != 0.0f ? ls.stick.y : ls.stick.x, 1.0f, move.speedRate01 * stance.moveRate * 0.5f, 0.1f);
                //motion.crossFade2D( msCrawlMove, msCrawlMove, ls.stick, moveSpeed * 0.5f, 0.1f );
                //motion.crossFade( msCrawlMove, 0.3f );


                output.loudness = 1.0f + m.mag * 0.33f;
            }
            else
            {
                motion.crossFade(msCrawl, 0.3f);


                //moveSpeed.inc( 0.0f, 0.0f );
                //move.velocity = 0.0f;
                move.setRepairTime(moveThresholds.walk);
                stance.setSpeedZero();


                // 立ち姿・移動ともに接地面に沿う
                lookAtForwardFitOnGround();


                output.loudness = 1.0f;
            }
        }

        if (GamePad._l3)
        {
            state.changeTo(walk);
        }
        else if (GamePad._l1 && grounder.isGround)
        {
            /*
             * if( ls.sqrmag > 0.6f * 0.6f )
             * {
             *      state.changeTo( avoidance );
             * }*/
            /*else if( ls.sqrmag < 0.1f * 0.1f )
             * {
             *      changeToJumpMode( 150.0f );
             * }
             */

            // ひっつき仮
            jtHang = gameObject.AddComponent <FixedJoint>();
            jtHang.connectedBody = grounder.groundCollider.attachedRigidbody;
        }
        else if (GamePad.l1_)
        {
            Destroy(jtHang);
            jtHang = null;            // 伏せ終期化にもある
        }
        else if (rb.velocity.y < Physics.gravity.y * (1.0f / 60.0f) * 60.0f)
        {
            changeToFallMode();
        }
    }
Esempio n. 8
0
    // overBarrier -------------------------------------------------------

    void overBarrier(ref ActionStateUnit.ActionHolder action)
    {
        action.first = () =>
        {
            motion.crossFade(msBarrierOver, 0.1f);

            //move.velocity = 0.0f;


            state.shiftTo(gettingOverBarrier);

            state.setPhysics(physFree);              // physHitCheckWall );


            //changeToStand();
            changeToCrawl();

            figure.changeCollider(EnStance.crawl);


            if (stance.direction.sqrMagnitude == 0.0f)
            {
                stance.direction = rb.rotation * Vector3.forward;
            }


            if (ls.sqrmag > 0.0f)
            {
                var m = new MoveUtilityUnit(ref ls);


                // 立ち姿・移動ともに常に直立
                lookAtForwardUpright(m.hdir);
            }


            msNowWaponUpperStance = null;

            motionUpperBody.fadeOut(0.1f);


            isRunable = false;

            playerShoot.available -= ShootOpenFlag.shoot;


            rb.isKinematic = true;


            output.set(1.0f, 1.0f, 1.0f, 1.0f, 0.0f);
        };

        action.last = () =>
        {
            figure.changeCollider(EnStance.stand);


            isRunable = true;

            playerShoot.available += ShootOpenFlag.shoot;


            rb.isKinematic = false;
        };
    }