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); }
// 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); }
// 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); }
// 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); }
// 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); }