/** * Sets the values of a new controller. * Adds weapons from the list provided. * * @param values * A json friendly version of a dictionary with the default * values for the attack controller */ public override void SetValues(IDictionary values) { IList WeaponList = (IList)values["weapons"]; Weapons.Clear(); foreach (IDictionary IWeapon in WeaponList) { string name = (string)IWeapon["name"]; string wepType = (string)IWeapon["type"]; string Key = GenerateKey(name); //TODO add correct amounts of maxshots and maxshots per turn float range = Convert.ToSingle(IWeapon["range"]); float lethality = Convert.ToSingle(IWeapon["lethality"]); float probHit = Convert.ToSingle(IWeapon["prob_of_hit"]); // probably string int count = Convert.ToInt32(IWeapon["count"]); int curammo = (IWeapon.Contains("curammo") ? Convert.ToInt32(IWeapon["curammo"]) : count); int maxRate = Convert.ToInt32(IWeapon["max_rate"]); Weapon NewWeapon; if (IWeapon.Contains("targets")) { IDictionary idict = (IDictionary)IWeapon["targets"]; Dictionary <string, int> temp = new Dictionary <string, int>(); foreach (object key in idict.Keys) { temp.Add(key.ToString(), Convert.ToInt32(idict[key])); } Dictionary <string, int> targets = temp; NewWeapon = new Weapon(wepType, range, lethality, probHit, count, curammo, maxRate, targets); } else { NewWeapon = new Weapon(wepType, range, lethality, probHit, count, curammo, maxRate); } NewWeapon.Name = name; Weapons.Add(Key, NewWeapon); // Set the owner for the new weapon NewWeapon.SetOwner((this.gameObject.GetComponent <IdentityController>()).GetGuid(), Key); } }
public BLL.App.DTO.Weapon MapNewWeaponToBll(NewWeapon inObject) { var bllEntity = new BLL.App.DTO.Weapon() { AppUserId = inObject.AppUserId, DndCharacterId = inObject.DndCharacterId, Name = inObject.Name, Comment = inObject.Comment, DamageDice = inObject.DamageDice, DamageType = inObject.DamageType, WeaponType = inObject.WeaponType, WeaponRange = inObject.WeaponRange, Properties = inObject.Properties, Weight = inObject.Weight, ValueInGp = inObject.ValueInGp, Quantity = inObject.Quantity }; return(bllEntity); }
public void EquipWeapon(string WeaponToEquipName) { WeaponBase NewWeapon; string WeaponPath = Name + "/Weapons/" + WeaponToEquipName; if (!File.Exists("Content/Triple Thunder/Weapons/" + WeaponPath + ".ttw")) { WeaponPath = Name + "/Grenades/" + WeaponToEquipName; } if (CurrentLayer == null) { NewWeapon = WeaponBase.CreateFromFile(Name, WeaponPath, false, null, null, null); } else { NewWeapon = WeaponBase.CreateFromFile(Name, WeaponPath, false, CurrentLayer.DicRequirement, CurrentLayer.DicEffect, CurrentLayer.DicAutomaticSkillTarget); } NewWeapon.WeaponName = WeaponToEquipName; NewWeapon.Load(Content); PrimaryWeapons.AddWeaponToStash(NewWeapon); ChangeWeapon(0); WeaponBase WeaponToUse = PrimaryWeapons.GetWeapon(WeaponPath); WeaponToUse.CurrentAnimation = null; WeaponToUse.ResetAnimation(ActiveMovementStance); WeaponToUse.InitiateFollowingAttack(true, ActiveMovementStance, this); if (WeaponToUse.CurrentAnimation == null) { ActivatePartialWeapon(WeaponToUse, WeaponToUse.GetAnimationName(ActiveMovementStance)); } }