Esempio n. 1
0
    public static void saveTopGameDataAt(TopGameData data, paths pathEnum)
    {
        if (data == null)
        {
            return;
        }

        if (pathEnum == paths.top1)
        {
            path = path_top1;
        }
        if (pathEnum == paths.top2)
        {
            path = path_top2;
        }
        if (pathEnum == paths.top3)
        {
            path = path_top3;
        }

        BinaryFormatter formatter = new BinaryFormatter();
        FileStream      stream    = new FileStream(path, FileMode.Create);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Esempio n. 2
0
    public static TopGameData loadTopGameDataAt(paths pathEnum)
    {
        if (pathEnum == paths.top1)
        {
            path = path_top1;
        }
        if (pathEnum == paths.top2)
        {
            path = path_top2;
        }
        if (pathEnum == paths.top3)
        {
            path = path_top3;
        }

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            TopGameData data = formatter.Deserialize(stream) as TopGameData;
            stream.Close();

            return(data);
        }
        else
        {
            //Debug.LogError("Save file not found in path: " + path);
            return(null);
        }
    }
Esempio n. 3
0
    public static GameDataSerializable loadGameDataAt(paths pathEnum)
    {
        if (pathEnum == paths.cell1)
        {
            path = path_cell1;
        }
        if (pathEnum == paths.cell2)
        {
            path = path_cell2;
        }
        if (pathEnum == paths.cell3)
        {
            path = path_cell3;
        }

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            GameDataSerializable data = formatter.Deserialize(stream) as GameDataSerializable;
            stream.Close();

            return(data);
        }
        else
        {
            //Debug.LogError("Save file not found in path: " + path);
            return(null);
        }
    }
        public ActionResult DeleteConfirmed(int id)
        {
            paths paths = db.paths.Find(id);

            db.paths.Remove(paths);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "path_id,path_name")] paths paths)
 {
     if (ModelState.IsValid)
     {
         db.Entry(paths).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(paths));
 }
    public void SaveData()
    {
        mapData md = new mapData();

        GameObject[] gbPaths  = GameObject.FindGameObjectsWithTag("path");
        GameObject[] gbPlaces = GameObject.FindGameObjectsWithTag("place");
        GameObject[] gbtags   = GameObject.FindGameObjectsWithTag("product");

        md.noOfPaths  = gbPaths.Length;
        md.noOfPlaces = gbPlaces.Length;
        md.noOftags   = gbtags.Length;
        foreach (GameObject gb in gbPaths)
        {
            paths p = new paths();

            p.name              = gb.name;
            p.position          = gb.transform.position;
            p.noOfPositions     = gb.GetComponent <LineRenderer>().positionCount;
            p.lineRendPositions = new Vector3[p.noOfPositions];

            gb.GetComponent <LineRenderer>().GetPositions(p.lineRendPositions);

            md.pathsList.Add(p);
        }

        foreach (GameObject gb in gbPlaces)
        {
            places p = new places();

            p.name     = gb.name;
            p.position = gb.transform.position;

            md.placesList.Add(p);
        }
        foreach (GameObject gb in gbtags)
        {
            tags p = new tags();

            p.name     = gb.name;
            p.position = gb.transform.position;

            md.tagsList.Add(p);
        }

        //xml saving script

        XmlSerializer serializer = new XmlSerializer(typeof(mapData));
        FileStream    stream     = new FileStream(Application.persistentDataPath + "/mapdata.xml", FileMode.Create);

        serializer.Serialize(stream, md);
        Debug.Log("File created");
        stream.Close();

        DataManagerCreator.ins.UploadeFile();
    }
        public ActionResult Create([Bind(Include = "path_id,path_name")] paths paths)
        {
            if (ModelState.IsValid)
            {
                db.paths.Add(paths);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(paths));
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            loadMapFromFile(@"maps\map.txt");
            paths longestPath = new paths();

            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < column; j++)
                {
                    if (!map[i, j].visited)
                    {
                        paths temp = getLongestPath(i, j);
                        if (longestPath.path.Count == temp.path.Count)
                        {
                            if (longestPath.path.Count > 0)
                            {
                                if ((temp.path.Peek().height - temp.path.ElementAt(temp.path.Count - 1).height) > (longestPath.path.Peek().height - longestPath.path.ElementAt(longestPath.path.Count - 1).height))
                                {
                                    longestPath = temp;
                                }
                            }
                            else
                            {
                                longestPath = temp;
                            }
                        }
                        else if (longestPath.path.Count < temp.path.Count)
                        {
                            longestPath = temp;
                        }
                    }
                }
            }
            Console.WriteLine("Maximal Path is: " + longestPath.path.Count.ToString() + "\nMaximal Drop is: " + (longestPath.path.Peek().height - longestPath.path.ElementAt(longestPath.path.Count - 1).height).ToString());
            Console.WriteLine("The path is : ");
            string printPath = "";

            for (int i = 0; i < longestPath.path.Count; i++)
            {
                if (i == longestPath.path.Count - 1)
                {
                    printPath += longestPath.path.ElementAt(i).height.ToString();
                }
                else
                {
                    printPath += longestPath.path.ElementAt(i).height.ToString() + "  >==>  ";
                }
            }
            Console.WriteLine(printPath);
            System.Console.ReadKey();
        }
        // GET: paths/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            paths paths = db.paths.Find(id);

            if (paths == null)
            {
                return(HttpNotFound());
            }
            return(View(paths));
        }
