コード例 #1
0
 public XElement ToXML()
 {
     return(new XElement("Equipment",
                         new XElement("OccupiesSlots", from a in OccupiesSlots select a.ToXML()),
                         new XElement("CoversSlots", from a in CoversSlots select a.ToXML()),
                         new XElement("OnEquip", OnEquip.ToXML()),
                         new XElement("OnUnequip", OnUnequip.ToXML()),
                         new XElement("OnMove", OnMove.ToXML())));
 }
コード例 #2
0
ファイル: Equipment.cs プロジェクト: corymaklin/rpg
        public void Equip(InventoryItem inventoryItem)
        {
            string equipmentType = inventoryItem.definition.GetStaticProperty("equipmentType").AsString();

            if (items.IsSlotSet(equipmentType))
            {
                UnEquip(items.Get(equipmentType));
            }

            items.Set(equipmentType, inventoryItem);
            OnEquip?.Invoke(inventoryItem);
        }
コード例 #3
0
        public void EquipItem(NPCSlots slot, ItemInst item)
        {
            if (item.BaseInst.Slot == (int)slot)
            {
                return;
            }


            BaseInst.EquipItem((int)slot, item.BaseInst);


            OnEquip?.Invoke(item);
        }
コード例 #4
0
        public void EquipItem(NPCSlots slot, ItemInst item)
        {
            if (item.BaseInst.Slot == (int)slot)
            {
                return;
            }

            pBeforeEquip(slot, item);
            this.BaseInst.EquipItem((int)slot, item.BaseInst);
            pAfterEquip(slot, item);

            OnEquip?.Invoke(item);
        }
コード例 #5
0
    public void Equip(GameObject prefab)
    {
        GameObject clone = Instantiate(prefab);

        clone.name = clone.name.Replace("(Clone)", string.Empty);
        clone.transform.SetParent(transform);
        EquipmentData equipmentData = clone.GetComponent <EquipmentData>();

        if (equipmentData == null)
        {
            Destroy(clone);
            throw new Exception("Invalid object");
        }

        //Unequip old
        Unequip(equipmentData.Slots);

        //Equip
        if (Application.isPlaying)
        {
            Destroy(clone.transform.GetChild(0).gameObject);
        }
        else
        {
            DestroyImmediate(clone.transform.GetChild(0).gameObject);
        }

        List <SkinnedMeshRenderer> childrenRenderers = new List <SkinnedMeshRenderer>(clone.GetComponentsInChildren <SkinnedMeshRenderer>());

        foreach (SkinnedMeshRenderer skinnedMeshRenderer in childrenRenderers)
        {
            var skinBones = skinnedMeshRenderer.bones;
            skinnedMeshRenderer.rootBone = bonesIndex[skinnedMeshRenderer.rootBone.name];
            List <Transform> nBones = new List <Transform>();
            foreach (Transform skinBone in skinBones)
            {
                nBones.Add(bonesIndex[skinBone.name]);
            }

            skinnedMeshRenderer.bones = nBones.ToArray();
        }

        foreach (EquipmentSlot dataSlot in equipmentData.Slots)
        {
            slotToGameobjectDictionary.Add(dataSlot, clone);
            OnEquip?.Invoke(dataSlot, equipmentData);
        }

        equipment.Add(clone);
    }
コード例 #6
0
            public virtual void Equip(EntityEquipable eq)
            {
                if (eq == null)
                {
                    return;
                }

                if (GetEquipped(eq.Type) != null)
                {
                    Unequip(eq.Type);
                }

                SetEquipped(eq.Type, eq);
                OnEquip.Invoke(master, eq);
            }
コード例 #7
0
    public void Equip(WeaponData weaponData)
    {
        GameObject go = Instantiate(weaponData.gameObject);

        weaponData = go.GetComponent <WeaponData>();

        if (_dictionary.ContainsKey(weaponData.equipmentSlot))
        {
            Unequip(weaponData.equipmentSlot);
        }

        _dictionary.Add(weaponData.equipmentSlot, weaponData);

        go.transform.SetParent(GetTransformFromEquipmentSlot(weaponData));
        go.transform.localRotation = Quaternion.identity;
        go.transform.localPosition = Vector3.zero;
        go.transform.localScale    = Vector3.one;

        OnEquip?.Invoke(weaponData);
    }
コード例 #8
0
ファイル: ChipInfo.cs プロジェクト: VirelaiSpades/Gadget-Core
 internal void InvokeOnEquip(int slot)
 {
     OnEquip?.Invoke(slot);
 }
コード例 #9
0
 private void UnsubscribeToEquipEvents()
 {
     OnEquip.Unsubscribe(OnEquipNet);
     OnUnequip.Unsubscribe(OnUnequipNet);
 }
コード例 #10
0
 private void SubscribeToEquipEvents()
 {
     OnEquip.SafeSubscribe(OnEquipNet);
     OnUnequip.SafeSubscribe(OnUnequipNet);
 }
コード例 #11
0
ファイル: Equip.cs プロジェクト: swet-s/Dark
 void Start()
 {
     OnEquip.Invoke();
     gun = player.GetComponent <GunManager>();
 }