Пример #1
0
 public void EquipToMeleeHandSlot(MeleeWeaponItem item, bool switchSelectedHandSlot = false)
 {
     MeleeHandSlot = item;
     if (switchSelectedHandSlot)
     {
         SelectedHandSlot = 2;
     }
 }
Пример #2
0
    protected override void FixedUpdate()
    {
        base.FixedUpdate();

        // If either weapon item changes
        if (meleeItem != MeleeWeapon ||
            rangedItem != RangedWeapon)
        {
            meleeItem  = MeleeWeapon;
            rangedItem = RangedWeapon;

            // update attackData array
            AssignWeaponAttackData();
        }
    }
Пример #3
0
 public void AutoWood()
 {
     if (CVars.Misc.AutoWood)
     {
         WoodBlockerTemp.numWood = -1f;
         Character component = PlayerClient.GetLocalPlayer().controllable.GetComponent <Character>();
         Inventory inventory = component.GetComponent(typeof(Inventory)) as Inventory;
         MeleeWeaponItem <MeleeWeaponDataBlock> meleeWeaponItem = inventory._activeItem as MeleeWeaponItem <MeleeWeaponDataBlock>;
         if (inventory._activeItem is MeleeWeaponItem <MeleeWeaponDataBlock> && Time.time - this.LAST_ATTACK_TIME > meleeWeaponItem.datablock.fireRate && this.AUTO_WOOD_GATHER)
         {
             this.LAST_ATTACK_TIME = Time.time;
             ItemRepresentation itemRepresentation = meleeWeaponItem.itemRepresentation;
             IMeleeWeaponItem   meleeWeaponItem2   = meleeWeaponItem.iface as IMeleeWeaponItem;
             RaycastHit2        raycastHit;
             bool    flag  = Physics2.Raycast2(component.eyesRay, out raycastHit, meleeWeaponItem.datablock.range, 406721553);
             Vector3 point = raycastHit.point;
             itemRepresentation.Action(3, uLink.RPCMode.Server);
             uLink.BitStream bitStream = new uLink.BitStream(false);
             if (flag)
             {
                 IDMain idMain = raycastHit.idMain;
                 bitStream.WriteBoolean(true);
                 bitStream.Write <NetEntityID>(NetEntityID.Get(idMain), new object[0]);
                 bitStream.WriteVector3(point);
                 bitStream.WriteBoolean(false);
                 itemRepresentation.ActionStream(1, uLink.RPCMode.Server, bitStream);
                 HUDHitIndicator hUDHitIndicator;
                 if (Facepunch.Bundling.Load <HUDHitIndicator>("content/hud/HUDHitIndicator", out hUDHitIndicator))
                 {
                     HUDHitIndicator.CreateIndicator(point, true, hUDHitIndicator);
                 }
             }
             else
             {
                 bitStream.WriteBoolean(false);
                 bitStream.WriteVector3(Vector3.zero);
                 bitStream.WriteBoolean(true);
                 itemRepresentation.ActionStream(1, uLink.RPCMode.Server, bitStream);
             }
         }
     }
 }
Пример #4
0
 public void AutoWood()
 {
     if (CVars.Misc.AutoWood)
     {
         Character component = PlayerClient.GetLocalPlayer().controllable.GetComponent <Character>();
         Inventory inventory = component.GetComponent(typeof(Inventory)) as Inventory;
         MeleeWeaponItem <MeleeWeaponDataBlock> item = inventory._activeItem as MeleeWeaponItem <MeleeWeaponDataBlock>;
         if (((inventory._activeItem is MeleeWeaponItem <MeleeWeaponDataBlock>) && ((Time.time - this.LAST_ATTACK_TIME) > item.datablock.fireRate)) && this.AUTO_WOOD_GATHER)
         {
             RaycastHit2 hit;
             this.LAST_ATTACK_TIME = Time.time;
             ItemRepresentation itemRepresentation = item.itemRepresentation;
             IMeleeWeaponItem   iface = item.iface as IMeleeWeaponItem;
             bool    flag             = Physics2.Raycast2(component.eyesRay, out hit, item.datablock.range, 0x183e1411);
             Vector3 point            = hit.point;
             itemRepresentation.Action(3, uLink.RPCMode.Server);
             uLink.BitStream stream = new uLink.BitStream(false);
             if (flag)
             {
                 HUDHitIndicator indicator;
                 IDMain          idMain = hit.idMain;
                 stream.WriteBoolean(true);
                 stream.Write <NetEntityID>(NetEntityID.Get((UnityEngine.MonoBehaviour)idMain), new object[0]);
                 stream.WriteVector3(point);
                 stream.WriteBoolean(false);
                 itemRepresentation.ActionStream(1, uLink.RPCMode.Server, stream);
                 if (Bundling.Load <HUDHitIndicator>("content/hud/HUDHitIndicator", out indicator))
                 {
                     HUDHitIndicator.CreateIndicator(point, true, indicator);
                 }
             }
             else
             {
                 stream.WriteBoolean(false);
                 stream.WriteVector3(Vector3.zero);
                 stream.WriteBoolean(true);
                 itemRepresentation.ActionStream(1, uLink.RPCMode.Server, stream);
             }
         }
     }
 }
