static JSONObject RetrieveDescriptionsObject(RenewableTypes renewableType) { TextAsset renewableDescriptionAsset = Resources.Load <TextAsset>(RENEWABLE_DESCRIPTIONS_DIRECTORY_PATH + "/" + renewableType.ToString()); JSONObject renewableDescriptionObject = new JSONObject(renewableDescriptionAsset.text); return(renewableDescriptionObject); }
UnityAction <BaseEventData> GenerateInventoryButtonListener_PointerEnter(RenewableTypes renewableType) { return((data) => { inventoryMenuController.RenewableInventoryMenu_PointerEnter(renewableType); }); }
public void EndDrag() { if (currentDraggingType == GearTypes.Hardware) { if (draggingHardwareType == HardwareType.None) { return; } draggingImage.gameObject.SetActive(false); if (OnStopDraggingHardware != null) { OnStopDraggingHardware(draggingHardwareType); } draggingHardwareType = HardwareType.None; draggingHardwareSubtype = null; } else if (currentDraggingType == GearTypes.Renewable) { if (draggingRenewableType == RenewableTypes.None) { return; } draggingImage.gameObject.SetActive(false); if (OnStopDraggingRenewable != null) { OnStopDraggingRenewable(draggingRenewableType); } draggingRenewableType = RenewableTypes.None; } }
void GenerateRenewable(RenewableTypes newRenewableType) { if (newRenewableType == RenewableTypes.None) { return; } Type newRenewable = GetRenewableType(newRenewableType); equippedRenewable = gameObject.AddComponent(newRenewable) as IRenewable; }
public InventoryData() { ObtainedHardware = new Dictionary <HardwareType, bool>(); ObtainedRenewables = new Dictionary <RenewableTypes, bool>(); DiscoveredHardwareSubtypes = new Dictionary <HardwareType, List <bool> >(); foreach (var value in Enum.GetValues(typeof(HardwareType))) { HardwareType hardwareType = (HardwareType)value; if (hardwareType != HardwareType.None) { ObtainedHardware[hardwareType] = false; DiscoveredHardwareSubtypes[hardwareType] = new List <bool>(3) { false, false, false }; } } foreach (var value in Enum.GetValues(typeof(RenewableTypes))) { RenewableTypes renewableType = (RenewableTypes)value; if (renewableType != RenewableTypes.None) { ObtainedRenewables[renewableType] = false; } } ObtainHardwareType(HardwareType.Parry); ObtainHardwareType(HardwareType.Blink); ObtainRenewableType(RenewableTypes.NoetherFrictionConverter); ObtainRenewableType(RenewableTypes.GravesandeImpulseAdapter); EquippedActiveHardware = new HardwareType[4] { HardwareType.Parry, HardwareType.Blink, HardwareType.None, HardwareType.None }; EquippedActiveSubtypes = new Type[4] { typeof(StandardIssueParryHardwareData), typeof(StandardIssueBlinkHardwareData), null, null }; EquippedPassiveHardware = new HardwareType[4]; EquippedRenewable = RenewableTypes.NoetherFrictionConverter; }
public void BeginDragging(Sprite image, RenewableTypes renewableType) { menuManager.DepopulateInformationText(); currentDraggingType = GearTypes.Renewable; draggingRenewableType = renewableType; draggingImage.sprite = image; draggingImage.preserveAspect = true; draggingImage.gameObject.SetActive(true); OnDraggingHardware(draggingHardwareType); }
void DisplayAndActivateDiscoveredRenewables() { for (int i = 0; i < renewableTypes.Length; i++) { RenewableTypes renewableType = renewableTypes[i]; if (InventoryController.HasDiscoveredRenewable(renewableType)) { Sprite discoverableRenewableBubImage = DataAssociations.GetRenewableTypeBubImage(renewableType); renewableInventoryImages[i].sprite = discoverableRenewableBubImage; EventTrigger trigger = renewableInventoryEventTriggers[i]; AssignDragEventListeners(trigger, discoverableRenewableBubImage, renewableType); } } }
void UpdateAvailability(InventoryData inventory) { for (int i = 0; i < renewableTypes.Length; i++) { RenewableTypes renewableType = renewableTypes[i]; if (inventory.EquippedRenewable == renewableType) { renewableInventoryImages[i].color = Color.grey; } else { renewableInventoryImages[i].color = Color.white; } } }
void UpdateRenewable(ref IRenewable activeRenewable) { RenewableTypes activeRenewableType = activeRenewable.Type; Sprite activeHardwareBubSprite = DataAssociations.GetRenewableTypeBubImage(activeRenewableType); renewableBubImage.sprite = activeHardwareBubSprite; activeRenewable.DurationUpdater = null; activeRenewable.DurationUpdater += GeneratePercentDurationUpdater(); activeRenewable.CooldownPercentUpdater = null; activeRenewable.CooldownPercentUpdater += GenerateCooldownPercentUpdater(); activeRenewable.CooldownDurationUpdater = null; activeRenewable.CooldownDurationUpdater += GenerateCooldownDurationUpdater(); }
public static string GetRenewableDescription(RenewableTypes renewableType) { if (!renewableTypeToDescriptionsMap.ContainsKey(renewableType)) { renewableTypeToDescriptionsMap[renewableType] = RetrieveDescriptionsObject(renewableType); } JSONObject renewableDescriptionObject = renewableTypeToDescriptionsMap[renewableType]; string renewableDescription = renewableDescriptionObject["Body"].str; if (renewableDescription == null) { renewableDescription = "Renewable description not found"; Debug.LogError(renewableDescription); } return(renewableDescription); }
Type GetRenewableType(RenewableTypes renewableType) { switch (renewableType) { case RenewableTypes.None: return(null); case RenewableTypes.NoetherFrictionConverter: return(typeof(NoetherFrictionConverter)); case RenewableTypes.GravesandeImpulseAdapter: return(null); default: return(null); } }
void AssignDragEventListeners(EventTrigger trigger, Sprite bubImage, RenewableTypes renewableType) { // Begin drag listener EventTrigger.Entry beginDragEntry = new EventTrigger.Entry { eventID = EventTriggerType.BeginDrag, }; beginDragEntry.callback.AddListener(GenerateInventoryButtonListener_BeginDrag(bubImage, renewableType)); trigger.triggers.Add(beginDragEntry); // End drag listener EventTrigger.Entry endDragEntry = new EventTrigger.Entry { eventID = EventTriggerType.EndDrag, }; endDragEntry.callback.AddListener(GenerateInventoryButtonListener_EndDrag()); trigger.triggers.Add(endDragEntry); // Point enter listener EventTrigger.Entry pointerEnterEntry = new EventTrigger.Entry { eventID = EventTriggerType.PointerEnter, }; pointerEnterEntry.callback.AddListener(GenerateInventoryButtonListener_PointerEnter(renewableType)); trigger.triggers.Add(pointerEnterEntry); // Point exit listener EventTrigger.Entry pointerExitEntry = new EventTrigger.Entry { eventID = EventTriggerType.PointerExit, }; pointerExitEntry.callback.AddListener(GenerateInventoryButtonListener_PointerExit()); trigger.triggers.Add(pointerExitEntry); }
public static Sprite GetRenewableTypeBubImage(RenewableTypes renewableType) { return(instance.renewableTypeToBubImageMap[renewableType]); }
public static bool HasDiscoveredRenewable(RenewableTypes renewableType) { return(Inventory.ObtainedRenewables[renewableType]); }
public static void DiscoverRenewable(RenewableTypes renewableType) { Inventory.ObtainRenewableType(renewableType); OnInventoryUpdated(Inventory); }
public static void EquipRenewable(RenewableTypes renewable) { Inventory.EquippedRenewable = renewable; }
public void ObtainRenewableType(RenewableTypes renewableType) { ObtainedRenewables[renewableType] = true; }
UnityAction <BaseEventData> GenerateInventoryButtonListener_BeginDrag(Sprite image, RenewableTypes renewableType) { return((data) => { if (InventoryController.Inventory.EquippedRenewable == renewableType) { return; } inventoryMenuController.BeginDragging(image, renewableType); }); }
public void RenewableInventoryMenu_PointerEnter(RenewableTypes renewableType) { string renewableDescription = MasterSerializer.GetRenewableDescription(renewableType); menuManager.PopulateInformationText(renewableType.ToString(), renewableDescription); }