private void AddBaitType(RescueGameController.BaitTypes BaitType) { GameObject BaitObj = Instantiate(RescueGameController.Instance.Baits[(int)BaitType]); BaitObj.transform.parent = BaitMenuParent.transform; BaitObj.transform.transform.localPosition = new Vector3(0, 1, 0); ShownBaitObjs.Add(BaitObj.GetComponent <BaitMenuItem>()); ShownBaitTypes.Add(BaitType); }
// Update is called once per frame void Update() { if (BaitMenuParent.activeInHierarchy) { for (int i = 0; i < ShownBaitObjs.Count; ++i) { ShownBaitObjs[i].SetSelected(i == SelectedBaitIndex); } if (Input.GetAxis("Horizontal") < 0 && CanSelectionMove) { --SelectedBaitIndex; if (SelectedBaitIndex < 0) { SelectedBaitIndex = ShownBaitObjs.Count - 1; } CanSelectionMove = false; } if (Input.GetAxis("Horizontal") > 0 && CanSelectionMove) { ++SelectedBaitIndex; if (SelectedBaitIndex > ShownBaitObjs.Count - 1) { SelectedBaitIndex = 0; } CanSelectionMove = false; } if (Input.GetAxis("Horizontal") == 0) { CanSelectionMove = true; } if (!Input.GetButtonDown("BaitTrap")) { CanMakeSelection = true; } if (Input.GetButtonDown("BaitTrap")) { selectedBait = ShownBaitTypes[SelectedBaitIndex]; BaitMenuParent.SetActive(false); RescueGameController.Instance.AllowPlayerToMove(true); } } }