public void Add_newItem() { if (!player_quickbar.Item_List.Contains(this_Item)) { // player_quickbar.Item_List.Add(this_Item); //Inventory_Manager.Creat_new_Item(this_Item); for (int i = 0; i < 10; i++) { if (player_quickbar.Item_List[i] == null) { player_quickbar.Item_List[i] = this_Item; break; } } Inventory_Manager.Refresh_quick_bar(); Debug.Log("成功添加新物品!"); } else { this_Item.itemheld += stack_number; //为解决拾取物品时 选择框会刷新到其他地方 采用一格一格的刷新 而不摧毁再重建 for (int i = 0; i < 10; i++) { Inventory_Manager.Refresh_Item(i); } } }
// Update is called once per frame void Update() { if (Select_ui())//通过鼠标滑轮选择物品 { sel_image_pos_temp.pos = Inventory_Manager.Get_slot_position(sel_slot_number); select_image.transform.position = sel_image_pos_temp.pos; //选择框位置改变 Debug.Log(Inventory_Manager.Get_slot_position(sel_slot_number)); //储存的位置信息也同时更新 } //没有滑轮响应时,通过点击slot的bottom也可以选择 if (ischangtemp == Inventory_Manager.Get_slot_position(sel_slot_number)) { return; } else { ischangtemp = Inventory_Manager.Get_slot_position(sel_slot_number); sel_image_pos_temp.pos = Inventory_Manager.Get_slot_position(sel_slot_number); select_image.transform.position = sel_image_pos_temp.pos; Debug.Log("wheel change"); } //储存的位置信息也同时更新 }
void Awake() { if (instance != null) { Destroy(this); } instance = this; Max_slot_number = instance.my_inventory.Item_List.Count; }
public void OnEndDrag(PointerEventData eventData) { if (eventData.pointerCurrentRaycast.gameObject.name == "item_Image")//判断下面的物体名字;如果存在物品则对调 { transform.SetParent(eventData.pointerCurrentRaycast.gameObject.transform.parent.parent); transform.position = eventData.pointerCurrentRaycast.gameObject.transform.parent.parent.position; //itemlist物品存储位置改变 var temp = my_bar.Item_List[current_item_iD]; my_bar.Item_List[current_item_iD] = my_bar.Item_List[eventData.pointerCurrentRaycast.gameObject.GetComponentInParent <Slot>().slot_ID]; my_bar.Item_List[eventData.pointerCurrentRaycast.gameObject.GetComponentInParent <Slot>().slot_ID] = temp; eventData.pointerCurrentRaycast.gameObject.transform.parent.position = original_parent.position; eventData.pointerCurrentRaycast.gameObject.transform.parent.SetParent(original_parent); GetComponent <CanvasGroup>().blocksRaycasts = true;//射线阻挡开启 不然无法再次选中移动的物品 Inventory_Manager.Refresh_quick_bar(); return; } //直接挂载到slot的物品槽内 if (eventData.pointerCurrentRaycast.gameObject.name == "slot(Clone)") { transform.SetParent(eventData.pointerCurrentRaycast.gameObject.transform); transform.position = eventData.pointerCurrentRaycast.gameObject.transform.position; //itemlist物品存储位置改变 my_bar.Item_List[eventData.pointerCurrentRaycast.gameObject.GetComponentInParent <Slot>().slot_ID] = my_bar.Item_List[current_item_iD]; if (eventData.pointerCurrentRaycast.gameObject.GetComponent <Slot>().slot_ID != current_item_iD)//不放在自己位置时,才清理旧位置的物品 { my_bar.Item_List[current_item_iD] = null; } GetComponent <CanvasGroup>().blocksRaycasts = true; Inventory_Manager.Refresh_quick_bar(); return; } //else //{ // transform.SetParent(original_parent); // transform.position = original_parent.position; // GetComponent<CanvasGroup>().blocksRaycasts = true; //} }
//public static MiniMap nimimMap;//小地图 //public static BossBlood bossBlood;//Boss血条 //public static TeamMates teamMates;//队友 void Awake() { inventory = GameObject.Find("Inventory").GetComponent <Inventory_Manager>(); equip = GameObject.Find("Equipment").GetComponent <Equip_Manager>(); key = GameObject.Find("short cut/Key").GetComponent <Key>(); skillUI = GameObject.Find("skill_UI").GetComponent <Skill_UI>(); taskUI = GameObject.Find("task_UI").GetComponent <Task_UI>(); money = GameObject.Find("inventory/Win/money").GetComponent <Money>(); UI = GameObject.Find("UI Root").GetComponent <UI_Manager>(); keyControl = GameObject.Find("short cut").GetComponent <KeyControl>(); //nimimMap = GameObject.Find("MiniMap").GetComponent<MiniMap>(); //bossBlood = GameObject.Find("BossBlood").GetComponent<BossBlood>(); //teamMates = GameObject.Find("TeamMates").GetComponent<TeamMates>(); }
// Use this for initialization void Start() { //Initalize weapons InventoryManager = GetComponentInParent <Inventory_Manager>(); offSet = 0; Weapons newWeapon = new Weapons("Pew Rifle", 29, 20, 3, 3, 1); // Rifle WeaponList.Add(newWeapon); newWeapon = new Weapons("Laser Sword", 35, 15, 3, 3, 2); // Sword WeaponList.Add(newWeapon); newWeapon = new Weapons("Shield", 10, 5, 3, 2, 3); // Shield WeaponList.Add(newWeapon); newWeapon = new Weapons("Strong Rifle", 45, 29, 3, 4, 4); WeaponList.Add(newWeapon); // Legendary rifle newWeapon = new Weapons("OP Sword", 60, 35, 3, 4, 5); WeaponList.Add(newWeapon); newWeapon = new Weapons("Test Sword", 30, 15, 3, 4, 6); WeaponList.Add(newWeapon); newWeapon = new Weapons("Final Sword", 43, 12, 3, 4, 7); WeaponList.Add(newWeapon); newWeapon = new Weapons("Filler Rifle", 43, 12, 3, 4, 8); WeaponList.Add(newWeapon); newWeapon = new Weapons("Helmet", 29, 20, 1, 3, 9); // Rifle ApparelList.Add(newWeapon); newWeapon = new Weapons("Chest Piece", 35, 15, 2, 3, 10); // Sword ApparelList.Add(newWeapon); newWeapon = new Weapons("Leggings", 10, 5, 4, 2, 11); // Shield ApparelList.Add(newWeapon); newWeapon = new Weapons("Boots", 45, 29, 5, 4, 12); ApparelList.Add(newWeapon); // Legendary rifle newWeapon = new Weapons("Testing Chest", 30, 15, 2, 4, 13); ApparelList.Add(newWeapon); newWeapon = new Weapons("Testing Leggings", 10, 15, 4, 4, 13); ApparelList.Add(newWeapon); newWeapon = new Weapons("Testing Helmet", 5, 5, 1, 4, 13); ApparelList.Add(newWeapon); for (int i = 0; i < ItemSlots.Length; ++i) { ItemSlots[i].transform.parent.gameObject.GetComponent <Image>().enabled = false; // works // ItemSlots[i].GetComponentInParent<Image>().enabled = false; // doesnt work // idk why lol } EMScript = EquipmentManager.GetComponent <Equipment_Manager>(); ItemSelectionTransform = ItemSelectionBox.GetComponent <RectTransform>(); isShown = false; }
protected void Start() { DynamicVisualAcuity = Random.Range(13, 20); Now_Action_Point = Pull_Action_Point; Now_Move_Point = Move_Point; UI_Manager = GameObject.Find("Canvas").GetComponent <UI_MANAGER>(); Inventory = GameObject.Find("Inventory").GetComponent <Inventory_Manager>(); T = transform.parent.GetComponent <Tile>(); _Tile = transform.parent.parent.GetComponent <Tile_Manager>(); x = T.X; y = T.Y; Init(); Board_Manager.m_Board_Manager.AddUnit(this); Board_Manager.m_Board_Manager.Loading++; Name = UI_Manager.EUFirstName[Random.Range(0, UI_Manager.EUFirstName.Length)] + " " + UI_Manager.EULastName[Random.Range(0, UI_Manager.EULastName.Length)]; }
public void ItemOnClicked() { Inventory_Manager.Updata_Item_name(slotinfo_name); Wheel_select_item.sel_slot_number = slot_ID; StartCoroutine(Delay_Disappear()); if (slot_item == null) { Tile_Item_use.baseTile = null; Tile_Item_use.use_tile_item = null; return; } if (slot_item.Istile) { Tile_Item_use.baseTile = Map_ctrl.Dec_name_to_Tiles[Slotname_to_TilesName[slot_item.Item_name]]; Tile_Item_use.use_tile_item = AssetDatabase.LoadAssetAtPath("Assets/Inventory/Items/" + Slotname_to_TilesName[slot_item.Item_name] + ".asset", typeof(UnityEngine.ScriptableObject)) as Item; } else { Tile_Item_use.use_tile_item = null; Tile_Item_use.baseTile = null; } }
private void Awake() { instance = this; }
public static TileBase baseTile; //使用的填充瓦片物品 void Update() { if (use_tile_item == null) { //Debug.Log("瓦片物品为空"); return; } if (baseTile == null) { //Debug.Log("没有选择瓦片" + use_tile_item.Item_name); return; } if (use_tile_item.itemheld < 1) { //Debug.Log("数量不足" + use_tile_item.Item_name); return; } //右击空白地方创造瓦片 if (use_tile_item.Item_name == "泥土" && Input.GetMouseButtonDown(1)) { Debug.Log(" " + use_tile_item.Item_name); Vector3 mousePosition = Input.mousePosition; Vector3 wordPosition = Camera.main.ScreenToWorldPoint(mousePosition); Vector3Int cellPosition = tilemap.WorldToCell(wordPosition); TileBase tb = tilemap.GetTile(cellPosition); TileBase up_tile = tilemap.GetTile(new Vector3Int(cellPosition.x, cellPosition.y + 1, cellPosition.z)); TileBase down_tile = tilemap.GetTile(new Vector3Int(cellPosition.x, cellPosition.y - 1, cellPosition.z)); TileBase left_tile = tilemap.GetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y, cellPosition.z)); TileBase right_tile = tilemap.GetTile(new Vector3Int(cellPosition.x + 1, cellPosition.y, cellPosition.z)); TileBase right_up_tile = tilemap.GetTile(new Vector3Int(cellPosition.x + 1, cellPosition.y + 1, cellPosition.z)); TileBase right_down_tile = tilemap.GetTile(new Vector3Int(cellPosition.x + 1, cellPosition.y - 1, cellPosition.z)); TileBase left_up_tile = tilemap.GetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y + 1, cellPosition.z)); TileBase left_down_tile = tilemap.GetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y - 1, cellPosition.z)); if (tb == Map_ctrl.Dec_name_to_Tiles["right_land_tile"]) { if (up_tile == Map_ctrl.Dec_name_to_Tiles["right_land_tile"] && down_tile == Map_ctrl.Dec_name_to_Tiles["right_land_tile"]) { tilemap.SetTile(cellPosition, baseTile); tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_up_land_tile"]); tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_land_tile"]); tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_corner_tile"]); tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_up_corner_tile"]); use_tile_item.itemheld--; Debug.Log(use_tile_item.itemheld); } } if (tb == Map_ctrl.Dec_name_to_Tiles["right_up_land_tile"]) { if (up_tile == Map_ctrl.Dec_name_to_Tiles["glass_tile"] && down_tile == Map_ctrl.Dec_name_to_Tiles["right_land_tile"]) { tilemap.SetTile(cellPosition, baseTile); //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_up_land_tile"]); tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_land_tile"]); tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_land_tile"]); tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_up_corner_tile"]); use_tile_item.itemheld--; Debug.Log(use_tile_item.itemheld); } } if (tb == Map_ctrl.Dec_name_to_Tiles["right_up_land_tile"]) { if (up_tile == Map_ctrl.Dec_name_to_Tiles["glass_tile"] && down_tile == Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]) { tilemap.SetTile(cellPosition, baseTile); //center //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //up tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["left_hole_land_tile"]); //down tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_land_tile"]); //left tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_land_tile"]); //left_up tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["double_right_corner_tile"]); //left_down //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right //tilemap.SetTile(new Vector3Int(cellPosition.x+1, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right_up //tilemap.SetTile(new Vector3Int(cellPosition.x+1, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right_down use_tile_item.itemheld--; Debug.Log(use_tile_item.itemheld); } } if (tb == Map_ctrl.Dec_name_to_Tiles["left_hole_land_tile"]) { if (up_tile == Map_ctrl.Dec_name_to_Tiles["glass_tile"] && down_tile == Map_ctrl.Dec_name_to_Tiles["glass_tile"] && left_tile == Map_ctrl.Dec_name_to_Tiles["double_right_corner_tile"] && right_tile == Map_ctrl.Dec_name_to_Tiles["glass_tile"]) { tilemap.SetTile(cellPosition, baseTile); //center //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //up //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["left_hole_land_tile"]); //down tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_land_tile"]); //left //tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_land_tile"]); //left_up //tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["double_right_corner_tile"]); //left_down //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right //tilemap.SetTile(new Vector3Int(cellPosition.x+1, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right_up //tilemap.SetTile(new Vector3Int(cellPosition.x+1, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right_down use_tile_item.itemheld--; Debug.Log(use_tile_item.itemheld); } } if (tb == Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]) { if (up_tile == Map_ctrl.Dec_name_to_Tiles["glass_tile"] && down_tile == Map_ctrl.Dec_name_to_Tiles["glass_tile"] && left_tile == Map_ctrl.Dec_name_to_Tiles["right_down_corner_tile"] && right_tile == Map_ctrl.Dec_name_to_Tiles["glass_tile"]) { tilemap.SetTile(cellPosition, baseTile); //center //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //up //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["left_hole_land_tile"]); //down tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_land_tile"]); //left //tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_land_tile"]); //left_up //tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["double_right_corner_tile"]); //left_down //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right //tilemap.SetTile(new Vector3Int(cellPosition.x+1, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right_up //tilemap.SetTile(new Vector3Int(cellPosition.x+1, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right_down use_tile_item.itemheld--; Debug.Log(use_tile_item.itemheld); } } if (tb == Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]) { if (up_tile == Map_ctrl.Dec_name_to_Tiles["right_up_corner_tile"] && down_tile == Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"] && left_tile == Map_ctrl.Dec_name_to_Tiles["sea_tile"] && right_tile == Map_ctrl.Dec_name_to_Tiles["glass_tile"]) { tilemap.SetTile(cellPosition, baseTile); //center //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //up //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["left_hole_land_tile"]); //down tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_land_tile"]); //left //tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_land_tile"]); //left_up //tilemap.SetTile(new Vector3Int(cellPosition.x - 1, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["double_right_corner_tile"]); //left_down //tilemap.SetTile(new Vector3Int(cellPosition.x, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right //tilemap.SetTile(new Vector3Int(cellPosition.x+1, cellPosition.y + 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right_up //tilemap.SetTile(new Vector3Int(cellPosition.x+1, cellPosition.y - 1, cellPosition.z), Map_ctrl.Dec_name_to_Tiles["right_down_land_tile"]); //right_down use_tile_item.itemheld--; Debug.Log(use_tile_item.itemheld); } } Inventory_Manager.Refresh_Item(Wheel_select_item.sel_slot_number); } }
private void ShowB() { Inventory_Manager.Updata_Item_name(""); }