Beispiel #1
0
    private void PositiveDelegate()
    {
        InventoryItem tmpItem = _itemType == InventoryItemType.Weapon ? _character.Weapons[_selectedItem] : (InventoryItem)_character.Skills[_selectedItem];

        if (_itemType == InventoryItemType.Weapon)
        {
            var weapon            = (Weapon)_mainItem;
            var notSelectedWeapon = _selectedItem == 0 ? 1 : 0;
            //GreatSword check
            if ((weapon.Type == WeaponType.GreatSword && !WeaponsData.IsSmallWeapon(_character.Weapons[notSelectedWeapon].Type)) ||
                (_character.Weapons[notSelectedWeapon].Type == WeaponType.GreatSword && !WeaponsData.IsSmallWeapon(weapon.Type)))
            {
                _instantiator.NewSnack("Great Swords can only be equipped with small weapons.");
                NegativeDelegate();
                return;
            }
            _character.Weapons[_selectedItem] = weapon;
            DisplayItem(_character.Weapons[_selectedItem]);
        }
        else
        {
            var skill = (Skill)_mainItem;
            if (skill.Type == SkillType.Racial && _character.Race != skill.Race)
            {
                _instantiator.NewSnack("You do not have the proper race to use this skill");
                NegativeDelegate();
                return;
            }
            _character.Skills[_selectedItem] = skill;
            DisplayItem(_character.Skills[_selectedItem]);
        }
        _character.Inventory[_mainItemId] = tmpItem;
        DisplayItem(_character.Inventory[_mainItemId], true);
        _positiveButton.GetComponent <BoxCollider2D>().enabled = false;
        Invoke(nameof(AfterSwitch), 0.5f);
        _containersPositions = new List <Vector3>();
        if (_itemType == InventoryItemType.Weapon)
        {
            _containersPositions.Add(_weaponContainers[0].transform.position);
            _containersPositions.Add(_weaponContainers[1].transform.position);
            _weaponContainers[0].transform.position = _containersPositions[1];
            _weaponContainers[1].transform.position = _containersPositions[0];
        }
        else
        {
            _containersPositions.Add(_skillContainers[0].transform.position);
            _containersPositions.Add(_skillContainers[1].transform.position);
            _skillContainers[0].transform.position = _containersPositions[1];
            _skillContainers[1].transform.position = _containersPositions[0];
        }
        _isSwitching = true;
    }
Beispiel #2
0
 private static void HandleGreatSword(Character tmpChar)
 {
     if (tmpChar.Weapons[0].Type == WeaponType.GreatSword && !WeaponsData.IsSmallWeapon(tmpChar.Weapons[1].Type))
     {
         if (tmpChar.Race == CharacterRace.Human || tmpChar.Race == CharacterRace.Dwarf)
         {
             tmpChar.Weapons[1] = null;
             tmpChar.Weapons[1] = WeaponsData.GetWeaponFromType(WeaponsData.GetRandomSmallWeaponType(), isBase: true);
         }
         else
         {
             tmpChar.Weapons[1] = null;
             tmpChar.Weapons[1] = WeaponsData.GetWeaponFromType(tmpChar.FavWeapons[1], isBase: true);
         }
     }
     else if (tmpChar.Weapons[1].Type == WeaponType.GreatSword)
     {
         tmpChar.Weapons[1] = null;
         tmpChar.Weapons[1] = WeaponsData.GetWeaponFromType(WeaponsData.GetRandomSmallWeaponType(), canBeAnythingAndGreatSword: false);
     }
 }