Exemplo n.º 1
0
        /// <summary>
        /// start to generte a multiplayer game
        /// </summary>
        public void StartGame()
        {
            Game g = ser.g;

            gamename        = g.Name;
            MyMaze          = g.You;
            YarivMaze       = g.Other;
            this.MazeString = MyMaze.GetMaze();
            this.Coordinate = MyMaze.GetStart();
            EndRow          = MyMaze.End.Row;
            EndCol          = MyMaze.End.Col;
            int r = MyMaze.Start.Row;
            int c = MyMaze.Start.Col;

            StartPoint          = new Pair(r, c);
            this.MyRow          = r;
            this.MyCol          = c;
            this.MazeName       = MyMaze.Name;
            this.Yriv_Cor       = YarivMaze.Start;
            this.YrivCol        = this.Yriv_Cor.Col;
            this.YrivRow        = this.Yriv_Cor.Row;
            this.EndYrivCol     = YarivMaze.End.Col;
            this.EndYrivRow     = YarivMaze.End.Row;
            this.YrivMazeString = YarivMaze.Maze;
            Wait = false;
        }
Exemplo n.º 2
0
/// <summary>
/// class of game
/// </summary>
/// <param name="name">game name</param>
/// <param name="mazename"></param>
/// <param name="u">my maze</param>
/// <param name="other">yriv maze</param>
        public Game(string name, string mazename, SingleMaze u, SingleMaze other)
        {
            this.Name     = name;
            this.MazeName = mazename;
            this.You      = u;
            this.Other    = other;
        }
Exemplo n.º 3
0
        /// <summary>
        /// create a single game by the value of serlize dictionary
        /// </summary>
        /// <returns>that single maze this serlize repersent</returns>
        public void CreateMaze()
        {
            string     maze  = this.Serlize["Maze"];
            string     n     = this.Serlize["Name"];
            Pair       start = CreatePair(this.Serlize["Start"]);
            Pair       end   = CreatePair(this.Serlize["End"]);
            SingleMaze m     = new SingleMaze(start, end, maze, n);

            this.maze = m;
        }
Exemplo n.º 4
0
        /// <summary>
        /// convert the msg of game
        /// </summary>
        public void ConvertStartGame()
        {
            string     name     = this.Serlize["Name"];
            string     mazename = this.Serlize["MazeName"];
            SingleMaze u        = WithoutName(this.Serlize["You"]);
            SingleMaze other    = WithoutName(this.Serlize["Other"]);
            Game       g        = new Game(name, mazename, u, other);

            this.g = g;
        }
Exemplo n.º 5
0
        /// <summary>
        /// convert the maze in game
        /// </summary>
        /// <param name="game"></param>
        /// <returns></returns>
        public SingleMaze WithoutName(string game)
        {
            Dictionary <string, string> ser = new Dictionary <string, string>();

            ser = JsonConvert.DeserializeObject <Dictionary <string, string> >(game);
            string     maze  = ser["Maze"];
            Pair       start = CreatePair(ser["Start"]);
            Pair       end   = CreatePair(ser["End"]);
            SingleMaze sm    = new SingleMaze(start, end, maze);

            return(sm);
        }
Exemplo n.º 6
0
 /// <summary>
 /// close multiplayer game
 /// </summary>
 public void closeGame(string name)
 {
     MyMaze     = null;
     MazeString = null;
     if (name.Length != 0)
     {
         this.Client.SendMsg("close " + name);
     }
     else
     {
         this.Client.SendMsg("close " + this.gamename);
     }
 }
Exemplo n.º 7
0
        public void MazeHelper()
        {
            MyMaze          = ser.maze;
            this.MazeString = MyMaze.GetMaze();
            this.Coordinate = MyMaze.GetStart();
            EndRow          = MyMaze.End.Row;
            EndCol          = MyMaze.End.Col;
            int r = MyMaze.Start.Row;
            int c = MyMaze.Start.Col;

            StartPoint    = new Pair(r, c);
            this.MyRow    = r;
            this.MyCol    = c;
            this.MazeName = MyMaze.Name;
        }
Exemplo n.º 8
0
 /// <summary>
 /// close the single game and clean old data
 /// </summary>
 public void closeSingle()
 {
     MyMaze     = null;
     MazeString = null;
 }