コード例 #1
0
ファイル: ItemGroup.cs プロジェクト: PenpenLi/Hifior
 public bool AddWeapon(WeaponItem Item, UnityAction AfterAddItem) //获得装备
 {
     if (Weapons.Count == MAX_WEAPON_COUNT)                       //装备已满返回false
     {
         Debug.Log("物品已达上限");
         weapons.Add(Item);
         RPG.UI.SendItemToWarehouse Sender = UIController.Instance.GetUI <RPG.UI.SendItemToWarehouse>();
         Sender.Show(weapons);
         return(false);
     }
     else
     {
         if (_currentEquipItemIndex < 0)   //没有装备武器,判断武器是否可以装备,如果可以装备到第一格,否则直接添加到末尾
         {
             if (IsWeaponEnabled(Item.ID)) //可用的武器
             {
                 Weapons.Insert(0, Item);
                 EquipWeapon(0);
             }
             else
             {
                 Weapons.Add(Item);
             }
         }
         else
         {
             Weapons.Add(Item);
         }
         return(true);
     }
 }
コード例 #2
0
ファイル: CharStatePanel.cs プロジェクト: PenpenLi/Hifior
 public void Show(RPGCharacter ch)
 {
     if (ch != null)
     {
         var logic = ch.Logic;
         charIcon.sprite = logic.GetPortrait();
         charName.text   = logic.GetName();
         hp.text         = logic.GetCurrentHP() + "/" + ch.Logic.GetMaxHP();
         lv.text         = ch.Logic.GetLevel().ToString();
         WeaponItem item = ch.Logic.Info.Items.GetEquipWeapon();
         if (item != null)
         {
             weaponIcon.gameObject.SetActive(true);
             weaponName.text   = item.GetDefinition().CommonProperty.Name;
             weaponIcon.sprite = item.GetDefinition().Icon;
         }
         else
         {
             weaponIcon.gameObject.SetActive(false);
             weaponName.text   = null;
             weaponIcon.sprite = null;
         }
         gameObject.transform.position = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z);
         gameObject.SetActive(true);
     }
     else
     {
         gameObject.SetActive(false);
     }
 }
コード例 #3
0
 /// <summary>
 /// SetItemData
 /// used by Equiplot.Equip
 /// </summary>
 /// <param name="equipedItem"></param>
 public void SetItemData(Item equipedItem)
 {
     if (equipedItem.ItemType == ItemType.Weapon)
     {
         if (equipedItem is WeaponItem)
         {
             WeaponItem weapon = (WeaponItem)equipedItem;
             equipedWeapon = weapon;
         }
     }
     else if (equipedItem.ItemType == ItemType.Head)
     {
         //Debug.Log(equipedItem.ItemType + );
         Head_Item headItem = (Head_Item)equipedItem;
         equipedHead = headItem;
     }
     else if (equipedItem.ItemType == ItemType.Armour)
     {
         Armour_Item armour = (Armour_Item)equipedItem;
         equipedArmour = armour;
     }
     else if (equipedItem.ItemType == ItemType.Trinket)
     {
         Trinket_Item trinket = (Trinket_Item)equipedItem;
         equipedTrinket = trinket;
     }
 }
コード例 #4
0
    /* Build the item info panel (right?) of the screen */
    void BuildItemInfoPanel()
    {
        Item item = HangarManager._instance.currentlySelectedMechItem;



        if (item != null)
        {
            if (item is WeaponItem)
            {
                WeaponItem weapon = item as WeaponItem;

                itemPnlName.text = weapon.name;

                itemPnlHealthVal.text = weapon.bonusIntegrity.ToString();

                itemPnlDamageVal.text = weapon.damage.ToString();
            }
            else if (item is Accessory)
            {
                Accessory upgrade = item as Accessory;
            }
        }


        //itemPnlIcon.sprite = item.icon;
    }
