Exemple #1
0
        /**
         * <summary>Deletes all item instances that make up a recipe's ingredients</summary>
         * <param name="recipe">The recipe to delete ingredients from</param>
         */
        public void DeleteRecipeIngredients(Recipe recipe)
        {
            if (recipe.useSpecificSlots)
            {
                for (int i = 0; i < recipe.ingredients.Count; i++)
                {
                    int numToRemove = recipe.ingredients[i].Amount;

                    if (i >= 0 && i < invInstances.Count && InvInstance.IsValid(invInstances[i]))
                    {
                        invInstances[i].Count -= numToRemove;
                    }
                }

                Clean();
                PlayerMenus.ResetInventoryBoxes();
            }
            else
            {
                foreach (Ingredient ingredient in recipe.ingredients)
                {
                    int itemIDToRemove = ingredient.ItemID;
                    int numToRemove    = ingredient.Amount;

                    Delete(itemIDToRemove, numToRemove);
                }
            }
        }
Exemple #2
0
 public ActionHelper()
 {
     actionHelperReference = this;
     ObjectInHand          = null;
     HasObjectInHand       = false;
     gameOverMenu          = PlayerMenus.GetMenuWithName("GameOver");
 }
Exemple #3
0
        /**
         * <summary>Deletes all inventory item instances associated with a given inventory item</summary>
         * <param name="itemID">The ID of the inventory item to delete</param>
         */
        public void DeleteAllOfType(int itemID)
        {
            if (KickStarter.inventoryManager == null)
            {
                return;
            }

            InvItem itemToRemove = KickStarter.inventoryManager.GetItem(itemID);

            if (itemToRemove == null)
            {
                return;
            }

            for (int i = 0; i < invInstances.Count; i++)
            {
                if (InvInstance.IsValid(invInstances[i]) && invInstances[i].ItemID == itemID)
                {
                    invInstances[i].Clear();
                }
            }

            Clean();
            PlayerMenus.ResetInventoryBoxes();
        }
        override public float Run()
        {
            if (!string.IsNullOrEmpty(menuName) && !string.IsNullOrEmpty(elementName))
            {
                MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName);
                if (menuElement is MenuInput)
                {
                    MenuInput menuInput = (MenuInput)menuElement;
                    if (setMenuInputBoxSource == SetMenuInputBoxSource.EnteredHere)
                    {
                        menuInput.SetLabel(newLabel);
                    }
                    else if (setMenuInputBoxSource == SetMenuInputBoxSource.FromGlobalVariable)
                    {
                        menuInput.SetLabel(GlobalVariables.GetStringValue(varID));
                    }
                }
                else
                {
                    ACDebug.LogWarning("Cannot find Element '" + elementName + "' within Menu '" + menuName + "'");
                }
            }

            return(0f);
        }
Exemple #5
0
 public void ClickOutput(AC.Menu _menu, MouseState _mouseState)
 {
     if (items.Count > 0)
     {
         if (_mouseState == MouseState.SingleClick)
         {
             if (KickStarter.runtimeInventory.selectedItem == null)
             {
                 // Pick up created item
                 if (activeRecipe.onCreateRecipe == OnCreateRecipe.SelectItem)
                 {
                     KickStarter.runtimeInventory.PerformCrafting(activeRecipe, true);
                 }
                 else if (activeRecipe.onCreateRecipe == OnCreateRecipe.RunActionList)
                 {
                     KickStarter.runtimeInventory.PerformCrafting(activeRecipe, false);
                     if (activeRecipe.invActionList != null)
                     {
                         AdvGame.RunActionListAsset(activeRecipe.invActionList);
                     }
                 }
                 else
                 {
                     KickStarter.runtimeInventory.PerformCrafting(activeRecipe, false);
                 }
             }
         }
         PlayerMenus.ResetInventoryBoxes();
     }
 }
