public void InventoryUnwieldItem() { IInventory inventory = new Inventory(60); IItemWeaponInfo info = new ItemWeaponInfo(ItemType.LongSword, ItemWieldType.OneHand, SkillType.HeavyBlade, 10, 3); IItem testItem = new Item(Guid.NewGuid(), info, null, ItemQualityCode.Superior, 1); IEntityStats stats = new EntityStats(); IEntityAbility abilities = new EntityAbility(GeneralAbilities.All, ItemAbilities.None, EntityAbilities.ModifyInterationAbilities, EffectAbilities.ModifyMagicAbilities, AIAbilities.None); inventory.Set(testItem, InventorySlot.Inventory1, stats); Assert.AreEqual(inventory.Remaining, 59); // equip the item bool wieldSuccess = inventory.Swap(InventorySlot.Inventory1, InventorySlot.WieldPrimary, stats); Assert.IsTrue(wieldSuccess); Assert.AreEqual(inventory.Remaining, 60); bool unwieldSuccess = inventory.Swap(InventorySlot.WieldPrimary, InventorySlot.Inventory1, stats); Assert.IsTrue(unwieldSuccess); Assert.AreEqual(inventory.Remaining, 59); // the item should be back in the zero'th position IItem getItem = inventory.Get(InventorySlot.Inventory1, stats); Assert.AreEqual(inventory.Remaining, 60); Assert.IsNotNull(getItem); }
public void SerializeAbilities() { IEntityAbility abilities = new EntityAbility(GeneralAbilities.All, ItemAbilities.None, EntityAbilities.ModifyInterationAbilities, EffectAbilities.ModifyMagicAbilities, AIAbilities.None); IEntityAbility abilitiesClone = Serializer.DeepClone(abilities); Assert.AreEqual(abilities, abilitiesClone); }
public void InventoryUnequipItem() { IInventory inventory = new Inventory(60); IItemInfo info = new ItemArmorInfo(ItemType.ClothCap, InventorySlot.Head, 10, 5); IItem testItem = new Item(Guid.NewGuid(), info, null, ItemQualityCode.Superior, 1); IEntityStats stats = new EntityStats(); IEntityAbility abilities = new EntityAbility(GeneralAbilities.All, ItemAbilities.None, EntityAbilities.ModifyInterationAbilities, EffectAbilities.ModifyMagicAbilities, AIAbilities.None); inventory.Set(testItem, InventorySlot.Inventory1, stats); Assert.AreEqual(inventory.Remaining, 59); // equip the item bool equipSuccess = inventory.Swap(InventorySlot.Inventory1, InventorySlot.Head, stats); Assert.IsTrue(equipSuccess); Assert.AreEqual(inventory.Remaining, 60); bool unequipSuccess = inventory.Swap(InventorySlot.Head, InventorySlot.Inventory1, stats); Assert.IsTrue(unequipSuccess); Assert.AreEqual(inventory.Remaining, 59); // the item should be back in the zero'th position IItem getItem = inventory.Get(InventorySlot.Inventory1, stats); Assert.AreEqual(inventory.Remaining, 60); Assert.IsNotNull(getItem); }
public bool enoughResources(EntityAbility info) { if (info.targetType.Equals(EntityType.BUILDING)) { return(enoughResources(Info.get.of(info.targetRace, info.targetBuilding).resources)); } return(enoughResources(Info.get.of(info.targetRace, info.targetUnit).resources)); }
/// <summary> /// Iterates all abilities on the /// </summary> protected void setupAbilities() { if (info.isUnit || info.isPseudoUnit) { _accumulatedModifier = new UnitAbility(); } else if (info.isBuilding) { _accumulatedModifier = new BuildingAbility(); } else { _accumulatedModifier = new ResourceAbility(); } foreach (EntityAbility ability in info.abilities) { // Try to get class with this name string abilityName = ability.ability.Replace(" ", ""); if (abilityName.Length == 0) { abilityName = ability.name.Replace(" ", ""); } Ability newAbility = null; try { var constructor = Type.GetType(abilityName). GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(UnitAbility), typeof(GameObject) }, null); if (constructor == null) { // Invalid constructor, use GenericAbility newAbility = new GenericAbility(ability, gameObject); } else { // Class found, use that! newAbility = (Ability)constructor.Invoke(new object[2] { ability, gameObject }); } } catch (Exception /*e*/) { // No such class, use the GenericAbility class newAbility = new GenericAbility(ability, gameObject); } newAbility.register(Ability.Actions.ENABLED, onAbilityToggled); newAbility.register(Ability.Actions.DISABLED, onAbilityToggled); _abilities.Add(newAbility); } }
private IEntity GetDummyEntity() { IEntityInfo info = new EntityInfo(EntityRace.Human, EntityOccupation.Barbarian, 365 * 25, "Grok"); IEntityStats stats = new EntityStats(statValues); IEntitySkills skills = new EntitySkills(skillValues); IInventory inventory = new Inventory(60); IEntityAbility abilities = new EntityAbility(GeneralAbilities.All, ItemAbilities.None, EntityAbilities.ModifyInterationAbilities, EffectAbilities.ModifyMagicAbilities, AIAbilities.None); Guid id = Guid.NewGuid(); IEntity entity = new Entity(id, info, skills, stats, inventory, abilities); return(entity); }
public void SerializeEntity() { IEntityInfo info = new EntityInfo(EntityRace.Human, EntityOccupation.Barbarian, 25 * 365, "Grok"); IEntityStats stats = new EntityStats(statValues); IEntitySkills skills = new EntitySkills(skillValues); IInventory inventory = new Inventory(60); IEntityAbility abilities = new EntityAbility(GeneralAbilities.All, ItemAbilities.None, EntityAbilities.ModifyInterationAbilities, EffectAbilities.ModifyMagicAbilities, AIAbilities.None); Guid id = Guid.NewGuid(); IEntity entity = new Entity(id, info, skills, stats, inventory, abilities); IEntity entityClone = Serializer.DeepClone(entity); // to do add equality tests here //Assert.Fail(); }
public IEntity Create(EntityProfile profile) { IEntityInfo info = GenerateEntityInfo(profile.Race, profile.Occupation); IEntityStats stats = GetStatsPoints(profile.Occupation, profile.Level * 10); IEntitySkills skills = new EntitySkills(); IInventory inventory = new Inventory(20); // smaller inventory for entity IEntityAbility abilities = new EntityAbility(GeneralAbilities.All, ItemAbilities.None, EntityAbilities.ModifyInterationAbilities, EffectAbilities.ModifyMagicAbilities, AIAbilities.None); Guid id = Guid.NewGuid(); IEntity entity = new Entity(id, info, skills, stats, inventory, abilities); this.AddOccupation(entity, info.Occupation); return(entity); }
public Create(EntityAbility info, GameObject gameObject) : base(info, gameObject) { _entity = _gameObject.GetComponent <IGameEntity>(); switch (_info.targetType) { case EntityType.UNIT: _infoToBuild = Info.get.of(_info.targetRace, _info.targetUnit); break; case EntityType.BUILDING: _infoToBuild = Info.get.of(_info.targetRace, _info.targetBuilding); break; } }
public void InventoryWieldItem() { IInventory inventory = new Inventory(60); IItemInfo info = new ItemWeaponInfo(ItemType.LongSword, ItemWieldType.OneHand, SkillType.HeavyBlade, 10, 3); IItem testItem = new Item(Guid.NewGuid(), info, null, ItemQualityCode.Superior, 1); IEntityAbility abilities = new EntityAbility(GeneralAbilities.All, ItemAbilities.None, EntityAbilities.ModifyInterationAbilities, EffectAbilities.ModifyMagicAbilities, AIAbilities.None); IEntityStats stats = new EntityStats(); bool wieldSuccess = inventory.Set(testItem, InventorySlot.WieldPrimary, null); Assert.IsTrue(wieldSuccess); // ensure we can no longer get the item IItem getItem = inventory.Get(InventorySlot.Inventory1, stats); Assert.IsNull(getItem); }
public void InventoryEquipItem() { IInventory inventory = new Inventory(60); IItemInfo info = new ItemArmorInfo(ItemType.ClothCap, InventorySlot.Head, 10, 5); IItem testItem = new Item(Guid.NewGuid(), info, null, ItemQualityCode.Superior, 1); IEntityAbility abilities = new EntityAbility(GeneralAbilities.All, ItemAbilities.None, EntityAbilities.ModifyInterationAbilities, EffectAbilities.ModifyMagicAbilities, AIAbilities.None); IEntityStats stats = new EntityStats(); inventory.Set(testItem, InventorySlot.Inventory1, null); bool equipSuccess = inventory.Swap(InventorySlot.Inventory1, InventorySlot.Head, stats); Assert.IsTrue(equipSuccess); // ensure we can no longer get the item IItem getItem = inventory.Get(0, null); Assert.IsNull(getItem); }
public void EntityCreate() { try { IEntityInfo info = new EntityInfo(EntityRace.Human, EntityOccupation.Barbarian, 365 * 25, "Grok"); IEntityStats stats = new EntityStats(statValues); IEntitySkills skills = new EntitySkills(skillValues); IInventory inventory = new Inventory(60); IEntityAbility abilities = new EntityAbility(GeneralAbilities.All, ItemAbilities.None, EntityAbilities.ModifyInterationAbilities, EffectAbilities.ModifyMagicAbilities, AIAbilities.None); Guid id = Guid.NewGuid(); // based on occupation generate some inventory items IEntity entity = new Entity(id, info, skills, stats, inventory, abilities); // check that we have an inventory of size 60 Assert.AreEqual(inventory, entity.Inventory); Assert.AreEqual(abilities, entity.Abilities); Assert.AreEqual(stats, entity.Stats); Assert.AreEqual(info, entity.Info); Assert.AreEqual(id, entity.ID); } catch { Assert.Fail(); } }
public ChangeWatchtowerDirection(EntityAbility info, GameObject gameObject) : base(info, gameObject) { }
public Sell(EntityAbility info, GameObject gameObject) : base(info, gameObject) { }
public GenericAbility(EntityAbility info, GameObject gameObject) : base(info, gameObject) { }
protected Ability(EntityAbility info, GameObject gameObject) { _info = info; _gameObject = gameObject; keyBinding = _info.keyBinding; }