示例#1
0
文件: GrhInfo.cs 项目: wtfcolt/game
        public static AnimatedGrhData CreateGrhData(IEnumerable <GrhIndex> frames, float speed, SpriteCategorization categorization)
        {
            var grhIndex = NextFreeIndex();
            var gd       = new AnimatedGrhData(grhIndex, categorization);

            gd.SetSpeed(speed);
            gd.SetFrames(frames);
            AddGrhData(gd);
            return(gd);
        }
示例#2
0
        /// <summary>
        /// When overridden in the derived class, creates a new <see cref="GrhData"/> equal to this <see cref="GrhData"/>
        /// except for the specified parameters.
        /// </summary>
        /// <param name="newCategorization">The <see cref="SpriteCategorization"/> to give to the new
        /// <see cref="GrhData"/>.</param>
        /// <param name="newGrhIndex">The <see cref="GrhIndex"/> to give to the new
        /// <see cref="GrhData"/>.</param>
        /// <returns>
        /// A deep copy of this <see cref="GrhData"/>.
        /// </returns>
        protected override GrhData DeepCopy(SpriteCategorization newCategorization, GrhIndex newGrhIndex)
        {
            var copyArray = new StationaryGrhData[_frames.Length];

            Array.Copy(_frames, copyArray, _frames.Length);

            var copy = new AnimatedGrhData(newGrhIndex, newCategorization)
            {
                _frames = copyArray
            };

            copy.SetSpeed(Speed);

            return(copy);
        }
示例#3
0
文件: GrhInfo.cs 项目: wtfcolt/game
        /// <summary>
        /// Replaces an existing GrhData with a new <see cref="AnimatedGrhData"/>.
        /// </summary>
        /// <param name="grhIndex">The index of the <see cref="GrhData"/> to convert.</param>
        /// <returns>The created <see cref="AnimatedGrhData"/>, or null if the replacement failed.</returns>
        public static AnimatedGrhData ReplaceExistingWithAnimated(GrhIndex grhIndex)
        {
            var gd = GetData(grhIndex);

            if (gd == null)
            {
                return(null);
            }

            if (gd is AnimatedGrhData)
            {
                return((AnimatedGrhData)gd);
            }

            var newGD = new AnimatedGrhData(gd.GrhIndex, gd.Categorization);

            Delete(gd);
            AddGrhData(newGD);

            return(newGD);
        }
示例#4
0
        /// <summary>
        /// When overridden in the derived class, creates a new <see cref="GrhData"/> equal to this <see cref="GrhData"/>
        /// except for the specified parameters.
        /// </summary>
        /// <param name="newCategorization">The <see cref="SpriteCategorization"/> to give to the new
        /// <see cref="GrhData"/>.</param>
        /// <param name="newGrhIndex">The <see cref="GrhIndex"/> to give to the new
        /// <see cref="GrhData"/>.</param>
        /// <returns>
        /// A deep copy of this <see cref="GrhData"/>.
        /// </returns>
        protected override GrhData DeepCopy(SpriteCategorization newCategorization, GrhIndex newGrhIndex)
        {
            var copyArray = new StationaryGrhData[_frames.Length];
            Array.Copy(_frames, copyArray, _frames.Length);

            var copy = new AnimatedGrhData(newGrhIndex, newCategorization) { _frames = copyArray };
            copy.SetSpeed(Speed);

            return copy;
        }