コード例 #1
0
ファイル: LVCUnityAmbassador.cs プロジェクト: damard/Unity
    ////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////// Utility Methods /////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////
    /**
     * A utility method which creates an fire weapon event data structure.
     *
     * @param firingID ID of entity which fired the detonating munition
     * @param lvcMunitionType the LVC Game munition type name
     * @param origin the location from which the munition originated
     * @param velocity the velocity of the munition
     * @param quantity (optional) the number of rounds fired in this "burst" (if unspecified, 1 is used)
     * @param rate (optional) the rate of fire in rounds per minute
     * @param warhead (optional) the DIS warhead type of the fired munition
     * @param fuse (optional) the DIS fuse type of the fired munition
     * @param targetId (optional) the ID of the entity targeted by this munition fire
     *
     * @return a populated LVCGame.FireWeaponData instance
     */
    public LVCGame.FireWeaponData MakeFireWeaponData(
							long firingID,
							string lvcMunitionType, 
							UnityEngine.Vector3 origin, UnityEngine.Vector3 velocity,
							uint quantity, uint rate, 
						    LVCGame.WarHeadType warheadType, 
							LVCGame.FuseType fuseType,
							long targetId
						   )
    {
        // convert Unity's LTP coordinates to lat/long/altitude
        LVCGame.Vector3 llaOrigin = LVCUtils.ltpToLla( LVCUtils.UnityCoords_to_LVCGameCoords(origin) );
        // convert Unity XYZ values to LVC axes
        LVCGame.Vector3 lvcVelocity = LVCUtils.UnityCoords_to_LVCGameCoords( velocity );

        LVCGame.Targeting targeting = new LVCGame.Targeting();
        targeting.eventId = GetNextTargetingEventID();
        targeting.firingId = firingID; // ID of entity which fired the weapon
        targeting.targetId = targetId; // ID of entity which is the target of the fire
        targeting.munitionId = 0; // unused - use munitionType field instead
        targeting.munitionType = lvcMunitionType; // LVC Game type name of the fired munition
        targeting.position = llaOrigin; // origin of the fired munition
        targeting.velocity = lvcVelocity; // velocity of the fired munition

        LVCGame.BurstDescriptor descriptor = new LVCGame.BurstDescriptor();
        descriptor.quantity = quantity; // amount of rounds fired in this burst
        descriptor.rate = rate; // rate of rounds fired in this burst in rounds per minute
        descriptor.warhead = warheadType; // warhead type
        descriptor.fuse = fuseType; // fuse type

        LVCGame.FireWeaponData fireWeaponData = new LVCGame.FireWeaponData();
        fireWeaponData.targeting = targeting;
        fireWeaponData.descriptor = descriptor;

        return fireWeaponData;
    }
コード例 #2
0
ファイル: LVCUnityAmbassador.cs プロジェクト: damard/Unity
    /**
     * A utility method which creates an munition detonation event data structure.
     *
     * @param firingID ID of entity which fired the detonating munition
     * @param lvcMunitionType the LVC Game munition type name
     * @param position the location at which the detonation occurs
     * @param velocity the velocity of the munition - this is the "approach vector" of the munition
     *        as viewed from the detonation location
     * @param quantity (optional) the number of rounds fired in this "burst" (if unspecified, 1 is used)
     * @param rate (optional) the rate of fire in rounds per minute
     * @param warhead (optional) the DIS warhead type of the detonated munition
     * @param fuse (optional) the DIS fuse type of the detonated munition
     * @param detonation (optional) the DIS detonation type of the detonated munition
     * @param targetId (optional) the ID of the entity targeted by this detonated
     * @param relativePosition (optional) the relative position of the detonation to the target
     *
     * @return a populated LVCGame.DetonateMunitionData instance
     */
    public LVCGame.DetonateMunitionData MakeDetonateMunitionData(
								  long firingID,
								  string lvcMunitionType, 
								  UnityEngine.Vector3 position, UnityEngine.Vector3 velocity,
								  uint quantity, uint rate, 
						    	  LVCGame.WarHeadType warheadType, 
								  LVCGame.FuseType fuseType,
								  LVCGame.DetonationType detonationType,
								  long targetId,
								  UnityEngine.Vector3 relativePosition
								)
    {
        // convert Unity's LTP coordinates to lat/long/altitude
        LVCGame.Vector3 llaPosition = LVCUtils.ltpToLla( LVCUtils.UnityCoords_to_LVCGameCoords(position) );
        // convert Unity XYZ values to LVC axes
        LVCGame.Vector3 lvcVelocity = LVCUtils.UnityCoords_to_LVCGameCoords( velocity );
        LVCGame.Vector3 lvcRelativePosition = LVCUtils.UnityCoords_to_LVCGameCoords( relativePosition );

        // Construct the targeting data
        LVCGame.Targeting targeting = new LVCGame.Targeting();
        targeting.eventId = GetNextTargetingEventID();
        targeting.firingId = firingID; // ID of entity which fired the detonating munition
        targeting.targetId = targetId; // ID of entity which was the target of the detonating munition
        targeting.munitionId = 0; // unused - use munitionType instead
        targeting.munitionType = lvcMunitionType; // LVC Game type name of the detonating munition
        targeting.position = llaPosition; // location of the detonation munition
        targeting.velocity = lvcVelocity; // velocity of the "approach" of the detonating munition

        // Construct the burst descriptor data
        LVCGame.BurstDescriptor descriptor = new LVCGame.BurstDescriptor();
        descriptor.quantity = quantity; // amount of munitions detonated in this burst
        descriptor.rate = rate; // rate of munitions detonated in this burst in rounds per minute
        descriptor.warhead = warheadType; // warhead type
        descriptor.fuse = fuseType; // fuse type

        // construct the detonation data
        LVCGame.DetonateMunitionData detonateMunitionData = new LVCGame.DetonateMunitionData();
        detonateMunitionData.targeting = targeting;
        detonateMunitionData.descriptor = descriptor;
        detonateMunitionData.detonation = detonationType;
        detonateMunitionData.relativePosition = lvcRelativePosition;

        return detonateMunitionData;
    }