本文整理汇总了C#中Chummer.StackedFocus类的典型用法代码示例。如果您正苦于以下问题:C# StackedFocus类的具体用法?C# StackedFocus怎么用?C# StackedFocus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StackedFocus类属于Chummer命名空间,在下文中一共展示了StackedFocus类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: cmdCreateStackedFocus_Click
private void cmdCreateStackedFocus_Click(object sender, EventArgs e)
{
int intFree = 0;
List<Gear> lstGear = new List<Gear>();
List<Gear> lstStack = new List<Gear>();
// Run through all of the Foci the character has and count the un-Bonded ones.
foreach (Gear objGear in _objCharacter.Gear)
{
if (objGear.Category == "Foci" || objGear.Category == "Metamagic Foci")
{
if (!objGear.Bonded)
{
intFree++;
lstGear.Add(objGear);
}
}
}
// If the character does not have at least 2 un-Bonded Foci, display an error and leave.
if (intFree < 2)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_CannotStackFoci"), LanguageManager.Instance.GetString("MessageTitle_CannotStackFoci"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
frmSelectItem frmPickItem = new frmSelectItem();
// Let the character select the Foci they'd like to stack, stopping when they either click Cancel or there are no more items left in the list.
do
{
frmPickItem.Gear = lstGear;
frmPickItem.AllowAutoSelect = false;
frmPickItem.Description = LanguageManager.Instance.GetString("String_SelectItemFocus");
frmPickItem.ShowDialog(this);
if (frmPickItem.DialogResult == DialogResult.OK)
{
// Move the item from the Gear list to the Stack list.
foreach (Gear objGear in lstGear)
{
if (objGear.InternalId == frmPickItem.SelectedItem)
{
objGear.Bonded = true;
lstStack.Add(objGear);
lstGear.Remove(objGear);
break;
}
}
}
} while (lstGear.Count > 0 && frmPickItem.DialogResult != DialogResult.Cancel);
// Make sure at least 2 Foci were selected.
if (lstStack.Count < 2)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_StackedFocusMinimum"), LanguageManager.Instance.GetString("MessageTitle_CannotStackFoci"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
// Make sure the combined Force of the Foci do not exceed 6.
if (!_objOptions.AllowHigherStackedFoci)
{
int intCombined = 0;
foreach (Gear objGear in lstStack)
intCombined += objGear.Rating;
if (intCombined > 6)
{
foreach (Gear objGear in lstStack)
objGear.Bonded = false;
MessageBox.Show(LanguageManager.Instance.GetString("Message_StackedFocusForce"), LanguageManager.Instance.GetString("MessageTitle_CannotStackFoci"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
// Create the Stacked Focus.
StackedFocus objStack = new StackedFocus(_objCharacter);
objStack.Gear = lstStack;
_objCharacter.StackedFoci.Add(objStack);
// Remove the Gear from the character and replace it with a Stacked Focus item.
int intCost = 0;
foreach (Gear objGear in lstStack)
{
intCost += objGear.TotalCost;
_objCharacter.Gear.Remove(objGear);
// Remove the TreeNode from Gear.
foreach (TreeNode nodRoot in treGear.Nodes)
{
foreach (TreeNode nodItem in nodRoot.Nodes)
{
if (nodItem.Tag.ToString() == objGear.InternalId)
{
nodRoot.Nodes.Remove(nodItem);
break;
}
}
}
}
//.........这里部分代码省略.........
示例2: treFoci_AfterCheck
private void treFoci_AfterCheck(object sender, TreeViewEventArgs e)
{
if (e.Node.Checked)
{
// Locate the Focus that is being touched.
Gear objSelectedFocus = new Gear(_objCharacter);
objSelectedFocus = _objFunctions.FindGear(e.Node.Tag.ToString(), _objCharacter.Gear);
if (objSelectedFocus != null)
{
Focus objFocus = new Focus();
objFocus.Name = e.Node.Text;
objFocus.Rating = objSelectedFocus.Rating;
objFocus.GearId = e.Node.Tag.ToString();
_objCharacter.Foci.Add(objFocus);
// Mark the Gear and Bonded and create an Improvements.
objSelectedFocus.Bonded = true;
if (objSelectedFocus.Equipped)
{
if (objSelectedFocus.Bonus != null)
{
if (objSelectedFocus.Extra != "")
_objImprovementManager.ForcedValue = objSelectedFocus.Extra;
_objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Gear, objSelectedFocus.InternalId, objSelectedFocus.Bonus, false, objSelectedFocus.Rating, objSelectedFocus.DisplayNameShort);
foreach (Power objPower in _objCharacter.Powers)
{
if (objFocus.GearId == objPower.BonusSource)
{
objSelectedFocus.Extra = objPower.Name;
break;
}
}
RefreshPowers();
_objController.PopulateFocusList(treFoci);
}
}
}
else
{
// This is a Stacked Focus.
StackedFocus objStack = new StackedFocus(_objCharacter);
foreach (StackedFocus objCharacterFocus in _objCharacter.StackedFoci)
{
if (e.Node.Tag.ToString() == objCharacterFocus.InternalId)
{
objStack = objCharacterFocus;
break;
}
}
objStack.Bonded = true;
Gear objStackGear = _objFunctions.FindGear(objStack.GearId, _objCharacter.Gear);
if (objStackGear.Equipped)
{
foreach (Gear objGear in objStack.Gear)
{
if (objGear.Bonus != null)
{
if (objGear.Extra != "")
_objImprovementManager.ForcedValue = objGear.Extra;
_objImprovementManager.CreateImprovements(Improvement.ImprovementSource.StackedFocus, objStack.InternalId, objGear.Bonus, false, objGear.Rating, objGear.DisplayNameShort);
}
}
}
}
}
else
{
Focus objFocus = new Focus();
foreach (Focus objCharacterFocus in _objCharacter.Foci)
{
if (objCharacterFocus.GearId == e.Node.Tag.ToString())
{
objFocus = objCharacterFocus;
break;
}
}
// Mark the Gear as not Bonded and remove any Improvements.
Gear objGear = new Gear(_objCharacter);
objGear = _objFunctions.FindGear(objFocus.GearId, _objCharacter.Gear);
if (objGear != null)
{
objGear.Bonded = false;
_objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);
_objCharacter.Foci.Remove(objFocus);
foreach (Power objPower in _objCharacter.Powers)
{
if (objPower.BonusSource == objGear.InternalId)
{
if (objPower.Free)
_objCharacter.Powers.Remove(objPower);
else if (objPower.FreeLevels < objPower.Rating)
{
objPower.Rating -= objPower.FreeLevels;
objPower.FreeLevels = 0;
//.........这里部分代码省略.........
示例3: treFoci_BeforeCheck
private void treFoci_BeforeCheck(object sender, TreeViewCancelEventArgs e)
{
// Don't bother to do anything since a node is being unchecked.
if (e.Node.Checked)
return;
// Locate the Focus that is being touched.
Gear objSelectedFocus = new Gear(_objCharacter);
objSelectedFocus = _objFunctions.FindGear(e.Node.Tag.ToString(), _objCharacter.Gear);
// Set the Focus count to 1 and get its current Rating (Force). This number isn't used in the following loops because it isn't yet checked or unchecked.
int intFociCount = 1;
int intFociTotal = 0;
if (objSelectedFocus != null)
intFociTotal = objSelectedFocus.Rating;
else
{
// This is a Stacked Focus.
StackedFocus objStack = new StackedFocus(_objCharacter);
foreach (StackedFocus objCharacterFocus in _objCharacter.StackedFoci)
{
if (e.Node.Tag.ToString() == objCharacterFocus.InternalId)
{
objStack = objCharacterFocus;
break;
}
}
intFociTotal = objStack.TotalForce;
}
// Run through the list of items. Count the number of Foci the character would have bonded including this one, plus the total Force of all checked Foci.
foreach (TreeNode objNode in treFoci.Nodes)
{
if (objNode.Checked)
{
intFociCount++;
foreach (Gear objCharacterFocus in _objCharacter.Gear)
{
if (objNode.Tag.ToString() == objCharacterFocus.InternalId)
{
intFociTotal += objCharacterFocus.Rating;
break;
}
}
foreach (StackedFocus objStack in _objCharacter.StackedFoci)
{
if (objNode.Tag.ToString() == objStack.InternalId)
{
if (objStack.Bonded)
{
intFociTotal += objStack.TotalForce;
break;
}
}
}
}
}
if (intFociTotal > _objCharacter.MAG.TotalValue * 5 && !_objCharacter.IgnoreRules)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_FocusMaximumForce"), LanguageManager.Instance.GetString("MessageTitle_FocusMaximum"), MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Cancel = true;
return;
}
if (intFociCount > _objCharacter.MAG.TotalValue && !_objCharacter.IgnoreRules)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_FocusMaximumNumber"), LanguageManager.Instance.GetString("MessageTitle_FocusMaximum"), MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Cancel = true;
}
}
示例4: Load
//.........这里部分代码省略.........
}
// Cyberware/Bioware.
objXmlNodeList = objXmlDocument.SelectNodes("/character/cyberwares/cyberware");
foreach (XmlNode objXmlCyberware in objXmlNodeList)
{
Cyberware objCyberware = new Cyberware(this);
objCyberware.Load(objXmlCyberware);
_lstCyberware.Add(objCyberware);
}
// Spells.
objXmlNodeList = objXmlDocument.SelectNodes("/character/spells/spell");
foreach (XmlNode objXmlSpell in objXmlNodeList)
{
Spell objSpell = new Spell(this);
objSpell.Load(objXmlSpell);
_lstSpells.Add(objSpell);
}
// Foci.
objXmlNodeList = objXmlDocument.SelectNodes("/character/foci/focus");
foreach (XmlNode objXmlFocus in objXmlNodeList)
{
Focus objFocus = new Focus();
objFocus.Load(objXmlFocus);
_lstFoci.Add(objFocus);
}
// Stacked Foci.
objXmlNodeList = objXmlDocument.SelectNodes("/character/stackedfoci/stackedfocus");
foreach (XmlNode objXmlStack in objXmlNodeList)
{
StackedFocus objStack = new StackedFocus(this);
objStack.Load(objXmlStack);
_lstStackedFoci.Add(objStack);
}
// Powers.
List<ListItem> lstPowerOrder = new List<ListItem>();
objXmlNodeList = objXmlDocument.SelectNodes("/character/powers/power");
// Sort the Powers in alphabetical order.
foreach (XmlNode objXmlPower in objXmlNodeList)
{
ListItem objGroup = new ListItem();
objGroup.Value = objXmlPower["extra"].InnerText;
objGroup.Name = objXmlPower["name"].InnerText;
lstPowerOrder.Add(objGroup);
}
objSort = new SortListItem();
lstPowerOrder.Sort(objSort.Compare);
foreach (ListItem objItem in lstPowerOrder)
{
Power objPower = new Power(this);
XmlNode objNode = objXmlDocument.SelectSingleNode("/character/powers/power[name = " + CleanXPath(objItem.Name) + " and extra = " + CleanXPath(objItem.Value) + "]");
objPower.Load(objNode);
_lstPowers.Add(objPower);
}
// Spirits/Sprites.
objXmlNodeList = objXmlDocument.SelectNodes("/character/spirits/spirit");
foreach (XmlNode objXmlSpirit in objXmlNodeList)
{
Spirit objSpirit = new Spirit(this);
示例5: treFoci_BeforeCheck
private void treFoci_BeforeCheck(object sender, TreeViewCancelEventArgs e)
{
if (_blnSkipRefresh)
return;
// If the item is being unchecked, confirm that the user wants to un-bind the Focus.
if (e.Node.Checked)
{
if (MessageBox.Show(LanguageManager.Instance.GetString("Message_UnbindFocus"), LanguageManager.Instance.GetString("MessageTitle_UnbindFocus"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
e.Cancel = true;
return;
}
// Locate the Focus that is being touched.
Gear objSelectedFocus = new Gear(_objCharacter);
objSelectedFocus = _objFunctions.FindGear(e.Node.Tag.ToString(), _objCharacter.Gear);
// Set the Focus count to 1 and get its current Rating (Force). This number isn't used in the following loops because it isn't yet checked or unchecked.
int intFociCount = 1;
int intFociTotal = 0;
if (objSelectedFocus != null)
intFociTotal = objSelectedFocus.Rating;
else
{
// This is a Stacked Focus.
StackedFocus objStack = new StackedFocus(_objCharacter);
foreach (StackedFocus objCharacterFocus in _objCharacter.StackedFoci)
{
if (e.Node.Tag.ToString() == objCharacterFocus.InternalId)
{
objStack = objCharacterFocus;
break;
}
}
intFociTotal = objStack.TotalForce;
}
// Run through the list of items. Count the number of Foci the character would have bonded including this one, plus the total Force of all checked Foci.
foreach (TreeNode objNode in treFoci.Nodes)
{
if (objNode.Checked)
{
intFociCount++;
foreach (Gear objCharacterFocus in _objCharacter.Gear)
{
if (objNode.Tag.ToString() == objCharacterFocus.InternalId)
{
intFociTotal += objCharacterFocus.Rating;
break;
}
}
foreach (StackedFocus objStack in _objCharacter.StackedFoci)
{
if (objNode.Tag.ToString() == objStack.InternalId)
{
intFociTotal += objStack.TotalForce;
break;
}
}
}
}
if (intFociTotal > _objCharacter.MAG.TotalValue * 5)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_FocusMaximumForce"), LanguageManager.Instance.GetString("MessageTitle_FocusMaximum"), MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Cancel = true;
return;
}
if (intFociCount > _objCharacter.MAG.TotalValue)
{
MessageBox.Show(LanguageManager.Instance.GetString("Message_FocusMaximumNumber"), LanguageManager.Instance.GetString("MessageTitle_FocusMaximum"), MessageBoxButtons.OK, MessageBoxIcon.Information);
e.Cancel = true;
return;
}
// If we've made it this far, everything is okay, so create a Karma Expense for the newly-bound Focus.
bool blnFound = false;
// Locate the Gear for the Focus.
Gear objFocus = new Gear(_objCharacter);
foreach (Gear objGear in _objCharacter.Gear)
{
if (objGear.InternalId == e.Node.Tag.ToString())
{
objFocus = objGear;
blnFound = true;
break;
}
}
if (blnFound)
{
// Determine how much Karma the Focus will cost to bind.
string strFocusName = objFocus.Name;
if (objFocus.Extra != "")
strFocusName += " (" + objFocus.Extra + ")";
int intPosition = strFocusName.IndexOf("(");
if (intPosition > -1)
//.........这里部分代码省略.........
示例6: Load
//.........这里部分代码省略.........
}
// Cyberware/Bioware.
objXmlNodeList = objXmlDocument.SelectNodes("/character/cyberwares/cyberware");
foreach (XmlNode objXmlCyberware in objXmlNodeList)
{
Cyberware objCyberware = new Cyberware(this);
objCyberware.Load(objXmlCyberware);
_lstCyberware.Add(objCyberware);
}
// Spells.
objXmlNodeList = objXmlDocument.SelectNodes("/character/spells/spell");
foreach (XmlNode objXmlSpell in objXmlNodeList)
{
Spell objSpell = new Spell(this);
objSpell.Load(objXmlSpell);
_lstSpells.Add(objSpell);
}
// Foci.
objXmlNodeList = objXmlDocument.SelectNodes("/character/foci/focus");
foreach (XmlNode objXmlFocus in objXmlNodeList)
{
Focus objFocus = new Focus();
objFocus.Load(objXmlFocus);
_lstFoci.Add(objFocus);
}
// Stacked Foci.
objXmlNodeList = objXmlDocument.SelectNodes("/character/stackedfoci/stackedfocus");
foreach (XmlNode objXmlStack in objXmlNodeList)
{
StackedFocus objStack = new StackedFocus(this);
objStack.Load(objXmlStack);
_lstStackedFoci.Add(objStack);
}
// Powers.
objXmlNodeList = objXmlDocument.SelectNodes("/character/powers/power");
foreach (XmlNode objXmlPower in objXmlNodeList)
{
Power objPower = new Power(this);
objPower.Load(objXmlPower);
_lstPowers.Add(objPower);
}
// Spirits/Sprites.
objXmlNodeList = objXmlDocument.SelectNodes("/character/spirits/spirit");
foreach (XmlNode objXmlSpirit in objXmlNodeList)
{
Spirit objSpirit = new Spirit(this);
objSpirit.Load(objXmlSpirit);
_lstSpirits.Add(objSpirit);
}
// Compex Forms/Technomancer Programs.
objXmlNodeList = objXmlDocument.SelectNodes("/character/techprograms/techprogram");
foreach (XmlNode objXmlProgram in objXmlNodeList)
{
TechProgram objProgram = new TechProgram(this);
objProgram.Load(objXmlProgram);
_lstTechPrograms.Add(objProgram);
}
// Martial Arts.
示例7: treFoci_AfterCheck
private void treFoci_AfterCheck(object sender, TreeViewEventArgs e)
{
if (e.Node.Checked)
{
// Locate the Focus that is being touched.
Gear objSelectedFocus = new Gear(_objCharacter);
objSelectedFocus = _objFunctions.FindGear(e.Node.Tag.ToString(), _objCharacter.Gear);
if (objSelectedFocus != null)
{
Focus objFocus = new Focus();
objFocus.Name = e.Node.Text;
objFocus.Rating = objSelectedFocus.Rating;
objFocus.GearId = e.Node.Tag.ToString();
_objCharacter.Foci.Add(objFocus);
// Mark the Gear and Bonded and create an Improvements.
objSelectedFocus.Bonded = true;
if (objSelectedFocus.Equipped)
{
if (objSelectedFocus.Bonus != null)
{
if (objSelectedFocus.Extra != "")
_objImprovementManager.ForcedValue = objSelectedFocus.Extra;
_objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Gear, objSelectedFocus.InternalId, objSelectedFocus.Bonus, false, objSelectedFocus.Rating, objSelectedFocus.DisplayNameShort);
foreach (Power objPower in _objCharacter.Powers)
{
if (objFocus.GearId == objPower.BonusSource)
{
objSelectedFocus.Extra = objPower.Name;
break;
}
}
RefreshPowers();
_objController.PopulateFocusList(treFoci);
}
}
}
else
{
// This is a Stacked Focus.
StackedFocus objStack = new StackedFocus(_objCharacter);
foreach (StackedFocus objCharacterFocus in _objCharacter.StackedFoci)
{
if (e.Node.Tag.ToString() == objCharacterFocus.InternalId)
{
objStack = objCharacterFocus;
break;
}
}
objStack.Bonded = true;
Gear objStackGear = _objFunctions.FindGear(objStack.GearId, _objCharacter.Gear);
if (objStackGear.Equipped)
{
foreach (Gear objGear in objStack.Gear)
{
if (objGear.Bonus != null)
{
if (objGear.Extra != "")
_objImprovementManager.ForcedValue = objGear.Extra;
_objImprovementManager.CreateImprovements(Improvement.ImprovementSource.StackedFocus, objStack.InternalId, objGear.Bonus, false, objGear.Rating, objGear.DisplayNameShort);
}
}
}
}
}
else
{
Focus objFocus = new Focus();
foreach (Focus objCharacterFocus in _objCharacter.Foci)
{
if (objCharacterFocus.GearId == e.Node.Tag.ToString())
{
objFocus = objCharacterFocus;
break;
}
}
// Mark the Gear as not Bonded and remove any Improvements.
Gear objGear = new Gear(_objCharacter);
objGear = _objFunctions.FindGear(objFocus.GearId, _objCharacter.Gear);
if (objGear != null)
{
objGear.Bonded = false;
_objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);
_objCharacter.Foci.Remove(objFocus);
foreach (Power objPower in _objCharacter.Powers)
{
if (objPower.BonusSource == objGear.InternalId)
{
//Remove the Bonus Source since this object will not be giving a bonus
objPower.BonusSource = "";
if (objPower.Free)
_objCharacter.Powers.Remove(objPower);
else if (objPower.FreeLevels > 0)
//.........这里部分代码省略.........
示例8: treFoci_AfterCheck
private void treFoci_AfterCheck(object sender, TreeViewEventArgs e)
{
if (e.Node.Checked)
{
// Locate the Focus that is being touched.
Gear objSelectedFocus = new Gear(_objCharacter);
objSelectedFocus = _objFunctions.FindGear(e.Node.Tag.ToString(), _objCharacter.Gear);
if (objSelectedFocus != null)
{
Focus objFocus = new Focus();
objFocus.Name = e.Node.Text;
objFocus.Rating = objSelectedFocus.Rating;
objFocus.GearId = e.Node.Tag.ToString();
_objCharacter.Foci.Add(objFocus);
// Mark the Gear and Bonded and create an Improvements.
objSelectedFocus.Bonded = true;
if (objSelectedFocus.Equipped)
{
if (objSelectedFocus.Bonus != null)
{
if (objSelectedFocus.Extra != "")
_objImprovementManager.ForcedValue = objSelectedFocus.Extra;
_objImprovementManager.CreateImprovements(Improvement.ImprovementSource.Gear, objSelectedFocus.InternalId, objSelectedFocus.Bonus, false, objSelectedFocus.Rating, objSelectedFocus.DisplayNameShort);
foreach (Power objPower in _objCharacter.Powers)
{
if (objFocus.GearId == objPower.BonusSource)
{
objSelectedFocus.Extra = objPower.Name;
break;
}
}
RefreshPowers();
_objController.PopulateFocusList(treFoci);
}
}
}
else
{
// This is a Stacked Focus.
StackedFocus objStack = new StackedFocus(_objCharacter);
foreach (StackedFocus objCharacterFocus in _objCharacter.StackedFoci)
{
if (e.Node.Tag.ToString() == objCharacterFocus.InternalId)
{
objStack = objCharacterFocus;
break;
}
}
objStack.Bonded = true;
Gear objStackGear = _objFunctions.FindGear(objStack.GearId, _objCharacter.Gear);
if (objStackGear.Equipped)
{
foreach (Gear objGear in objStack.Gear)
{
if (objGear.Bonus != null)
{
if (objGear.Extra != "")
_objImprovementManager.ForcedValue = objGear.Extra;
_objImprovementManager.CreateImprovements(Improvement.ImprovementSource.StackedFocus, objStack.InternalId, objGear.Bonus, false, objGear.Rating, objGear.DisplayNameShort);
}
}
}
}
}
else
{
Focus objFocus = new Focus();
foreach (Focus objCharacterFocus in _objCharacter.Foci)
{
if (objCharacterFocus.GearId == e.Node.Tag.ToString())
{
objFocus = objCharacterFocus;
break;
}
}
// Mark the Gear as not Bonded and remove any Improvements.
Gear objGear = new Gear(_objCharacter);
objGear = _objFunctions.FindGear(objFocus.GearId, _objCharacter.Gear);
if (objGear != null)
{
objGear.Bonded = false;
_objImprovementManager.RemoveImprovements(Improvement.ImprovementSource.Gear, objGear.InternalId);
_objCharacter.Foci.Remove(objFocus);
foreach (Power objPower in _objCharacter.Powers)
{
// Known issues:
// 1) If freelevels > MAG, AND multiple sources give free levels, the calculation for the left-over free levels
// will not be correct
// Foci give their rating / 4 in power points - use power points per level to calculate the amount of levels this
// focus is worth. May be troublesome in foci of non-integer power levels, but as foci should not be created
// with such, this will be better handled in the focus rating itself.
if (objPower.BonusSource == objGear.InternalId)
//.........这里部分代码省略.........