Exemplo n.º 1
0
    private void Start()
    {
        playerItemUsableCount = 0;
        playerStatus          = PlayerStatus.WAIT;
        goalResultStatus      = GoalResultStatus.NONGOAL;
        //_selectItem = PlayerInfo.player.playerSelectItem;
        //playerItemUsableCount = _selectItem.itemUsableCount;
        ResetItemMaxVelocity();

        itemPlayStatus = ItemPlayStatus.UNUSED;

        playerJM2DR.motorSpeed = 0.0f;
        playerJM2DL.motorSpeed = 0.0f;

        playerVelocity     = Vector2.zero;
        rightWheelVelocity = Vector2.zero;
        leftWheelVelocity  = Vector2.zero;

        goalDistance      = 0.0f;
        itemDurationTimer = 0.0f;
        ResetTimer();
    }
Exemplo n.º 2
0
 public void SetItemDurationTimer(float itemDurationTimer)
 {
     this.itemDurationTimer = itemDurationTimer;
     itemPlayStatus         = ItemPlayStatus.USING;
 }
Exemplo n.º 3
0
    private void FixedUpdate()
    {
        switch (playerStatus)
        {
        case PlayerStatus.WAIT:
            // 待機中
            //playerRB2D.velocity = Vector2.zero;
            RightWheel.useMotor = false;
            LeftWheel.useMotor  = false;
            break;

        case PlayerStatus.READY:
            // 準備中
            break;

        case PlayerStatus.RUN:
            // 滑走中
            // TODO 仮

            /*
             * playerRB2D.AddForce(playerRB2D.velocity * addForce, ForceMode2D.Force);
             * RightWheelRB2D.AddTorque(addTorque, ForceMode2D.Force);
             * LeftWheelRB2D.AddTorque(addTorque, ForceMode2D.Force);
             * if (CenterWheelRB2D != null)
             * {
             *  CenterWheelRB2D.AddTorque(addTorque, ForceMode2D.Force);
             * }
             */
            RightWheel.useMotor        = true;
            LeftWheel.useMotor         = true;
            playerJM2DR.motorSpeed     = RightWheel.motor.motorSpeed;
            playerJM2DR.maxMotorTorque = RightWheel.motor.maxMotorTorque;
            playerJM2DL.motorSpeed     = LeftWheel.motor.motorSpeed;
            playerJM2DL.maxMotorTorque = LeftWheel.motor.maxMotorTorque;
            TimeCounter.isPose         = false;
            break;

        case PlayerStatus.CONTACT:
            // 接触
            break;

        case PlayerStatus.GOAL:
            // ゴール

            /*
             * if (0.0f < RightWheel.motor.motorSpeed)
             * {
             *  playerJM2DR.motorSpeed = -RightWheel.motor.motorSpeed / 2.0f;
             *  RightWheel.motor = playerJM2DR;
             * }
             * else if (RightWheel.motor.motorSpeed <= 0.0f)
             * {
             *  playerJM2DR.motorSpeed = 0.0f;
             *  RightWheel.motor = playerJM2DR;
             *  RightWheel.useMotor = false;
             * }
             * if (0.0f < LeftWheel.motor.motorSpeed)
             * {
             *  playerJM2DL.motorSpeed = -LeftWheel.motor.motorSpeed / 2.0f;
             *  LeftWheel.motor = playerJM2DL;
             * }
             * else if (LeftWheel.motor.motorSpeed <= 0.0f)
             * {
             *  playerJM2DL.motorSpeed = 0.0f;
             *  LeftWheel.motor = playerJM2DL;
             *  LeftWheel.useMotor = false;
             * }
             */
            RightWheel.useMotor = false;
            LeftWheel.useMotor  = false;
            TimeCounter.isPose  = true;
            if (0.5f < RightWheel.attachedRigidbody.velocity.magnitude)
            {
                RightWheel.attachedRigidbody.AddForce(Vector2.left * RightWheel.attachedRigidbody.velocity.magnitude * 2.0f);
            }
            else
            {
                RightWheel.attachedRigidbody.velocity = Vector2.zero;
            }
            if (0.5f < LeftWheel.attachedRigidbody.velocity.magnitude)
            {
                LeftWheel.attachedRigidbody.AddForce(Vector2.left * LeftWheel.attachedRigidbody.velocity.magnitude * 2.0f);
            }
            else
            {
                LeftWheel.attachedRigidbody.velocity = Vector2.zero;
            }
            break;

        case PlayerStatus.END:
            // 終了
            RightWheel.useMotor = false;
            LeftWheel.useMotor  = false;
            playerRB2D.velocity = Vector2.zero;
            //
            playerRB2D.simulated     = false;
            RightWheelRB2D.simulated = false;
            LeftWheelRB2D.simulated  = false;
            // 重力の停止
            playerRB2D.isKinematic     = true;
            RightWheelRB2D.isKinematic = true;
            LeftWheelRB2D.isKinematic  = true;
            break;
        }

        /*
         * if (GravityFlg)
         * {
         *  // 重力調整
         *  Gravity();
         * }
         *
         * // velocity限界値調整
         * VelocityLimitValueAdjust();
         */

        // 回転制限
        RotationLimitter();

        if (0.0f < itemDurationTimer)
        {
            seconds += Time.deltaTime;

            if (itemDurationTimer <= seconds)
            {
                ResetItemMaxVelocity();

                itemDurationTimer = 0.0f;
                if (0 < playerItemUsableCount)
                {
                    itemPlayStatus = ItemPlayStatus.AVAILABLE;
                }
                else
                {
                    itemPlayStatus = ItemPlayStatus.UNAVAILABLE;
                }

                ResetTimer();
            }
        }

        playerVelocity     = playerRB2D.velocity;
        rightWheelVelocity = RightWheelRB2D.velocity;
        leftWheelVelocity  = LeftWheelRB2D.velocity;

        if (RightWheelController.IsGround &&
            1.0f <= RightWheelRB2D.velocity.x)
        {
            // レイがコライダーの表面に衝突したワールド座標での地点に
            // 砂埃のようなエフェクトを表示
            runEffectsController.PlayParticle();
        }
        else
        {
            runEffectsController.StopParticle();
        }

        if (_goalPosTF != null)
        {
            // ゴールまでの距離を取得
            GetGoalDistance();
        }
    }