2024-01-31 19:16:05 +08:00
using Plugins.JNGame.BepuPhysics ;
using UnityEngine ;
2024-01-29 19:07:52 +08:00
namespace Script.battle.mode
{
public class GWorldSceneModeInput
{
}
public class GWorldSceneMode : GBaseMode < GWorldSceneModeInput >
{
2024-01-30 19:22:27 +08:00
public GameObject [ ] balls = null ;
2024-01-31 19:16:05 +08:00
private JNBepuPhysics Physics ;
2024-01-29 19:07:52 +08:00
2024-01-30 19:22:27 +08:00
public override void OnSyncLoad ( )
{
2024-01-31 19:16:05 +08:00
Physics = new ( ) ;
2024-01-30 19:22:27 +08:00
// BufferPool pool = new BufferPool();
// Simulation.Create(pool, new DemoNarrowPhaseCallbacks(), new DemoPoseIntegratorCallbacks(new System.Numerics.Vector3(0, -10, 0)), new PositionFirstTimestepper());
}
2024-01-29 19:07:52 +08:00
public override void OnSyncUpdate ( int dt , JNFrameInfo frame , GWorldSceneModeInput input )
{
2024-01-31 19:16:05 +08:00
Physics . OnUpdate ( ( float ) dt / 1000 ) ;
2024-02-01 04:56:41 +08:00
if ( frame . Index > 0 )
2024-01-29 19:07:52 +08:00
{
2024-01-30 19:22:27 +08:00
var index = GetSync ( ) . nRandomInt ( 0 , balls . Length - 1 ) ;
Debug . Log ( index ) ;
var ballNode = Instantiate ( balls [ index ] , this . transform ) ;
2024-01-29 19:07:52 +08:00
var transformPosition = ballNode . transform . position ;
2024-01-30 19:22:27 +08:00
ballNode . transform . position = new Vector3 ( GetSync ( ) . nRandomFloat ( - 6 , 6 ) , transformPosition . y , GetSync ( ) . nRandomFloat ( - 6 , 6 ) ) ;
2024-01-29 19:07:52 +08:00
}
}
}
}