private bool AddItemToQuick(RPGObject item) { bool result = false; if (item != null && item.isOfType(typeof(RPGItem))) { result = thisActor.inventory.AddQuickItem(item as RPGItem); LoadQuickGrid(thisActor); } return(result); }
public bool AddItem(RPGObject obj) { if (obj.isOfType(typeof(RPGDrop))) { RPGObject[] objs = ((RPGDrop)obj).GetItems(); for (int i = 0; i < objs.Length; i++) { AddItem((RPGItem)objs[i]); } return(true); } else if (obj.isOfType(typeof(RPGItem))) { return(AddPackItem((RPGItem)obj)); } else { // don't recognize item type. return(false); } }
void btnEquip_Click(object sender, EventArgs e) { // move selected pack item to body, at correct slot // if already equipped, then switch locations. RPGObject item = GetSelectedItemFromPack(); // now, check if body already has an item at that slot if (item == null) { MessageBox.Show("No item selected from pack to equip."); return; } else if (item.isOfType(typeof(RPGItem)) == false) { MessageBox.Show("This item type cannot be equipped."); return; } else { // check if destination slot is already filled if (thisActor.inventory.GetBodyItem(((RPGItem)item).Slot) != null) { // find currently equipped item and remove it RPGItem currentlyEquippedItem = thisActor.inventory.GetBodyItem(((RPGItem)item).Slot); if (AddItemToPack(currentlyEquippedItem)) { RemoveItemFromBody(currentlyEquippedItem); } else { MessageBox.Show("Unable to add equipped item back into pack."); return; } } // end it slot is already filled else { // add new item to body if (AddItemToBody(((RPGItem)item), ((RPGItem)item).Slot)) { RemoveItemFromPack(item); } else { MessageBox.Show("Unable to equip item."); } } // end else - destination slot empty } // end else - item ok }
private void LoadPackRow(RPGObject item) { if (item == null) { return; } DataRow row = dtPackItems.NewRow(); row[0] = item.Name; row[1] = GetItemType(item); if (item.isOfType(typeof(RPGItem))) { row[2] = (item as RPGItem).Description; } dtPackItems.Rows.Add(row); }
public bool AddObject(RPGObject obj) { int s = GetObjSlot(); if (s > -1) { RPGObjects[s] = obj; if (obj.isOfType(typeof(Actor))) { (obj as Actor).ResetStats(); } return(true); } else { return(false); } }
private string CreateDetailText() { string result = ""; if (thisItem.isOfType(typeof(RPGWeapon))) { result += "Type: " + Enum.GetName(typeof(RPGWeapon.WeaponType), (thisItem as RPGWeapon).weaponType) + NL; result += "Type: " + Enum.GetName(typeof(RPGWeapon.WeaponClass), (thisItem as RPGWeapon).weaponClass) + NL; result += "Dmg: " + (thisItem as RPGWeapon).minDmg + " - " + (thisItem as RPGWeapon).maxDmg + NL; result += "Range (px): " + (thisItem as RPGWeapon).Range + NL; result += "Speed (ms delay): " + (thisItem as RPGWeapon).CoolDown + NL; if ((thisItem as RPGWeapon).is2Handed) { result += "2 Handed" + NL; } if ((thisItem as RPGWeapon).StackQuantity > 1) { result += "Quantity: " + (thisItem as RPGWeapon).StackQuantity + NL; } if ((thisItem as RPGWeapon).Effects == null || (thisItem as RPGWeapon).Effects[0] == null) { result += "Effects: None" + NL; } else { result += "Effects:" + NL; for (int i = 0; i < thisItem.Effects.Length; i++) { if (thisItem.Effects[i] != null) { result += "* " + thisItem.Effects[i].GetDescriptionSimple() + NL; } } } } // end RPGWeapon else if (thisItem.isOfType(typeof(RPGArmor))) { result += "Type: " + Enum.GetName(typeof(RPGArmor.ArmorClass), (thisItem as RPGArmor).Class) + NL; result += "Defense: " + (thisItem as RPGArmor).Defense + " AC" + NL; result += "Max Dex Bonus: " + (thisItem as RPGArmor).MaxDeterityBonus + NL; result += "Durability: " + (thisItem as RPGArmor).Durability + " / " + (thisItem as RPGArmor).DurabilityMax + NL; if ((thisItem as RPGArmor).Effects == null || (thisItem as RPGArmor).Effects[0] == null) { result += "Effects: None" + NL; } else { result += "Effects:" + NL; for (int i = 0; i < thisItem.Effects.Length; i++) { if (thisItem.Effects[i] != null) { result += "* " + thisItem.Effects[i].GetDescriptionSimple() + NL; } } } } else if (thisItem.isOfType(typeof(RPGPotion))) { foreach (RPGEffect effect in thisItem.Effects) { if (effect != null) { result += effect.GetDescriptionFull() + NL; } } } return(result); }
public void ApplyToTarget(RPGObject targetObject) { this.TargetObject = targetObject; Actor targetActor = targetObject as Actor; string PrintLine = ""; if (targetObject.isOfType(typeof(Actor))) { targetActor = targetObject as Actor; PrintLine += targetActor.Name; } // actually change the target based on the effect if (EffectIsABuff) { switch (TargetBuff) { case (EffectTargetBuff.Attack): { targetActor.BaseAttack += Power; targetActor.UpdateAttack(); PrintLine += " Attack changed by " + Power; break; } case (EffectTargetBuff.Charisma): { targetActor.BaseCharisma += Power; targetActor.ResetAttributes(); PrintLine += " Charisma changed by " + Power; break; } case (EffectTargetBuff.Constitution): { targetActor.BaseConstitution += Power; targetActor.ResetAttributes(); PrintLine += " Constitution changed by " + Power; break; } case (EffectTargetBuff.Defense): { targetActor.BaseDefense += Power; targetActor.UpdateDefense(); PrintLine += " Defense changed by " + Power; break; } case (EffectTargetBuff.Dexterity): { targetActor.BaseDexterity += Power; targetActor.ResetAttributes(); PrintLine += " Dexterity changed by " + Power; break; } case (EffectTargetBuff.Intelligence): { targetActor.BaseIntelligence += Power; targetActor.ResetAttributes(); PrintLine += " Intelligence changed by " + Power; break; } case (EffectTargetBuff.RaiseDamage): { targetActor.BaseDamage += Power; PrintLine += " Damage changed by " + Power; break; } case (EffectTargetBuff.RaiseMaxHP): { targetActor.HPBaseMax += Power; targetActor.HPAdjustCurrentMax(Power); targetActor.HPAdjustCurrent(Power); PrintLine += " Max HP changed by " + Power; break; } case (EffectTargetBuff.RaiseMaxMP): { targetActor.MPBaseMax += Power; targetActor.MPAdjustCurrentMax(Power); targetActor.MPAdjustCurrent(Power); PrintLine += " Max MP changed by " + Power; break; } case (EffectTargetBuff.RestoreHP): { // because we are only restoring, it cannot go over the max targetActor.HPAdjustCurrent(Math.Min(Power, Math.Max(targetActor.HPCurrentMax - targetActor.HPCurrent, 0))); PrintLine += " HP restored by " + Power; break; } case (EffectTargetBuff.RestoreMP): { // because we are only restoring, it cannot go over the max targetActor.MPAdjustCurrent(Math.Min(Power, Math.Max(targetActor.MPCurrentMax - targetActor.MPCurrent, 0))); PrintLine += " MP restored by " + Power; break; } case (EffectTargetBuff.Speed): { targetActor.BaseSpeed += Power; targetActor.CurrentSpeed += Power; PrintLine += " Speed changed by " + Power; break; } case (EffectTargetBuff.Strength): { targetActor.BaseStrength += Power; targetActor.ResetAttributes(); PrintLine += " Strength changed by " + Power; break; } case (EffectTargetBuff.Wisdom): { targetActor.BaseWisdom += Power; targetActor.ResetAttributes(); PrintLine += " Wisdom changed by " + Power; break; } } // end switch } else { } Session.Print(PrintLine); }