private void Awake() { inventory.onItemAdded.AddListener(OnItemAdded); itemDropHandler = GetComponentInChildren <ItemDropHandler>(true); itemDropHandler.onItemDropped.AddListener(OnItemDropped); }
public void Build_Mount_Point_Drop_Panels() { //**************************** //Get the list of mount points //**************************** GameObject g = null; if (this.command_module == null) { //We need to hide all buttons and only show a command SetScreenNoCommandModule(); } else { if (this.tmp_drop_panel) { Destroy(this.tmp_drop_panel); } if (drop_panels_loaded) { return; } GameObject mount_points = this.command_module.transform.Find("MountPoints").gameObject; ShipModule sys = mount_points.GetComponentInParent <ShipModule>(); mount_point_drop_zone_list = new GameObject[sys.mount_points.Count]; foreach (MountPoint m in sys.mount_points) { if (m.zone == Enums.emun_zone.intern) { g = Instantiate(mount_point_drop_zone_grid, mount_point_panels[(int)m.zone].gameObject.transform); } else { g = Instantiate(mount_point_drop_zone, mount_point_panels[(int)m.zone].gameObject.transform); } mount_point_drop_zone_list[m.index] = g.transform.Find("DropZone").gameObject; MountPoint omp = g.GetComponent <MountPoint>(); omp.SetValues(m); omp.SetSize(new Vector2(100 + (m.max_mounting * 50), 50)); omp.mount_type_util_top = m.mount_type_util_top; omp.mount_type_util_side = m.mount_type_util_side; omp.mount_type_thruster = m.mount_type_thruster; omp.mount_type_engine = m.mount_type_engine; omp.associated_mountpoint = m.gameObject; ItemDropHandler dh = g.GetComponentInChildren <ItemDropHandler>(); dh.enforce_max = true; dh.max_items = m.max_mounting; } DisableEnableButtons(true); Populate_Mount_Point_Drop_Panels(); Build_Inventory_List_Items(); drop_panels_loaded = true; } }
public void OnBeginDrag(PointerEventData eventData) { currentTouchId = eventData.pointerId; startParent = transform.parent; startPosition = transform.position; startSlot = transform.parent.GetComponent <ItemDropHandler>(); canvasGroup.blocksRaycasts = false; transform.parent = Inventory.instance.topOfCanvas; }
// Start is called before the first frame update void Start() { if (!itemDropHandler) { itemDropHandler = GetComponent <ItemDropHandler>(); } if (!dungeonManager) { dungeonManager = FindObjectOfType <DungeonManager>(); } rooms = GetComponentsInChildren <DungeonRoomController>(); currentRoom = rooms.FirstOrDefault(x => x.RoomType == DungeonRoomType.Start); currentRoomIndex = Array.IndexOf(rooms, currentRoom); }
void Start() { if (!gameManager) { gameManager = FindObjectOfType <GameManager>(); } if (!itemDropHandler) { itemDropHandler = FindObjectOfType <ItemDropHandler>(); } //ResetText.SetActive(false); //RedTeamWins.SetActive(false); //BlueTeamWins.SetActive(false); //NoTeamWins.SetActive(false); }
///public static void loadScene(int number) public static void loadScene(string sceneName) { for (int i = 0; i < Inventory.allItems.Count; i++) { string path = Application.persistentDataPath + "Scene#" + sceneName + "_" + Inventory.allItems[i].name + ".item.sav"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); ItemData data = formatter.Deserialize(stream) as ItemData; Vector3 position = new Vector3(data.position[0], data.position[1], data.position[2]); ItemDropHandler.loadItem(Inventory.allItems[i].ItemPrefab, position); } } }
void FixedUpdate() { int timeInSeconds = (int)Time.realtimeSinceStartup; if (_currentItemCount < MaxAllowedItems && timeInSeconds > _lastGeneratedTime && timeInSeconds % CheckIntervalSeconds == 0 && Random.value < Possibility) { _currentItemCount++; _lastGeneratedTime = timeInSeconds; float xPos = Random.Range(RangeXMin, RangeXMax); GameObject itemDrop = (GameObject)Instantiate(Resources.Load("Prefabs/ItemDrops/ItemDrop")); itemDrop.transform.position = new Vector3(xPos, 10, 0); ItemDropHandler handler = itemDrop.GetComponent <ItemDropHandler>(); handler.SetOnLandedCallback(OnItemLanded); handler.SetType(ITEM_TYPES[_rand.Next(ITEM_TYPES.Length)]); handler.SetOnDestroyCallback(OnItemDropDestroyCallback); // Debug.Log("dropping item"); } }
void Start() { dropHandler = GameObject.Find("Inventaire").GetComponent <ItemDropHandler>(); gmg = FindObjectOfType <GameManager>(); sprr = transform.gameObject.GetComponent <Image>(); }