Example #1
0
        // TODO: separate loading for data edited by MonoAGS version
        private static void loadAIPathsData(TrackAIData data, string assetpath, Size trackSize)
        {
            Stream s = File.OpenRead(assetpath + "aipaths.dat");

            if (s == null)
            {
                return;
            }

            List <AIPathNode> paths   = new List <AIPathNode>();
            AGSFileReader     f       = new AGSFileReader(s);
            int        firstNodeIndex = f.ReadInt();
            int        lastNodeIndex  = f.ReadInt();
            int        n    = firstNodeIndex;
            AIPathNode last = null;

            do
            {
                int x = f.ReadInt();
                int y = f.ReadInt();
                // NOTE: since MonoAGS has Y axis pointing up, we need to invert one read from AGS file
                y = trackSize.Height - y;
                AIPathNode node = new AIPathNode();
                node.pt        = new Vector2(x, y);
                node.radius    = f.ReadInt();
                node.threshold = f.ReadInt();
                node.speed     = f.ReadInt();
                int p = f.ReadInt();
                n = f.ReadInt();
                if (last != null)
                {
                    node.prev = last;
                    last.next = node;
                }
                last = node;
                paths.Add(node);
            }while (n != firstNodeIndex);
            // Bind last node to the first one
            if (last != null)
            {
                last.next     = paths[0];
                paths[0].prev = last;
            }

            data.AIPathNodes = paths;
        }
Example #2
0
        private static List <RaceNode> loadCheckpoints(string assetpath, Size trackSize)
        {
            Stream s = File.OpenRead(assetpath + "checkpoints.dat");

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

            List <RaceNode> checkpoints    = new List <RaceNode>();
            AGSFileReader   f              = new AGSFileReader(s);
            int             firstNodeIndex = f.ReadInt();
            int             lastNodeIndex  = f.ReadInt();
            int             n              = firstNodeIndex;
            RaceNode        last           = null;

            do
            {
                int x = f.ReadInt();
                int y = f.ReadInt();
                // NOTE: since MonoAGS has Y axis pointing up, we need to invert one read from AGS file
                y = trackSize.Height - y;
                RaceNode node = new RaceNode();
                node.pt    = new Vector2(x, y);
                node.order = checkpoints.Count;
                int p = f.ReadInt();
                n = f.ReadInt();
                if (last != null)
                {
                    node.prev = last;
                    last.next = node;
                }
                last = node;
                checkpoints.Add(node);
            }while (n != firstNodeIndex);
            // Bind last node to the first one
            if (last != null)
            {
                last.next           = checkpoints[0];
                checkpoints[0].prev = last;
            }

            return(checkpoints);
        }