コード例 #1
0
 public void ChangeSequence(string sequenceName)
 {
     if (mCurrentSequenceName != sequenceName)
     {
         mCurrentSequence     = mSequenceData[sequenceName];
         mSequenceIndex       = 0;
         mCurrentTick         = 0.0;
         mCurrentSequenceName = sequenceName;
     }
 }
コード例 #2
0
        public void LoadContent(ContentManager content)
        {
            string[] descriptors = System.IO.Directory.GetFiles("Descriptors/Images/Enemy/", "*.json", System.IO.SearchOption.TopDirectoryOnly);
            foreach (var descriptor in descriptors)
            {
                string         aJson      = File.ReadAllText(descriptor);
                EnemyAtlasInfo aInfo      = JsonConvert.DeserializeObject <EnemyAtlasInfo>(aJson);
                Texture2D      image      = content.Load <Texture2D>("Images/Enemy/" + aInfo.Image);
                SpriteAtlas    enemyAtlas = new SpriteAtlas();
                Dictionary <string, List <Rectangle> > clipMap = new Dictionary <string, List <Rectangle> >();
                Dictionary <string, int> originMap             = new Dictionary <string, int>();
                foreach (var clipset in aInfo.ClipSets)
                {
                    List <Rectangle> clips = new List <Rectangle>();
                    foreach (var clip in clipset.Set)
                    {
                        clips.Add(new Rectangle(clip[0], clip[1], clip[2], clip[3]));
                    }
                    clipMap.Add(clipset.Key, clips);
                    originMap.Add(clipset.Key, 0);
                    mNameToAtlasMap.Add(clipset.Key, enemyAtlas);
                }
                enemyAtlas.SetImage(image);
                enemyAtlas.SetClipMap(clipMap, originMap);

                foreach (var enemy in aInfo.EnemySequences)
                {
                    Dictionary <string, SpriteSequenceData> sequenceMap = new Dictionary <string, SpriteSequenceData>();
                    foreach (var sequence in enemy.Sequences)
                    {
                        SpriteSequenceData s = new SpriteSequenceData();
                        s.mSequence = sequence.Seq;
                        s.mLooping  = sequence.Looping;
                        s.mSubLoop  = sequence.SubLoop;
                        sequenceMap.Add(sequence.Key, s);
                    }
                    mNameToSequencesetMap.Add(enemy.Key, sequenceMap);
                }
            }
        }