GameCommon.MeshObjectAnimationController.GetRandomAnimationNumber C# (CSharp) Метод

GetRandomAnimationNumber() публичный Метод

public GetRandomAnimationNumber ( string animationBaseName, bool firstAnimationIn10TimesMoreOften ) : int
animationBaseName string
firstAnimationIn10TimesMoreOften bool
Результат int
        public int GetRandomAnimationNumber( string animationBaseName,
            bool firstAnimationIn10TimesMoreOften)
        {
            int maxIndex;

            if( !maxAnimationIndices.TryGetValue( animationBaseName, out maxIndex ) )
            {
                //calculate max animation index
                maxIndex = 1;
                for( int n = 2; ; n++ )
                {
                    if( meshObject.GetAnimationState( animationBaseName + n.ToString() ) != null )
                        maxIndex++;
                    else
                        break;
                }
                maxAnimationIndices.Add( animationBaseName, maxIndex );
            }

            int number;

            //The first animation in 10 times more often
            if( firstAnimationIn10TimesMoreOften )
            {
                number = World.Instance.Random.Next( 10 + maxIndex ) + 1 - 10;
                if( number < 1 )
                    number = 1;
            }
            else
                number = World.Instance.Random.Next( maxIndex ) + 1;

            return number;
        }