void Awake() { machinePlayer = GetComponent <MachinePlayer>(); keyboardPlayer = GetComponent <KeyboardPlayer>(); followPlayer = GetComponent <FollowPlayer>(); // color sprite = GetComponent <SpriteRenderer>(); shadow = transform.GetChild(0).GetComponent <SpriteRenderer>(); }
public override void Init() { Game.Instance.MapManager = new MapManager(Game.Instance, Game.Instance.SpriteBatch); World world = Game.Instance.World; PlayerOne = new KeyboardPlayer(world); PlayerOne.Position = new Vector2(500, 500); players[0] = PlayerOne; if (players.Length == 2) { PlayerTwo = new GamepadPlayer(world, PlayerIndex.One); PlayerTwo.Position = new Vector2(500, 700); Players[1] = PlayerTwo; } else { WeaponComponent weaponComponent = PlayerOne.Components .FirstOrDefault(c => c is WeaponComponent) as WeaponComponent; weaponComponent.CurrentWeapon.AddPower(15); } topWall = new Wall(world, new Vector2(Game.Instance.ScreenWidth / 2f, Game.Instance.ScreenHeight / 2f - 50), Game.Instance.ScreenWidth * 2, 100); bottomWall = new Wall(world, new Vector2(Game.Instance.ScreenWidth / 2f, Game.Instance.ScreenHeight + 50), Game.Instance.ScreenWidth * 2, 100); leftWall = new Wall(world, new Vector2(-50, Game.Instance.ScreenHeight / 2f), 100, Game.Instance.ScreenHeight); rightWall = new Wall(world, new Vector2(Game.Instance.ScreenWidth + 50, Game.Instance.ScreenHeight / 2f), 100, Game.Instance.ScreenHeight); Game.Instance.Components.Add(Game.Instance.MapManager); StateTrigger trigger = new StateTrigger(Game.Instance); Game.Instance.Components.Add(trigger); Game.Instance.MapManager.ChangeMap("testmap"); Song bgmusic = Game.Instance.Content.Load <Song>("music\\bgmusic"); MediaPlayer.Play(bgmusic); MediaPlayer.Volume = 0.15f; MediaPlayer.IsRepeating = true; }
public string Play() { if (!SteamUtil.IsSteamRunning()) { MessageBox.Show("If you own the Steam Version, please open Steam, then click OK"); } var options = profile.Options; KeyboardPlayer playerKeyboard = (KeyboardPlayer)profile.Options["keyboardPlayer"]; int pKeyboard = (int)playerKeyboard; IniFile file = new IniFile(saveFile); file.IniWriteValue("SystemSettings", "WindowedFullscreen", "False"); file.IniWriteValue("SystemSettings", "Fullscreen", "False"); file.IniWriteValue("Engine.Engine", "bMuteAudioWhenNotInFocus", "False"); file.IniWriteValue("Engine.Engine", "bPauseOnLossOfFocus", "False"); file.IniWriteValue("WillowGame.WillowGameEngine", "bPauseLostFocusWindowed", "False"); file.IniWriteValue("WillowGame.WillowGameEngine", "bMuteAudioWhenNotInFocus", "False"); Screen[] all = Screen.AllScreens; // minimize everything //User32.MinimizeEverything(); List <PlayerInfo> players = profile.PlayerData; string backupDir = GameManager.Instance.GetBackupFolder(this.userGame.Game); string binFolder = Path.GetDirectoryName(executablePlace); string rootFolder = Path.GetDirectoryName( Path.GetDirectoryName(binFolder)); int gamePadId = 0; for (int i = 0; i < players.Count; i++) { string linkFolder = Path.Combine(backupDir, "Instance" + i); PlayerInfo player = players[i]; // Set Borderlands 2 Resolution and stuff to run Rectangle playerBounds = player.monitorBounds; // find the monitor that has this screen Screen owner = null; for (int j = 0; j < all.Length; j++) { Screen s = all[j]; if (s.Bounds.Contains(playerBounds)) { owner = s; break; } } int width = playerBounds.Width; int height = playerBounds.Height; if (owner == null) { // log // screen doesn't exist //continue; } else { Rectangle ob = owner.Bounds; if (playerBounds.X == ob.X && playerBounds.Y == ob.Y && playerBounds.Width == ob.Width && playerBounds.Height == ob.Height) { // borderlands 2 has a limitation for max-screen size, we can't go up to the monitor's bounds // in windowed mode file.IniWriteValue("SystemSettings", "WindowedFullscreen", "True"); } else { file.IniWriteValue("SystemSettings", "WindowedFullscreen", "False"); } } file.IniWriteValue("SystemSettings", "ResX", width.ToString(CultureInfo.InvariantCulture)); file.IniWriteValue("SystemSettings", "ResY", height.ToString(CultureInfo.InvariantCulture)); // Link-making Directory.CreateDirectory(linkFolder); int exitCode; CmdUtil.LinkDirectories(rootFolder, linkFolder, out exitCode, "binaries"); string linkBin = Path.Combine(linkFolder, @"Binaries\Win32"); Directory.CreateDirectory(linkBin); CmdUtil.LinkDirectories(binFolder, linkBin, out exitCode); CmdUtil.LinkFiles(binFolder, linkBin, out exitCode, "xinput", "borderlands"); string exePath = Path.Combine(linkBin, this.userGame.Game.ExecutableName); File.Copy(this.executablePlace, exePath, true); // Link-end ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = exePath; startInfo.WindowStyle = ProcessWindowStyle.Hidden; // NEW object option = options["saveid" + i]; //object option = 11; int id = (int)option; if (i == pKeyboard) { startInfo.Arguments = "-AlwaysFocus -NoController -SaveDataId=" + id.ToString(CultureInfo.InvariantCulture); } else { byte[] xdata = null; switch (gamePadId) { case 0: xdata = Nucleus.Coop.Games.GamesResources.xinput1; break; case 1: xdata = Nucleus.Coop.Games.GamesResources.xinput2; break; case 2: xdata = Nucleus.Coop.Games.GamesResources.xinput3; break; case 3: xdata = Nucleus.Coop.Games.GamesResources.xinput4; break; default: xdata = Nucleus.Coop.Games.GamesResources.xinput4; break; } using (Stream str = File.OpenWrite(Path.Combine(linkBin, "xinput1_3.dll"))) { str.Write(xdata, 0, xdata.Length); } startInfo.Arguments = "-AlwaysFocus -nostartupmovies -SaveDataId=" + id.ToString(CultureInfo.InvariantCulture); gamePadId++; } startInfo.UseShellExecute = true; startInfo.WorkingDirectory = Path.GetDirectoryName(exePath); Process proc = Process.Start(startInfo); ScreenData data = new ScreenData(); data.Position = new Point(playerBounds.X, playerBounds.Y); data.Size = new Size(playerBounds.Width, playerBounds.Height); player.Process = proc; player.Tag = data; } return(string.Empty); }