public frmGame() { InitializeComponent(); try { // graphics quality this.graphics = this.CreateGraphics(); this.graphics.SmoothingMode = SmoothingMode.HighQuality; this.graphics.CompositingMode = CompositingMode.SourceCopy; this.graphics.CompositingQuality = CompositingQuality.HighQuality; // background image string path = ConfigurationManager.AppSettings["pathImages"]; this.BackgroundImage = Image.FromFile(path + "GameBackground.png", false); // get the input method (keyboard/mouse) from settings string input = ConfigurationManager.AppSettings["input"]; this.inputType = (input == "Mouse" ? Balls.eInputType.Mouse : Balls.eInputType.Keyboard); if (inputType == Balls.eInputType.Mouse) { this.MouseMove += new MouseEventHandler(this.frmGame_MouseMove); } // world objects this.balls = new Balls(inputType); this.board = new Board(1); this.playerPad = new PlayerPad(); this.outputLine = new OutputLine(); this.gameControl = new GameControl(); this.scoreBoard = new ScoreBoard(); this.highScores = new HighScores(); this.particlesSystem = new ParticlesSystem(); this.collisionsSystem = new CollisionsSystem(); // add the listeners for objects comunication this.playerPad.DoubleBallRewardEvent += new PlayerPad.DoubleBallEventHandler(balls.DoubleBallEvent); this.playerPad.TripleBallRewardEvent += new PlayerPad.TripleBallEventHandler(balls.TripleBallEvent); this.playerPad.WinLevelRewardEvent += new PlayerPad.WinLevelEventHandler(gameControl.WinLevelEvent); this.playerPad.SlowBallRewardEvent += new PlayerPad.SlowBallEventHandler(balls.SlowBallEvent); this.playerPad.DemolitionBallRewardEvent += new PlayerPad.DemolitionBallEventHandler(balls.DemolitionBallEvent); // start this.tmrStart.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }
// Start is called before the first frame update void Start() { myRigidBody = GetComponent <Rigidbody2D>(); controller = new PlayerPad(); rig2d = gameObject.GetComponent <Rigidbody2D>(); tr = gameObject.GetComponent <Transform>(); anim = gameObject.GetComponent <Animator>(); spriteRenderer = gameObject.GetComponent <SpriteRenderer>(); weapon = gameObject.transform.GetChild(0).gameObject; w_tr = weapon.GetComponent <Transform>(); hp = UseJsonFile().recentHP; mp = max_mp; }
/// <summary> /// Assigns a specified player to a certain pad. /// </summary> /// <param name="player">The player to assign to a device.</param> /// <param name="pad">The input device to be assigned a player.</param> /// <remarks>Allows the programmer to check input on a device without knowing what it's type/index is.</remarks> public static void LockController(PPG_Player player, PlayerPad pad) { bindings[(int)player] = pad; }