Beispiel #1
0
    public static bool MeshVisible(CreationMeshLoader loader)
    {
#if PLANET_EXPLORERS
//		if ( PlayerFactory.mMainPlayer != null )
//			return ( (PlayerFactory.mMainPlayer.transform.position - loader.transform.position).magnitude < 100 );
//		else
        return(true);
#else
        return(true);
#endif
    }
Beispiel #2
0
    static GameObject InstantiateCreationModel(CreationData crd, Action <Transform> initTransform)
    {
        if (crd == null)
        {
            return(null);
        }
        if (crd.m_Prefab == null)
        {
            return(null);
        }

        GameObject product = null;

        if (lastProduct)
        {
            var drag = lastProduct.GetComponent <ItemDraggingBase>();
            if (drag)
            {
                if (lastCreationData == crd)
                {
                    UnityEngine.Object.Destroy(drag);
                    product = lastProduct;
                }
                else
                {
                    UnityEngine.Object.Destroy(lastProduct);
                }
            }
            lastProduct      = null;
            lastCreationData = null;
        }

        if (!product)
        {
            product          = UnityEngine.Object.Instantiate(crd.m_Prefab) as GameObject;
            lastProduct      = product;
            lastCreationData = crd;
        }

        product.transform.SetParent(null, false);
        product.SetActive(true);

        if (initTransform != null)
        {
            initTransform(product.transform);
        }
        else
        {
            product.transform.position   = Vector3.zero;
            product.transform.localScale = Vector3.one;
            product.transform.rotation   = Quaternion.identity;
        }

        // 新创建物体初始化
        if (lastProduct)
        {
            var creationController = product.GetComponent <CreationController>();
            creationController.enabled = true;



            if (crd.m_IsoData.m_HeadInfo.Category == EVCCategory.cgDbSword)
            {
                // Mesh manager
                VCMeshMgr[]          meshmgrs   = product.GetComponentsInChildren <VCMeshMgr>();
                CreationMeshLoader[] meshloader = new CreationMeshLoader[2];
                for (int i = 0; i < meshmgrs.Length; i++)
                {
                    meshmgrs[i].m_ColorMap = crd.m_IsoData.m_Colors;
                    meshmgrs[i].Init();

                    meshloader[i] = meshmgrs[i].gameObject.AddComponent <CreationMeshLoader>();
                    meshloader[i].m_Meshdagger = crd.m_IsoData.m_HeadInfo.Category == EVCCategory.cgDbSword;
                    meshloader[i].Init(creationController);
                }

                // Mesh loader
                //meshloader[0].Init(creationController);
                //meshloader[1].Init(creationController);
                //meshloader[1].InitClone(creationController, meshloader[0].m_Computer.m_DataSource, meshmgrs[1]);
            }
            else
            {
                // Mesh manager
                VCMeshMgr meshmgr = product.GetComponentInChildren <VCMeshMgr>();
                meshmgr.m_ColorMap = crd.m_IsoData.m_Colors;
                meshmgr.Init();

                // Mesh loader
                CreationMeshLoader meshloader = meshmgr.gameObject.AddComponent <CreationMeshLoader>();
                meshloader.Init(creationController);
            }

            //    meshmgr.m_ColorMap = crd.m_IsoData.m_Colors;
            //meshmgr.Init();

            //// Mesh loader
            //CreationMeshLoader meshloader = meshmgr.gameObject.AddComponent<CreationMeshLoader>();
            //meshloader.Init(creationController);

            // Decal data
            VCDecalHandler[] dclhs = product.GetComponentsInChildren <VCDecalHandler>(true);
            foreach (VCDecalHandler dclh in dclhs)
            {
                dclh.m_Iso = crd.m_IsoData;
            }
        }

        return(product);
    }