Esempio n. 1
0
    public void CmdRequestSpawnObject(Vector3 position, Quaternion rotation, string itemID, string itemData)
    {
        ItemData itemdata = UnitZ.itemManager.GetItemDataByID(itemID);

        if (itemdata)
        {
            if (itemdata.ItemFPS)
            {
                FPSItemPlacing fpsplacer = itemdata.ItemFPS.GetComponent <FPSItemPlacing>();
                if (fpsplacer)
                {
                    if (fpsplacer.Item)
                    {
                        GameObject obj = UnitZ.gameNetwork.RequestSpawnObject(fpsplacer.Item, position, rotation);
                        if (obj)
                        {
                            ObjectPlacing objplaced = obj.GetComponent <ObjectPlacing>();
                            objplaced.SetItemUID(objplaced.GetUniqueID());
                            objplaced.SetItemID(itemID);
                            objplaced.SetItemData(itemData);
                        }
                    }
                }
            }
        }
    }
Esempio n. 2
0
 void Start()
 {
     for (int i = 0; i < ItemsList.Length; i++)
     {
         UnitZ.gameNetwork.spawnPrefabs.Add(ItemsList[i].gameObject);
         if (ItemsList[i].ItemFPS)
         {
             FPSItemPlacing fpsItemPlacer = ItemsList[i].ItemFPS.GetComponent <FPSItemPlacing>();
             if (fpsItemPlacer)
             {
                 if (fpsItemPlacer.Item != null)
                 {
                     NetworkIdentity objPlace = fpsItemPlacer.Item.GetComponent <NetworkIdentity>();
                     if (objPlace)
                     {
                         UnitZ.gameNetwork.spawnPrefabs.Add(fpsItemPlacer.Item.gameObject);
                     }
                 }
             }
             //扔出物品
             FPSItemThrow fpsItemThrow = ItemsList[i].ItemFPS.GetComponent <FPSItemThrow>();
             if (fpsItemThrow)
             {
                 if (fpsItemThrow.Item != null)
                 {
                     NetworkIdentity objPlace = fpsItemThrow.Item.GetComponent <NetworkIdentity>();
                     if (objPlace)
                     {
                         UnitZ.gameNetwork.spawnPrefabs.Add(fpsItemThrow.Item.gameObject);
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
 void Awake()
 {
     ItemEquipments = new Dictionary <int, FPSItemEquipment>(ItemsList.Length);
     for (int i = 0; i < ItemsList.Length; i++)
     {
         ItemsList[i].ItemID    = Suffix + i;
         ItemsList[i].ItemIndex = i;
         //每个物体分配ID
         if (ItemsList[i].ItemFPS)
         {
             FPSItemEquipment fpsItemEquipment = ItemsList[i].ItemFPS.GetComponent <FPSItemEquipment>();
             if (fpsItemEquipment)
             {
                 fpsItemEquipment.ItemID    = ItemsList[i].ItemID;
                 fpsItemEquipment.ItemIndex = i;
                 ItemEquipments[i]          = fpsItemEquipment;
             }
             FPSWeaponEquipment weapon = ItemsList[i].ItemFPS.GetComponent <FPSWeaponEquipment>();
             if (weapon)
             {
                 if (ItemsList[i].ItemEquip)
                 {
                     ItemsList[i].ItemEquip.UsingType = weapon.UsingType;
                 }
             }
             //物品放置
             FPSItemPlacing fpsItemPlacer = ItemsList[i].ItemFPS.GetComponent <FPSItemPlacing>();
             if (fpsItemPlacer)
             {
                 if (fpsItemPlacer.Item != null)
                 {
                     ObjectSpawn objSpawn = fpsItemPlacer.Item.GetComponent <ObjectSpawn>();
                     if (objSpawn)
                     {
                         objSpawn.ItemID = ItemsList[i].ItemID;
                         if (objSpawn.Item)
                         {
                             ObjectPlacing objPlace = objSpawn.Item.GetComponent <ObjectPlacing>();
                             if (objPlace)
                             {
                                 objPlace.ItemID = ItemsList[i].ItemID;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 4
0
    //放置物品
    public void PlacingObject(string itemid, Vector3 position, Vector3 normal)
    {
        ItemData itemdata = GetItemDataByID(itemid);

        if (itemdata.ItemFPS)
        {
            FPSItemPlacing fpsplacing = itemdata.ItemFPS.GetComponent <FPSItemPlacing>();
            if (fpsplacing)
            {
                if (fpsplacing.Item)
                {
                    GameObject obj = UnitZ.gameNetwork.RequestSpawnObject(fpsplacing.Item, position, Quaternion.identity);
                    if (obj)
                    {
                        ObjectPlacing objplaced = obj.GetComponent <ObjectPlacing>();
                        objplaced.transform.forward = normal;
                        objplaced.SetItemID(itemid);
                    }
                }
            }
        }
    }
Esempio n. 5
0
    //直接放置物品
    public void DirectPlacingObject(string itemid, string itemuid, Vector3 position, Quaternion rotation)
    {
        //Debug.Log("Direct place "+itemid);
        ItemData itemdata = GetItemDataByID(itemid);

        if (itemdata.ItemFPS)
        {
            FPSItemPlacing fpsplacing = itemdata.ItemFPS.GetComponent <FPSItemPlacing>();
            if (fpsplacing)
            {
                if (fpsplacing.Item)
                {
                    GameObject obj = UnitZ.gameNetwork.RequestSpawnObject(fpsplacing.Item, position, rotation);
                    if (obj)
                    {
                        ObjectPlacing objplaced = obj.GetComponent <ObjectPlacing>();
                        objplaced.SetItemID(itemid);
                        objplaced.SetItemUID(itemuid);
                    }
                }
            }
        }
    }