/// <summary> /// Called when a button defining an action of the item is clicked. /// Processes the action. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Action_Event(object sender, EventArgs e) { Button btn = (Button)sender; string s = this.actions["c" + btn.TabIndex.ToString()]["redirect"].ToString(); int score = (int)this.actions["c" + btn.TabIndex.ToString()]["score"]; GameWindow.GetInstance().SetScore(score); if (s.Length == 0 || s == "0") { PNCWindow window = ((PNCWindow)this.FindForm()); GameWindow.GetInstance().SwitchSituation(); ((PNCWindow)this.FindForm()).Close(); Exit(); } else if (s == "-1") { Exit(); } else { this.actions = Tools.Get_From_JSON(manager.GetLibraryPath() + Path.DirectorySeparatorChar + "dialogs" + Path.DirectorySeparatorChar + s + ".json"); this.lbl_desc.Text = actions["question"].ToString(); DisplayActions(); } }
/// <summary> /// Sets the number of items that needs to be validated in order to complete the situation. /// Calls the GameWindow to switch situation if all the items are validated. /// </summary> /// <param name="n">Number of items</param> public void setItemsLeft(int n) { this.items_left = n; if (n == 0) { GameWindow.GetInstance().SwitchSituation(); } }
/// <summary> /// Update the transition to fade in or fade out. /// </summary> public void Update() { if (t) { if (state < 10) { state++; } } else { if (state == 1) { t = true; GameWindow.GetInstance().RemoveTransition(); } else { state--; } } }
/// <summary> /// Create a image from a file specified by the path. /// </summary> /// <param name="path">Path to the file.</param> /// <returns>The image created from the file.</returns> public Image CreateImage(string path) { try { Bitmap orig = new Bitmap(path); Bitmap clone = new Bitmap(orig.Width, orig.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); using (Graphics gr = Graphics.FromImage(clone)) { gr.DrawImage(orig, new Rectangle(0, 0, clone.Width, clone.Height)); } orig.Dispose(); return((Image)clone); } catch (Exception) { MessageBox.Show("L'image de la texture n'a pas été trouvée, ou elle est inaccessible.\n" + "Veuillez vérifier qu'elle soit bien ici : " + path); GameWindow.GetInstance().Close(); } return(null); }
/// <summary> /// Open the map of the user clicks on the map icon. /// </summary> /// <param name="sender">Control calling the method.</param> /// <param name="e">Arguments from the action whose caused the call of this method.</param> private void pbox_map_Click(object sender, EventArgs e) { GameWindow.GetInstance().RemoveAllControls(); this.FindForm().Controls.Add(new Map(this.FindForm().Text)); }
/// <summary> /// Open the phone if the user clicks on the phone icon. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pbox_phone_Click(object sender, EventArgs e) { GameWindow.GetInstance().RemoveAllControls(); this.FindForm().Controls.Add(new Phone()); }
/// <summary> /// Remove the game message in the game window. /// </summary> /// <param name="sender">Control calling the method.</param> /// <param name="e">Arguments from the action whose caused the call of this method.</param> private void btn_ok_Click(object sender, EventArgs e) { GameWindow.GetInstance().Controls.Remove(this); GameWindow.GetInstance().Focus(); GameWindow.GetInstance().Refresh(); }