Exemple #6
0
        public override void PreDisplay(int _slot, int languageNumber, bool isActive)
        {
            if (buttonClickType == AC_ButtonClickType.OffsetElementSlot && onlyShowWhenEffective && inventoryBoxTitle != "" && Application.isPlaying)
            {
                if (elementToShift == null)
                {
                    foreach (AC.Menu _menu in PlayerMenus.GetMenus())
                    {
                        if (_menu != null && _menu.elements.Contains(this))
                        {
                            elementToShift = PlayerMenus.GetElementWithName(_menu.title, inventoryBoxTitle);
                            break;
                        }
                    }
                }
                if (elementToShift != null)
                {
                    isVisible = elementToShift.CanBeShifted(shiftInventory);
                }
            }

            fullText = TranslateLabel(label, languageNumber);

            if (uiButton != null)
            {
                UpdateUIElement(uiButton);
                if (uiText != null)
                {
                    uiText.text = fullText;
                }
            }
        }
Exemple #7
0
        public override bool ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState)
        {
            if (KickStarter.stateHandler.gameState == GameState.Cutscene)
            {
                return(false);
            }

            bool clickConsumed = false;

            switch (craftingType)
            {
            case CraftingElementType.Ingredients:
                clickConsumed = HandleDefaultClick(_mouseState, _slot);
                break;

            case CraftingElementType.Output:
                clickConsumed = ClickOutput(_menu, _mouseState);
                break;

            default:
                break;
            }

            PlayerMenus.ResetInventoryBoxes();
            _menu.Recalculate();

            if (clickConsumed)
            {
                base.ProcessClick(_menu, _slot, _mouseState);
                return(true);
            }

            return(false);
        }
Exemple #8
0
        public void HandleDefaultClick(MouseState _mouseState, int _slot)
        {
            if (craftingType == CraftingElementType.Ingredients)
            {
                if (_mouseState == MouseState.SingleClick)
                {
                    if (KickStarter.runtimeInventory.selectedItem == null)
                    {
                        if (GetItem(_slot) != null)
                        {
                            KickStarter.runtimeInventory.TransferCraftingToLocal(GetItem(_slot).recipeSlot, true);
                        }
                    }
                    else
                    {
                        if (GetItem(_slot) != null)
                        {
                            KickStarter.runtimeInventory.TransferCraftingToLocal(GetItem(_slot).recipeSlot, false);
                        }

                        KickStarter.runtimeInventory.TransferLocalToCrafting(KickStarter.runtimeInventory.selectedItem, _slot);
                    }
                }
                else if (_mouseState == MouseState.RightClick)
                {
                    if (KickStarter.runtimeInventory.selectedItem != null)
                    {
                        KickStarter.runtimeInventory.SetNull();
                    }
                }

                PlayerMenus.ResetInventoryBoxes();
            }
        }
Exemple #9
0
        /**
         * <summary>Removes an inventory item from the Container's contents.</summary>
         * <param name = "_id">The ID number of the InvItem to remove</param>
         * <param name = "amount">How many instances of the inventory item to remove</param>
         * <param name = "removeAllInstances">If True, then all instances of the item will be removed. If False, only the first-found will be removed</param>
         */
        public void Remove(int _id, int amount, bool removeAllInstances = false)
        {
            // Reduce "count" by 1 for appropriate ID

            for (int i = 0; i < items.Count; i++)
            {
                ContainerItem item = items[i];
                if (item != null && item.linkedID == _id)
                {
                    if (item.count > 0)
                    {
                        item.count -= amount;
                    }
                    if (item.count < 1)
                    {
                        if (KickStarter.settingsManager.canReorderItems)
                        {
                            items[i] = null;
                        }
                        else
                        {
                            items.Remove(item);
                        }
                    }

                    PlayerMenus.ResetInventoryBoxes();

                    if (!removeAllInstances)
                    {
                        return;
                    }
                }
            }
        }
