private void TargetGroundWithItemAction(ActionButton btn, Point loc) { // use the button item on this location foreach (RPGEffect effect in btn.Item.Effects) { if (effect == null) { continue; } // go through all possible targets and see if each applies. bool targetFound = false; foreach (RPGObject target in Session.thisSession.thisArea.GetObjects()) { if (effect.IsCorrectTarget(SelectedObject, target, loc)) { // need to use a copy constructor - one for each actor! if (targetFound == false) { targetFound = true; Session.Print((SelectedObject as Actor).Name + " used " + btn.Item.Name); } target.AddEffect(new RPGEffect(effect)); } // end if good target } // if we found a target, or we used it on an open space, then use up the item. if (targetFound || btn.Item.Effects[0].Range == RPGEffect.EffectRange.Area || btn.Item.Effects[0].Range == RPGEffect.EffectRange.TargetArea) { // assuming a potion for now, the item gets consumed. (SelectedObject as Actor).inventory.RemoveQuickItem(btn.Item); btn.ClearItem(); } else { Session.Print((SelectedObject as Actor).Name + " did not use " + btn.Item.Name + ", no target found"); } } }
private void TargetObjectWithSpellAction(ActionButton btn, RPGObject target) { // cast the button spell on the target MessageBox.Show("Not done yet."); }
private void TargetObjectWithSkillAction(ActionButton btn, RPGObject target) { // perform the button skill on the target MessageBox.Show("Not done yet."); }
private void TargetObjectWithBasicAction(ActionButton btn, RPGObject target) { // do the button action to the target MessageBox.Show("Not done yet."); }
private void TargetObject(RPGObject target) { // object is selected, and a new target is right-clicked // check ActionButtons if (m_toolbar.isAnyButtonSelected()) { ActionButton[] btns = m_toolbar.GetSelectedButtons(); if (btns.Length == 1) { // only one selected, do action of button. ActionButton btn = btns[0]; switch (btn.ActionType) { case (ActionButton.ActionButtonType.BasicAction): { TargetObjectWithBasicAction(btn, target); break; } case (ActionButton.ActionButtonType.SkillAction): { TargetObjectWithSkillAction(btn, target); break; } case (ActionButton.ActionButtonType.SpellAction): { TargetObjectWithSpellAction(btn, target); break; } case (ActionButton.ActionButtonType.ItemAction): { TargetObjectWithItemAction(btn, target); break; } default: { break; } } // end switch } else { // multiple buttons selected, do complex logic. } } else { if (target == SelectedObject) { // right clicked on same selected item, do anything? // No return; } // if no action button was selected, then do the default... // based on friend/foe/neutral, do default action... if (target.GetType() == typeof(Actor)) { SelectedObject.Act(RPGObject.Action.Attack, new Point(target.X, target.Y), target); } else if (target.GetType() == typeof(PlayerCharacter)) { SelectedObject.Act(RPGObject.Action.Attack, new Point(target.X, target.Y), target); } else if (target.GetType() == typeof(RPGDrop)) { SelectedObject.Act(RPGObject.Action.Get, new Point(target.X, target.Y), target); } } // end else - no ActionButton selected }
private void TargetGroundWithSpellAction(ActionButton btn, Point loc) { // do the button action to the target MessageBox.Show("Not done yet."); }
private void InitializeComponent() { this.SuspendLayout(); #region Stat labels lblName = new Label(); lblName.Font = new Font(lblName.Font, FontStyle.Bold); lblName.Location = new Point(10, 10); lblName.Height = LBL_HEIGHT; lblName.Width = LBL_WIDTH; this.Controls.Add(lblName); lblHP = new Label(); lblHP.Location = new Point(10, 30); lblHP.Height = LBL_HEIGHT; lblHP.Width = LBL_WIDTH; this.Controls.Add(lblHP); lblMP = new Label(); lblMP.Location = new Point(10, 50); lblMP.Height = LBL_HEIGHT; lblMP.Width = LBL_WIDTH; this.Controls.Add(lblMP); lblAttDef = new Label(); lblAttDef.Location = new Point(10, 70); lblAttDef.Height = LBL_HEIGHT; lblAttDef.Width = LBL_WIDTH; this.Controls.Add(lblAttDef); SetAllLabelTextsToDefault(); #endregion // Ticker ticker = new ActionTicker(); ticker.Width = 500; ticker.Height = 90; ticker.Location = new Point(150, 5); this.Controls.Add(ticker); #region Buttons btnTalk = new ActionButton(ActionButton.ActionButtonType.BasicAction); btnTalk.Location = new Point(BTN_COL_1, BTN_ROW_1); SetBtnSize(btnTalk); btnTalk.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnTalk); btnAttack = new ActionButton(ActionButton.ActionButtonType.BasicAction); btnAttack.Location = new Point(BTN_COL_1, BTN_ROW_2); SetBtnSize(btnAttack); btnAttack.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnAttack); btnUse = new ActionButton(ActionButton.ActionButtonType.BasicAction); btnUse.Location = new Point(BTN_COL_1, BTN_ROW_3); SetBtnSize(btnUse); btnUse.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnUse); btnSpell1 = new ActionButton(ActionButton.ActionButtonType.SpellAction); btnSpell1.Location = new Point(BTN_COL_2, BTN_ROW_1); SetBtnSize(btnSpell1); btnSpell1.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnSpell1); btnSpell2 = new ActionButton(ActionButton.ActionButtonType.SpellAction); btnSpell2.Location = new Point(BTN_COL_2, BTN_ROW_2); SetBtnSize(btnSpell2); btnSpell2.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnSpell2); btnSpell3 = new ActionButton(ActionButton.ActionButtonType.SpellAction); btnSpell3.Location = new Point(BTN_COL_2, BTN_ROW_3); SetBtnSize(btnSpell3); btnSpell3.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnSpell3); btnSkill1 = new ActionButton(ActionButton.ActionButtonType.SkillAction); btnSkill1.Location = new Point(BTN_COL_3, BTN_ROW_1); SetBtnSize(btnSkill1); btnSkill1.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnSkill1); btnSkill2 = new ActionButton(ActionButton.ActionButtonType.SkillAction); btnSkill2.Location = new Point(BTN_COL_3, BTN_ROW_2); SetBtnSize(btnSkill2); btnSkill2.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnSkill2); btnSkill3 = new ActionButton(ActionButton.ActionButtonType.SkillAction); btnSkill3.Location = new Point(BTN_COL_3, BTN_ROW_3); SetBtnSize(btnSkill3); btnSkill3.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnSkill3); btnItem1 = new ActionButton(ActionButton.ActionButtonType.ItemAction); btnItem1.Location = new Point(BTN_COL_4, BTN_ROW_1); SetBtnSize(btnItem1); btnItem1.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnItem1); btnItem2 = new ActionButton(ActionButton.ActionButtonType.ItemAction); btnItem2.Location = new Point(BTN_COL_4, BTN_ROW_2); SetBtnSize(btnItem2); btnItem2.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnItem2); btnItem3 = new ActionButton(ActionButton.ActionButtonType.ItemAction); btnItem3.Location = new Point(BTN_COL_4, BTN_ROW_3); SetBtnSize(btnItem3); btnItem3.MouseClick += new MouseEventHandler(actionButton_MouseClick); this.Controls.Add(btnItem3); SetAllButtonTextsToDefault(); #endregion this.ResumeLayout(false); }
private void ClearButton(ActionButton btn) { btn.IsSelected = false; }
private void SetBtnSize(ActionButton button) { button.Height = BTN_HEIGHT; button.Width = BTN_WIDTH; }