Example #1
0
 public void ThreadProc()
 {
     while( !shouldStop )
     {
         if( this.lvcClient == null )
         {
             shouldStop = true;
         }
         else
         {
             this.lvcClient.Tick( this.waitTime );
             Thread.Sleep(waitTime);
         }
     }
     this.lvcClient = null;
 }
Example #2
0
    //----------------------------------------------------------
    //                    INSTANCE METHODS
    //----------------------------------------------------------
    /**
     * Initialisation and setup. This is only used internally.
     */
    private void init()
    {
        internalEntityRegistry = new Dictionary<long, GameObject>();
        externalEntityRegistry = new Dictionary<long, LVCPair<LVCGame.EntityData, GameObject>>();
        gameObjectToLvcIdMap = new Dictionary<GameObject, long>();

        pendingExternalCreates = new List<LVCGame.EntityData>();
        pendingExternalUpdates = new List<LVCGame.EntityData>();
        pendingExternalDeletes = new List<long>();
        pendingExternalFires = new List<LVCGame.FireWeaponData>();
        pendingExternalDetonations = new List<LVCGame.DetonateMunitionData>();

        // TODO - these initialisation values should not be hard coded
        string lvcConfigPath = LVCUtils.GetLVCConfigPath();
        lvcClient = new LVCClient( LVCUtils.CLIENT_TYPE,
                                   LVCUtils.LocalizePath(lvcConfigPath+"/LVCGame.log") );
        lvcClient.Initialize( LVCUtils.LocalizePath(lvcConfigPath) );

        lvcClient.SetEventsHandlerCallbacks( this, false );

        lvcClient.Start();

        simTicker = new SimTicker( ref lvcClient, 1.0f/30.0f);
        simTickThread = new Thread( new ThreadStart( simTicker.ThreadProc ));
        simTickThread.Start ();
    }
Example #3
0
 public SimTicker( ref ILVCClient lvcClient, float waitTime )
 {
     this.lvcClient = lvcClient;
     this.waitTime = (int)(waitTime * 1000);
     this.shouldStop = false;
 }
Example #4
0
    /**
     * Shut down the LVC Client instance.
     */
    public void ShutDown()
    {
        Debug.Log("Shutting down instance of LVC Game");

        if( simTickThread!= null )
        {
            simTicker.shutDown();
            simTickThread.Abort();
            simTickThread = null;
            simTicker = null;
        }

        if( lvcClient != null )
        {
            lvcClient.Tick(500);
            lvcClient.Stop();
            lvcClient = null;
        }
    }