示例#1
0
        private void EquipWeapon(WeaponItemData weapon)
        {
            switch (weapon.weaponType)
            {
            case WeaponItemData.WEAPON_TYPE.SHIELD:
                if (weapon == LeftWeapon)
                {
                    LeftWeapon = null;
                }
                else
                {
                    LeftWeapon = weapon;
                }
                break;

            case WeaponItemData.WEAPON_TYPE.WEAPON:
                if (weapon == RightWeapon)
                {
                    RightWeapon = null;
                }
                else
                {
                    RightWeapon = weapon;
                }
                break;
            }

            RaiseOnEquipmentChange(weapon);
        }
示例#2
0
    public WeaponItemData SelectLatestWeapon()
    {
        WeaponItemData temp = currentWeapon;

        //verify if we had a previous weapon
        if (LatestWeaponDifferentFromWeapon(currentWeapon))
        {
            currentWeapon = latestWeapon;
            latestWeapon  = temp;
            for (int i = 0; i < arsenalSize; i++)
            {
                if (arsenal[i] == currentWeapon)
                {
                    currentArsenalIndex = i;
                    break;
                }
            }
        }
        else //select next weapon
        {
            currentWeapon = SelectNextWeapon();
            latestWeapon  = temp;
        }
        return(currentWeapon);
    }
示例#3
0
 public WeaponItemData SelectPreviousWeapon()
 {
     currentArsenalIndex = currentArsenalIndex - 1 < 0 ? arsenal.Count - 1 : currentArsenalIndex - 1;
     latestWeapon        = currentWeapon;
     currentWeapon       = arsenal[currentArsenalIndex];
     return(currentWeapon);
 }
示例#4
0
        private void LoadEquipment(WeaponItemData weapon)
        {
            if (weapon.weaponType == WeaponItemData.WEAPON_TYPE.WEAPON)
            {
                if (rightHandAnchor.childCount != 0)
                {
                    Destroy(rightHandAnchor.GetChild(0).gameObject);
                }

                if (Equipment.RightWeapon != null)
                {
                    GameObject item = Instantiate(Equipment.RightWeapon.prefab);
                    item.transform.SetParent(rightHandAnchor);
                    item.transform.localPosition = Vector3.zero;
                    item.transform.localRotation = Quaternion.identity * Quaternion.Euler(new Vector3(90, 0, 0));
                }
            }

            else if (weapon.weaponType == WeaponItemData.WEAPON_TYPE.SHIELD)
            {
                if (leftHandAnchor.childCount != 0)
                {
                    Destroy(leftHandAnchor.GetChild(0).gameObject);
                }

                if (Equipment.LeftWeapon != null)
                {
                    GameObject item = Instantiate(Equipment.LeftWeapon.prefab);
                    item.transform.SetParent(leftHandAnchor);
                    item.transform.localPosition = Vector3.zero;
                    item.transform.localRotation = Quaternion.identity;
                }
            }
        }
    public IEnumerator ChangeWeapon(int input)
    {
        WeaponItemData weaponItemData = null;

        //check if changing weapon is possible (more than 1 weapon in inventory)
        if (HasInventory() && input != 0 && inventory.GetArsenalSize() > 1 && CanChangeWeapon())
        {
            ChangeWeaponAxisInUse = true;
            Debug.Log(input);
            if (input < 0)
            {
                weaponItemData = inventory.SelectNextWeapon();
            }
            else if (input > 0)
            {
                weaponItemData = inventory.SelectPreviousWeapon();
            }
            if (weaponItemData != null)
            {
                InstantiateWeapon(weaponItemData.GetPrefabPath());
                yield return(weaponSwapDelaySeconds);
            }
        }
        ChangeWeaponAxisInUse = false;
    }