Exemple #10
0
        /**
         * <summary>Removes an inventory item from the Container's contents.</summary>
         * <param name = "containerItem">A data class with information about the inventory item to remove</param>
         * <param name = "amount">If >0, then that many instances of the inventory item will be removed.</param>
         */
        public void Remove(ContainerItem containerItem, int amount = -1)
        {
            if (containerItem != null)
            {
                for (int i = 0; i < items.Count; i++)
                {
                    if (items[i] == containerItem)
                    {
                        if (amount < 0)
                        {
                            containerItem.count = 0;
                        }
                        else if (containerItem.count > 0)
                        {
                            containerItem.count -= amount;
                        }

                        if (containerItem.count < 1)
                        {
                            if (KickStarter.settingsManager.canReorderItems && i < (items.Count - 1))
                            {
                                containerItem.IsEmpty = true;
                            }
                            else
                            {
                                items.Remove(containerItem);
                            }

                            PlayerMenus.ResetInventoryBoxes();
                        }
                    }
                }
            }
        }
Exemple #11
0
        public void RenameProfile(string newProfileLabel, int profileIndex = -2, bool includeActive = true)
        {
            if (!KickStarter.settingsManager.useProfiles || newProfileLabel.Length == 0)
            {
                return;
            }

            int profileID = KickStarter.options.ProfileIndexToID(profileIndex, includeActive);

            if (profileID == -1)
            {
                Debug.LogWarning("Invalid profile index: " + profileIndex + " - nothing to delete!");
                return;
            }
            else if (profileIndex == -2)
            {
                profileID = Options.GetActiveProfileID();
            }

            if (profileID == GetActiveProfileID())
            {
                optionsData.label = newProfileLabel;
                SavePrefs();
            }
            else if (PlayerPrefs.HasKey(GetPrefKeyName(profileID)))
            {
                OptionsData tempOptionsData = LoadPrefsFromID(profileID, false);
                tempOptionsData.label = newProfileLabel;
                SavePrefsToID(profileID, tempOptionsData, true);
            }

            PlayerMenus.RecalculateAll();
        }
        public override void AssignValues(List <ActionParameter> parameters)
        {
            if (useActive)
            {
                runtimeContainer = KickStarter.playerInput.activeContainer;
            }
            else
            {
                runtimeContainer = AssignFile <Container> (parameters, parameterID, constantID, container);
            }

            if (!useActive && setElement && !string.IsNullOrEmpty(menuName) && !string.IsNullOrEmpty(containerElementName))
            {
                string runtimeMenuName             = AssignString(parameters, menuParameterID, menuName);
                string runtimeContainerElementName = AssignString(parameters, elementParameterID, containerElementName);

                runtimeMenuName             = AdvGame.ConvertTokens(runtimeMenuName, Options.GetLanguage(), localVariables, parameters);
                runtimeContainerElementName = AdvGame.ConvertTokens(runtimeContainerElementName, Options.GetLanguage(), localVariables, parameters);

                MenuElement element = PlayerMenus.GetElementWithName(runtimeMenuName, runtimeContainerElementName);
                if (element != null)
                {
                    runtimeInventoryBox = element as MenuInventoryBox;
                }
            }
        }
Exemple #13
0
        override public bool CheckCondition()
        {
            AC.Menu _menu = PlayerMenus.GetMenuWithName(menuToCheck);
            if (_menu != null)
            {
                if (checkType == MenuCheckType.MenuIsVisible)
                {
                    return(_menu.IsVisible());
                }
                else if (checkType == MenuCheckType.MenuIsLocked)
                {
                    return(_menu.isLocked);
                }
                else if (checkType == MenuCheckType.ElementIsVisible)
                {
                    MenuElement _element = PlayerMenus.GetElementWithName(menuToCheck, elementToCheck);
                    if (_element != null)
                    {
                        return(_element.IsVisible);
                    }
                }
            }

            return(false);
        }
