Exemple #1
0
    private void SpawnItem(Vector3 positionToSpawn, DroppableItems itemToSpawn)
    {
        GameObject itemMesh = ObjectPoolManager.Instance.GetObjectFromNetworkPool(itemToSpawn.ToString());

        //chests behave differently then regular pick up items but can still be dropped so they get managed here
        if (itemToSpawn == DroppableItems.Chest)
        {
            ChestItemMesh chest = itemMesh.GetComponent <ChestItemMesh>();
            //get the closest position to the ground and place the chest in that location
            chest.transform.position = MathFunc.CalculateClosestGroundPosition(positionToSpawn);
            chest.SetActive(true);
        }
        //other 3D items that are not chests
        else
        {
            ItemMesh3D item = itemMesh.GetComponent <ItemMesh3D>();
            //set the item assembly of the item
            item.AssemblyName = PickupDetails.GetDroppableItemAssembly(itemToSpawn);

            if (!m_PickUpItemsInGame.ContainsKey(item.AssemblyName))
            {
                photonView.RPC("RPCCreateAndAddItemToList", PhotonTargets.All, item.AssemblyName);
            }

            float   speed     = UnityEngine.Random.Range(5.0f, 7.5f);
            Vector3 direction = Vector3.up;
            direction.x = UnityEngine.Random.Range(-0.25f, 0.25f);
            direction.z = UnityEngine.Random.Range(-0.25f, 0.25f);

            item.SetActive(true, positionToSpawn, Quaternion.identity.eulerAngles, direction, speed);

            object actualItem = GetObjectFromName(item.AssemblyName);

            item.photonView.RPC("Item3DSetUp", PhotonTargets.All, item.AssemblyName, (actualItem as AbstractItem).ItemType, (actualItem as AbstractItem).SpriteName, false);
            item.CanPlayerObtainItem = (actualItem as AbstractItem).CanObtainItem;
        }
    }
Exemple #2
0
    private void SpawnPickup(string obj, Transform pos)
    {
        GameObject itemMesh = ObjectPoolManager.Instance.GetObjectFromNetworkPool(obj);

        //other 3D items that are not chests

        ItemMesh3D item = itemMesh.GetComponent <ItemMesh3D>();

        //set the item assembly of the item
        item.AssemblyName = "TheNegative.Items." + obj + "PickUp";

        float   speed     = UnityEngine.Random.Range(5.0f, 7.5f);
        Vector3 direction = Vector3.up;

        direction.x = UnityEngine.Random.Range(-0.25f, 0.25f);
        direction.z = UnityEngine.Random.Range(-0.25f, 0.25f);

        item.SetActive(true, pos.position, Quaternion.identity.eulerAngles, direction, speed);

        object actualItem = ItemManager.Instance.GetObjectFromName(item.AssemblyName);

        item.photonView.RPC("Item3DSetUp", PhotonTargets.All, item.AssemblyName, (actualItem as AbstractItem).ItemType);
        item.CanPlayerObtainItem = (actualItem as AbstractItem).CanObtainItem;
    }