コード例 #5
0
    /*
     * Remove an item from the inventory by checking if the item's ID equals an item's ID in the database.
     * If the item is a weapon, then unequip it.
     * If the item is a note, destroy it, else if it's not, drop it on the ground.
     * Also, player a random sound
     */
    public void Remove(Item item)
    {
        if (item != null)
        {
            foreach (GameObject i in GameManagerSingleton.instance.GetComponent <ItemDatabase>().items)
            {
                if (item.itemID.Equals(i.GetComponent <Item>().itemID))
                {
                    // If the weapon item id is the same as the equipped weapon, unequip first
                    if (GetComponentInChildren <PlayerWeapon>().equippedWeapon != null)
                    {
                        if (item.itemID == GetComponentInChildren <PlayerWeapon>().equippedWeapon.itemID)
                        {
                            WeaponItem weapon = (WeaponItem)item;
                            GetComponentInChildren <PlayerWeapon>().UnequipWeapon(weapon);
                        }
                    }

                    if (item is NoteItem)
                    {
                        GameManagerSingleton.instance.GetComponent <NoteHandler>().isNotePanelOpen = false;
                    }
                    else
                    {
                        Instantiate(i, gameObject.transform.position, Quaternion.identity);
                    }

                    // Play random drop sound
                    soundManager.PlayRandomOneShot(soundManager.dropItemSounds);
                }
            }
        }
    }
