//-------------------------------------------------------------------------
    /// Copy Constructor - creates a deep copy of the src object.
    public ColliderGenTK2DParametersForSprite(ColliderGenTK2DParametersForSprite src)
    {
        mSpriteIndex = src.mSpriteIndex;

        mOutlineVertexCount = src.mOutlineVertexCount;
        // other old unused parameters skipped.

        // deep copy of the following two member variables
        if (src.mRegionIndependentParameters != null) {
            mRegionIndependentParameters = new RegionIndependentParametersTK2D(src.mRegionIndependentParameters);
        }
        else {
            mRegionIndependentParameters = null;
        }

        if (src.mColliderRegionParameters != null) {
            mColliderRegionParameters = new ColliderRegionParametersTK2D[src.mColliderRegionParameters.Length];
            for (int index = 0; index < src.mColliderRegionParameters.Length; ++index) {
                mColliderRegionParameters[index] = new ColliderRegionParametersTK2D(src.mColliderRegionParameters[index]);
            }
        }
        else {
            src.mColliderRegionParameters = null;
        }

        mVersionID = src.mVersionID;
    }
    //-------------------------------------------------------------------------
    /// Copy Constructor - creates a deep copy of the src object.
    public ColliderGenTK2DParametersForSprite(ColliderGenTK2DParametersForSprite src)
    {
        mSpriteIndex = src.mSpriteIndex;

        mOutlineVertexCount = src.mOutlineVertexCount;
        // other old unused parameters skipped.

        // deep copy of the following two member variables
        if (src.mRegionIndependentParameters != null)
        {
            mRegionIndependentParameters = new RegionIndependentParametersTK2D(src.mRegionIndependentParameters);
        }
        else
        {
            mRegionIndependentParameters = null;
        }

        if (src.mColliderRegionParameters != null)
        {
            mColliderRegionParameters = new ColliderRegionParametersTK2D[src.mColliderRegionParameters.Length];
            for (int index = 0; index < src.mColliderRegionParameters.Length; ++index)
            {
                mColliderRegionParameters[index] = new ColliderRegionParametersTK2D(src.mColliderRegionParameters[index]);
            }
        }
        else
        {
            src.mColliderRegionParameters = null;
        }

        mVersionID = src.mVersionID;
    }
Пример #3
0
 //-------------------------------------------------------------------------
 public void UpdateToCurrentVersionIfNecessary()
 {
     for (int count = 0; count < mStoredParameters.Count; ++count)
     {
         ColliderGenTK2DParametersForSprite paramObject = mStoredParameters[count];
         paramObject.UpdateToCurrentVersionIfNecessary();
     }
 }
    //-------------------------------------------------------------------------
    public ColliderGenTK2DParametersForSprite GetParametersForSprite(int spriteIndex)
    {
        foreach (ColliderGenTK2DParametersForSprite paramObject in mStoredParameters) {
            if (paramObject.mSpriteIndex == spriteIndex) {

                ColliderGenTK2DParametersForSprite deepParametersCopy = new ColliderGenTK2DParametersForSprite(paramObject);
                return deepParametersCopy;
            }
        }
        return null;
    }
Пример #5
0
 //-------------------------------------------------------------------------
 public ColliderGenTK2DParametersForSprite GetParametersForSprite(int spriteIndex)
 {
     foreach (ColliderGenTK2DParametersForSprite paramObject in mStoredParameters)
     {
         if (paramObject.mSpriteIndex == spriteIndex)
         {
             ColliderGenTK2DParametersForSprite deepParametersCopy = new ColliderGenTK2DParametersForSprite(paramObject);
             return(deepParametersCopy);
         }
     }
     return(null);
 }
    //-------------------------------------------------------------------------
    public void SaveParametersForSprite(int spriteIndex, ColliderGenTK2DParametersForSprite parametersToSave)
    {
        ColliderGenTK2DParametersForSprite deepParametersCopy = new ColliderGenTK2DParametersForSprite(parametersToSave);

        for (int count = 0; count < mStoredParameters.Count; ++count) {
            ColliderGenTK2DParametersForSprite paramObject = mStoredParameters[count];
            if (paramObject.mSpriteIndex == spriteIndex) {

                mStoredParameters[count] = deepParametersCopy;
                return;
            }
        }

        // does not exist yet - add it
        mStoredParameters.Add(deepParametersCopy);
    }
Пример #7
0
    //-------------------------------------------------------------------------
    public void SaveParametersForSprite(int spriteIndex, ColliderGenTK2DParametersForSprite parametersToSave)
    {
        ColliderGenTK2DParametersForSprite deepParametersCopy = new ColliderGenTK2DParametersForSprite(parametersToSave);

        for (int count = 0; count < mStoredParameters.Count; ++count)
        {
            ColliderGenTK2DParametersForSprite paramObject = mStoredParameters[count];
            if (paramObject.mSpriteIndex == spriteIndex)
            {
                mStoredParameters[count] = deepParametersCopy;
                return;
            }
        }

        // does not exist yet - add it
        mStoredParameters.Add(deepParametersCopy);
    }
Пример #8
0
    //-------------------------------------------------------------------------
    protected void SaveValuesToParameterStore(ColliderGenTK2DParameterStore parameterStore, int[] spriteIDs)
    {
        if (spriteIDs.Length == 0 || parameterStore == null)
        {
            return;
        }

        foreach (int spriteID in spriteIDs)
        {
            ColliderGenTK2DParametersForSprite parameters = new ColliderGenTK2DParametersForSprite();

            parameters.mRegionIndependentParameters = mAlgorithmHelper.RegionIndependentParams;
            parameters.mColliderRegionParameters    = mAlgorithmHelper.ColliderRegionParams;

            parameters.mSpriteIndex = spriteID;

            parameterStore.SaveParametersForSprite(spriteID, parameters);
        }
    }
Пример #9
0
    //-------------------------------------------------------------------------
    protected bool LoadValuesFromParameterStore(ColliderGenTK2DParameterStore parameterStore, int[] spriteIDs)
    {
        if (spriteIDs.Length == 0 || parameterStore == null)
        {
            return(false);
        }

        ColliderGenTK2DParametersForSprite parameters = parameterStore.GetParametersForSprite(spriteIDs[0]);

        if (parameters == null)
        {
            return(false);
        }

        mAlgorithmHelper.RegionIndependentParams = parameters.mRegionIndependentParameters;
        mAlgorithmHelper.ColliderRegionParams    = parameters.mColliderRegionParameters;

        return(true);
    }