示例#6
0
 public void RaiseOnEquipmentChange(WeaponItemData weapon)
 {
     if (onEquipmentChange != null)
     {
         onEquipmentChange(weapon);
     }
 }
 public void PlayerInteraction()
 {
     if (intDetector != null)
     {
         Interaction interaction = intDetector.GetClosestInteraction();
         if (interaction is WeaponItem && inventory != null)
         {
             WeaponItemData weaponItemData = ((WeaponItem)interaction).GetWeaponItemData();
             inventory.AddWeapon(weaponItemData);
             Destroy(interaction.gameObject);
             //If this is the only weapon in inventory, and no weapon is equiped, equip it
             if (inventory.GetArsenalSize() == 1 && equippedWeapon == null)
             {
                 InstantiateWeapon(weaponItemData.GetPrefabPath());
             }
             Debug.Log(interaction.gameObject.name);
         }
         else if (interaction is Door)
         {
             Door door = (Door)interaction;
             if (door.IsInteractive())
             {
                 door.Open();
             }
         }
     }
     else
     {
         Debug.Log("Interaction detector not found on " + gameObject.name);
     }
 }
示例#8
0
    public WeaponItemData SelectNextWeapon()
    {
        currentArsenalIndex = (currentArsenalIndex + 1) % arsenal.Count;
        latestWeapon        = currentWeapon;
        currentWeapon       = arsenal[currentArsenalIndex];

        return(currentWeapon);
    }
示例#9
0
 private bool LatestWeaponDifferentFromWeapon(WeaponItemData weapon)
 {
     if (latestWeapon != weapon)
     {
         return(true);
     }
     return(false);
 }
示例#10
0
        private IList <WeaponItemData> ReadWeaponsData(BinaryReader r)
        {
            var a = new WeaponItemData[Data.WeaponsCount];

            for (int i = 0; i < Data.WeaponsCount; i++)
            {
                a[i] = ParseWeaponData(r);
            }

            return(a);
        }
示例#11
0
 public bool AlreadyInInventory(WeaponItemData weaponData)
 {
     foreach (WeaponItemData w in arsenal)
     {
         if (w.GetItemName() == weaponData.GetItemName())
         {
             Debug.Log("Item Already In inventory");
             return(true);
         }
     }
     return(false);
 }
示例#12
0
 public MagicType GetWeaponMagicType()
 {
     foreach (var item in _inventoryItems)
     {
         if (item.Item.ItemType == ItemType.eWEAPON)
         {
             WeaponItemData weaponData = (WeaponItemData)item.Item;
             return(weaponData.MagicalType);
         }
     }
     return(MagicType.eNONE);
 }
示例#13
0
    public void EquipWeapon(WeaponItemData weaponItem, Inventory partyInventory)
    {
        //check if the magic type of the item is the same as the rest
        if (weaponItem.MagicalType != _weaponMagicType)
        {
            //first check if the chracter has a magic type
            if (Character.Magic != MagicType.eNONE)
            {
                //character has a magic type, check if the weapon is the same as the characters magic
                if (Character.Magic != weaponItem.MagicalType)
                {
                    return;
                }
            }
            else if (weaponItem.MagicalType != _weaponMagicType && hasWeapon())
            {
                return;
            }
        }

        //Remove the item from the part inventory
        partyInventory.RemoveItem(weaponItem.Name);

        BaseItemData itemToRemove = null;

        //check if a weapon is already in the equipment
        foreach (var inventoryItem in _inventoryItems)
        {
            if (inventoryItem.Item.ItemType == ItemType.eWEAPON)
            {
                WeaponItemData inventoryWeaponItem = (WeaponItemData)inventoryItem.Item;
                if ((inventoryWeaponItem.IsMainHand == weaponItem.IsMainHand))
                {
                    //Weapon already equipped, add it back to the party inventory
                    partyInventory.AddItem(inventoryItem.Item);
                    //remove weapon from equipment
                    itemToRemove = inventoryItem.Item;
                    break;
                }
            }
        }

        if (itemToRemove != null)
        {
            RemoveItem(itemToRemove.Name);
        }

        //Add it to the equipment
        AddItem(weaponItem);

        _weaponMagicType = weaponItem.MagicalType;
    }
