Example #1
0
        public void CreatePlayers(Dictionary <int, string> playerImageNames)
        {
            foreach (var id in playerImageNames.Keys)
            {
                var imageName = playerImageNames[id];
                if (GamepadManager.GetSlot(id).IsConnected)
                {
                    if (ActivePlayers.Find(p => p.ControllerId == id) != null)
                    {
                        continue;
                    }
                    if (ActivePlayers.Count < 4)
                    {
                        Player p = new Player(id, ActivePlayers.Count, imageName);

                        p.Health      = StartingHealth;
                        p.PunchDamage = PunchDamage;
                        p.Lives       = StartingLives;

                        ActivePlayers.Add(p);
                        AllPlayers.Add(p);
                    }
                }
            }
        }
Example #2
0
        public MenuWorld()
        {
            allImages   = LoadAllPlayers();
            takenImages = new List <string>();

            controllerMenus = new Dictionary <int, ControllerSelect>();
            pool            = new Stack <int>();

            for (int i = 0; i < 4; i++)
            {
                if (GamepadManager.GetSlot(i).IsConnected)
                {
                    AddController(i);
                }
            }
        }
Example #3
0
        void InitController()
        {
            var slot = GamepadManager.GetSlot(ControllerId);

            if (!slot.IsConnected)
            {
                return;
            }

            if (SnesController.IsMatch(slot))
            {
                var snes = new SnesController(slot);
                Jump            = snes.B;
                Attack          = snes.Y;
                Dodge           = snes.R;
                ActivateUpgrade = snes.X;
                Guard           = snes.L;
                Start           = snes.Start;

                Direction = snes.Dpad;
            }
            else if (Xbox360Controller.IsMatch(slot))
            {
                var xbox = new Xbox360Controller(slot);

                Jump            = xbox.A;
                Attack          = xbox.X;
                Dodge           = xbox.RB;
                ActivateUpgrade = xbox.Y;
                Guard           = xbox.LB;
                Start           = xbox.Start;

                Direction = xbox.LeftStick;
            }
            else
            {
                throw new Exception("invalid controller woh");
            }
        }
Example #4
0
        public ControllerSelect(MenuWorld parent, int playerSlot, int joyId)
        {
            var font = Library.GetFont("fonts/Laffayette_Comic_Pro.ttf");

            changing = false;

            this.parent = parent;
            Height      = FP.Height - 20;
            Width       = 250;

            this.JoyId      = joyId;
            this.PlayerSlot = playerSlot;

            Image            = new Image(Library.GetTexture("menu.png"));
            Image.Color      = new Color(Color = colors[PlayerSlot]);
            pressStart       = new Text("PRESS START");
            pressStart.Font  = font;
            pressStart.X    -= 80;
            pressStart.Y     = Height - 100;
            pressStart.Size  = 20;
            pressStart.Color = new Color(0);

            check = new Image(Library.GetTexture("ready.png"));
            check.CenterOO();
            check.Y      = Height * 0.75f;
            check.ScaleY = 0;

            OriginX       = Width / 2;
            Image.OriginX = Image.Width / 2;

            var slot = GamepadManager.GetSlot(joyId);

            if (SnesController.IsMatch(slot))
            {
                var snes = new SnesController(slot);
                confirm = new Image(Library.GetTexture("Snes_1.png"));
                Cursor  = snes.Dpad;
                Start   = snes.Start;
                Back    = snes.A;
                Confirm = snes.B;
            }
            else if (Xbox360Controller.IsMatch(slot))
            {
                var xbox = new Xbox360Controller(slot);
                confirm = new Image(Library.GetTexture("Xbox_1.png"));
                Cursor  = xbox.LeftStick;
                Start   = xbox.Start;
                Confirm = xbox.A;
                Back    = xbox.B;
            }
            else
            {
                throw new Exception("Invalid gamepad type, sorry D:");
            }

            AddComponent(Image);
            AddComponent(pressStart);
            if (wins.ContainsKey(JoyId))
            {
                var score = new Text(wins[joyId].ToString("Wins: 0"));
                score.Font  = font;
                score.Color = new Color(0);
                score.Size  = 20;
                score.X     = pressStart.X + 32;
                score.Y     = pressStart.Y + score.Size;
                AddComponent(score);
            }
        }