コード例 #1
0
 protected void CheckFootfalls()
 {
     if (!isGrounded && !isInWater)
     {
         Vector3 curPos = transform.position;
         int     x      = (int)curPos.x;
         int     y      = (int)curPos.y;
         int     z      = (int)curPos.z;
         if (x != lastPosX || y != lastPosY || z != lastPosZ)
         {
             lastPosX = x;
             lastPosY = y;
             lastPosZ = z;
             VoxelIndex index = env.GetVoxelUnderIndex(curPos, true);
             if (index.typeIndex != lastVoxelTypeIndex)
             {
                 lastVoxelTypeIndex = index.typeIndex;
                 if (lastVoxelTypeIndex != 0)
                 {
                     VoxelDefinition vd = index.type;
                     SetFootstepSounds(vd.footfalls, vd.landingSound, vd.jumpSound);
                     if (vd.triggerWalkEvent && OnVoxelWalk != null)
                     {
                         OnVoxelWalk(index.chunk, index.voxelIndex);
                     }
                     CheckDamage(vd);
                 }
             }
         }
     }
 }