Esempio n. 10
0
        private static int column;      // the column length of the matrix


        public static paths getLongestPath(int i, int j)
        {
            map[i, j].visited = true;
            paths p       = new paths();
            paths curPath = new paths();

            if (j > 0 && map[i, j].height > map[i, j - 1].height)// search left direction
            {
                curPath = getLongestPath(i, j - 1);
                if (curPath.path.Count > p.path.Count) // if the current path length is bigger
                {
                    p = curPath;
                }
            }
            if (j < (column - 1) && map[i, j].height > map[i, j + 1].height)// search right direction
            {
                curPath = getLongestPath(i, j + 1);
                if (curPath.path.Count > p.path.Count)
                {
                    p = curPath;
                }
            }
            if (i > 0 && map[i, j].height > map[i - 1, j].height)// search Up direction
            {
                curPath = getLongestPath(i - 1, j);
                if (curPath.path.Count > p.path.Count)
                {
                    p = curPath;
                }
            }
            if (i < (row - 1) && map[i, j].height > map[i + 1, j].height)// search down direction
            {
                curPath = getLongestPath(i + 1, j);
                if (curPath.path.Count > p.path.Count)
                {
                    p = curPath;
                }
            }
            location l = new location(i, j, map[i, j].height);

            p.path.Push(l);
            return(p);
        }
Esempio n. 11
0
    public static void saveGameDataAt(GameDataSerializable data, paths pathEnum)
    {
        if (pathEnum == paths.cell1)
        {
            path = path_cell1;
        }
        if (pathEnum == paths.cell2)
        {
            path = path_cell2;
        }
        if (pathEnum == paths.cell3)
        {
            path = path_cell3;
        }

        BinaryFormatter formatter = new BinaryFormatter();
        FileStream      stream    = new FileStream(path, FileMode.Create);

        formatter.Serialize(stream, data);
        stream.Close();
    }
			ents[i] = new DirCacheEntry(paths[i]);
Esempio n. 13
0
 ThrowIfNull(paths, nameof(paths));
Esempio n. 14
0
        public static mapData UnpackBSP(string sourceFolder, string outputPath)
        {
            //Find the bsp file
            string[] found = Directory.GetFiles(sourceFolder, "*.bsp");
            if (found.Count() == 0)
            {
                throw new ArgumentException("Could not find BSP file in folder", "outputFolder");
            }
            else
            {
                string bsp = Directory.GetFiles(sourceFolder, "*.bsp")[0]; //Find the bsp file

                //Setup extraction arguments
                string extractarg = "-extract \"" + Path.GetFullPath(bsp) + "\" \"" + sourceFolder + "/extracted" + "\"";

                //Run the process
                Process bspzip = new Process();
                bspzip.StartInfo = new ProcessStartInfo
                {
                    FileName        = Environment.CurrentDirectory + "/bspzip.exe",
                    Arguments       = extractarg,
                    CreateNoWindow  = true, //Make sure to create no window since its gui now
                    UseShellExecute = false,
                };

                bspzip.Start();
                bspzip.WaitForExit();

                paths overview = new paths();

                //Extract the zip file's overview components
                using (var zip = ZipFile.OpenRead(sourceFolder + "/extracted.zip"))
                {
                    foreach (var entry in zip.Entries.ToList())
                    {                                                       //Uncommon error fix where path would contain drive letter
                        if (entry.FullName.ToLower().Contains("overviews") && !entry.FullName.Contains(":"))
                        {
                            //Setup target dir
                            string targetdir = sourceFolder + "/files/" + Path.GetDirectoryName(entry.FullName);
                            Directory.CreateDirectory(targetdir);

                            //Extract to target dir
                            string targetfile = sourceFolder + "/files/" + entry.FullName;
                            entry.ExtractToFile(targetfile, true);
                            Debug.Success("Extracted " + entry.FullName);


                            //File name sorting for the paths struct
                            string purefilename = Path.GetFileName(entry.FullName);
                            if (purefilename.Contains("radar_spectate"))
                            {
                                overview.path_radar_spectate = targetfile;
                            }

                            else if (purefilename.Contains("_radar"))
                            {
                                overview.path_radar = targetfile;
                            }

                            else if (purefilename.Contains(".txt"))
                            {
                                overview.path_radar_txt = targetfile;
                            }
                        }
                    }
                }

                mapData toSave = new mapData();

                if (overview.path_radar != null)
                {
                    toSave.image_radar = DDS.LoadImage(overview.path_radar, false);
                }

                if (overview.path_radar_spectate != null)
                {
                    toSave.image_radar_spectate = DDS.LoadImage(overview.path_radar_spectate, false);
                }

                if (overview.path_radar_txt != null)
                {
                    toSave.radar = new Radar(overview.path_radar_txt);
                }

                serialwrite.Binary.WriteToBinaryFile <mapData>(Path.ChangeExtension(outputPath, ".maprad"), toSave);

                return(toSave);
            }
        }