예제 #1
0
파일: AIServer.cs 프로젝트: Mattias1/pacman
 public AIServer(PacManServer server, MultiPlayerInfo mpInfo)
 {
     this.Server = server;
     this.Server.SetAI(this);
     this.multiplayerInfo = mpInfo;
     this.locked          = false;
     this.gameDatas       = new string[Level.MAXPLAYERCOUNT];
 }
예제 #2
0
 public AIClient(PacManClient client, MultiPlayerInfo mpInfo)
 {
     this.client = client;
     this.client.SetAI(this);
     this.multiplayerInfo = mpInfo;
     this.locked          = false;
     this.gameData        = "";
     this.gameCommands    = new Queue <string>();
 }
예제 #3
0
        public void Create()
        {
            this.errorMessages = "";
            if (!this.saveIPandPort())
            {
                return;
            }
            MultiPlayerInfo mpInfo = new MultiPlayerInfo(true);

            mpInfo.Server.Start();

            this.Remove();
            this.screenManager.AddScreen(new LobbyScreen(this.screenManager, this.bgLevel, mpInfo));
        }
예제 #4
0
파일: Level.cs 프로젝트: Mattias1/pacman
 public Level(ScreenManager sM, string map, AI[] ais, MultiPlayerInfo mpInfo = null)
     : base(Vector2.Zero, Vector2.Zero)
 {
     this.ScreenManager  = sM;
     this.particleSystem = new ParticleSystem();
     this.DrawText       = true;
     this.Graphics       = sM.Graphics;
     if (ais.Length != Level.MAXPLAYERCOUNT)
     {
         throw new Exception(String.Format("There should be {0} AIs", Level.MAXPLAYERCOUNT));
     }
     this.Ais = ais;
     if (map == "")
     {
         map = Settings.Get.Map;
     }
     this.loadGrid(map);
     this.CreateMesh();
     this.multiplayerInfo = mpInfo;
     this.Initialize();
 }
예제 #5
0
        public void Join()
        {
            // Try to connect
            bool lastErrorWasConnectionFailed = this.errorMessages == "Connection failed.";

            this.errorMessages = "";
            if (!this.saveIPandPort())
            {
                return;
            }
            MultiPlayerInfo mpInfo = new MultiPlayerInfo(false);

            if (!mpInfo.Client.Connect(Settings.Get.IP, Settings.Get.Port))
            {
                this.errorMessages = lastErrorWasConnectionFailed ? "Connection failed!" : "Connection failed.";
                return;
            }
            mpInfo.Client.Start();

            // Start the lobby
            this.Remove();
            this.screenManager.AddScreen(new LobbyScreen(this.screenManager, this.bgLevel, mpInfo));
        }
예제 #6
0
 public GameScreen(ScreenManager sM, string map, AI[] ais, MultiPlayerInfo mpInfo = null)
     : base(sM)
 {
     this.level = new Level(sM, map, ais, mpInfo);
 }
예제 #7
0
파일: AIServer.cs 프로젝트: Mattias1/pacman
 public PacManServer(MultiPlayerInfo mpInfo)
     : base(Settings.Get.IP, Settings.Get.Port)
 {
     this.MultiPlayerInfo = mpInfo;
 }
예제 #8
0
        public LobbyScreen(ScreenManager sM, BackgroundLevel bgLevel = null, MultiPlayerInfo mpInfo = null)
            : base(sM)
        {
            // Some settings
            if (bgLevel == null)
            {
                this.bgLevel = new BackgroundLevel(this.screenManager);
            }
            else
            {
                this.bgLevel = bgLevel;
            }
            this.errorMessages   = "";
            this.multiplayerInfo = mpInfo;
            this.MenuSize        = this.screenManager.ScreenResolution - 150 * Vector2.UnitX;
            this.NrOfColumns     = 2;
            this.PositionMenuScreen(MenuItem.HorizontalAlign.Center, MenuItem.VerticalAlign.Top);
            this.FavMenuItem.TextAlign          = MenuItem.HorizontalAlign.Left;
            this.HorizontalAndVerticalArrowKeys = true;

            // Start and back buttons
            MenuItem miStart = new MenuItem("Start", sM.Graphics);

            if (!this.MultiPlayer || this.multiplayerInfo.IsHost())
            {
                miStart.OnClick += (o, e) => { this.Start(); }
            }
            ;
            this.AddMenuItem(miStart);
            this.miBack          = new MenuItem("Back", sM.Graphics);
            this.miBack.OnClick += (o, e) => { this.Remove(); };
            this.AddMenuItem(this.miBack, 1);

            // The player dropdowns
            List <string> options = new List <string>()
            {
                Settings.Get.Name, "Stupid", "Normal", "Euclidian", NONE
            };

            this.miPacMan   = new MenuItemList("PacMan", new List <string>(options), sM.Graphics);
            this.miMsPacMan = new MenuItemList("Ms PacMan", new List <string>(options), sM.Graphics);
            this.miGhosts   = new MenuItemList[4];
            for (int i = 0; i < this.miGhosts.Length; i++)
            {
                this.miGhosts[i] = new MenuItemList(Ghost.GetName(i), new List <string>(options), sM.Graphics);
            }
            if (this.MultiPlayer)
            {
                this.managePlayersMP();
            }
            this.finishCreatingMenus();

            // The maps
            MenuItem[] miMaps = new MenuItem[6];
            for (int i = 0; i < miMaps.Length; i++)
            {
                miMaps[i]          = new MenuItem("Map " + i.ToString(), sM.Graphics);
                miMaps[i].OnClick += generateSetMap(i);
                this.AddMenuItem(miMaps[i], 1);
            }

            // Colour the menus (and position them)
            this.FastLayout(this.FavMenuItem);
            miBack.TextAlign = MenuItem.HorizontalAlign.Right;

            // Set the PacMan and ghost colours
            this.miPacMan.SelectedColour    = Color.Yellow;
            this.miMsPacMan.SelectedColour  = Color.Yellow;
            this.miGhosts[0].SelectedColour = Color.Red;
            this.miGhosts[1].SelectedColour = Color.DeepPink;
            this.miGhosts[2].SelectedColour = Color.Cyan;
            this.miGhosts[3].SelectedColour = Color.Orange;

            // Position the menus (override previous positioning)
            this.positionMenuItems(miStart, miMaps);

            // Load the values
            this.Load();

            // Subscribe to the multiplayer info events
            if (this.MultiPlayer)
            {
                this.multiplayerInfo.OnRefresh += (o, e) => { this.managePlayersMP(); }
            }
            ;
        }
예제 #9
0
 public PacManClient(MultiPlayerInfo mpInfo)
     : base()
 {
     this.MultiPlayerInfo = mpInfo;
     this.printAtStart    = false;
 }