// Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // add menu to scene if it doesn't exist
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.inventoryMenu, true);
            HeroObject    item         = null;
            int           count        = 0;
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.name = HeroKitCommonRuntime.settingsInfo.inventoryMenu.name;
                targetObject.gameObject.SetActive(true);

                // get the container for the inventory slots
                GameObject parent = HeroKitCommonRuntime.GetChildGameObject(targetObject.gameObject, "Inventory Menu Content");
                if (parent != null)
                {
                    // get the item we want to remove
                    item = HeroObjectFieldValue.GetValueC(heroKitObject, 0);
                    if (item != null)
                    {
                        // get the number of items to remove
                        bool addMultiple = BoolValue.GetValue(heroKitObject, 1);
                        count = (addMultiple) ? IntegerFieldValue.GetValueA(heroKitObject, 2) : 1;

                        // check to see if the inventory slot already exists in the menu
                        GameObject    gameObject = HeroKitCommonRuntime.GetChildGameObject(parent, item.name, false);
                        HeroKitObject heroObject = null;

                        // if the item exists, remove it
                        if (gameObject != null)
                        {
                            // get hero kit object
                            if (heroObject == null)
                            {
                                heroObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject);
                            }

                            // add the # of items to add to integer variable list, slot 1
                            heroObject.heroList.ints.items[1].value = count;

                            // play event 2 in the hero kit object attached to this prefab
                            heroObject.PlayEvent(2);
                        }
                    }
                }
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Item: " + item + "\n" +
                                      "Count: " + count;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Exemple #2
0
        public HeroKitObject SetupSaveMenu(string menuTitle, int menuID)
        {
            // add menu to scene if it doesn't exist
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.saveMenu, true);

            targetObject.gameObject.SetActive(true);

            // change title
            string     title       = menuTitle;
            GameObject titleObject = HeroKitCommonRuntime.GetChildGameObject(targetObject.gameObject, "SaveMenuTitle", true);
            Text       titleText   = targetObject.GetGameObjectComponent <Text>("Text", false, titleObject);

            titleText.text = title;

            // add save slots
            GameObject parentObject = HeroKitCommonRuntime.GetChildGameObject(targetObject.gameObject, "Save Menu Content", true);

            if (parentObject.transform.childCount == 0)
            {
                HeroKitObject         saveObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.saveSlot, false);
                DuplicateHeroUIObject dup        = new DuplicateHeroUIObject();
                dup.CreateUIObjects(saveObject.gameObject, parentObject, 20, true, saveObject, 1, 4, true);
            }

            // menu type = save
            HeroKitObject[] children = parentObject.transform.GetComponentsInChildren <HeroKitObject>();
            for (int i = 0; i < children.Length; i++)
            {
                children[i].heroList.ints.items[0].value = menuID;
            }

            return(targetObject);
        }
Exemple #3
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // add menu to scene if it doesn't exist
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.optionsMenu, true);
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.SetActive(true);

                // menu was called from start menu
                bool calledFromStartMenu = BoolValue.GetValue(heroKitObject, 0);
                targetObject.heroList.bools.items[1].value = calledFromStartMenu;

                // enable the canvas
                Canvas canvas = targetObject.GetHeroComponent <Canvas>("Canvas");
                canvas.enabled = true;
            }

            if (heroKitObject.debugHeroObject)
            {
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject));
            }

            return(-99);
        }
Exemple #4
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // add menu to scene if it doesn't exist
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.gameoverMenu, true);
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.SetActive(true);

                // save the scene to load
                UnityObjectField objectData = UnityObjectFieldValue.GetValueA(heroKitObject, 0);
                targetObject.heroList.unityObjects.items[0] = objectData;

                // enable the canvas
                Canvas canvas = targetObject.GetHeroComponent <Canvas>("Canvas");
                canvas.enabled = true;

                // play event 0
                targetObject.PlayEvent(0);
            }

            if (heroKitObject.debugHeroObject)
            {
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject));
            }

            return(-99);
        }