示例#14
0
        public IGrabableItem CreateWeapon(WeaponItemData weapon)
        {
            weapon.Processed = true;
            var initializator = new WeaponInitializer
            {
                IsBroken    = weapon.IsBroken,
                ChargeCount = weapon.ChargeCount,
                IsCursed    = weapon.IsCursed,
                IsPoisoned  = weapon.IsPoisoned
            };

            return(builder.Factories.WeaponFactories[currentDescriptor.InCategoryIndex].Create(initializator));
        }
示例#15
0
        private bool IsBetterThanEquiped(WeaponItemData weapon)
        {
            switch (weapon.weaponType)
            {
            case WeaponItemData.WEAPON_TYPE.WEAPON:
                return(weapon.IsBetterThan(playerEquipment.RightWeapon));

            case WeaponItemData.WEAPON_TYPE.SHIELD:
                return(weapon.IsBetterThan(playerEquipment.LeftWeapon));
            }

            return(false);
        }
示例#16
0
 public void Start()
 {
     cam      = Camera.main;
     animator = GetComponent <Animator>();
     if (!animator)
     {
         animator = GetComponentInChildren <Animator>();
     }
     weaponData = playerInventory.FindWeaponDataByName(weaponName);
     if (weaponData == null)
     {
         Debug.Log("Weapon data found in inventory");
     }
     firingStart = -(1 / fireRate);
 }