Exemple #14
0
        override public float Run()
        {
            if (KickStarter.runtimeInventory)
            {
                if (!setAmount)
                {
                    amount = 1;
                }

                int _playerID = -1;

                if (KickStarter.settingsManager.playerSwitching == PlayerSwitching.Allow && !KickStarter.settingsManager.shareInventory && setPlayer)
                {
                    _playerID = playerID;
                }

                if (invAction == InvAction.Add)
                {
                    KickStarter.runtimeInventory.Add(invID, amount, false, _playerID, addToFront);
                }
                else if (invAction == InvAction.Remove)
                {
                    KickStarter.runtimeInventory.Remove(invID, amount, setAmount, _playerID);
                }
                else if (invAction == InvAction.Replace)
                {
                    KickStarter.runtimeInventory.Replace(invID, invIDReplace, amount);
                }

                PlayerMenus.ResetInventoryBoxes();
            }

            return(0f);
        }
        public static void SetGameEngine(GameObject _gameEngine = null)
        {
            if (_gameEngine != null)
            {
                gameEnginePrefab = _gameEngine;

                menuSystemComponent        = null;
                playerCursorComponent      = null;
                playerInputComponent       = null;
                playerInteractionComponent = null;
                playerMovementComponent    = null;
                playerMenusComponent       = null;
                playerQTEComponent         = null;
                kickStarterComponent       = null;
                sceneSettingsComponent     = null;
                dialogComponent            = null;
                menuPreviewComponent       = null;
                navigationManagerComponent = null;
                actionListManagerComponent = null;
                localVariablesComponent    = null;
                eventManagerComponent      = null;

                return;
            }

            if (gameEnginePrefab == null)
            {
                SceneSettings sceneSettings = UnityVersionHandler.GetKickStarterComponent <SceneSettings>();
                if (sceneSettings != null)
                {
                    gameEnginePrefab = sceneSettings.gameObject;
                }
            }
        }
        public override float Run()
        {
            if (!string.IsNullOrEmpty(menuName))
            {
                Menu menu = PlayerMenus.GetMenuWithName(menuName);
                if (menu != null)
                {
                    if (selectFirstVisible)
                    {
                        GameObject elementObject = menu.GetObjectToSelect();
                        if (elementObject != null)
                        {
                            KickStarter.playerMenus.SelectUIElement(elementObject);
                        }
                    }
                    else if (!string.IsNullOrEmpty(elementName))
                    {
                        MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName);
                        if (menuElement != null)
                        {
                            menu.Select(elementName, slotIndex);
                        }
                    }
                }
            }

            return(0f);
        }
Exemple #17
0
        private void StartDrag(AC.Menu _menu)
        {
            menuToDrag = _menu;

            if (dragType == DragElementType.SingleElement)
            {
                if (elementName != "")
                {
                    MenuElement element = PlayerMenus.GetElementWithName(_menu.title, elementName);
                    if (element == null)
                    {
                        ACDebug.LogWarning("Cannot drag " + elementName + " as it cannot be found on " + _menu.title);
                    }
                    else if (element.positionType == AC_PositionType2.Aligned)
                    {
                        ACDebug.LogWarning("Cannot drag " + elementName + " as its Position is set to Aligned");
                    }
                    else if (_menu.sizeType == AC_SizeType.Automatic)
                    {
                        ACDebug.LogWarning("Cannot drag " + elementName + " as its parent Menu's Size is set to Automatic");
                    }
                    else
                    {
                        elementToDrag     = element;
                        dragStartPosition = elementToDrag.GetDragStart();
                    }
                }
            }
            else
            {
                dragStartPosition = _menu.GetDragStart();
            }
        }
