protected override void OnEnable() { base.OnEnable(); m_PickupAction = (PickupAction)m_Action; m_EffectProp = serializedObject.FindProperty("m_Effect"); // Collect Pickup Triggers that depend on this Pickup Action. m_DependentTriggers.Clear(); var pickupTriggers = StageUtility.GetCurrentStageHandle().FindComponentsOfType <PickupTrigger>(); foreach (var trigger in pickupTriggers) { if (trigger.GetMode() == PickupTrigger.Mode.SpecificPickups) { var specificPickups = trigger.GetSpecificPickupActions(); if (specificPickups.Contains(m_PickupAction)) { m_DependentTriggers.Add(trigger); } } } }
void PickupCollected(PickupAction pickup) { if (m_PickupActions.Contains(pickup)) { Progress++; } }
protected override void CreateGUI() { TargetPropGUI(); EditorGUI.BeginDisabledGroup(EditorApplication.isPlaying); EditorGUILayout.PropertyField(m_ModeProp); if ((PickupTrigger.Mode)m_ModeProp.enumValueIndex == PickupTrigger.Mode.AmountOfPickups) { EditorGUILayout.PropertyField(m_AmountModeCountProp, new GUIContent("Pickup Count")); } else if ((PickupTrigger.Mode)m_ModeProp.enumValueIndex == PickupTrigger.Mode.SpecificPickups) { if (EditorGUILayout.PropertyField(m_SpecificModePickupActionsProp, new GUIContent("Specific Pickups"), false)) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(m_SpecificModePickupActionsProp.FindPropertyRelative("Array.size")); for (var i = 0; i < m_SpecificModePickupActionsProp.arraySize; ++i) { GUI.SetNextControlName("Pickup " + i); EditorGUILayout.PropertyField(m_SpecificModePickupActionsProp.GetArrayElementAtIndex(i)); } EditorGUI.indentLevel--; } } EditorGUI.EndDisabledGroup(); EditorGUILayout.PropertyField(m_RepeatProp); var previousFocusedPickup = m_FocusedPickup; // Find the currently focused Pickup Action. var focusedControlName = GUI.GetNameOfFocusedControl(); var lastSpace = focusedControlName.LastIndexOf(' '); if (focusedControlName.StartsWith("Pickup") && lastSpace >= 0) { var index = int.Parse(focusedControlName.Substring(lastSpace + 1)); if (index < m_SpecificModePickupActionsProp.arraySize) { m_FocusedPickup = (PickupAction)m_SpecificModePickupActionsProp.GetArrayElementAtIndex(index).objectReferenceValue; } else { m_FocusedPickup = null; } } else { m_FocusedPickup = null; } if (m_FocusedPickup != previousFocusedPickup) { SceneView.RepaintAll(); } }
void PickupAdded(PickupAction pickup) { if (!m_PickupActions.Contains(pickup)) { m_PickupActions.Add(pickup); if (m_Mode == Mode.AllPickups) { Goal++; } OnProgress?.Invoke(); } }
void Update() { if (Input.GetKeyDown(KeyCode.E) && currentlyControlled) { if (carrying) { DropAction da = new DropAction(this); loopTracker.RegisterAction(da); da.PlayAction(); } else { PickupAction pa = new PickupAction(this); loopTracker.RegisterAction(pa); pa.PlayAction(); } } }
//Item pickup, but with a little logic for determining if a UI needs to get involved. private void PickupSmartDetection() { CustomTile tile = Map.current.GetTile(monster.location); Inventory onFloor = tile.GetComponent <Inventory>(); switch (onFloor.Count) { case 0: return; //Exit early case 1: //Use the new pickup action system to just grab whatever is there. //If this breaks, the problem now lies in that file, instead of cluttering Player.cs nextAction = new PickupAction(0); break; default: //Open dialouge box UIController.singleton.OpenInventoryPickup(); break; } }
void PickupCollected(PickupAction pickup) { Progress++; pickup.OnCollected -= PickupCollected; }
public override void HandleInput(PlayerAction action, string inputString) { switch (queuedAction) { case ItemAction.INSPECT: //Break down input into item types foreach (char c in inputString.Where(c => char.IsLetter(c))) { int index = Conversions.NumberingToInt(c); if (index < examinedInventory.capacity && examinedInventory[index] != null) { //Display an item! UIController.singleton.OpenItemInspect(examinedInventory, index); break; } } break; case ItemAction.EQUIP: //Break down input into item types foreach (char c in inputString.Where(c => char.IsLetter(c))) { int index = Conversions.NumberingToInt(c); if (index < examinedInventory.capacity && examinedInventory[index] != null && index >= 0) { //Equip an item! Player.player.SetAction(new EquipAction(index, queuedEquipmentIndex)); ExitAllWindows(); break; } } break; case ItemAction.PICK_UP: case ItemAction.DROP: if (action == PlayerAction.ACCEPT) { //Splitting this up because of the new action system. //TODO: Refactor this bit better List <int> indices = new List <int>(); for (int i = 0; i < selected.Length; i++) { if (selected[i]) { indices.Add(i); } } GameAction act; if (queuedAction == ItemAction.DROP) { act = new DropAction(indices); } else { act = new PickupAction(indices); } Player.player.SetAction(act); ExitAllWindows(); } else { //Flip bits for selected items foreach (char c in inputString.Where(c => char.IsLetter(c))) { //Attempt to flip the bit int index = Conversions.NumberingToInt(c); selected[index] = !selected[index]; for (int i = 0; i < displayed.Count; i++) { ItemPanel current = displayed[i]; if (current.index == index) { current.Select(); break; } } } } break; case ItemAction.APPLY: foreach (char c in inputString.Where(c => char.IsLetter(c))) { int index = Conversions.NumberingToInt(c); if (index < examinedInventory.capacity && examinedInventory[index] != null && index >= 0) { //Equip an item! Player.player.inventory.Apply(index); ExitAllWindows(); break; } } break; } }