示例#1
0
    public void createEntity(string typeName, string entityID, bool isPlayer, float x, float y, float z, float yaw, Hashtable attrs)
    {
        for (int i = 0; i < entityList.Length; i++)
        {
            ClientEntity objModel = entityList [i];

            if (objModel.GetType().Name == typeName)
            {
                Debug.Log("GameObject " + objModel.gameObject + " scene" + objModel.gameObject.scene);
                GameObject   obj    = Instantiate(objModel.gameObject);
                ClientEntity entity = obj.GetComponent(typeName) as ClientEntity;
                Debug.Assert(entity != null);
                Debug.Log("Entity " + typeName + "." + entityID + " created: " + entity);
                entity.Init(this, entityID, isPlayer, x, y, z, yaw, attrs);
                entity.Space = this.space;

                if (isPlayer)
                {
                    this.player = entity;
                    GameObject.DontDestroyOnLoad(entity.gameObject);
                }

                this.entities [entityID] = entity;
                entity.OnCreated();

                return;
            }
        }

        Debug.LogAssertionFormat("Entity type {0} is unknown", typeName);
    }