示例#17
0
    public void RemoveWeapon(WeaponItemData weaponToRemove)
    {
        //ajouter traitement au cass où on enlèverait l'arme courante ou récemment utilisée
        //

        if (arsenalSize == 0)
        {
            Debug.Log("Nothing to remove");
        }
        else
        {
            arsenal.Remove(weaponToRemove);
        }
        arsenalSize = arsenal.Count;
    }
    public IEnumerator EquipWeaponSlot(int slot)
    {
        WeaponItemData weaponItemData = null;

        if (HasInventory() && CanChangeWeapon())
        {
            weaponItemData        = inventory.SelectWeaponSlot(slot);
            ChangeWeaponAxisInUse = true;
            if (weaponItemData != null)
            {
                InstantiateWeapon(weaponItemData.GetPrefabPath());
                yield return(weaponSwapDelaySeconds);
            }
        }
        ChangeWeaponAxisInUse = false;
    }
    void RemoveItemUI(InventoryItem item)
    {
        if (item == null)
        {
            return;
        }

        if (item.Item.ItemType == ItemType.eARMOUR)
        {
            ArmourItemData armourItem = (ArmourItemData)item.Item;
            switch (armourItem.ArmourSlotType)
            {
            case ArmourItemData.SlotType.eHEAD:
                HeadButton.image.sprite = DefaultPreviewSprite;
                HeadButton.GetComponent <InventoryItemButton>().Item = null;
                break;

            case ArmourItemData.SlotType.eCHEST:
                BodyButton.image.sprite = DefaultPreviewSprite;
                BodyButton.GetComponent <InventoryItemButton>().Item = null;
                break;

            case ArmourItemData.SlotType.eLEGS:
                LegsButton.image.sprite = DefaultPreviewSprite;
                LegsButton.GetComponent <InventoryItemButton>().Item = null;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        else if (item.Item.ItemType == ItemType.eWEAPON)
        {
            WeaponItemData weaponItem = (WeaponItemData)item.Item;
            if (weaponItem.IsMainHand)
            {
                MainHandButton.image.sprite = DefaultPreviewSprite;
                MainHandButton.GetComponent <InventoryItemButton>().Item = null;
            }
            else
            {
                OffHandButton.image.sprite = DefaultPreviewSprite;
                OffHandButton.GetComponent <InventoryItemButton>().Item = null;
            }
        }
    }
    void AddUIItem(InventoryItem item)
    {
        if (item.Item.ItemType == ItemType.eARMOUR)
        {
            ArmourItemData armourItem = (ArmourItemData)item.Item;
            switch (armourItem.ArmourSlotType)
            {
            case ArmourItemData.SlotType.eHEAD:
                HeadButton.image.sprite = armourItem.PreviewSprite;
                HeadButton.GetComponent <InventoryItemButton>().Item      = item;
                HeadButton.GetComponent <InventoryItemButton>().Inventory = _playerManager.Characters[_currentCharacterIndex].Equipment;
                break;

            case ArmourItemData.SlotType.eCHEST:
                BodyButton.image.sprite = armourItem.PreviewSprite;
                BodyButton.GetComponent <InventoryItemButton>().Item      = item;
                BodyButton.GetComponent <InventoryItemButton>().Inventory = _playerManager.Characters[_currentCharacterIndex].Equipment;
                break;

            case ArmourItemData.SlotType.eLEGS:
                LegsButton.image.sprite = armourItem.PreviewSprite;
                LegsButton.GetComponent <InventoryItemButton>().Item      = item;
                LegsButton.GetComponent <InventoryItemButton>().Inventory = _playerManager.Characters[_currentCharacterIndex].Equipment;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        else if (item.Item.ItemType == ItemType.eWEAPON)
        {
            WeaponItemData weaponItem = (WeaponItemData)item.Item;
            if (weaponItem.IsMainHand)
            {
                MainHandButton.image.sprite = weaponItem.PreviewSprite;
                MainHandButton.GetComponent <InventoryItemButton>().Item      = item;
                MainHandButton.GetComponent <InventoryItemButton>().Inventory = _playerManager.Characters[_currentCharacterIndex].Equipment;
            }
            else
            {
                OffHandButton.image.sprite = weaponItem.PreviewSprite;
                OffHandButton.GetComponent <InventoryItemButton>().Item      = item;
                OffHandButton.GetComponent <InventoryItemButton>().Inventory = _playerManager.Characters[_currentCharacterIndex].Equipment;
            }
        }
    }
    public IEnumerator EquipLatestWeapon()
    {
        WeaponItemData weaponItemData = null;

        //check if changing weapon is possible (more than 1 weapon in inventory)
        if (HasInventory() && inventory.GetArsenalSize() > 1 && CanChangeWeapon())
        {
            weaponItemData        = inventory.SelectLatestWeapon();
            ChangeWeaponAxisInUse = true;
            if (weaponItemData != null && weaponItemData.GetPrefabPath() != weapon.GetPrefab())
            {
                InstantiateWeapon(weaponItemData.GetPrefabPath());
                yield return(weaponSwapDelaySeconds);
            }
        }
        ChangeWeaponAxisInUse = false;
    }
示例#22
0
        private void CompareEquipment(Button button)
        {
            ItemData item = button.GetComponent <ItemButton>().itemData;

            if (item.Type == ItemData.TYPE.ARMOR)
            {
                ArmorItemData armor = item as ArmorItemData;

                button.transform.Find("EquipedArrow").gameObject.SetActive(item && IsEquiped(armor));
                button.transform.Find("UpgradeArrow").gameObject.SetActive(item && IsBetterThanEquiped(armor));
            }
            else if (item.Type == ItemData.TYPE.WEAPON)
            {
                WeaponItemData weapon = item as WeaponItemData;

                button.transform.Find("EquipedArrow").gameObject.SetActive(item && IsEquiped(weapon));
                button.transform.Find("UpgradeArrow").gameObject.SetActive(item && IsBetterThanEquiped(weapon));
            }
        }
示例#23
0
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
     arsenalSize         = arsenal.Count;
     currentArsenalIndex = 0;
     if (arsenalSize > 0)
     {
         currentWeapon = arsenal[currentArsenalIndex];
         latestWeapon  = currentWeapon;
     }
 }
示例#24
0
 public WeaponItemData AddWeapon(WeaponItemData weaponToAdd)
 {
     if (arsenalSize == inventoryCapacity)
     {
         Debug.Log("Inventory is full");
     }
     else if (!AlreadyInInventory(weaponToAdd))
     {
         arsenal.Add(weaponToAdd);
         arsenalSize = arsenal.Count;
         if (arsenalSize == 1)
         {
             currentWeapon = arsenal[0];
             latestWeapon  = currentWeapon;
             return(currentWeapon);
         }
     }
     return(null);
 }
示例#25
0
        private WeaponItemData ParseWeaponData(BinaryReader r)
        {
            var w = new WeaponItemData();

            w.NextObjectID = r.ReadUInt16();

            ushort data = r.ReadUInt16();

            w.IsBroken = ((data >> 14) & oneBitMask) == 1;

            w.ChargeCount = (data >> 10) & fourBitsMask;

            w.IsPoisoned  = ((data >> 9) & oneBitMask) == 1;
            w.IsCursed    = ((data >> 8) & oneBitMask) == 1;
            w.IsImportant = ((data >> 7) & oneBitMask) == 1;

            w.ItemTypeIndex = data & sevenBitsMask;

            return(w);
        }
示例#26
0
 public WeaponItemData SelectWeaponSlot(int slot)
 {
     Debug.Log(slot);
     if (slot < arsenalSize)
     {
         if (arsenal[slot] != null && arsenal[slot] != currentWeapon)
         {
             if (LatestWeaponDifferentFromWeapon(arsenal[slot]))
             {
                 latestWeapon = currentWeapon;
             }
             currentWeapon       = arsenal[slot];
             currentArsenalIndex = slot;
             return(currentWeapon);
         }
         else
         {
             Debug.Log("Weapon already equipped");
         }
     }
     Debug.Log("Weapon not found");
     return(currentWeapon);
 }
示例#27
0
    public void ShowWeapon(WeaponItemData weapon)
    {
        foreach (var prototype in _iconInstances)
        {
            prototype.ReturnToPool();
        }
        _iconInstances.Clear();

        var caliberIcon = IconPrototype.Instantiate <Image>();

        _iconInstances.Add(caliberIcon.GetComponent <Prototype>());
        caliberIcon.sprite = Settings.GetIcon(weapon.WeaponCaliber);

        var rangeIcon = IconPrototype.Instantiate <Image>();

        _iconInstances.Add(rangeIcon.GetComponent <Prototype>());
        rangeIcon.sprite = Settings.GetIcon(weapon.WeaponRange);

        var typeIcon = IconPrototype.Instantiate <Image>();

        _iconInstances.Add(typeIcon.GetComponent <Prototype>());
        typeIcon.sprite = Settings.GetIcon(weapon.WeaponType);

        foreach (var sprite in Settings.GetIcons(weapon.WeaponFireTypes))
        {
            var fireTypeIcon = IconPrototype.Instantiate <Image>();
            _iconInstances.Add(fireTypeIcon.GetComponent <Prototype>());
            fireTypeIcon.sprite = sprite;
        }

        foreach (var sprite in Settings.GetIcons(weapon.WeaponModifiers))
        {
            var modifierIcon = IconPrototype.Instantiate <Image>();
            _iconInstances.Add(modifierIcon.GetComponent <Prototype>());
            modifierIcon.sprite = sprite;
        }
    }
示例#28
0
        private IList<WeaponItemData> ReadWeaponsData(BinaryReader r)
        {
            var a = new WeaponItemData[Data.WeaponsCount];

            for (int i = 0; i < Data.WeaponsCount; i++)
                a[i] = ParseWeaponData(r);

            return a;
        }
示例#29
0
        private WeaponItemData ParseWeaponData(BinaryReader r)
        {
            var w = new WeaponItemData();
            w.NextObjectID = r.ReadUInt16();

            ushort data = r.ReadUInt16();
            w.IsBroken = ((data >> 14) & oneBitMask) == 1;

            w.ChargeCount = (data >> 10) & fourBitsMask;

            w.IsPoisoned = ((data >> 9) & oneBitMask) == 1;
            w.IsCursed = ((data >> 8) & oneBitMask) == 1;
            w.IsImportant = ((data >> 7) & oneBitMask) == 1;

            w.ItemTypeIndex = data & sevenBitsMask;

            return w;
        }
示例#30
0
 public ItemData CreateWeapon(WeaponItemData weapon)
 {
     currentTile.GrabableItems.Add(weapon);
     return(weapon);
 }
示例#31
0
 public override ItemData CreateInstance()
 {
     WeaponItemData data = new WeaponItemData ();
     data.info = this;
     return data;
 }
    public static WeaponItemData RandomWeapon(SpriteManager spriteManager)
    {
        loadAdjvectives();

        string itemName = "";

        WeaponItemData weapon = ScriptableObject.CreateInstance <WeaponItemData>();

        //create guid
        weapon.DatabaseName = System.Guid.NewGuid().ToString();

        weapon.Rarity = (ItemRarity)Random.Range(0, 5);


        //decide what type of weapon to generate
        float randonValue = Random.value;

        if (randonValue <= .10f)
        {
            weapon.WeaponType = WeaponItemData.Type.eGUN;
        }
        else if (randonValue > .10f && randonValue <= .30f)
        {
            weapon.WeaponType = WeaponItemData.Type.eRANGE;
        }
        else
        {
            weapon.WeaponType = WeaponItemData.Type.eSWORD;
        }

        switch (weapon.WeaponType)
        {
        case WeaponItemData.Type.eSWORD:
            weapon.IsMelee    = true;
            weapon.IsMainHand = true;


            //decide if the sword should use strength or agilty (rapier)
            if (Random.value <= .75f)
            {
                weapon.StatType = WeaponItemData.StatTypes.eSTRENGTH;
            }
            else
            {
                weapon.StatType = WeaponItemData.StatTypes.eAGILTITY;
            }

            //calculate random damage on weapon type and stat type and rarity
            if (weapon.StatType == WeaponItemData.StatTypes.eSTRENGTH)
            {
                //decide if the weapon is a shortsword, longsword or a whip
                randonValue = Random.value;
                if (randonValue <= .33f)     // shortsword
                {
                    weapon.WeaponSubType  = WeaponItemData.SubType.eSHORTSWORD;
                    weapon.BaseDamage     = Random.Range(4, 7);
                    weapon.MinDamage      = Mathf.Max(3, Random.Range(weapon.BaseDamage - 4, weapon.BaseDamage - 1));
                    weapon.MaxDamage      = Random.Range(weapon.BaseDamage + 1, weapon.MaxDamage + 3);
                    weapon.VarianceDamage = Random.Range(2, 4);

                    itemName = "Penne";
                }
                else if (randonValue > .33f && randonValue <= .66f)     // longsword
                {
                    weapon.WeaponSubType  = WeaponItemData.SubType.eLONGSWORD;
                    weapon.BaseDamage     = Random.Range(6, 9);
                    weapon.MinDamage      = Mathf.Max(4, Random.Range(weapon.BaseDamage - 4, weapon.BaseDamage - 1));
                    weapon.MaxDamage      = Random.Range(weapon.BaseDamage + 1, weapon.MaxDamage + 3);
                    weapon.VarianceDamage = Random.Range(3, 5);

                    itemName = "Spaghetti";
                }
                else if (randonValue > .66f)     // whip
                {
                    weapon.WeaponSubType  = WeaponItemData.SubType.eWHIP;
                    weapon.BaseDamage     = Random.Range(3, 6);
                    weapon.MinDamage      = Mathf.Max(1, Random.Range(weapon.BaseDamage - 4, weapon.BaseDamage - 1));
                    weapon.MaxDamage      = Random.Range(weapon.BaseDamage + 1, weapon.MaxDamage + 3);
                    weapon.VarianceDamage = Random.Range(4, 7);

                    itemName = "Linguine";
                }
            }
            else if (weapon.StatType == WeaponItemData.StatTypes.eAGILTITY)
            {
                weapon.WeaponSubType  = WeaponItemData.SubType.eRAPIER;    // rapier
                weapon.BaseDamage     = Random.Range(3, 6);
                weapon.MinDamage      = Mathf.Max(2, Random.Range(weapon.BaseDamage - 4, weapon.BaseDamage - 1));
                weapon.MaxDamage      = Random.Range(weapon.BaseDamage + 1, weapon.MaxDamage + 3);
                weapon.VarianceDamage = Random.Range(1, 3);

                itemName = "Fedelini";
            }
            break;

        case WeaponItemData.Type.eRANGE:
            weapon.StatType = WeaponItemData.StatTypes.eAGILTITY;

            //decide if the weapon is a throwing star, bow
            randonValue = Random.value;
            if (randonValue <= .33f)     //throwing star
            {
                weapon.WeaponSubType  = WeaponItemData.SubType.eTHROWINGSTAR;
                weapon.BaseDamage     = Random.Range(2, 5);
                weapon.MinDamage      = Mathf.Max(2, Random.Range(weapon.BaseDamage - 4, weapon.BaseDamage - 1));
                weapon.MaxDamage      = Random.Range(weapon.BaseDamage + 1, weapon.MaxDamage + 3);
                weapon.VarianceDamage = Random.Range(1, 3);

                itemName = "Conchiglie";
            }
            else     // bow
            {
                weapon.WeaponSubType  = WeaponItemData.SubType.eBOW;
                weapon.BaseDamage     = Random.Range(3, 6);
                weapon.MinDamage      = Mathf.Max(2, Random.Range(weapon.BaseDamage - 4, weapon.BaseDamage - 1));
                weapon.MaxDamage      = Random.Range(weapon.BaseDamage + 1, weapon.MaxDamage + 3);
                weapon.VarianceDamage = Random.Range(2, 4);

                itemName = "Bucatini";
            }
            break;

        case WeaponItemData.Type.eGUN:
            weapon.StatType = WeaponItemData.StatTypes.eNONE;

            //decide if the weapon is a pistol, rifle
            randonValue = Random.value;
            if (randonValue <= .33f)     //rifle
            {
                weapon.WeaponSubType  = WeaponItemData.SubType.eRIFLE;
                weapon.BaseDamage     = Random.Range(8, 14);
                weapon.MinDamage      = weapon.BaseDamage;
                weapon.MaxDamage      = weapon.BaseDamage;
                weapon.VarianceDamage = 0;
                weapon.MissFire       = 10.0f;

                itemName = "Fusilli Rifle";
            }
            else     // pistol
            {
                weapon.WeaponSubType  = WeaponItemData.SubType.ePISTOL;
                weapon.BaseDamage     = Random.Range(4, 9);
                weapon.MinDamage      = weapon.BaseDamage;
                weapon.MaxDamage      = weapon.BaseDamage;
                weapon.VarianceDamage = 0;
                weapon.MissFire       = 5.0f;

                itemName = "Fusilli Pistol";
            }
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        string magicName = string.Empty;

        //random magic 30 change the item has magic
        if (Random.value <= .45f)
        {
            weapon.MagicalType     = (MagicType)Random.Range(1, 4);
            weapon.MagicalModifier = Random.Range(2, 5);

            switch (weapon.MagicalType)
            {
            case MagicType.eNONE:
                break;

            case MagicType.eTOMATO:
                magicName = "Tomato";
                break;

            case MagicType.eCHEESE:
                magicName = "Cheese";
                break;

            case MagicType.ePESTO:
                magicName = "Pesto";
                break;

            default:
                break;
            }
        }
        else
        {
            weapon.MagicalType = MagicType.eNONE;
        }

        //Random description
        weapon.Description = "TODO:: Add a random description";

        weapon.BaseMoneyValue = Random.Range(5, 30);

        weapon.PreviewSprite = spriteManager.GetRandomWeaponIcon(weapon.WeaponSubType);

        //select random name
        if (magicName != string.Empty)
        {
            weapon.Name = WeaponAdjectives[Random.Range(0, WeaponAdjectives.Count)] + " " + magicName + " " + itemName;
        }
        else
        {
            weapon.Name = WeaponAdjectives[Random.Range(0, WeaponAdjectives.Count)] + " " + itemName;
        }


        return(weapon);
    }
示例#33
0
 private void Start()
 {
     weaponData = new WeaponItemData(id, interactionName, GetWeaponPrefabPath(), clipAmmo, maxClipAmmo, inventoryAmmo, maxTotalAmmo);
 }