public override void Init(params object[] param) { //初始化用户的材料信息 List <UserItemData> list = ItemManager.Instance.GetInitUserItemData(); for (int i = 0; i < list.Count; i++) { UserItemData data = list[i]; UserItem userItem = UserItemFactory.GenerateUserItem(data.id, data.num, this.place); AddUserItem(userItem); } }
private void DropItemObj(WorldPos pos, int itemId, int num) { UserItem userItem = UserItemFactory.GenerateUserItem(itemId, num, (int)ItemPlaceType.Scene); Texture2D tex = GetItemTexture(itemId); float x = UnityEngine.Random.Range(0.2f, 0.8f); float z = UnityEngine.Random.Range(0.2f, 0.8f); DropItem dropItem = GameObject.Instantiate(_dropItemPrefab, new Vector3(pos.x + x, pos.y + 0.5f, pos.z + z), Quaternion.identity) as DropItem; dropItem.transform.parent = this.transform; dropItem.Init(userItem, tex); dropItem.On_PickUp += HandleOn_PickUp; dropItem.On_SelfDisappear += HandleOn_SelfDisappear; _dropItemMap.Add(dropItem.GetInstanceID(), dropItem); }