Exemple #5
0
        public void CloseSaveMenu()
        {
            // get the menu
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.saveMenu, true);

            if (targetObject != null)
            {
                // disable the canvas
                Canvas canvas = targetObject.GetHeroComponent <Canvas>("Canvas");
                canvas.enabled = false;
            }
        }
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // add menu to scene if it doesn't exist
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.journalMenu, true);
            HeroObject    item         = null;
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.name = HeroKitCommonRuntime.settingsInfo.journalMenu.name;
                targetObject.gameObject.SetActive(true);

                // get the container for the inventory slots
                GameObject parent = HeroKitCommonRuntime.GetChildGameObject(targetObject.gameObject, "Journal Menu Content");
                if (parent != null)
                {
                    // get the item we want to remove
                    item = HeroObjectFieldValue.GetValueC(heroKitObject, 0);
                    if (item != null)
                    {
                        // check to see if the inventory slot already exists in the menu
                        GameObject gameObject = HeroKitCommonRuntime.GetChildGameObject(parent, item.name, false);

                        // if the item exists, remove it
                        if (gameObject != null)
                        {
                            HeroKitObject heroObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject);

                            // play event 2 in the hero kit object attached to this prefab
                            if (heroObject != null)
                            {
                                heroObject.PlayEvent(2);
                            }
                        }
                    }
                }
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Journal Entry: " + item;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Exemple #7
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // get field values
            startColor = ColorValue.GetValue(heroKitObject, 0);
            speed      = IntegerFieldValue.GetValueA(heroKitObject, 1) * 0.01f;

            // get the fade UI
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.fadeInOutScreen, true);
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.SetActive(true);

                // fade out the scene
                uiColor             = targetObject.GetHeroComponent <UIColor>("UIColor", true);
                uiColor.targetImage = targetObject.GetComponentInChildren <Image>(true);
                uiColor.targetColor = startColor;
                uiColor.startColor  = new Color(0, 0, 0, 0);
                uiColor.speed       = speed;
                uiColor.Initialize();

                // set up update for long action
                eventID = heroKitObject.heroStateData.eventBlock;
                heroKitObject.heroState.heroEvent[eventID].waiting = true;
                updateIsDone = false;
                heroKitObject.longActionsFixed.Add(this);
            }

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Speed: " + speed + "\n" +
                                      "Start Color:" + startColor;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // return value
            return(-99);
        }
Exemple #8
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // add menu to scene if it doesn't exist
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.optionsMenu, true);
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.SetActive(true);
            }

            if (heroKitObject.debugHeroObject)
            {
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject));
            }

            return(-99);
        }
Exemple #9
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // add menu to scene if it doesn't exist
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.startMenu, false);
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                // disable the canvas
                Canvas canvas = targetObject.GetHeroComponent <Canvas>("Canvas");
                canvas.enabled = false;
            }

            if (heroKitObject.debugHeroObject)
            {
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject));
            }

            return(-99);
        }
Exemple #10
0
        // Check to see if an integer meets certain conditions in an if statement
        // This is used by both If and Else If
        public int Execute(HeroKitObject hko)
        {
            // assign variables
            heroKitObject = hko;
            eventID       = heroKitObject.heroStateData.eventBlock;
            int actionID      = heroKitObject.heroStateData.action;
            int currentIndent = heroKitObject.heroState.heroEvent[eventID].actions[actionID].indent;

            // evaluate the if statement
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.startMenu, false);
            bool          evaluation   = false;
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.SetActive(true);

                // enable the canvas
                Canvas canvas = targetObject.GetHeroComponent <Canvas>("Canvas");
                evaluation = canvas.enabled;
            }

            // next we need to get the action that we want the game loop to think just executed
            // this checks to see if the if statement should be run
            // if it should run, it disables the next conditional action if it is "Else" or "Else If"
            int thisAction = HeroActionCommonRuntime.RunConditionalIfAction(heroKitObject, eventID, actionID, currentIndent, evaluation);

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Result: " + evaluation;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // return the action that we want the game loop to think just executed
            return(thisAction);
        }