Пример #5
0
    private void ShowEditItem()
    {
        mSelectedItemIndex = EditorGUILayout.Popup("Item: ", mSelectedItemIndex, mItemOptions);
        InventoryItem nextItem = ItemList[mSelectedItemIndex];

        if (nextItem != mSelectedItem)
        {
            // clear the sprite so it will be reloaded
            mSelectedItemSprite = null;
            mSelectedItem       = ItemList[mSelectedItemIndex];
        }

        System.Type currentType = mSelectedItem.GetType();
        #region Consumables
        if (currentType == typeof(HPRecover))
        {
            HPRecover item = (HPRecover)mSelectedItem;

            ShowEditItemBase(item);

            // recovery
            item.Amount = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        }
        //if (currentType == typeof(RecoveryItem))
        //{
        //    RecoveryItem item = (RecoveryItem)mSelectedItem;

        //    ShowEditItemBase(item);

        //    // recovery
        //    item.ConsumableStatType = (Enums.eConsumableStatType)EditorGUILayout.EnumPopup("Stat Type: ", item.ConsumableStatType);
        //    item.Amount = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        //}
        //else if (currentType == typeof(StatUpgradeItem))
        //{
        //    StatUpgradeItem item = (StatUpgradeItem)mSelectedItem;

        //    ShowEditItemBase(item);

        //    // stat upgrade
        //    item.StatType = (Enums.eStatType)EditorGUILayout.EnumPopup("Boost Stat: ", item.StatType);
        //    item.Amount = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        //}
        //else if (currentType == typeof(StatusEffectItem))
        //{
        //    StatusEffectItem item = (StatusEffectItem)mSelectedItem;

        //    ShowEditItemBase(item);

        //    // status effect
        //    item.Effect = (Enums.eStatusEffect)EditorGUILayout.EnumPopup("Effect: ", item.Effect);
        //}
        //else if (currentType == typeof(WeaponUpgradeItem))
        //{
        //    WeaponUpgradeItem item = (WeaponUpgradeItem)mSelectedItem;

        //    ShowEditItemBase(item);

        //    // weapon upgrade
        //    item.Amount = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        //}
        //else if (currentType == typeof(CharacterSupportItem))
        //{
        //    // TODO
        //}
        #endregion

        #region Companions
        else if (currentType == typeof(CompanionItem))
        {
            CompanionItem item = (CompanionItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // companion
        }
        #endregion

        #region Stat Boosts
        else if (currentType == typeof(StatBoostItem))
        {
            StatBoostItem item = (StatBoostItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // stat boost
            item.StatType = (Enums.eStatType)EditorGUILayout.EnumPopup("Stat: ", item.StatType);
            item.Amount   = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        }
        else if (currentType == typeof(LongTermEffectItem))
        {
            LongTermEffectItem item = (LongTermEffectItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // long term effect
            item.EffectType = (Enums.eLongTermEffectType)EditorGUILayout.EnumPopup("Effect: ", item.EffectType);
            item.Delay      = EditorGUILayout.FloatField("Interval: ", Mathf.Clamp(item.Delay, 0, 10));
            item.Amount     = EditorGUILayout.IntField("Amount: ", Mathf.Clamp(item.Amount, 0, 999));
        }
        else if (currentType == typeof(ResistItem))
        {
            ResistItem item = (ResistItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // resist
            item.Effect  = (Enums.eStatusEffect)EditorGUILayout.EnumPopup("Effect: ", item.Effect);
            item.Percent = EditorGUILayout.FloatField("Percent: ", Mathf.Clamp(item.Percent, 0, 100));
        }
        #endregion

        #region Armours
        else if (currentType == typeof(HeadArmourItem))
        {
            HeadArmourItem item = (HeadArmourItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // head armour
        }
        else if (currentType == typeof(BodyArmourItem))
        {
            BodyArmourItem item = (BodyArmourItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // body armour
            item.Slots = EditorGUILayout.IntField("# Slots: ", Mathf.Clamp(item.Slots, 0, 5));
        }
        else if (currentType == typeof(ArmArmourItem))
        {
            ArmArmourItem item = (ArmArmourItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // arm armour
        }
        #endregion

        #region Weapons
        else if (currentType == typeof(MeleeWeaponItem))
        {
            MeleeWeaponItem item = (MeleeWeaponItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // melee weapon
            item.TwoHanded = EditorGUILayout.Toggle("Two Handed?: ", item.TwoHanded);
        }
        else if (currentType == typeof(RangedWeaponItem))
        {
            RangedWeaponItem item = (RangedWeaponItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // ranged weapon
            item.Range = EditorGUILayout.FloatField("Range: ", Mathf.Clamp(item.Range, 0, 99));
        }
        else if (currentType == typeof(MagicWeaponItem))
        {
            MagicWeaponItem item = (MagicWeaponItem)mSelectedItem;

            ShowEditItemBase(item);
            ShowEditEquippableBase(item);

            // magic weapon
            item.FocusType   = (Enums.eMagicFocusType)EditorGUILayout.EnumPopup("Focus: ", item.FocusType);
            item.MagicType   = (Enums.eMagicType)EditorGUILayout.EnumPopup("Type: ", item.MagicType);
            item.Radius      = EditorGUILayout.FloatField("Radius: ", Mathf.Clamp(item.Radius, 0, 99));
            item.MagicEffect = (Enums.eStatusEffect)EditorGUILayout.EnumPopup("Effect: ", item.MagicEffect);
            item.MPCost      = EditorGUILayout.IntField("Cost: ", Mathf.Clamp(item.MPCost, 0, 999));
        }
        #endregion

        if (GUILayout.Button("Delete Item"))
        {
            mConfirmPopup = ConfirmPopup.Create();
            mConfirmPopup.OnResultClicked += OnPopupClosed;
            mConfirmPopup.SetMessage("Are you sure you'd like to delete this item?");
        }

        if (GUILayout.Button("Update"))
        {
            Save();
        }
    }
Пример #6
0
    private void CreateItem()
    {
        //System.Type currentType = mCurrentItem.GetType();
        System.Type currentType = mCurrentCreateType.GetType();

        // fill in required fields
        #region Consumables
        if (currentType == typeof(HPRecover))
        {
            HPRecover item = new HPRecover(itemID);
            item.Amount = recoveryAmount;

            SetItemBase(item);

            ItemList.Add(item);
        }

        //if (currentType == typeof(RecoveryItem))
        //{
        //    RecoveryItem item = new RecoveryItem(itemID);
        //    item.ConsumableStatType = newRecoveryStatType;
        //    item.Amount = recoveryAmount;

        //    SetItemBase(item);

        //    ItemList.Add(item);
        //}
        //else if (currentType == typeof(StatUpgradeItem))
        //{
        //    StatUpgradeItem item = new StatUpgradeItem(itemID);
        //    item.StatType = newStatType;
        //    item.Amount = statBoostAmount;

        //    SetItemBase(item);

        //    ItemList.Add(item);
        //}
        //else if (currentType == typeof(StatusEffectItem))
        //{
        //    StatusEffectItem item = new StatusEffectItem(itemID);
        //    item.Effect = newEffectType;

        //    SetItemBase(item);

        //    ItemList.Add(item);
        //}
        //else if (currentType == typeof(WeaponUpgradeItem))
        //{
        //    WeaponUpgradeItem item = new WeaponUpgradeItem(itemID);
        //    item.Amount = weaponUpgradeAmount;

        //    SetItemBase(item);

        //    ItemList.Add(item);
        //}
        //else if (currentType == typeof(CharacterSupportItem))
        //{
        //    // TODO
        //}
        #endregion

        #region Companions
        else if (currentType == typeof(CompanionItem))
        {
            CompanionItem item = new CompanionItem(itemID);

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        #endregion

        #region Stat Boosts
        else if (currentType == typeof(StatBoostItem))
        {
            StatBoostItem item = new StatBoostItem(itemID);

            item.Stat   = StatToBoost;
            item.Amount = BoostAmount;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(LongTermEffectItem))
        {
            LongTermEffectItem item = new LongTermEffectItem(itemID);

            item.EffectType = LongTermEffect;
            item.Delay      = LongTermDelay;
            item.Amount     = LongTermAmount;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(ResistItem))
        {
            ResistItem item = new ResistItem(itemID);

            item.Effect  = ResistEffect;
            item.Percent = ResistPercent;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        #endregion

        #region Armours
        else if (currentType == typeof(HeadArmourItem))
        {
            HeadArmourItem item = new HeadArmourItem(itemID);

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(BodyArmourItem))
        {
            BodyArmourItem item = new BodyArmourItem(itemID);

            item.Slots = BodySlots;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(ArmArmourItem))
        {
            ArmArmourItem item = new ArmArmourItem(itemID);

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        #endregion

        #region Weapons
        else if (currentType == typeof(MeleeWeaponItem))
        {
            MeleeWeaponItem item = new MeleeWeaponItem(itemID);

            item.TwoHanded = MeleeTwoHanded;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(RangedWeaponItem))
        {
            RangedWeaponItem item = new RangedWeaponItem(itemID);

            item.Range = Range;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        else if (currentType == typeof(MagicWeaponItem))
        {
            MagicWeaponItem item = new MagicWeaponItem(itemID);

            item.FocusType   = MagicFocusType;
            item.MagicType   = MagicType;
            item.Radius      = MagicRadius;
            item.MagicEffect = MagicEffect;
            item.MPCost      = MagicCost;

            SetItemBase(item);
            SetEquippableBase(item);

            ItemList.Add(item);
        }
        #endregion

        itemID += 1;
        Reset();
    }
Пример #7
0
 public void PrepareMeleeDamage(MeleeWeaponItem item)
 {
     meleeDamage.size   = new Vector2(item.range, 1f);
     meleeDamage.offset = new Vector2(item.range / 2f, -0.1f);
     meleeWeaponObject  = item;
 }