Ejemplo n.º 1
0
 public ItemSword(int par1, ToolMaterial par2EnumToolMaterial) : base(par1)
 {
     ToolMaterial = par2EnumToolMaterial;
     MaxStackSize = 1;
     SetMaxDamage(par2EnumToolMaterial.MaxUses);
     WeaponDamage = 4 + par2EnumToolMaterial.DamageVsEntity;
 }
Ejemplo n.º 2
0
 public bool Damage(ToolType toolType, ToolMaterial toolMaterial)
 {
     if (toolType.CanHarvest(this.toolType) && toolMaterial.StrongEnough(this.toolMaterial))
     {
         float multiplier = toolType.RightTool(this.toolType) ? toolMaterial.Multiplier : 1;
         currentDamage += Time.deltaTime * multiplier * 0.666666f;
         if (currentDamage >= totalDamage)
         {
             if (destroyed)
             {
                 return(true);
             }
             destroyed = true;
             ItemEntity.Spawn(transform.position, item, 1);
         }
     }
     else
     {
         currentDamage += Time.deltaTime * 0.2f;
     }
     if (currentDamage >= totalDamage)
     {
         destroyed = true;
         OnDestroyed();
         Destroy(gameObject);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 3
0
 protected ItemTool(int par1, int par2, ToolMaterial par3EnumToolMaterial, Block[] par4ArrayOfBlock) : base(par1)
 {
     EfficiencyOnProperMaterial = 4F;
     ToolMaterial           = par3EnumToolMaterial;
     BlocksEffectiveAgainst = par4ArrayOfBlock;
     MaxStackSize           = 1;
     SetMaxDamage(par3EnumToolMaterial.MaxUses);
     EfficiencyOnProperMaterial = par3EnumToolMaterial.EfficiencyOnProperMaterial;
     DamageVsEntity             = par2 + par3EnumToolMaterial.DamageVsEntity;
 }
Ejemplo n.º 4
0
        public override DataTable get()
        {
            int      stock = (int)ToolCell.isNull(getBuilder().getParameterValue(TablePRCLIST.CARDREF), (int)0);
            int      unit  = (int)ToolCell.isNull(getBuilder().getParameterValue(TablePRCLIST.UOMREF), (int)0);
            DateTime date  = (DateTime)ToolCell.isNull(getBuilder().getParameterValue(TablePRCLIST.BEGDATE), DateTime.Now);

            getBuilder().deleteParameter(TablePRCLIST.TABLE, TablePRCLIST.UOMREF);
            getBuilder().deleteParameter(TablePRCLIST.TABLE, TablePRCLIST.BEGDATE);
            DataTable    prices = base.get();
            IPagedSource source = new PagedSourceMaterialUnits(environment);

            source.getBuilder().addParameterValue(TableITMUNITA.ITEMREF, stock);
            return(ToolMaterial.getMatUnitPrices(unit, date, environment, prices, source.get()));
        }
Ejemplo n.º 5
0
 protected BlockType(string name, float hardness, ToolType toolType, ToolMaterial toolMaterial, Func <Sprite> texture, Func <Item> itemDrop, Action specialAction = null, Func <Block> blockPrefab = null) : base(name)
 {
     Name          = name;
     Hardness      = hardness;
     ToolType      = toolType;
     ToolMaterial  = toolMaterial;
     Texture       = texture;
     GetItem       = itemDrop;
     SpecialAction = specialAction;
     if (blockPrefab == null)
     {
         prefab = () => Block.Prefab;
     }
     else
     {
         prefab = blockPrefab;
     }
 }
Ejemplo n.º 6
0
    void SwitchMaterial(ToolMaterial material_tool)
    {
        switch (material_tool)
        {
        case ToolMaterial.Wood:
            my_strength = 20;
            my_curve    = curves.Curves_List[0];
            break;

        case ToolMaterial.Iron:
            my_strength = 40;
            my_curve    = curves.Curves_List[1];
            break;

        case ToolMaterial.Diamond:
            my_strength = 60;
            my_curve    = curves.Curves_List[2];
            break;
        }
    }
Ejemplo n.º 7
0
 public ItemPickaxe(int par1, ToolMaterial par2EnumToolMaterial) : base(par1, 2, par2EnumToolMaterial, BlocksEffectiveAgainst)
 {
 }
Ejemplo n.º 8
0
 public DoorType(string name, float hardness, ToolType toolType, ToolMaterial toolMaterial, Func <Sprite> texture, Func <Item> itemDrop, Action specialAction = null, Func <Block> blockPrefab = null) : base(name, hardness, toolType, toolMaterial, texture, itemDrop, specialAction, blockPrefab)
 {
 }
Ejemplo n.º 9
0
 public ItemHoe(int par1, ToolMaterial par2EnumToolMaterial) : base(par1)
 {
     MaxStackSize = 1;
     SetMaxDamage(par2EnumToolMaterial.MaxUses);
 }
Ejemplo n.º 10
0
 public ToolItem(string displayName, Func <Sprite> icon, ToolType type, ToolMaterial material) : base(displayName, icon, false)
 {
     putInHand      = () => Player.Instance.ChangeTool(type, material);
     removeFromHand = () => Player.Instance.ChangeTool(ToolType.None, ToolMaterial.All);
 }
Ejemplo n.º 11
0
    public static Block Place(Block prefab, Vector3 worldPosition, string name, float hardness, ToolType toolType, ToolMaterial toolMaterial, Sprite texture, Item item, Action specialAction = null, bool background = false)
    {
        Block block = Instantiate(prefab, worldPosition, Quaternion.identity);

        block.BlockName             = name;
        block.hardness              = hardness;
        block.toolMaterial          = toolMaterial;
        block.toolType              = toolType;
        block.spriteRenderer.sprite = texture;
        block.totalDamage           = hardness;
        if (specialAction != null)
        {
            block.specialAction = specialAction;
        }
        block.item = item;
        if (background)
        {
            block.spriteRenderer.color        = new Color(1, 1, 1, 0.7f);
            block.spriteRenderer.sortingOrder = -1;
        }
        else
        {
            block.blockCollider.enabled = true;
        }
        return(block);
    }
Ejemplo n.º 12
0
 public void ChangeTool(ToolType tool, ToolMaterial material)
 {
     activeTool   = tool;
     toolMaterial = material;
 }
Ejemplo n.º 13
0
 internal EnumToolMaterial(ToolMaterial type, int harvestLevel, int maxUses, float efficiencyOnProperMaterial, float damageVsEntity, int enchantability)
 {
     this.Enum = type;
 }
Ejemplo n.º 14
0
 public bool StrongEnough(ToolMaterial blockRequiredMaterial)
 {
     return(Value >= blockRequiredMaterial.Value);
 }
Ejemplo n.º 15
0
 public ItemSpade(int par1, ToolMaterial par2EnumToolMaterial) : base(par1, 1, par2EnumToolMaterial, BlocksEffectiveAgainst)
 {
 }
Ejemplo n.º 16
0
        protected override Material ParseModelFromJavaField(string line)
        {
            System.Globalization.CultureInfo invariancy = System.Globalization.CultureInfo.InvariantCulture;

            int    startIndex = 0;
            int    endIndex   = line.IndexOf(" ", startIndex);
            string type       = line.Substring(startIndex, endIndex - startIndex);

            startIndex = endIndex + 1;
            endIndex   = line.IndexOf(" ", startIndex);
            string name = line.Substring(startIndex, endIndex - startIndex);

            Material material = null;

            if (type == "ToolMaterial")
            {
                material = new ToolMaterial()
                {
                    Name = name
                };
                ToolMaterial toolMaterial = (ToolMaterial)material;

                startIndex = line.IndexOf(",", endIndex) + 1;
                endIndex   = line.IndexOf(",", startIndex);
                string harvestLevel = line.Substring(startIndex, endIndex - startIndex);
                toolMaterial.HarvestLevel = int.Parse(harvestLevel, invariancy);

                startIndex = line.IndexOf(",", endIndex) + 1;
                endIndex   = line.IndexOf(",", startIndex);
                string maxUses = line.Substring(startIndex, endIndex - startIndex);
                toolMaterial.MaxUses = int.Parse(maxUses, invariancy);

                startIndex = line.IndexOf(",", endIndex) + 1;
                endIndex   = line.IndexOf(",", startIndex);
                string efficiency = line.Substring(startIndex, endIndex - startIndex);
                toolMaterial.Efficiency = float.Parse(efficiency, invariancy);

                startIndex = line.IndexOf(",", endIndex) + 1;
                endIndex   = line.IndexOf(",", startIndex);
                string damage = line.Substring(startIndex, endIndex - startIndex);
                toolMaterial.AttackDamage = float.Parse(damage, invariancy);

                startIndex = line.IndexOf(",", endIndex) + 1;
                endIndex   = line.IndexOf(",", startIndex);
                string enchantability = line.Substring(startIndex, endIndex - startIndex);
                toolMaterial.Enchantability = int.Parse(enchantability, invariancy);
            }
            else if (type == "ArmorMaterial")
            {
                material = new ArmorMaterial()
                {
                    Name = name
                };
                ArmorMaterial armorMaterial = (ArmorMaterial)material;

                startIndex = line.IndexOf(",", endIndex) + 1;
                endIndex   = line.IndexOf(",", startIndex);
                string textureName = line.Substring(startIndex, endIndex - startIndex);
                armorMaterial.TextureName = textureName;

                startIndex = line.IndexOf(",", endIndex) + 1;
                endIndex   = line.IndexOf(",", startIndex);
                string durability = line.Substring(startIndex, endIndex - startIndex);
                armorMaterial.Durability = int.Parse(durability, invariancy);

                startIndex = line.IndexOf("{", endIndex) + 1;
                endIndex   = line.IndexOf("}", startIndex);
                string reductionAmounts = line.Substring(startIndex, endIndex - startIndex).Trim();
                armorMaterial.HelmetDamageReduction = (int)char.GetNumericValue(reductionAmounts, 0);
                armorMaterial.PlateDamageReduction  = (int)char.GetNumericValue(reductionAmounts, 2);
                armorMaterial.LegsDamageReduction   = (int)char.GetNumericValue(reductionAmounts, 4);
                armorMaterial.BootsDamageReduction  = (int)char.GetNumericValue(reductionAmounts, 6);

                startIndex = line.IndexOf(",", endIndex) + 1;
                endIndex   = line.IndexOf(",", startIndex);
                string enchantability = line.Substring(startIndex, endIndex - startIndex);
                armorMaterial.Enchantability = int.Parse(enchantability, invariancy);

                startIndex = line.IndexOf(",", endIndex) + 1;
                endIndex   = line.IndexOf(",", startIndex);
                string soundOnEquip = line.Substring(startIndex, endIndex - startIndex);
                armorMaterial.SoundEvent = soundOnEquip;

                startIndex = line.IndexOf(",", endIndex) + 1;
                endIndex   = line.IndexOf(",", startIndex);
                string toughness = line.Substring(startIndex, endIndex - startIndex);
                armorMaterial.Toughness = float.Parse(toughness, invariancy);
            }
            else if (type == "Material")
            {
                material = new BlockMaterial()
                {
                    Name = name
                };
                BlockMaterial blockMaterial = (BlockMaterial)material;

                startIndex = line.IndexOf("(", endIndex) + 1;
                endIndex   = line.IndexOf(")", startIndex);
                string solid = line.Substring(startIndex, endIndex - startIndex);
                blockMaterial.IsSolid = bool.Parse(solid);

                startIndex = line.IndexOf("(", endIndex) + 1;
                endIndex   = line.IndexOf(")", startIndex);
                string liquid = line.Substring(startIndex, endIndex - startIndex);
                blockMaterial.IsLiquid = bool.Parse(liquid);

                startIndex = line.IndexOf("(", endIndex) + 1;
                endIndex   = line.IndexOf(")", startIndex);
                string blockLight = line.Substring(startIndex, endIndex - startIndex);
                blockMaterial.BlocksLight = bool.Parse(blockLight);

                startIndex = line.IndexOf("(", endIndex) + 1;
                endIndex   = line.IndexOf(")", startIndex);
                string blockMovement = line.Substring(startIndex, endIndex - startIndex);
                blockMaterial.BlocksMovement = bool.Parse(blockMovement);

                startIndex = line.IndexOf("(", endIndex) + 1;
                endIndex   = line.IndexOf(")", startIndex);
                string translucent = line.Substring(startIndex, endIndex - startIndex);
                blockMaterial.IsTranslucent = bool.Parse(translucent);

                startIndex = line.IndexOf("(", endIndex) + 1;
                endIndex   = line.IndexOf(")", startIndex);
                string requiresNoTool = line.Substring(startIndex, endIndex - startIndex);
                blockMaterial.RequiresNoTool = bool.Parse(requiresNoTool);

                startIndex = line.IndexOf("(", endIndex) + 1;
                endIndex   = line.IndexOf(")", startIndex);
                string burning = line.Substring(startIndex, endIndex - startIndex);
                blockMaterial.CanBurn = bool.Parse(burning);

                startIndex = line.IndexOf("(", endIndex) + 1;
                endIndex   = line.IndexOf(")", startIndex);
                string replaceable = line.Substring(startIndex, endIndex - startIndex);
                blockMaterial.IsReplaceable = bool.Parse(replaceable);

                startIndex = line.IndexOf("(", endIndex) + 1;
                endIndex   = line.IndexOf(")", startIndex);
                string adventureModeExempt = line.Substring(startIndex, endIndex - startIndex);
                blockMaterial.IsAdventureModeExempt = bool.Parse(adventureModeExempt);

                startIndex = line.IndexOf("(", endIndex) + 1;
                endIndex   = line.IndexOf(")", startIndex);
                string mobilityFlag = line.Substring(startIndex, endIndex - startIndex);
                blockMaterial.MobilityFlag = (PushReaction)System.Enum.Parse(typeof(PushReaction), mobilityFlag.Remove(0, "EnumPushReaction.".Length), true);
            }
            else
            {
                throw new System.NotImplementedException($"Implementation of {type} was not found");
            }

            material.IsDirty = false;
            return(material);
        }