public override void SafeAwake()
        {
            try
            {
                cmcl        = GetComponent <CogMotorControllerHinge>();
                SpeedSlider = cmcl.SpeedSlider;

                base.SafeAwake();
            }
            catch { }

#if DEBUG
            ConsoleController.ShowMessage("动力铰链添加进阶属性");
#endif
        }
      //MKey RotationKey;

      //public List<KeyCode> Rotation;

      //public bool Locked;

      //public float Lerp;

      public override void OnSimulateStart_EnhancementEnabled()
      {
          //RotationKey = GetKey(Rotation);

          HJ   = GetComponent <HingeJoint>();
          CMCH = GetComponent <CogMotorControllerHinge>();

          CMCH.speedLerpSmooth = Lerp;

          if (Locked)
          {
              HJ.useLimits = true;
          }
          else
          {
              HJ.useLimits = false;
          }
      }
示例#3
0
 /// <summary>
 /// Creates a Block handler.
 /// </summary>
 /// <param name="bb">BlockBehaviour object.</param>
 public Cog(BlockBehaviour bb) : base(bb)
 {
     cmc = bb.GetComponent <CogMotorControllerHinge>();
 }
        protected override void OnSimulateStart()
        {
            //BrakeKey = GetKey(Brake);
            HJ        = GetComponent <HingeJoint>();
            Colliders = GetComponentsInChildren <Collider>();
            MyId      = GetComponent <BlockVisualController>().ID;

            angleDrag = GetComponent <Rigidbody>().angularDrag;

            JointLimits jl = HJ.limits;

            jl.min    = jl.max = jl.bounciness = jl.bounceMinVelocity = 0;
            HJ.limits = jl;


            HJ.spring = new JointSpring()
            {
                damper = 10000, spring = 10000, targetPosition = 0
            };

            if (Collider)
            {
                //禁用原有碰撞
                foreach (Collider c in Colliders)
                {
                    if (c.name == "CubeColliders")
                    {
                        c.enabled = false;
                    }
                }

                WheelCollider = new GameObject("Wheel Collider");

                mFilter      = WheelCollider.AddComponent <MeshFilter>();
                mFilter.mesh = WheelMesh = SimpleMesh.MeshFromObj(Application.dataPath + "/Mods/Resources/BlockEnhancement/Wheel.obj");

                mCollider        = WheelCollider.AddComponent <MeshCollider>();
                mCollider.convex = true;

                PM = mCollider.material;

                //静摩擦力
                PM.staticFriction = Friction;
                //动摩擦力
                PM.dynamicFriction = Friction;
                //摩擦力组合
                PM.frictionCombine = PhysicMaterialCombine.Multiply;
                //弹力
                PM.bounciness = 0;
                //弹力组合
                PM.bounceCombine = PhysicMaterialCombine.Minimum;


#if DEBUG
                mRenderer = WheelCollider.AddComponent <MeshRenderer>();
                mRenderer.material.color = Color.red;
#endif

                PaS pas = GetPositionAndScale(MyId);

                WheelCollider.transform.parent     = mCollider.transform.parent = transform;
                WheelCollider.transform.rotation   = mCollider.transform.rotation = transform.rotation;
                WheelCollider.transform.position   = mCollider.transform.position = transform.TransformPoint(transform.InverseTransformPoint(transform.position) + pas.Position);
                WheelCollider.transform.localScale = mCollider.transform.localScale = pas.Scale;
                WheelCollider.AddComponent <DestroyIfEditMode>();
            }
            else if (FrictionT)
            {
                //设置原有碰撞的参数
                foreach (Collider c in Colliders)
                {
                    if (c.name == "CubeColliders")
                    {
                        PhysicMaterial PM = c.GetComponent <BoxCollider>().material;

                        //静摩擦力
                        PM.staticFriction = Friction;
                        //动摩擦力
                        PM.dynamicFriction = Friction;
                        Debug.Log(PM.bounciness);
                        //摩擦力组合
                        PM.frictionCombine = PhysicMaterialCombine.Multiply;
                        //弹力
                        PM.bounciness = 0;
                        //弹力组合
                        PM.bounceCombine = PhysicMaterialCombine.Minimum;
                    }
                }
            }

            if (MyId == (int)BlockType.Wheel || MyId == (int)BlockType.LargeWheel)
            {
                CMCH = GetComponent <CogMotorControllerHinge>();
                CMCH.speedLerpSmooth = Lerp;
            }
        }
示例#5
0
 public override void SafeAwake()
 {
     base.SafeAwake();
     cogMotor = BB.GetComponent <CogMotorControllerHinge>();
     FPLogic  = cogMotor.AddToggle("FPIO", "accept_fpio", false);
 }