Example #1
0
        public static void Load(string path)
        {
            if (!GameData.FileExists(path))
            {
                return;
            }

            var lines = GameData.Read(path);

            int i = 0;

            while (lines != null && i < lines.Length)
            {
                string hitboxName = lines[i++];

                if (string.IsNullOrWhiteSpace(hitboxName) || hitboxName.StartsWith("#"))
                {
                    continue;
                }

                HitboxSetManager hitboxSetManager = new HitboxSetManager {
                    allHitboxSets = new List <HitboxSet>()
                };

                bool isSameHitbox = true;
                while (isSameHitbox)
                {
                    string vertexSetDef = lines[i];

                    var parseResult = smartParse.Match(vertexSetDef);

                    if (parseResult.Success)
                    {
                        // string vertexSetName = parseResult.Groups["name"].Value;
                        Point  offset     = parsePoint(parseResult.Groups["offsets"].Value);
                        Point  dimensions = parsePoint(parseResult.Groups["dimensions"].Value);
                        string options    = parseResult.Groups["options"].Value;
                        bool   hFlip      = parseOption(options, 'H');
                        bool   vFlip      = parseOption(options, 'V');
                        bool   passive    = parseOption(options, 'P');

                        HitboxSet hitboxSet = new HitboxSet(offset, dimensions, hFlip, vFlip, passive);
                        hitboxSetManager.allHitboxSets.Add(hitboxSet);
                    }

                    i++;

                    if (i >= lines.Length || !lines[i].StartsWith("\t"))
                    {
                        isSameHitbox = false;
                        allHitboxCollections.Add(hitboxName, hitboxSetManager);
                    }
                }
            }
        }
Example #2
0
 public void UseHitbox(int hbNumber, bool isFlippedX, bool isFlippedY)
 {
     currentHitboxSet = allHitboxSets[hbNumber];
     SetFlipping(isFlippedX, isFlippedY);
 }