コード例 #6
0
    public override void AddItem(Item item)
    {
        WeaponItem wItem = (WeaponItem)item;

        switch (wItem.WeaponCategory)
        {
        case WeaponCategory.Strzeleckie:
            _w1.AddItem(item);
            break;

        case WeaponCategory.Miecz:
            _w2.AddItem(item);
            break;

        case WeaponCategory.Tarcza:
            _w3.AddItem(item);
            break;

        case WeaponCategory.Topór:
            _w4.AddItem(item);
            break;

        case WeaponCategory.Włócznia:
            _w5.AddItem(item);
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
コード例 #7
0
    public bool ChangeWeapon(WeaponItem weaponItem)
    {
        var newWeapon = weaponItem.weapon;

        if (weapon != newWeapon)
        {
            if (currentWeaponItem)
            {
                currentWeaponItem.itemSlot.background.color = normalBackground;
            }

            weaponItem.itemSlot.background.color = equipedBackground;

            weapon            = newWeapon;
            currentWeaponItem = weaponItem;

            GameManager.instance.player.OnChangeWeapon(newWeapon);
            GameManager.instance.attackButton.OnChangeWeapon(newWeapon);
            return(true);
        }
        else
        {
            currentWeaponItem.itemSlot.background.color = normalBackground;
            currentWeaponItem = null;

            weapon = defaultWeapon;
            GameManager.instance.player.OnChangeWeapon(defaultWeapon);
            GameManager.instance.attackButton.OnChangeWeapon(defaultWeapon);
            return(false);
        }
    }
コード例 #8
0
        private void UnEquipItem(MessageTemplate template, NetIncomingMessage message)
        {
            int index = -1;

            try
            {
                int.TryParse(template.JsonMessage, out index);
            }
            catch
            { }

            if (index != -1)
            {
                CharacterPlayer character = MapContainer.FindCharacterByID(message.SenderConnection.RemoteUniqueIdentifier);
                WeaponItem      newItem   = character.GetInventory().ElementAt(index);
                if (newItem != null)
                {
                    int        type        = (int)newItem.GetEqupmentType();
                    WeaponItem currentItem = character.Equipment[type];

                    if (currentItem == null)
                    {
                        character.Inventory[index] = null;
                    }
                    else
                    {
                        character.Inventory[index] = currentItem;
                    }

                    character.Equipment[type] = newItem;
                }
            }
        }
コード例 #9
0
 void ConstructItemDatabase()
 {
     for (int i = 0; i < itemData.Count; i++)
     {
         dataBase.Add(new Item((int)itemData[i]["id"], itemData[i]["title"].ToString(), itemData[i]["type"].ToString(),
                               (int)itemData[i]["value"], itemData[i]["description"].ToString(), (int)itemData[i]["rarity"],
                               (bool)itemData[i]["stackable"], itemData[i]["slug"].ToString()));
         if (dataBase[i].Type == "Weapon")
         {
             WeaponItem newWeapon = new WeaponItem(dataBase[i], itemData[i]["components"]["1"].ToString(),
                                                   itemData[i]["components"]["2"].ToString(), itemData[i]["components"]["3"].ToString(),
                                                   (int)itemData[i]["stats"]["moveSpeed"], (int)itemData[i]["stats"]["damage"], (int)itemData[i]["stats"]["range"],
                                                   (bool)itemData[i]["droppable"]);
             dataBase[i] = newWeapon;
         }
         else if (dataBase[i].Type == "Component")
         {
             ComponentItem newComponent = new ComponentItem(dataBase[i]);
             for (int j = 0; j < itemData[i]["parts"].Count; j++)
             {
                 ComponentData newComponentData = new ComponentData(dataBase[i].Slug, itemData[i]["parts"][j].ToString());
                 newComponent.componentTypes.Add(newComponentData);
             }
             dataBase[i] = newComponent;
         }
     }
 }
コード例 #10
0
 public void LoadWeapon(WeaponItem weaponItem)
 {
     //UnloadWeaponAndDestroy();
     if (weaponItem == null)
     {
         UnloadWeapon();
         return;
     }
     //GameObject model = Instantiate(weaponItem.modelPrefab) as GameObject;
     if (model != null)
     {
         if (parentOverride != null)
         {
             //parentOverride.localPosition += offset;
             model.transform.parent = parentOverride;
             //model.transform.localPosition = new Vector3(0.820865f, -0.41220f, -0.959670f);
             //model.transform.localRotation = new Quaternion(-158.692f, -10.91f, -4.164978f);
         }
         else
         {
             model.transform.parent = transform;
         }
         //model.transform.localPosition = Vector3.zero;
         //model.transform.localRotation = Quaternion.identity;
     }
     currentWeaponModel = model;
 }
コード例 #11
0
ファイル: QuickSlotsUI.cs プロジェクト: skyteks/Crawler
    public void UpdateWeaponQuickslotsUI(WeaponHolderSlot.SlotTypes slotType, WeaponItem weapon)
    {
        switch (slotType)
        {
        case WeaponHolderSlot.SlotTypes.leftHand:
            if (weapon.icon != null)
            {
                leftWeaponIcon.sprite  = weapon.icon;
                leftWeaponIcon.enabled = true;
            }
            else
            {
                leftWeaponIcon.sprite  = null;
                leftWeaponIcon.enabled = false;
            }
            break;

        case WeaponHolderSlot.SlotTypes.rightHand:
            if (weapon.icon != null)
            {
                rightWeaponIcon.sprite  = weapon.icon;
                rightWeaponIcon.enabled = true;
            }
            else
            {
                rightWeaponIcon.sprite  = null;
                rightWeaponIcon.enabled = false;
            }
            break;
        }
    }
コード例 #12
0
        private bool CheckIfNeedToUpdate(CharacterPlayer current, CharacterPlayer recieved)
        {
            for (int i = 0; i < current.GetInventory().Length - 1; i++)
            {
                WeaponItem existing = current.GetInventory()[i];
                WeaponItem newItem  = recieved.GetInventory()[i];

                if ((existing != null && newItem == null) || (existing == null && newItem != null))
                {
                    return(true);
                }
                if (existing != null & newItem != null && !existing.Name.Equals(newItem.Name))
                {
                    return(true);
                }
            }
            for (int i = 0; i < current.Equipment.Length - 1; i++)
            {
                EqupmentBase existing = current.GetEquipment()[i];
                EqupmentBase newItem  = recieved.GetEquipment()[i];

                if ((existing != null && newItem == null) || (existing == null && newItem != null))
                {
                    return(true);
                }
                if (existing != null & newItem != null && !existing.Name.Equals(newItem.Name))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #13
0
    public void ClearSlot()
    {
        item = null;

        icon.enabled = false;
        icon.sprite  = null;
    }
コード例 #14
0
 public virtual void AddItem(WeaponItem newItem)
 {
     item         = newItem;
     icon.sprite  = item.icon;
     icon.enabled = true;
     gameObject.SetActive(true);
 }
コード例 #15
0
 public virtual void ClearSlot()
 {
     item         = null;
     icon.sprite  = null;
     icon.enabled = false;
     gameObject.SetActive(false);
 }
コード例 #16
0
        private void CreateNewData()
        {
            AssetDatabase.CreateAsset(_weaponItem, $"Assets/Scriptable Objects/Weapons/" + _name + ".asset");
            AssetDatabase.SaveAssets();

            _weaponItem = CreateInstance <WeaponItem>();
        }
コード例 #17
0
    private void Awake()
    {
        if (photonView.IsMine != true)
        {
            return;
        }

        foreach (Transform t in this.transform.Find("Model"))
        {
            if (t.name == "Firing")
            {
                Weapons.Add(t);
            }
        }

        Cube   = this.GetComponent <PlayerCube>();
        Weapon = Cube.weapon;
        foreach (FiringPoint Point in Weapon.Points)
        {
            NextTimesToFire.Add(0);
        }
        foreach (FiringPoint Point in Weapon.Points)
        {
            SplitFiringSelection.Add(0);
        }
    }
コード例 #18
0
ファイル: TidyUpPanel.cs プロジェクト: PenpenLi/Hifior
        public void exchangeItem(int char_Index0, int item_Index0, int char_Index1, int item_Index1)
        {
            RPGCharacter ch0   = _gameCharList[char_Index0];
            RPGCharacter ch1   = _gameCharList[char_Index1];
            WeaponItem   item0 = ch0.Logic.Info.Items.GetWeaponByIndex(item_Index0);
            WeaponItem   item1 = ch1.Logic.Info.Items.GetWeaponByIndex(item_Index1);

            if (item0 == null)
            {
                return;
            }
            if (item1 == null)
            {
                ch0.Logic.Info.Items.RemoveWeaponByIndex(item_Index0);
                ch1.Logic.Info.Items.AddWeapon(item0, null);
            }
            else
            {
                ch0.Logic.Info.Items.RemoveWeaponByIndex(item_Index0);
                ch1.Logic.Info.Items.RemoveWeaponByIndex(item_Index1);
                ch0.Logic.Info.Items.AddWeapon(item1, item_Index0);
                ch1.Logic.Info.Items.AddWeapon(item0, item_Index1);
            }
            ipBottom.Init(_gameCharList[selectedCharIndex].Logic);
            ipTop.Init(_gameCharList[exchangeCharIndex].Logic);
        }
コード例 #19
0
ファイル: UIManager.cs プロジェクト: PenpenLi/Hifior
    private void BattleAction_SelectWeapon(WeaponItem item)
    {
        battleManager.ChangeState(BattleManager.EBattleState.SelectTarget);
        if (item == null)
        {
            Debug.LogError("选择的武器是null");
        }
        else
        {
            Debug.Log(item.ToString());
        }
        BattleActionMenu.Hide();
        BattleSelectWeaponMenu.Hide();
        CharacterLogic logic = battleManager.CurrentCharacterLogic;

        logic.Info.Items.EquipWeapon(item);
        //从选择的武器确定
        var rangeType = item.GetDefinition().RangeType;
        EnumSelectEffectRangeType selRangeType = rangeType.SelectType;
        Vector2Int selRange = rangeType.SelectRange;
        EnumSelectEffectRangeType effRangeType = rangeType.EffectType;
        Vector2Int effRange = rangeType.EffectRange;

        logic.BattleInfo.SetSelectTargetParam(CharacterBattleInfo.EBattleActionType.Attack, logic.GetTileCoord(), selRangeType, selRange, effRangeType, effRange);
        battleManager.ShowSelectTargetRangeAction(logic);
        MenuUndoAction.Push(UndoSelectWeapon);
    }
コード例 #20
0
    public void AddItem(WeaponItem newItem)
    {
        item = newItem;

        //icon.sprite = newItem.icon;
        icon.enabled = true;
    }
コード例 #21
0
        public void LoadData(Data data)
        {
            WeaponItem item = ((Data <WeaponItem>)data).value;

            weapon = Instantiate(item.itemRef).GetComponent <Weapon>();
            SetWeapon();
        }
コード例 #22
0
    private void BuildClassWeapon(WeaponItem wItem, MechManager mechManager, SectionManager sectionManager, int secIndex, int subIndex, int classIndex)
    {
        if (wItem == null)
        {
            return;
        }

        /* Create the Wep */
        GameObject newWeapon = Object.Instantiate(wItem.prefab);

        newWeapon.transform.parent           = sectionManager.GetSectionLinksByIndex(secIndex, classIndex)[subIndex];
        newWeapon.transform.localPosition    = Vector3.zero;
        newWeapon.transform.localEulerAngles = Vector3.zero;

        /* Add the weapons to the MechManager on the mech encapsulating object */
        mechManager.GetWeaponObjByIndex(secIndex).Add(newWeapon);

        /* Add the ref to the parent section to the weapon's script */
        newWeapon.GetComponent <WeaponExecutable>().sectionParent = sectionManager.GetSectionByIndex(secIndex);
        newWeapon.GetComponent <WeaponExecutable>().mechManager   = mechManager;

        // Move into modify???
        /* Create an executable for the weapon and add it to MechManager ref */
        mechManager.GetExecutableByIndex(secIndex).Add(newWeapon.GetComponent <WeaponExecutable>());
    }
コード例 #23
0
    public void ChangeLeftWeapon()
    {
        currentLeftWeaponIndex = currentLeftWeaponIndex + 1;

        if (currentLeftWeaponIndex == 0 && weaponInLeftHandSlots[0] != null)
        {
            leftWeapon = weaponInLeftHandSlots[currentLeftWeaponIndex];
            weaponSlotManager.LoadWeaponOnSlot(weaponInLeftHandSlots[currentLeftWeaponIndex], true);
        }
        else if (currentLeftWeaponIndex == 0 && weaponInLeftHandSlots[0] == null)
        {
            currentLeftWeaponIndex = currentLeftWeaponIndex + 1;
        }
        else if (currentLeftWeaponIndex == 1 && weaponInLeftHandSlots[1] != null)
        {
            leftWeapon = weaponInLeftHandSlots[currentLeftWeaponIndex];
            weaponSlotManager.LoadWeaponOnSlot(weaponInLeftHandSlots[currentLeftWeaponIndex], true);
        }
        else if (currentLeftWeaponIndex == 1 && weaponInLeftHandSlots[1] == null)
        {
            currentLeftWeaponIndex = currentLeftWeaponIndex + 1;
        }

        if (currentLeftWeaponIndex > weaponInLeftHandSlots.Length - 1)
        {
            currentLeftWeaponIndex = 0;
            leftWeapon             = weaponInLeftHandSlots[currentLeftWeaponIndex];
            weaponSlotManager.LoadWeaponOnSlot(weaponInLeftHandSlots[currentLeftWeaponIndex], true);
        }
        isFireWeaponEquiped = false;
    }
コード例 #24
0
    public void ChangeRightWeapon()
    {
        currentRightWeaponIndex = currentRightWeaponIndex + 1;

        if (currentRightWeaponIndex == 0 && weaponInRightHandSlots[0] != null)
        {
            rightWeapon = weaponInRightHandSlots[currentRightWeaponIndex];
            weaponSlotManager.LoadWeaponOnSlot(weaponInRightHandSlots[currentRightWeaponIndex], false);
        }
        else if (currentRightWeaponIndex == 0 && weaponInRightHandSlots[0] == null)
        {
            currentRightWeaponIndex = currentRightWeaponIndex + 1;
        }
        else if (currentRightWeaponIndex == 1 && weaponInRightHandSlots[1] != null)
        {
            rightWeapon = weaponInRightHandSlots[currentRightWeaponIndex];
            weaponSlotManager.LoadWeaponOnSlot(weaponInRightHandSlots[currentRightWeaponIndex], false);
        }
        else if (currentRightWeaponIndex == 1 && weaponInRightHandSlots[1] == null)
        {
            currentRightWeaponIndex = currentRightWeaponIndex + 1;
        }

        if (currentRightWeaponIndex > weaponInRightHandSlots.Length - 1)
        {
            currentRightWeaponIndex = 0;
            rightWeapon             = weaponInRightHandSlots[currentRightWeaponIndex];
            weaponSlotManager.LoadWeaponOnSlot(weaponInRightHandSlots[currentRightWeaponIndex], false);
        }

        isFireWeaponEquiped = false;
        _gunSheet.DisableGunSheet();
    }
コード例 #25
0
    void ConsumeRequiredWeaponsAmmo(Entity caster)
    {
        // requires no weapon category?
        // then we can't find weapon and check ammo. just allow it.
        // (monsters have no weapon requirements and don't even have an
        //  equipment component)
        if (string.IsNullOrWhiteSpace(requiredWeaponCategory))
        {
            return;
        }

        int weaponIndex = caster.equipment.GetEquippedWeaponIndex();

        if (weaponIndex != -1)
        {
            // no ammo required, or has that ammo equipped?
            WeaponItem itemData = (WeaponItem)caster.equipment.slots[weaponIndex].item.data;
            if (itemData.requiredAmmo != null)
            {
                int ammoIndex = caster.equipment.GetItemIndexByName(itemData.requiredAmmo.name);
                if (ammoIndex != 0)
                {
                    // reduce it
                    ItemSlot slot = caster.equipment.slots[ammoIndex];
                    --slot.amount;
                    caster.equipment.slots[ammoIndex] = slot;
                }
            }
        }
    }
コード例 #26
0
        private void SetupDualWieldItem(WeaponItemRuntime item)
        {
            //Place Weapon In Left Hand
            item.transform.SetParent(playerLeftHand);
            item.transform.localPosition = Vector3.zero;
            item.transform.localRotation = Quaternion.identity;

            //Get Ranged Component To Setup Left Hand Pivot
            WeaponItemRuntimeRanged leftHandRangedComponent = item as WeaponItemRuntimeRanged;

            leftHandRangedComponent.pivot.localPosition = leftHandRangedComponent.rangedData.leftHandPivotPosition;
            leftHandRangedComponent.pivot.localRotation = Quaternion.Euler(leftHandRangedComponent.rangedData.leftHandPivotRotation);
            leftHandRangedComponent.PickupWeaponPlayer();

            WeaponItemRuntimeRanged rightHandRangedComponent = inventoryWeapons[currentWeaponInList] as WeaponItemRuntimeRanged;


            //Add Dual Wield Component To It
            WeaponItemRuntimeRangedDualWielded dualWieldComponent = item.gameObject.AddComponent <WeaponItemRuntimeRangedDualWielded>();
            WeaponItemRanged_DualWielded       dualData           = leftHandRangedComponent.rangedData.dualWieldParentData;

            dualWieldComponent.SetupDualWield(dualData, leftHandRangedComponent, rightHandRangedComponent);

            //Swap Inventory To The Dual Wield Component
            inventoryWeapons[currentWeaponInList] = dualWieldComponent;
            currentWeaponItem        = dualData;
            currentWeaponItemRuntime = dualWieldComponent;
            weaponController.OnWeaponEquipped(currentWeaponItemRuntime);
        }
コード例 #27
0
    public bool EquipWeapon(ItemInfo toEquip)
    {
        if (toEquip == null || !toEquip.item)
        {
            return(false);
        }
        if (!toEquip.item.IsWeapon)
        {
            return(false);
        }
        WeaponItem weapon = toEquip.item as WeaponItem;

        ATK += weapon.CutATK + weapon.Powerup.ATK_Add +
               (toEquip.gemstone1 ? toEquip.gemstone1.Powerup.ATK_Add : 0) + (toEquip.gemstone2 ? toEquip.gemstone2.Powerup.ATK_Add : 0);
        DEF += weapon.DEF + weapon.Powerup.DEF_Add +
               (toEquip.gemstone1 ? toEquip.gemstone1.Powerup.DEF_Add : 0) + (toEquip.gemstone2 ? toEquip.gemstone2.Powerup.DEF_Add : 0);
        Hit += weapon.Hit + weapon.Powerup.Hit_Add +
               (toEquip.gemstone1 ? toEquip.gemstone1.Powerup.Hit_Add : 0) + (toEquip.gemstone2 ? toEquip.gemstone2.Powerup.Hit_Add : 0);

        HP.Max += (toEquip.gemstone1 ? toEquip.gemstone1.Powerup.HP_Add : 0) + (toEquip.gemstone2 ? toEquip.gemstone2.Powerup.HP_Add : 0);
        MP.Max += (toEquip.gemstone1 ? toEquip.gemstone1.Powerup.MP_Add : 0) + (toEquip.gemstone2 ? toEquip.gemstone2.Powerup.MP_Add : 0);
        Dodge  += (toEquip.gemstone1 ? toEquip.gemstone1.Powerup.Dodge_Add : 0) + (toEquip.gemstone2 ? toEquip.gemstone2.Powerup.Dodge_Add : 0);

        if (weapon.IsPrimary)
        {
            primaryWeapon = toEquip;
        }
        else
        {
            secondaryWeapon = toEquip;
        }

        return(true);
    }
コード例 #28
0
    public void CreateAnimation(Player player, GameObject animationObject, WeaponItem weapon, Transform targetTransform, float animationSpeed)
    {
        //Set the animation's sprite
        //TODO make or find a sprite for fisticuffs attacks
        Sprite         weaponSprite            = weapon == null ? player.sprite : weapon.GroundSprite;
        SpriteRenderer animationSpriteRenderer = animationObject.GetComponent <SpriteRenderer>();

        animationSpriteRenderer.sprite = weaponSprite;

        //Calculate relative location of the enemy
        Vector3 targetLoc = targetTransform.position - animationObject.transform.position;

        Animation attackAnimation = animationObject.GetComponent <Animation>();

        AnimationClip attackClip = new AnimationClip();

        attackClip.legacy = true;

        AnimationEvent showSprite = new AnimationEvent();

        showSprite.functionName             = "EnableSprite";
        showSprite.objectReferenceParameter = animationSpriteRenderer;
        showSprite.time = 0.0f;

        AnimationEvent hideSprite = new AnimationEvent();

        hideSprite.functionName             = "DisableSprite";
        hideSprite.objectReferenceParameter = animationSpriteRenderer;
        hideSprite.time = 2.0f;

        attackClip.AddEvent(showSprite);
        attackClip.AddEvent(hideSprite);

        // create curves to move the sprite
        //Create shared initial and end frames
        Keyframe initFrame = new Keyframe(0.0f, 0.0f);
        Keyframe endFrame  = new Keyframe(2.0f, 0.0f);

        //Create keyframe array for x position transformation
        Keyframe[]     xKeys  = new Keyframe[] { initFrame, new Keyframe(1.0f, targetLoc.x), endFrame };
        AnimationCurve xCurve = new AnimationCurve(xKeys);

        //Create keyframe array for y position transformation
        Keyframe[]     yKeys  = new Keyframe[] { initFrame, new Keyframe(1.0f, targetLoc.y), endFrame };
        AnimationCurve yCurve = new AnimationCurve(yKeys);



        attackClip.SetCurve("", typeof(Transform), "localPosition.x", xCurve);
        attackClip.SetCurve("", typeof(Transform), "localPosition.y", yCurve);

        attackAnimation.AddClip(attackClip, "attack");

        attackAnimation["attack"].speed = animationSpeed;

        Debug.Log("animation speed: " + animationSpeed.ToString());

        //attackAnimation.Play("attack");
        Vector3 endLoc = animationObject.transform.position;
    }
コード例 #29
0
 public void ClearItem()
 {
     weapon       = null;
     icon.sprite  = null;
     icon.enabled = false;
     gameObject.SetActive(false);
 }
コード例 #30
0
    public void SetNewWeapon(WeaponItem weapon)
    {
        if (weapon.type == WeaponType.Dual || weapon.type == WeaponType.Single)
        {
            DisableAll(rHipWeapons);
            DisableAll(lHipWeapons);

            weapon.rHip.SetActive(true);

            if (weapon.type == WeaponType.Dual)
            {
                weapon.lHip.SetActive(true);
            }
        }
        else
        {
            DisableAll(auxiliaryWeapons);
            weapon.auxiliary.SetActive(true);
        }

        // Disable old weapon hand items
        DisableWeaponHands();

        currentWeapon = weapon;
    }
コード例 #31
0
ファイル: Shooting.cs プロジェクト: denjin/Castles
 public static int GetTargetModifier(Unit target, WeaponItem weapon)
 {
     int modifier = 0;
     if (target.running) {
         modifier -= 1;
     }
     Debug.Log("target modifier = " + modifier);
     return modifier;
 }
コード例 #32
0
ファイル: Shooting.cs プロジェクト: denjin/Castles
    public static int GetShooterModifier(Unit shooter, WeaponItem weapon, int range)
    {
        int modifier = 0;
        if (range <= weapon.shortRange) {
            modifier += weapon.shortModifier;
        } else if (range > weapon.shortRange && range <= weapon.longRange) {
            modifier += weapon.longModifier;
        }
        Debug.Log("shooter modifier = " + modifier);

        return modifier;
    }
コード例 #33
0
ファイル: Shooting.cs プロジェクト: denjin/Castles
 public static int GetRequiredWoundRoll(Unit target, WeaponItem weapon, int roll)
 {
     int requiredRoll;
     int t = target.toughness;
     int s = weapon.strength;
     requiredRoll = t - s + 4;
     if (requiredRoll > 7) {
         requiredRoll = 100;
     } else if (requiredRoll == 7) {
         requiredRoll = 6;
     }
     return requiredRoll;
 }
コード例 #34
0
ファイル: Character.cs プロジェクト: MorganMoon/DungeonGame
 //Sets current WeaponItem 'weapon'
 public void SetWeapon(WeaponItem weapon)
 {
     this.weapon = weapon;
 }
コード例 #35
0
ファイル: WeaponScript.cs プロジェクト: adriwankenobi/space
 void Awake()
 {
     item = WeaponItem.create(itemType);
 }
コード例 #36
0
ファイル: Creature.cs プロジェクト: FlygonC/BattelingGameRepo
 public void EquipWeapon(WeaponItem a_weapon)
 {
     _EquipedWeapon = a_weapon;
     /*if (_EquipedWeapon != null)//Stat setting
     {
         _AttackDamage = _EquipedWeapon.attackDamage;
         _AttackSpeed = _EquipedWeapon.attackSpeed;
         _AttackRange = _EquipedWeapon.range;
         //_Weight.flatBonus = _EquipedWeapon.weight;
     }*/
 }
コード例 #37
0
ファイル: Character.cs プロジェクト: plmng/SoftUni_OOP_HWs
 public void EquipWeapon(WeaponItem i)
 {
     if (i.EquipedState)
     {
         this.Aggression -= i.AggressionValue;
         i.EquipedState = false;
     }
     else
     {
         this.Aggression += i.AggressionValue;
         i.EquipedState = true;
     }
 }
コード例 #38
0
ファイル: Weapon.cs プロジェクト: yantian001/2DShooting
    public void Awake()
    {

        //Debug.Log("wepon init");
        weaponItem = WeaponManager.Instance.GetWeaponItemById(ID);
        if (weaponItem == null)
        {
            Debug.LogError("Miss weapon info.");
            return;
        }

        WeaponProperty wp = weaponItem.GetCurrentProperty();
        attack = wp.Power;
        shootInterval = 1f / wp.FireRate;
        this.scoreBonus = wp.ScoreBonus;
        curBulltCount = BulletCount = wp.BulletCount;

        magSize = wp.ClipSize;

    }
コード例 #39
0
 public void spawnWeapon(WeaponItem weapon, Point spawnTile, int spawnType)
 {
     weapon.onSpawn(spawnTile, spawnType);
 }