Exemple #1
0
        // Fait appel à la dll pour disposer les unités à l'initialisation du jeu sur la map
        public static void placePlayers(int width, int[] posPlayers)
        {
            IntPtr algo = MapAlgo_new();

            ApiUtil.MapAlgo_placePlayers(algo, 10, posPlayers);
            MapAlgo_delete(algo);
        }
Exemple #2
0
        // Génère l'ensemble des unités
        public void createUnits(int nbUnits)
        {
            UnitFactory unitFct = new UnitFactory();

            var    posPlayers = new int[2];
            IntPtr algo       = ApiUtil.MapAlgo_new();

            ApiUtil.MapAlgo_placePlayers(algo, Map.Width, posPlayers);
            foreach (KeyValuePair <int, Player> kvp in PlayersDictionary)
            {
                int         idPlayer       = kvp.Key;
                Player      player         = kvp.Value;
                UnitType    race           = player.Race;
                List <Unit> unitsList      = new List <Unit>();
                Position    positionDepart = new Position(posPlayers[idPlayer - 1] / Map.Width, posPlayers[idPlayer - 1] % Map.Width);

                for (int i = 1; i <= nbUnits; i++)
                {
                    unitsList.Add(unitFct.createUnit(positionDepart, player.Race, i));
                }
                UnitsDictionary.Add(idPlayer, unitsList);
            }
        }