コード例 #1
0
ファイル: Consume.cs プロジェクト: Fulborg/dwarrowdelf
        bool CheckConsumeAction(ItemObject item)
        {
            if (item == null)
            {
                SendFailReport(new ConsumeActionReport(this, null), "not in inventory");
                return false;
            }

            if (item.RefreshmentValue == 0 && item.NutritionalValue == 0)
            {
                SendFailReport(new ConsumeActionReport(this, item), "non-digestible");
                return false;
            }

            return true;
        }
コード例 #2
0
ファイル: GetItem.cs プロジェクト: tomba/dwarrowdelf
        bool CheckGetItemAction(ItemObject item)
        {
            if (item == null)
            {
                SendFailReport(new GetItemActionReport(this, item), "item not found");
                return false;
            }

            if (item.Environment != this.Environment || item.Location != this.Location)
            {
                SendFailReport(new GetItemActionReport(this, item), "item not there");
                return false;
            }

            return true;
        }
コード例 #3
0
        bool CheckDropItemAction(ItemObject item)
        {
            if (item == null)
            {
                SendFailReport(new DropItemActionReport(this, item), "item not found");
                return(false);
            }

            if (item.Container != this)
            {
                SendFailReport(new DropItemActionReport(this, item), "not in inventory");
                return(false);
            }

            if (item.IsEquipped)
            {
                SendFailReport(new DropItemActionReport(this, item), "item equipped");
                return(false);
            }

            return(true);
        }
コード例 #4
0
ファイル: DropItem.cs プロジェクト: Fulborg/dwarrowdelf
        bool CheckDropItemAction(ItemObject item)
        {
            if (item == null)
            {
                SendFailReport(new DropItemActionReport(this, item), "item not found");
                return false;
            }

            if (item.Parent != this)
            {
                SendFailReport(new DropItemActionReport(this, item), "not in inventory");
                return false;
            }

            if (item.IsEquipped)
            {
                SendFailReport(new DropItemActionReport(this, item), "item equipped");
                return false;
            }

            return true;
        }
コード例 #5
0
        bool CheckEquipItem(ItemObject item)
        {
            if (item == null)
            {
                var report = new EquipItemActionReport(this, null);
                report.SetFail("object doesn't exist");
                SendReport(report);
                return(false);
            }

            if (item.Container != this)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("doesn't have the object");
                SendReport(report);
                return(false);
            }

            if (!item.IsArmor && !item.IsWeapon)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("not equippable");
                SendReport(report);
                return(false);
            }

            if (item.IsEquipped)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("already equipped");
                SendReport(report);
                return(false);
            }

            return(true);
        }
コード例 #6
0
ファイル: UnequipItem.cs プロジェクト: tomba/dwarrowdelf
        bool CheckUnequipItem(ItemObject item)
        {
            if (item == null)
            {
                var report = new UnequipItemActionReport(this, null);
                report.SetFail("object doesn't exist");
                SendReport(report);
                return false;
            }

            if (item.Container != this)
            {
                var report = new UnequipItemActionReport(this, item);
                report.SetFail("doesn't have the object");
                SendReport(report);
                return false;
            }

            if (!item.IsArmor && !item.IsWeapon)
            {
                var report = new UnequipItemActionReport(this, item);
                report.SetFail("not equippable");
                SendReport(report);
                return false;
            }

            if (item.IsEquipped == false)
            {
                var report = new UnequipItemActionReport(this, item);
                report.SetFail("not equipped");
                SendReport(report);
                return false;
            }

            return true;
        }
コード例 #7
0
ファイル: EquipItem.cs プロジェクト: Fulborg/dwarrowdelf
        bool CheckEquipItem(ItemObject item)
        {
            if (item == null)
            {
                var report = new EquipItemActionReport(this, null);
                report.SetFail("object doesn't exist");
                SendReport(report);
                return false;
            }

            if (item.Parent != this)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("doesn't have the object");
                SendReport(report);
                return false;
            }

            if (!item.IsArmor || !item.IsWeapon)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("not equippable");
                SendReport(report);
                return false;
            }

            if (item.IsEquipped)
            {
                var report = new EquipItemActionReport(this, item);
                report.SetFail("already equipped");
                SendReport(report);
                return false;
            }

            return true;
        }
コード例 #8
0
ファイル: ItemObject.cs プロジェクト: tomba/dwarrowdelf
 internal static ItemObject Create(World world, ItemObjectBuilder builder)
 {
     var ob = new ItemObject(builder);
     ob.Initialize(world);
     return ob;
 }
コード例 #9
0
ファイル: LivingObject.cs プロジェクト: Fulborg/dwarrowdelf
 internal void OnItemIsEquippedChanged(ItemObject item, bool isEquipped)
 {
     if (item.IsArmor)
         RecalcArmorClass();
 }
コード例 #10
0
ファイル: LivingObject.cs プロジェクト: Fulborg/dwarrowdelf
        public void UnequipItem(ItemObject item)
        {
            Debug.Assert(item.Parent == this);
            Debug.Assert(item.IsEquipped);
            Debug.Assert((item.IsArmor && item.ArmorInfo != null) || (item.IsWeapon && item.WeaponInfo != null));

            item.IsEquipped = false;
        }
コード例 #11
0
ファイル: LivingObject.cs プロジェクト: Fulborg/dwarrowdelf
        public void EquipItem(ItemObject item)
        {
            Debug.Assert(item.Parent == this);
            Debug.Assert(item.IsEquipped == false);
            Debug.Assert((item.IsArmor && item.ArmorInfo != null) || (item.IsWeapon && item.WeaponInfo != null));

            if (item.IsArmor)
            {
                if (this.Inventory.OfType<ItemObject>().Where(i => i.IsArmor && i.IsEquipped)
                    .Any(i => i.ArmorInfo.Slot == item.ArmorInfo.Slot))
                    throw new Exception();
            }
            else if (item.IsWeapon)
            {
                if (this.Weapon != null)
                    throw new Exception();
            }
            else
            {
                throw new Exception();
            }

            item.IsEquipped = true;
        }
コード例 #12
0
 public ItemObject Create(World world)
 {
     return(ItemObject.Create(world, this));
 }