static void ServerExample(string address, int port, int syncRate) { // Networked Object var hisPos = new Position(); var hisPosRef = new SyncObjectRef <Position>(hisPos); var sserver = new ObjectSyncServer <Position>(hisPosRef, address, port, syncRate); // Server Game Loop while (true) { hisPos = hisPosRef.Value; // local pos = received pos (Interpolate positions here) Console.WriteLine("Server: " + hisPos.ToString()); DrawGame(hisPos, GAME_RATE); } }
protected override void OnStart(GUnit unit, ObjectStateData stateData) { var moveSpeedData = unit.GetData <ObjectMoveSpeedData>(); var assetData = unit.GetData <AssetData>(); var animator = assetData.GetComponent <Animator>(); var rigidbody = assetData.GetComponent <Rigidbody2D>(); animator.SetBool(ObjectTestConstant.ANIMATOR_PARAM_MOVE, true); var moveParamData = unit.GetData <ObjectMoveParamData>(); moveParamData.moveDispose = ObjectSyncServer.EverySyncUpdate().Subscribe(_ => { var deltaX = stateData.param.x * moveSpeedData.allValue * ObjectTestConstant.OBJECTTEST_FIXED_MSECOND; deltaX /= ObjectTestConstant.MSECOND_TO_SECOND * ObjectTestConstant.MSECOND_TO_SECOND; _movePosition.x = deltaX; rigidbody.MovePosition(rigidbody.position + _movePosition); }); }