Exemple #1
0
    /// <summary>
    /// 设置数据
    /// </summary>
    /// <param name="hp"></param>
    /// <param name="mp"></param>
    /// <param name="id"></param>
    /// <param name="name"></param>
    /// <param name="quality"></param>
    /// <param name="type"></param>
    /// <param name="description"></param>
    /// <param name="amount"></param>
    /// <param name="capacity"></param>
    /// <param name="buyprice"></param>
    /// <param name="sellprice"></param>
    /// <param name="assetId"></param>
    /// <param name="itemEffect"></param>
    public void SetData(int hp, int mp, int itemEffect, int id, string name, ItemQuality quality, ItemType type, string description, int amount, int capacity, int buyprice, int sellprice)
    {
        ItemConsumable dataTmp = new ItemConsumable();//正常里式替换原则,不可以子类转父类,但如果我们一开始分配的内存就是按父类来算的话,强转回子类也ok

        dataTmp.SetData(hp, mp, itemEffect, id, name, quality, type, description, amount, capacity, buyprice, sellprice);
        data = dataTmp;
    }
Exemple #2
0
        // consume the specified consumable - this lets the monster take a turn
        public void UseConsumable(ItemConsumable consumable)
        {
            Player.CurrentHitPoints += consumable.HitPoints;
            Player.RemoveItemFromInventory(consumable.ID, 1);
            RaiseMessage("You consume a " + consumable.Name);

            DoMonsterMove();
        }
Exemple #3
0
    /// <summary>
    /// 解析消耗品
    /// </summary>
    private void ParseConsumable()
    {
        var jsonData = SerializeTool.JsonDeserialize(Contract.Instance.consumableDataPath);//解析js数据

        for (int i = 0; i < jsonData.Count; i++)
        {
            var consumableData = new ItemConsumable();
            consumableData.SetData(jsonData[i]);
            allItems.Add(consumableData.id, consumableData);//向物品管理器中添加该数据
        }
    }
Exemple #4
0
        public void RandomItemConsumable()
        {
            var randomNumber = new Random();
            var randomItem   = randomNumber.Next(0, 5);

            if (randomItem == 1)
            {
                ItemConsumable bread = new ItemConsumable("dry bread", 4, ItemType.FOOD);
                this.ItemConsumable = bread;
            }
            else if (randomItem == 2)
            {
                ItemConsumable meat = new ItemConsumable("meat jerky", 8, ItemType.FOOD);
                this.ItemConsumable = meat;
            }
        }
        public Monster GenerateOneMonster()
        {
            Monster monster = new Monster();

            monster.Model       = GameModel.ModelGeometryCompiler.LoadModel("default");
            monster.DisplayName = "monster. kill me please.";
            Vector3 pos = new Vector3(RNG.NextInt(63), 0, RNG.NextInt(63));

            monster.Position             = pos;
            monster.LeashRadius          = 30;
            monster.PrimaryLootRollCount = 2;
            monster.PrimaryLootTable     = new List <Tuple <int, Item> >();
            ItemConsumable potA = new ItemConsumable
            {
                Colour = new Color(200, 50, 0),
                Name   = "HP potion"
            };
            ItemConsumable potB = new ItemConsumable
            {
                Colour = new Color(0, 100, 200),
                Name   = "MP potion"
            };
            Material  matA  = Material.MaterialTemplates.GetRandomMaterial();
            ItemEquip weapA = new ItemEquip();

            BonusPool p = BonusPool.Load("heavy_0_10");

            weapA.Bonuses.Add(p.PickBonus());
            weapA.Bonuses.Add(p.PickBonus());
            weapA.SubType           = RNG.NextInt(0, 1) * 4;
            weapA.PrimaryMaterial   = Material.MaterialTemplates.GetRandomMaterial();
            weapA.SecondaryMaterial = Material.MaterialTemplates.GetRandomMaterial();
            monster.PrimaryLootTable.Add(new Tuple <int, Item>(5, potA));
            monster.PrimaryLootTable.Add(new Tuple <int, Item>(5, potB));
            monster.PrimaryLootTable.Add(new Tuple <int, Item>(1, matA));
            monster.PrimaryLootTable.Add(new Tuple <int, Item>(3, null));
            monster.PrimaryLootTable.Add(new Tuple <int, Item>(10, weapA));

            return(monster);
        }
Exemple #6
0
    /// <summary>
    /// 根据id创建item 一定要返回新创建的item 否则引用数据备份会出现bug
    /// </summary>
    /// <param name="id"></param>
    private BaseItemData GetItemDataById(int id)
    {
        if (allItems.Count != 0)
        {
            BaseItemData baseItemData;
            allItems.TryGetValue(id, out baseItemData);
            switch (baseItemData.type)
            {
            case ItemType.Consumable:
                ItemConsumable itemConsumable = (ItemConsumable)baseItemData;
                ItemConsumable resultItem     = new ItemConsumable();
                resultItem.SetData(itemConsumable.hp, itemConsumable.mp, itemConsumable.itemEffect, baseItemData.id, baseItemData.name, baseItemData.quality, baseItemData.type, baseItemData.description, baseItemData.amount, baseItemData.capacity, baseItemData.buyprice, baseItemData.sellprice);
                return(resultItem);

            case ItemType.Equipment:
                ItemEquipment itemEquipment = (ItemEquipment)baseItemData;
                ItemEquipment resultItem1   = new ItemEquipment();
                resultItem1.SetData(itemEquipment.strength, itemEquipment.intellect, itemEquipment.agility, itemEquipment.stamina, itemEquipment.equipmentType, baseItemData.id, baseItemData.name, baseItemData.quality, baseItemData.type, baseItemData.description, baseItemData.amount, baseItemData.capacity, baseItemData.buyprice, baseItemData.sellprice);
                return(resultItem1);

            case ItemType.Material:
                ItemMaterial itemMaterial = (ItemMaterial)baseItemData;
                ItemMaterial resultItem2  = new ItemMaterial();
                resultItem2.SetData(baseItemData.id, baseItemData.name, baseItemData.quality, baseItemData.type, baseItemData.description, baseItemData.amount, baseItemData.capacity, baseItemData.buyprice, baseItemData.sellprice);
                return(resultItem2);

            case ItemType.Weapon:
                ItemWeapon itemWeapon  = (ItemWeapon)baseItemData;
                ItemWeapon resultItem3 = new ItemWeapon();
                resultItem3.SetData(itemWeapon.damage, itemWeapon.weaponType, itemWeapon.weaponEffects, baseItemData.id, baseItemData.name, baseItemData.quality, baseItemData.type, baseItemData.description, baseItemData.amount, baseItemData.capacity, baseItemData.buyprice, baseItemData.sellprice);
                return(resultItem3);
            }
        }
        else
        {
            Debug.LogError("物品列表中没有物品");
        }
        return(null);
    }