Пример #1
0
        public Labyrinthe()
        {
            // get the dimensions of the matrix before initialized the temp matrix
            StreamReader file1 = new StreamReader("board.txt");
            string       line1;
            int          n    = 0;
            bool         done = false;

            while ((line1 = file1.ReadLine()) != null)
            {
                if (!done)
                {
                    dimY = line1.Length;
                    done = true;
                }
                n++;
            }
            dimX = n;

            // fill the temp matrix with the data inside the file
            string       line2;
            StreamReader file2 = new StreamReader("board.txt");

            temp = new string[dimX, dimY];

            while ((line2 = file2.ReadLine()) != null)
            {
                for (int i = 0; i < dimX; i++)
                {
                    string data = line2;
                    for (int j = 0; j < dimY; j++)
                    {
                        temp[i, j] = data[j].ToString();
                    }
                    line2 = file2.ReadLine();
                }
            }

            caseFactory       = new CaseFactory();
            combattantFactory = new CombattantFactory();

            RemplissageBoard();
            //AffichageBoardTemp();
            //displayBoard();
            actionList = new Stack <int []>();
        }
Пример #2
0
        public GameManager()
        {
            delay            = 500;
            labyrinthe       = new Labyrinthe();
            listeCombattants = new List <OtherCase>();
            listeObjets      = new List <OtherCase>();

            combattantFactory = new CombattantFactory();
            caseFactory       = new CaseFactory();

            random          = new Random();
            threadAffichage = new Thread(() => labyrinthe.displayBoard(delay, true));
            entierBloque    = 0;
            directionBloque = false;

            InitBoard();

            threadViesCombattant = new Thread(() => VieCombattants(listeCombattants));

            /*
             * //create thread for each combattant
             * threadCombattant = new Thread[listeCombattants.Count];
             *
             *
             * for(int i = 0; i != threadCombattant.Length; i++)
             * {
             *  threadCombattant[i] = new Thread(new ThreadStart(()=>initCombattantListVisitesAndQueue(listeCombattants[i])));
             *  threadCombattant[i].Start();
             * }
             */
            Console.WriteLine("Appuyer pour jouer");
            Console.ReadLine();
            Console.Clear();
            threadAffichage.Start();
            Thread threadAffichageStack = new Thread(AjouterStackActionList);

            threadAffichageStack.Start();

            Thread t1 = new Thread(() => FunctionCombattant(listeCombattants[0]));
            Thread t2 = new Thread(() => FunctionCombattant(listeCombattants[1]));

            t1.Start();
            t2.Start();
        }