Ejemplo n.º 1
0
        public void TestToString()
        {
            string         guid = "0123456789abcdef9876543210fedcba";
            NetworkHash128 hash = NetworkHash128.Parse(guid);

            Assert.That(hash.ToString(), Is.EqualTo(guid));
        }
Ejemplo n.º 2
0
    public static GameObject SpawnObjectsDefault(Vector3 position, NetworkHash128 assetId)
    {
        if (position.x == 0 && position.y == 0)
        {
            return(null);
        }

        GameObject spawned = Instantiate(Utils.FindAssetID(assetId.ToString()));
        Room       room    = Utils.GetRoomFromPosition(position).GetComponent <Room>();

        spawned.transform.parent   = room.gameObject.transform.Find("Objects");
        spawned.transform.position = position;

        return(spawned);
    }
Ejemplo n.º 3
0
        private static GameObject NetworkSpawnItemHandler(Vector3 pos, NetworkHash128 asset_id)
        {
            //Debug.Log("CTF: client " + NetworkMatch.m_my_lobby_id + " flag spawning " + asset_id);
            GameObject prefabFromAssetId = m_registered_prefabs[asset_id];

            if (prefabFromAssetId == null)
            {
                Debug.LogErrorFormat("CTF: Error looking up item prefab with asset_id {0}", asset_id.ToString());
                return(null);
            }
            GameObject gameObject = UnityEngine.Object.Instantiate(prefabFromAssetId, pos, Quaternion.identity);

            if (gameObject == null)
            {
                Debug.LogErrorFormat("CTF: Error instantiating item prefab {0}", prefabFromAssetId.name);
                return(null);
            }
            gameObject.SetActive(true);
            //Debug.Log("Spawning flag " + asset_id + " active " + gameObject.activeSelf + " seg " + gameObject.GetComponent<Item>().m_current_segment);

            var netId = gameObject.GetComponent <NetworkIdentity>();

            netId.GetType().GetField("m_AssetId", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(netId, asset_id);
            //Debug.Log("post spawn assetid " + gameObject.GetComponent<NetworkIdentity>().assetId);

            return(gameObject);
        }
Ejemplo n.º 4
0
 // On the client, instantiate the prefab using Zenject's container.
 private GameObject Spawn(Vector3 position, NetworkHash128 assetId)
 {
     Debug.Log("Spawn(" + assetId.ToString() + ")");
     return(Container.InstantiatePrefab(assetIdToPrefab[assetId]));
 }