//---------------------------------------------------------- // CONSTRUCTORS //---------------------------------------------------------- public EntityDataManager( string gameType, string marking, LVCGame.UnitForceType force ) { this.lvcUnityAmbassador = LVCUnityAmbassador.GetInstance(); this.lvcClient = lvcUnityAmbassador.GetLVCClient(); // initialise the entity data container which will hold salient details about // the entity state which we want to send in LVC updates entityData = new LVCGame.EntityData(); entityData.id = new LVCGame.EntityID(); entityData.physics = new LVCGame.EntityPhysics(); entityData.properties = new LVCGame.EntityProperties(); entityData.properties.force = force; // assign a unique ID number to this entity entityData.id.instance = lvcUnityAmbassador.GetNextEntityID(); // initialise types and markings entityData.id.gameType = gameType; entityData.id.marking = marking; lvcGameState = LVCGameState.UNINTIALISED; }
//---------------------------------------------------------- // CONSTRUCTORS //---------------------------------------------------------- //---------------------------------------------------------- // INSTANCE METHODS //---------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// MonoBehaviour Overrides ////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////// /** * OVERRIDE * * Used for initialization. Awake is *always* called, and the call happens before Start() */ void OnEnable() { // initialise the LVC ambassador instance we will use for updates this.lvcUnityAmbassador = LVCUnityAmbassador.GetInstance(); // create a lookup table for munition type names vs detonation effects List<LVCPair<string, GameObject>> munitionDetonations = new List<LVCPair<string, GameObject>>(); munitionDetonations.Add( new LVCPair<string, GameObject>(miniMunitionTypes.Trim(), miniMunitionDetonation) ); munitionDetonations.Add( new LVCPair<string, GameObject>(smallMunitionTypes.Trim(), smallMunitionDetonation) ); munitionDetonations.Add( new LVCPair<string, GameObject>(mediumMunitionTypes.Trim(), mediumMunitionDetonation) ); munitionDetonations.Add( new LVCPair<string, GameObject>(largeMunitionTypes.Trim(), largeMunitionDetonation) ); munitionDetonations.Add( new LVCPair<string, GameObject>(extraLargeMunitionTypes.Trim(), extraLargeMunitionDetonation) ); munitionDetonationMap = new Dictionary<string, GameObject>(); // go through each of the detonation sizes foreach(LVCPair<string, GameObject> pair in munitionDetonations) { // if there is no detonation effect for this size, skip this part if( pair.B == null) continue; // create a lookup for the munition name to the detonation effect string[] munitionTypeNames = pair.A.Split(','); foreach( string munitionTypeName in munitionTypeNames ) { munitionDetonationMap.Add( munitionTypeName.Trim(), pair.B ); } } // create a lookup table for smoke munition type names. The smoke munition // names are expected to be in the form: // LVCNAME-COLOUR // ...for example: // smokeBomb-FF00FF // which would result in a magenta smoke flare being instantiated. smokeMunitionColorMap = new Dictionary<string, Color>(); string[] smokeMunitionTypeNames = smokeMunitionTypes.Split(','); foreach( string munitionTypeName in smokeMunitionTypeNames ) { string[] nameAndColour = munitionTypeName.Trim().Split('-'); if( nameAndColour.Length == 2) { Color smokeColor = LVCUtils.hexToColor( nameAndColour[1] ); smokeMunitionColorMap.Add( nameAndColour[0], smokeColor ); } } }
//---------------------------------------------------------- // STATIC METHODS //---------------------------------------------------------- /** * Obtain a reference to the LVC Client instance. * * @return the LVC Client instance. */ public static LVCUnityAmbassador GetInstance() { if(lvcUnityAmbassador == null) lvcUnityAmbassador = new LVCUnityAmbassador(); return lvcUnityAmbassador; }