Exemple #18
0
        override public void Skip()
        {
            AC.Menu _menu = PlayerMenus.GetMenuWithName(_menuToChange);

            if (_menu != null)
            {
                if (changeType == MenuChangeType.TurnOnMenu)
                {
                    if (_menu.appearType == AppearType.Manual || _menu.appearType == AppearType.OnInputKey)
                    {
                        _menu.TurnOn(false);
                    }
                }
                else if (changeType == MenuChangeType.TurnOffMenu)
                {
                    if (_menu.appearType == AppearType.Manual || _menu.appearType == AppearType.OnInputKey || _menu.appearType == AppearType.OnContainer)
                    {
                        _menu.ForceOff();
                    }
                }
                else if (changeType == MenuChangeType.LockMenu)
                {
                    _menu.isLocked = true;
                    _menu.ForceOff();
                }
                else
                {
                    RunInstant(_menu);
                }
            }
        }
 override public void Skip()
 {
     KickStarter.playerQTE.SkipQTE();
     if (menuName != "")
     {
         PlayerMenus.GetMenuWithName(menuName).TurnOff(true);
     }
 }
 /**
  * <summary>Removes a Document from the Player's own collection</summary>
  * <param name = "document">The Document to remove</param>
  */
 public void RemoveFromCollection(Document document)
 {
     if (collectedDocuments.Contains(document.ID))
     {
         collectedDocuments.Remove(document.ID);
         PlayerMenus.ResetInventoryBoxes();
     }
 }
 /**
  * <summary>Adds a Document to the Player's own collection</summary>
  * <param name = "document">The Document to add</param>
  */
 public void AddToCollection(Document document)
 {
     if (!collectedDocuments.Contains(document.ID))
     {
         collectedDocuments.Add(document.ID);
         PlayerMenus.ResetInventoryBoxes();
     }
 }
Exemple #22
0
 public override void Skip()
 {
     KickStarter.playerQTE.SkipQTE();
     if (!string.IsNullOrEmpty(menuName))
     {
         PlayerMenus.GetMenuWithName(menuName).TurnOff(true);
     }
 }
Exemple #23
0
    // Start is called before the first frame update
    void Start()
    {
        this.inventoryMenu = PlayerMenus.GetMenuWithName("Inventory");
        this.lblAction     = PlayerMenus.GetElementWithName("Inventory", "lblAction") as MenuLabel;
        GameObject navCam = GameObject.Find("NavCam 1");

        Debug.Log(navCam);
        this.followCamera2D = navCam.GetComponent <GameCamera2D>();
    }
Exemple #24
0
 // Start is called before the first frame update
 void Start()
 {
     //Debug.Log(Input.GetJoystickNames()[0]);
     this.interactionMenu = PlayerMenus.GetMenuWithName("Interaction2");
     this.inventoryMenu   = PlayerMenus.GetMenuWithName("Inventory");
     this.hotspotNameMenu = PlayerMenus.GetMenuWithName("Hotspot");
     //this.dragObject = GameObject.Find("BoxDraggable").GetComponent<Moveable_Drag>();
     //KickStarter.playerInput.InputGetButtonDownDelegate = CustomGetButtonDown;
 }
Exemple #25
0
        /**
         * <summary>Deletes a set number of inventory item instances at a given index</summary>
         * <param name="index">The index to delete from</param>
         * <param name="amount">The amount to delete</param>
         */
        public void DeleteAtIndex(int index, int amount)
        {
            if (index > 0 && index < invInstances.Count && InvInstance.IsValid(invInstances[index]))
            {
                invInstances[index].Clear(amount);

                Clean();
                PlayerMenus.ResetInventoryBoxes();
            }
        }
 private void ProcessReturn(string input, string menuName)
 {
     if (input == "KeypadEnter" || input == "Return" || input == "Enter")
     {
         if (linkedButton != "" && menuName != "")
         {
             PlayerMenus.SimulateClick(menuName, PlayerMenus.GetElementWithName(menuName, linkedButton), 1);
         }
     }
 }