Exemple #11
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;

            // get common values
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.dialogBox, true);
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.SetActive(true);

                // get the dialog script
                uiDialog                = targetObject.GetHeroComponent <UIDialog>("UIDialog", true);
                uiDialog.textAction     = UIDialog.TextAction.showDialog;
                uiDialog.heroKitObject  = heroKitObject;
                uiDialog.dontHideCanvas = BoolValue.GetValue(heroKitObject, 30);
                uiDialog.eventID        = heroKitObject.heroStateData.eventBlock;
                uiDialog.actionID       = heroKitObject.heroStateData.action;

                // get values for title
                uiDialog.setTitle = BoolValue.GetValue(heroKitObject, 0);
                if (uiDialog.setTitle)
                {
                    uiDialog.title = StringFieldValue.GetValueA(heroKitObject, 1, true);
                    uiDialog.changeTitleAlignment = BoolValue.GetValue(heroKitObject, 26);
                    if (uiDialog.changeTitleAlignment)
                    {
                        uiDialog.titleAlignmentType = DropDownListValue.GetValue(heroKitObject, 27);
                    }
                }

                // get values for message
                uiDialog.message = StringFieldValue.GetValueA(heroKitObject, 2, true);

                // get values for audio
                UnityObjectField unityObjectAudio = UnityObjectFieldValue.GetValueA(heroKitObject, 28, false);
                uiDialog.audioClip = (unityObjectAudio.value != null) ? (AudioClip)unityObjectAudio.value : null;

                // get values for message choices
                uiDialog.addChoices = BoolValue.GetValue(heroKitObject, 21);
                if (uiDialog.addChoices)
                {
                    uiDialog.selectedChoiceID = 29;
                    uiDialog.numberOfChoices  = DropDownListValue.GetValue(heroKitObject, 22);
                    uiDialog.choiceText       = new UnityEngine.UI.Text[3];
                    uiDialog.choice           = new string[uiDialog.numberOfChoices];

                    if (uiDialog.numberOfChoices >= 1)
                    {
                        uiDialog.choice[0] = StringFieldValue.GetValueA(heroKitObject, 23, true);
                    }
                    if (uiDialog.numberOfChoices >= 2)
                    {
                        uiDialog.choice[1] = StringFieldValue.GetValueA(heroKitObject, 24, true);
                    }
                    if (uiDialog.numberOfChoices >= 3)
                    {
                        uiDialog.choice[2] = StringFieldValue.GetValueA(heroKitObject, 25, true);
                    }
                }

                // get values for left portrait
                SetPortraitInfo(0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 31, 32);

                // get values for right portrait
                SetPortraitInfo(1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 33, 34);

                // enable the dialog script
                uiDialog.enabled = true;
                uiDialog.Initialize();

                eventID = heroKitObject.heroStateData.eventBlock;
                heroKitObject.heroState.heroEvent[eventID].waiting = true;
                updateIsDone = false;
                heroKitObject.longActions.Add(this);
            }

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string dialogText   = (uiDialog != null) ? uiDialog.message : "";
                string debugMessage = "Message: " + dialogText;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Exemple #12
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // add menu to scene if it doesn't exist
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.inventoryMenu, true);
            HeroObject    item         = null;
            int           count        = 0;
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.SetActive(true);

                // get the container for the inventory slots
                GameObject parent = HeroKitCommonRuntime.GetChildGameObject(targetObject.gameObject, "Inventory Menu Content");
                if (parent != null)
                {
                    // get the item we want to add
                    item = HeroObjectFieldValue.GetValueC(heroKitObject, 0);
                    if (item != null)
                    {
                        // get the number of items to add
                        bool addMultiple = BoolValue.GetValue(heroKitObject, 1);
                        count = (addMultiple) ? IntegerFieldValue.GetValueA(heroKitObject, 2) : 1;

                        // check to see if the inventory slot already exists in the menu
                        GameObject    gameObject = HeroKitCommonRuntime.GetChildGameObject(parent, item.name, true);
                        HeroKitObject heroObject = null;

                        // add item if it doesn't exist
                        if (gameObject == null)
                        {
                            // get the inventory slot
                            GameObject prefab = HeroKitCommonRuntime.settingsInfo.inventorySlot;
                            if (prefab == null)
                            {
                                Debug.LogError("Can't add prefab because it can't be found. (Inventory Slot)");
                            }

                            // add prefab to parent
                            if (parent != null && prefab != null)
                            {
                                // create the game object
                                gameObject = UnityEngine.Object.Instantiate(prefab, parent.transform);

                                // get the hero kit listener component
                                HeroKitListenerUI heroListener = heroKitObject.GetGameObjectComponent <HeroKitListenerUI>("HeroKitListenerUI", false, gameObject);
                                if (heroListener != null)
                                {
                                    // add item
                                    heroListener.item = item;

                                    // setup notifications
                                    HeroKitObject notifications = HeroObjectFieldValue.GetValueA(heroKitObject, 3)[0];
                                    if (notifications != null)
                                    {
                                        heroListener.sendNotificationsHere = notifications;
                                        heroListener.actionType            = 1;
                                        heroListener.stateID = EventValue.GetStateID(heroKitObject, 4);
                                        heroListener.eventID = EventValue.GetEventID(heroKitObject, 4);
                                    }

                                    // rename the object
                                    gameObject.name = heroListener.item.name;
                                }

                                // get the hero object component
                                heroObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject);
                                if (heroObject != null)
                                {
                                    heroObject.doNotSave = true;
                                    heroObject.heroGUID  = HeroKitCommonRuntime.GetHeroGUID();
                                }

                                // enable the game object
                                gameObject.SetActive(true);
                            }
                        }

                        // if prefab is not active, make it active
                        if (!gameObject.activeSelf)
                        {
                            gameObject.SetActive(true);
                        }

                        // get hero kit object
                        if (heroObject == null)
                        {
                            heroObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject);
                        }

                        // add the # of items to add to integer variable list, slot 1
                        heroObject.heroList.ints.items[1].value = count;

                        // play event 1 in the hero kit object attached to this prefab
                        heroObject.PlayEvent(1);
                    }
                }
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Item: " + item + "\n" +
                                      "Count: " + count;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Exemple #13
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // add menu to scene if it doesn't exist
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.journalMenu, true);
            HeroObject    item         = null;
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.SetActive(true);

                // get the container for the inventory slots
                GameObject parent = HeroKitCommonRuntime.GetChildGameObject(targetObject.gameObject, "Journal Menu Content");
                if (parent != null)
                {
                    // get the item we want to add
                    item = HeroObjectFieldValue.GetValueC(heroKitObject, 0);
                    if (item != null)
                    {
                        // check to see if the inventory slot already exists in the menu
                        GameObject    gameObject = HeroKitCommonRuntime.GetChildGameObject(parent, item.name, true);
                        HeroKitObject heroObject = null;

                        // add item if it doesn't exist
                        if (gameObject == null)
                        {
                            // get the inventory slot
                            GameObject prefab = HeroKitCommonRuntime.settingsInfo.journalSlot;
                            if (prefab == null)
                            {
                                Debug.LogError("Prefab for journal slot is missing. (Journal Slot)");
                            }

                            // add prefab to parent
                            if (parent != null && prefab != null)
                            {
                                // create the game object
                                gameObject = UnityEngine.Object.Instantiate(prefab, parent.transform);

                                // get the hero kit listener component
                                HeroKitListenerUI heroListener = heroKitObject.GetGameObjectComponent <HeroKitListenerUI>("HeroKitListenerUI", false, gameObject);
                                if (heroListener != null)
                                {
                                    // add item
                                    heroListener.item = item;

                                    // rename the object
                                    gameObject.name = heroListener.item.name;
                                }

                                // get the hero object component
                                heroObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject);
                                if (heroObject != null)
                                {
                                    heroObject.doNotSave = true;
                                    heroObject.heroGUID  = HeroKitCommonRuntime.GetHeroGUID();
                                }

                                // enable the game object
                                gameObject.SetActive(true);
                            }

                            // if prefab is not active, make it active
                            if (!gameObject.activeSelf)
                            {
                                gameObject.SetActive(true);
                            }

                            // get hero kit object
                            if (heroObject == null)
                            {
                                heroObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject);
                            }

                            // play event 1 in the hero kit object attached to this prefab
                            heroObject.PlayEvent(1);
                        }
                        else
                        {
                            gameObject.SetActive(true);
                        }
                    }
                }
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Journal Entry: " + item;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }