/// <summary> /// Occurs when the user clicks the new game button. When a new game is created the office /// camera is shown and a user instance is created. This is also a good time to setup the /// Game logic engine which handles the characters and user. The flashlight is also /// initialized. /// </summary> /// <param name="sender">ignored</param> /// <param name="e">ignored</param> private void NewGameImageButton_Click(object sender, EventArgs e) { OfficeForm officeCameraForm = new OfficeForm(); // // Stop the theme music anytime a game starts. // _soundEngine.StopSound(_startMenuThemeMusic); User user = new User() { MaskImage = global::FNAF.Properties.Resources.FreddyMask, CurrentForm = officeCameraForm, LastForm = this }; // // Start the game engine. This is the engine that handles basic game logic such as // when to play certain sounds, randomly moves characters throughout the rooms and // decides when to scare if to scare at all. This will also setup the user/security // guard. // ThreadingEngine.StartThread(new GameEngine(user)); // // Each game requires the flashlight so start the flashlight thread here. // ThreadingEngine.StartThread(new Flashlight()); // // The new game is initialized now start the office camera to begin. // GameEngine.ShowForm(officeCameraForm, this); }
protected override void OnClosing(CancelEventArgs e) { if (this.Sound != null) { ThreadingEngine.GetThread <SoundEngine>().StopSound(this.Sound); } base.OnClosing(e); }
public CameraForm(Sound sound, string name) : base(name) { InitializeComponent(); if (Sound != null) { base.Sound = ThreadingEngine.GetThread <SoundEngine>().PlaySound(Sound); } }
private CharacterCollection GetCharacters(Button button) { switch (button.Name) { case "Camera1Button": return(ThreadingEngine.GetThread <GameEngine>().GetCharacters(RoomType.PartyRoom1)); case "Camera2Button": return(ThreadingEngine.GetThread <GameEngine>().GetCharacters(RoomType.PartyRoom2)); case "Camera3Button": return(ThreadingEngine.GetThread <GameEngine>().GetCharacters(RoomType.PartyRoom3)); case "Camera4Button": return(ThreadingEngine.GetThread <GameEngine>().GetCharacters(RoomType.PartyRoom4)); case "Camera5Button": return(ThreadingEngine.GetThread <GameEngine>().GetCharacters(RoomType.MainHall)); case "Camera6Button": break; case "Camera7Button": break; case "Camera8Button": break; case "Camera9Button": break; case "Camera10Button": break; case "Camera11utton": break; case "Camera12Button": break; case "YouButton": break; } return(new CharacterCollection()); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); new StartMenuForm().Show(); Application.Run(); ThreadingEngine.Dispose(); }
private void CameraButton_Click(object sender, EventArgs e) { _soundEngine.PlaySound(global::FNAF.Properties.Resources.VariousFNAFSound); Button button = (Button)sender; CharacterCollection characters = GetCharacters(button); FormBase form = GetForm(button); FormBase parent = GetParentForm(); ThreadingEngine.GetThread <GameEngine>().UpdateForm(parent, form); }
private FormBase GetForm(Button button) { switch (button.Name) { case "Camera1Button": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.PartyRoom1)); case "Camera2Button": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.PartyRoom2)); case "Camera3Button": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.PartyRoom3)); case "Camera4Button": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.PartyRoom4)); case "Camera5Button": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.LeftAirVent)); case "Camera6Button": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.RightAirVent)); case "Camera7Button": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.MainHall)); case "Camera8Button": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.PartsService)); case "Camera9Button": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.ShowStage)); case "Camera10Button": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.GameArea)); case "Camera11utton": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.PrizeCorner)); case "Camera12Button": return(ThreadingEngine.GetThread <GameEngine>().GetCameraForm(RoomType.KidsCove)); case "YouButton": return(new OfficeForm()); } return(new CameraForm()); }
/// <summary> /// Overridden OnLoad Event sets up the form and starts the engines needed for this form /// as well as playing the theme music in a loop. /// </summary> /// <param name="e">Not used, passed down to the base class' OnLoad event handler</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); // // Start the sound engine here to play the theme mustic. // ThreadingEngine.StartThread(_soundEngine); // // Start the theme mustic for the start menu // _startMenuThemeMusic = _soundEngine.PlaySound( global::FNAF.Properties.Resources.StartMenuThemeMusic, // theme mustic for the menu true // play it in a loop ); }
public CameraMap() { _soundEngine = ThreadingEngine.GetThread <SoundEngine>(); InitializeComponent(); }
protected override void OnLoad(EventArgs e) { // // The PictureBox with the Image of the room. // this.BackgroundPictureBox = new PictureBox(); this.BackgroundPictureBox.BackColor = System.Drawing.Color.Transparent; this.BackgroundPictureBox.Image = this.DefaultImage; this.BackgroundPictureBox.Location = new System.Drawing.Point(0, 0); this.BackgroundPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.BackgroundPictureBox.Size = new Size(this.Size.Width - 5, this.Size.Height - 15); this.Controls.Add(this.BackgroundPictureBox); if (this.AutoScrollBackForth) { _scrollBackForthTimer = new Timer(); _scrollBackForthTimer.Interval = 500; // 1/2 second this.BackgroundPictureBox.Size = new Size(this.Size.Width + 100, this.Size.Height + 100); } if (this.SupportsFlashlight) { _flashlight = ThreadingEngine.GetThread <Flashlight>(); _flashlight.OutOfPower += Flashlight_OutOfPower; _flashlight.ImageChanged += Flashlight_ImageChanged; this.FlashlightPowerPictureBox = new PictureBox(); this.FlashlightPowerPictureBox.BackColor = System.Drawing.Color.Transparent; this.FlashlightPowerPictureBox.Image = _flashlight.Image; this.FlashlightPowerPictureBox.Location = new System.Drawing.Point(20, 20); this.FlashlightPowerPictureBox.Name = "FlashlightPictureBox"; this.FlashlightPowerPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.FlashlightPowerPictureBox.Size = new Size(_flashlight.Image.Width / 3, _flashlight.Image.Height / 3); this.FlashlightPowerPictureBox.Tag = _flashlight.Image.Tag; this.BackgroundPictureBox.Controls.Add(this.FlashlightPowerPictureBox); } if (this.SupportsMask) { // // The PictureBox to overlay on the BackgroundPictureBox // this.MaskPictureBox = new PictureBox(); this.MaskPictureBox.BackColor = System.Drawing.Color.Transparent; this.MaskPictureBox.Image = ThreadingEngine.GetThread <GameEngine>().User.MaskImage; this.MaskPictureBox.Location = new System.Drawing.Point(0, 0); this.MaskPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.MaskPictureBox.Size = new Size(this.Size.Width - 5, this.Size.Height - 15); this.MaskPictureBox.Visible = false; this.BackgroundPictureBox.Controls.Add(this.MaskPictureBox); } if (this.SupportsMap) { // // The PictureBox to overlay on the BackgroundPictureBox // this.CameraMap = new CameraMap(); this.CameraMap.BackColor = System.Drawing.Color.Transparent; this.CameraMap.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; this.CameraMap.Visible = true; this.BackgroundPictureBox.Controls.Add(this.CameraMap); } this.KeyDown += new KeyEventHandler(Form_KeyDown); base.OnLoad(e); }