Exemple #27
0
        /**
         * <summary>Deletes a given inventory item instance, provided it is a part of this collection</summary>
         * <param name="invInstance">The inventory item instance to delete</param>
         * <param name="amount">The amount to delete</param>
         */
        public void Delete(InvInstance invInstance, int amount)
        {
            if (invInstances.Contains(invInstance))
            {
                invInstance.Clear(amount);

                Clean();
                PlayerMenus.ResetInventoryBoxes();
            }
        }
        /**
         * Restores the menu and cursor systems to their former states, after taking a screenshot.
         */
        public void PostScreenshotBackup()
        {
            menuIsOff   = originalMenuState;
            cursorIsOff = originalCursorState;

            foreach (Menu menu in PlayerMenus.GetMenus())
            {
                menu.PostScreenshotBackup();
            }
        }
Exemple #29
0
        /**
         * <summary>Adds an inventory item to the Container's contents.</summary>
         * <param name = "_id">The ID number of the InvItem to add</param>
         * <param name = "amount">How many instances of the inventory item to add</param>
         * <returns>True if the addition was succesful</returns>
         */
        public bool Add(int _id, int amount)
        {
            InvItem itemToAdd = KickStarter.inventoryManager.GetItem(_id);

            if (itemToAdd != null)
            {
                if (itemToAdd.canCarryMultiple && !itemToAdd.useSeparateSlots)
                {
                    // Raise "count" by amount for appropriate ID
                    foreach (ContainerItem containerItem in items)
                    {
                        if (containerItem != null && containerItem.linkedID == _id)
                        {
                            containerItem.count += amount;
                            PlayerMenus.ResetInventoryBoxes();
                            return(true);
                        }
                    }
                }

                // Not already carrying the item
                if (limitToCategory && !categoryIDs.Contains(itemToAdd.binID))
                {
                    return(false);
                }

                if (!itemToAdd.canCarryMultiple)
                {
                    amount = 1;
                }

                ContainerItem containerItemToAdd = new ContainerItem(_id, amount, GetIDArray());
                if (KickStarter.settingsManager.canReorderItems)
                {
                    // Try to find empty slot
                    for (int i = 0; i < items.Count; i++)
                    {
                        if (items[i].IsEmpty)
                        {
                            items[i] = containerItemToAdd;
                            PlayerMenus.ResetInventoryBoxes();

                            return(true);
                        }
                    }
                }

                items.Add(containerItemToAdd);
                PlayerMenus.ResetInventoryBoxes();

                return(true);
            }
            return(false);
        }
Exemple #30
0
        override public float Run()
        {
            if (duration <= 0f || inputName == "")
            {
                isRunning = false;
                return(0f);
            }

            if (!isRunning)
            {
                isRunning = true;

                Animator animator = null;
                if (menuName != "")
                {
                    AC.Menu menu = PlayerMenus.GetMenuWithName(menuName);
                    menu.TurnOn(true);
                    if (menu.canvas != null && menu.canvas.GetComponent <Animator>())
                    {
                        animator = menu.canvas.GetComponent <Animator>();
                    }
                }

                if (qteType == QTEType.SingleKeypress)
                {
                    KickStarter.playerQTE.StartQTE(inputName, duration, animator, wrongKeyFails);
                }
                else if (qteType == QTEType.HoldKey)
                {
                    KickStarter.playerQTE.StartQTE(inputName, duration, holdDuration, animator, wrongKeyFails);
                }
                else if (qteType == QTEType.ButtonMash)
                {
                    KickStarter.playerQTE.StartQTE(inputName, duration, targetPresses, doCooldown, cooldownTime, animator, wrongKeyFails);
                }

                return(defaultPauseTime);
            }
            else
            {
                if (KickStarter.playerQTE.GetState() == QTEState.None)
                {
                    return(defaultPauseTime);
                }

                if (menuName != "")
                {
                    PlayerMenus.GetMenuWithName(menuName).TurnOff(true);
                }

                isRunning = false;
                return(0f);
            }
        }