/// <summary> /// Updates the trap UI /// </summary> /// <param name="state">The state of the trap</param> /// <param name="type">The type of trap on the trap currently</param> /// <param name="userTrap">The trap type the user has active</param> public void UpdateTrapUIDetails(TrapStates state, TrapTypes type, TrapTypes userTrap) { if (state.Equals(TrapStates.PlaceTrap)) { prefabInstance.GetComponentsInChildren <Text>()[0].text = "Place " + userTrap.ToString() + " Trap"; } else if (state.Equals(TrapStates.PickupTrap)) { prefabInstance.GetComponentsInChildren <Text>()[0].text = "Pickup " + type.ToString() + " Trap"; } prefabInstance.GetComponentsInChildren <Text>()[1].text = userTrap.ToString() + " Trap Selected"; if (isGamepad) { if (state.Equals(TrapStates.PlaceTrap)) { prefabInstance.GetComponentsInChildren <Text>()[2].text = controllerPlace; } else if (state.Equals(TrapStates.PickupTrap)) { prefabInstance.GetComponentsInChildren <Text>()[2].text = controllerPickup; } prefabInstance.GetComponentsInChildren <Text>()[3].text = controllerToggle; } else { if (state.Equals(TrapStates.PlaceTrap)) { prefabInstance.GetComponentsInChildren <Text>()[2].text = keyboardPlace; } else if (state.Equals(TrapStates.PickupTrap)) { prefabInstance.GetComponentsInChildren <Text>()[2].text = keyboardPickup; } prefabInstance.GetComponentsInChildren <Text>()[3].text = keyboardToggle; } }
private void Update() { if (input.Gnome.UseTrap.phase.Equals(InputActionPhase.Performed) && canUseInput) { if (!trapState.Equals(TrapStates.PickupTrap) && trapState.Equals(TrapStates.PlaceTrap)) { // place trap down in area. switch (selectedTrap) { case TrapTypes.None: break; case TrapTypes.Cable: if (cableTraps > 0) { PlaceTrap(); currentTrapLocation.hasTrap = true; currentTrapLocation.currentTrap = TrapTypes.Cable; cableTraps -= 1; cablePlaced += 1; } break; case TrapTypes.BBQ: if (bbqTrays > 0) { PlaceTrap(); currentTrapLocation.hasTrap = true; currentTrapLocation.currentTrap = TrapTypes.BBQ; bbqTrays -= 1; bbqPlaced += 1; } break; default: break; } } else if (trapState.Equals(TrapStates.PickupTrap) && !trapState.Equals(TrapStates.PlaceTrap)) { // pick up trap in area. switch (trapGnomeOn) { case TrapTypes.None: break; case TrapTypes.Cable: PickupTrap(); currentTrapLocation.hasTrap = false; currentTrapLocation.currentTrap = TrapTypes.None; cableTraps += 1; cablePlaced -= 1; break; case TrapTypes.BBQ: PickupTrap(); currentTrapLocation.hasTrap = false; currentTrapLocation.currentTrap = TrapTypes.None; bbqTrays += 1; bbqPlaced -= 1; break; default: break; } } // input delay StartCoroutine(InputDelay()); } // toggle selected trap if (input.Gnome.ToggleTrap.phase == InputActionPhase.Performed) { if (canUseToggle) { if (selectedTrap.Equals(TrapTypes.Cable)) { selectedTrap = TrapTypes.BBQ; } else { selectedTrap = TrapTypes.Cable; } StartCoroutine(InputToggleDelay()); } } }