// 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); }
// Gets objects in a scene that match a certerin criteria public int Execute(HeroKitObject hko) { // Get variables heroKitObject = hko; eventID = hko.heroStateData.eventBlock; // get the source object GameObject sourceGameObject = heroKitObject.heroState.heroEvent[eventID].messenger; HeroKitObject sourceHeroObject = null; bool runThis = (sourceGameObject != null); // get the hero object if (runThis) { sourceHeroObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, sourceGameObject); List <HeroKitObject> heroObjectList = new List <HeroKitObject>(); heroObjectList.Add(sourceHeroObject); // save hero object HeroObjectFieldValue.SetValueB(heroKitObject, 0, heroObjectList); } //----------------------------------------- // debugging stuff //----------------------------------------- if (heroKitObject.debugHeroObject) { string debugMessage = "Hero Object: " + sourceHeroObject; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
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); }
public void CreateUIObjects(GameObject prefabObject, GameObject contentObject, int objectCount, bool incrementID, HeroKitObject notificationObject, int stateID, int eventID, bool selfNotify) { GameObject prefab = prefabObject; GameObject parent = contentObject; int count = objectCount; for (int i = 0; i < count; i++) { // create the game object GameObject gameObject = UnityEngine.Object.Instantiate(prefab, parent.transform); gameObject.name = prefab.name + " " + (i + 1); HeroKitObject hko = gameObject.GetComponent <HeroKitObject>(); // get the hero kit listener component HeroKitListenerUI heroListener = hko.GetGameObjectComponent <HeroKitListenerUI>("HeroKitListenerUI", false, gameObject); if (heroListener != null) { // increment item id? if (incrementID) { heroListener.itemID = (i + 1); } // setup notifications HeroKitObject notifications = (selfNotify) ? hko : notificationObject; if (notifications != null) { heroListener.sendNotificationsHere = notifications; heroListener.actionType = 1; heroListener.stateID = stateID; heroListener.eventID = eventID; } } // get the hero object component HeroKitObject heroObject = hko.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject); if (heroObject != null) { heroObject.doNotSave = true; heroObject.heroGUID = HeroKitCommonRuntime.GetHeroGUID(); } gameObject.SetActive(true); } }
// Execute the action public int Execute(HeroKitObject hko) { // get values heroKitObject = hko; String imageGroupPrefabName = "HeroKit Image Canvas"; String imagePrefabName = "HeroKit Image Sprite"; int imageID = IntegerFieldValue.GetValueA(heroKitObject, 0); int speed = IntegerFieldValue.GetValueA(heroKitObject, 1); float scale = IntegerFieldValue.GetValueA(heroKitObject, 2) * 0.01f; wait = BoolValue.GetValue(heroKitObject, 3); HeroKitObject targetObject = null; Vector3 currentScale = new Vector3(); Vector3 targetScale = new Vector3(); // get the game object that contains the images GameObject imageGroup = GetImageGroup(imageGroupPrefabName); if (imageGroup != null) { // get the game object that contains the image GameObject imageObject = GetImage(imagePrefabName, imageID, imageGroup); if (imageObject != null) { // get the hero kit object targetObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, imageObject); // get the current position currentScale = targetObject.transform.localScale; targetScale = new Vector3(scale, scale, targetObject.transform.localScale.z); } } // pan the camera uiScale = targetObject.GetHeroComponent <UIScale>("UIScale", true); uiScale.targetScale = targetScale; uiScale.speed = speed; uiScale.Initialize(); // set up update for long action eventID = heroKitObject.heroStateData.eventBlock; heroKitObject.heroState.heroEvent[eventID].waiting = wait; updateIsDone = false; heroKitObject.longActions.Add(this); // debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Image ID: " + imageID + "\n" + "Scale: " + scale * 100 + "\n" + "Speed: " + speed; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Gets objects in a scene that match a certerin criteria public int Execute(HeroKitObject hko) { // Get variables heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); HeroKitListenerUI listener = null; if (objectData.heroKitObject != null) { listener = objectData.heroKitObject[0].GetHeroComponent <HeroKitListenerUI>("HeroKitListenerUI"); } else if (objectData.gameObject != null) { listener = heroKitObject.GetGameObjectComponent <HeroKitListenerUI>("HeroKitListenerUI", false, objectData.gameObject[0]); } if (listener != null) { // get item id bool getItemID = BoolValue.GetValue(heroKitObject, 2); if (getItemID) { listener.itemID = IntegerFieldValue.GetValueA(heroKitObject, 3); } // get item bool getItem = BoolValue.GetValue(heroKitObject, 9); if (getItem) { listener.item = HeroObjectFieldValue.GetValueC(heroKitObject, 10); } // get hero kit object, state, and event to play bool getEvent = BoolValue.GetValue(heroKitObject, 6); if (getEvent) { listener.sendNotificationsHere = HeroObjectFieldValue.GetValueA(heroKitObject, 7)[0]; listener.stateID = EventValue.GetStateID(heroKitObject, 8); listener.eventID = EventValue.GetEventID(heroKitObject, 8); } } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string debugMessage = "Listener: " + listener; 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); }
// Gets objects in a scene that match a certerin criteria public int Execute(HeroKitObject hko) { // Get variables heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); HeroKitListenerUI listener = null; if (objectData.heroKitObject != null) { listener = objectData.heroKitObject[0].GetHeroComponent <HeroKitListenerUI>("HeroKitListenerUI"); } else if (objectData.gameObject != null) { listener = heroKitObject.GetGameObjectComponent <HeroKitListenerUI>("HeroKitListenerUI", false, objectData.gameObject[0]); } if (listener != null) { // get item id bool getItemID = BoolValue.GetValue(heroKitObject, 2); if (getItemID) { IntegerFieldValue.SetValueB(heroKitObject, 3, listener.itemID); } // get item id bool getItem = BoolValue.GetValue(heroKitObject, 4); if (getItem) { HeroObjectFieldValue.SetValueC(heroKitObject, 5, listener.item); } } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string debugMessage = "Hero Kit Listener: " + listener; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get field values Camera camera = CameraFieldValue.GetValue(heroKitObject, 0, 4); int speed = IntegerFieldValue.GetValueA(heroKitObject, 1); int magnitude = IntegerFieldValue.GetValueA(heroKitObject, 2); int time = IntegerFieldValue.GetValueA(heroKitObject, 3); bool runThis = (camera != null); // make sure object is a camera if (runThis) { // shake the camera cameraShake = heroKitObject.GetGameObjectComponent <CameraShake>("CameraShake", true, camera.gameObject); cameraShake.speed = speed; cameraShake.magnitude = magnitude; cameraShake.time = time; cameraShake.Initialize(); // set up update for long action eventID = heroKitObject.heroStateData.eventBlock; heroKitObject.heroState.heroEvent[eventID].waiting = true; updateIsDone = false; heroKitObject.longActions.Add(this); } // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Camera: " + camera + "\n" + "Magnitude: " + magnitude + "\n" + "Speed: " + speed + "\n" + "Speed: " + speed; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } // return value return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); bool showCanvas = BoolFieldValue.GetValueA(heroKitObject, 2); Canvas canvas = null; // object is hero object if (objectData.heroKitObject != null) { canvas = objectData.heroKitObject[0].GetHeroComponent <Canvas>("Canvas"); } // object is game object else if (objectData.gameObject != null) { canvas = heroKitObject.GetGameObjectComponent <Canvas>("Canvas", false, objectData.gameObject[0]); } if (canvas != null) { canvas.enabled = showCanvas; } else { Debug.LogError("Can't toggle canvas. There is no canvas attached to this game object."); } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string strGO = (canvas != null) ? canvas.gameObject.name : ""; string debugMessage = "Game Object: " + strGO; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, 2); Sprite sprite = (unityObject.value != null) ? (Sprite)unityObject.value : null; Image image = null; // object is hero object if (objectData.heroKitObject != null) { image = objectData.heroKitObject[0].GetHeroComponent <Image>("Image"); } // object is game object else if (objectData.gameObject != null) { image = heroKitObject.GetGameObjectComponent <Image>("Image", false, objectData.gameObject[0]); } if (image != null) { image.sprite = sprite; } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string strImage = (image != null) ? image.gameObject.name : ""; string strSprite = (image != null && image.sprite != null) ? image.sprite.name : ""; string debugMessage = "Game Object: " + strImage + "\n" + "Image: " + strSprite; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); Slider slider = null; // object is hero kit object if (objectData.heroKitObject != null) { slider = objectData.heroKitObject[0].GetHeroComponent <Slider>("Slider"); } // object is game object else if (objectData.gameObject != null) { slider = heroKitObject.GetGameObjectComponent <Slider>("Slider", false, objectData.gameObject[0]); } if (slider != null) { IntegerFieldValue.SetValueB(heroKitObject, 2, (int)slider.value); } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string strGO = (slider != null) ? slider.gameObject.name : ""; string strValue = (slider != null) ? slider.value.ToString() : ""; string debugMessage = "Game Object: " + strGO + "\n" + "Value: " + strValue; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); bool value = BoolFieldValue.GetValueA(heroKitObject, 2); Toggle toggle = null; // object is hero object if (objectData.heroKitObject != null) { toggle = objectData.heroKitObject[0].GetHeroComponent <Toggle>("Toggle"); } // object is game object else if (objectData.gameObject != null) { toggle = heroKitObject.GetGameObjectComponent <Toggle>("Toggle", false, objectData.gameObject[0]); } if (toggle != null) { toggle.isOn = value; } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string strGO = (toggle != null) ? toggle.gameObject.name : ""; string debugMessage = "Game Object: " + strGO + "\n" + "Value: " + value; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); string stringForText = StringFieldValue.GetValueA(heroKitObject, 2, true); Text text = null; // object is hero object if (objectData.heroKitObject != null) { text = objectData.heroKitObject[0].GetHeroComponent <Text>("Text"); } // object is game object else if (objectData.gameObject != null) { text = heroKitObject.GetGameObjectComponent <Text>("Text", false, objectData.gameObject[0]); } if (text != null) { text.text = stringForText; } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string strGO = (text != null) ? text.gameObject.name : ""; string debugMessage = "Game Object: " + strGO + "\n" + "Text: " + stringForText; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get field values Camera camera = CameraFieldValue.GetValue(heroKitObject, 0, 1); bool runThis = (camera != null); if (runThis) { CameraController cameraController = heroKitObject.GetGameObjectComponent <CameraController>("CameraController", true, camera.gameObject); cameraController.enabled = false; } // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Camera: " + camera; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { // get values heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); Font font = ObjectValue.GetValue <Font>(heroKitObject, 2); // get the text box Text text = null; if (objectData.heroKitObject != null) { text = objectData.heroKitObject[0].GetHeroComponent <Text>("Text"); } else if (objectData.gameObject != null) { text = heroKitObject.GetGameObjectComponent <Text>("Text", false, objectData.gameObject[0]); } // change the font if (text != null) { text.font = font; } // show debug message if (heroKitObject.debugHeroObject) { string textName = (text != null) ? text.gameObject.name : ""; string debugMessage = "Font: " + font + "Text Object: " + textName; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); float value = FloatFieldValue.GetValueA(heroKitObject, 2); Slider slider = null; // object is hero kit object if (objectData.heroKitObject != null) { slider = objectData.heroKitObject[0].GetHeroComponent <Slider>("Slider"); } // object is game object else if (objectData.gameObject != null) { slider = heroKitObject.GetGameObjectComponent <Slider>("Slider", false, objectData.gameObject[0]); } if (slider != null) { slider.value = value; } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string debugMessage = "Value: " + value; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { // get values heroKitObject = hko; String imageGroupPrefabName = "HeroKit Image Canvas"; String imagePrefabName = "HeroKit Image Sprite"; int imageID = IntegerFieldValue.GetValueA(heroKitObject, 0); int speed = IntegerFieldValue.GetValueA(heroKitObject, 1); Color targetColor = ColorValue.GetValue(heroKitObject, 2); wait = BoolValue.GetValue(heroKitObject, 3); HeroKitObject targetObject = null; Image targetImage = null; Color currentColor = new Color(); // get the game object that contains the images GameObject imageGroup = GetImageGroup(imageGroupPrefabName); if (imageGroup != null) { // get the game object that contains the image GameObject imageObject = GetImage(imagePrefabName, imageID, imageGroup); if (imageObject != null) { // get the hero kit object targetObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, imageObject); // get the image component on the game object targetImage = heroKitObject.GetGameObjectComponent <Image>("Image", false, imageObject); if (targetImage != null) { currentColor = targetImage.color; } } } // pan the camera uiColor = targetObject.GetHeroComponent <UIColor>("UIColor", true); uiColor.targetImage = targetImage; uiColor.targetColor = targetColor; uiColor.startColor = targetImage.color; uiColor.speed = speed; uiColor.Initialize(); // set up update for long action eventID = heroKitObject.heroStateData.eventBlock; heroKitObject.heroState.heroEvent[eventID].waiting = wait; updateIsDone = false; heroKitObject.longActions.Add(this); // debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Image ID: " + imageID + "\n" + "Target Image: " + targetImage + "\n" + "Target Color: " + targetColor + "\n" + "Speed: " + speed; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get field values int smoothing = 5; float posY = 0; float posX = 0; float size = 5; // get the object to follow HeroKitObject targetObject = HeroObjectFieldValue.GetValueA(heroKitObject, 1)[0]; // get the camera Camera camera = CameraFieldValue.GetValue(heroKitObject, 0, 11); // change settings if (BoolValue.GetValue(heroKitObject, 2)) { // change smoothing if (BoolValue.GetValue(heroKitObject, 3)) { smoothing = IntegerFieldValue.GetValueA(heroKitObject, 4); } // change Z pos if (BoolValue.GetValue(heroKitObject, 5)) { posX = FloatFieldValue.GetValueA(heroKitObject, 6); } // change Y pos if (BoolValue.GetValue(heroKitObject, 7)) { posY = FloatFieldValue.GetValueA(heroKitObject, 8); } // change size of viewport if (BoolValue.GetValue(heroKitObject, 9)) { size = FloatFieldValue.GetValueA(heroKitObject, 10); } } bool runThis = (camera != null && targetObject != null); if (runThis) { // change perspective to "orthographic" camera.orthographic = true; camera.orthographicSize = size; // set up the camera CameraController cameraController = heroKitObject.GetGameObjectComponent <CameraController>("CameraController", true, camera.gameObject); cameraController.targetObject = targetObject; cameraController.smoothing = smoothing; cameraController.defaultPos = new Vector3(posX, posY, -10); cameraController.defaultAngles = new Vector3(0, 0, 0); cameraController.firstPerson = false; cameraController.Initialize(); } // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Camera: " + camera; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { // get values heroKitObject = hko; String imageGroupPrefabName = "HeroKit Image Canvas"; String imagePrefabName = "HeroKit Image Sprite"; int imageID = IntegerFieldValue.GetValueA(heroKitObject, 0); // get the game object that contains the images GameObject imageGroup = AddImageGroup(imageGroupPrefabName); if (imageGroup != null) { // get the game object that contains the image GameObject targetObject = AddImage(imagePrefabName, imageID, imageGroup); if (targetObject != null) { // get the image component on the game object Image image = heroKitObject.GetGameObjectComponent <Image>("Image", false, targetObject); if (image != null) { bool changeSprite = BoolValue.GetValue(heroKitObject, 1); if (changeSprite) { UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, 2); Sprite sprite = (unityObject.value != null) ? (Sprite)unityObject.value : null; image.sprite = sprite; RectTransform rectTransform = heroKitObject.GetGameObjectComponent <RectTransform>("RectTransform", false, image.gameObject); rectTransform.sizeDelta = new Vector2(sprite.rect.width, sprite.rect.height); rectTransform.localPosition = new Vector3(); } bool flipSprite = BoolValue.GetValue(heroKitObject, 3); if (flipSprite) { Vector3 eulerAngles = new Vector3(); eulerAngles = image.transform.eulerAngles; eulerAngles.y += 180f; image.transform.eulerAngles = eulerAngles; } bool changeScale = BoolValue.GetValue(heroKitObject, 4); if (changeScale) { float newScale = FloatFieldValue.GetValueA(heroKitObject, 5); image.transform.localScale = new Vector3(newScale, newScale, newScale) * 0.01f; } bool changeXPos = BoolValue.GetValue(heroKitObject, 6); if (changeXPos) { float xPos = FloatFieldValue.GetValueA(heroKitObject, 7); image.transform.localPosition = new Vector3(xPos, image.transform.localPosition.y, image.transform.localPosition.z); } bool changeYPos = BoolValue.GetValue(heroKitObject, 8); if (changeYPos) { float yPos = FloatFieldValue.GetValueA(heroKitObject, 9); image.transform.localPosition = new Vector3(image.transform.localPosition.x, yPos, image.transform.localPosition.z); } } // change the color (alpha = transparent if image is null) Color color = image.color; color.a = (image.sprite == null) ? color.a = 0 : color.a = 1; image.color = color; // enable the game object targetObject.SetActive(true); } } // debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Image ID: " + imageID; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); endAlpha = SliderValue.GetValue(heroKitObject, 2) * 0.01f; duration = (float)(IntegerFieldValue.GetValueA(heroKitObject, 3) * 0.10); wait = BoolValue.GetValue(heroKitObject, 4); Canvas canvas = null; // object is hero object if (objectData.heroKitObject != null) { canvas = objectData.heroKitObject[0].GetHeroComponent <Canvas>("Canvas"); if (canvas != null) { canvasGroup = objectData.heroKitObject[0].GetHeroComponent <CanvasGroup>("CanvasGroup", true); } else { Debug.LogError("Can't change alpha because this game object does not have a Canvas component attached to it."); return(-99); } } // object is game object else if (objectData.gameObject != null) { canvas = heroKitObject.GetGameObjectComponent <Canvas>("Canvas", false, objectData.gameObject[0]); if (canvas != null) { canvasGroup = heroKitObject.GetGameObjectComponent <CanvasGroup>("CanvasGroup", true, objectData.gameObject[0]); } else { Debug.LogError("Can't change alpha because this game object does not have a Canvas component attached to it."); return(-99); } } if (canvasGroup.alpha != endAlpha) { startAlpha = canvasGroup.alpha; // set up update for long action heroKitObject.heroState.heroEvent[eventID].waiting = wait; updateIsDone = false; heroKitObject.longActionsFixed.Add(this); } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string strCanvas = (canvas != null) ? canvas.gameObject.name : ""; string debugMessage = "Canvas: " + strCanvas + "\n" + "Alpha: " + endAlpha + "\n" + "Duration: " + duration; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { // get values heroKitObject = hko; String imageGroupPrefabName = "HeroKit Image Canvas"; String imagePrefabName = "HeroKit Image Sprite"; int degrees = 0; int duration = 0; int imageID = IntegerFieldValue.GetValueA(heroKitObject, 0); int speed = IntegerFieldValue.GetValueA(heroKitObject, 1); int rotationType = DropDownListValue.GetValue(heroKitObject, 2); if (rotationType == 1) { degrees = IntegerFieldValue.GetValueA(heroKitObject, 3); } else if (rotationType == 2 || rotationType == 3) { duration = IntegerFieldValue.GetValueA(heroKitObject, 4); } wait = BoolValue.GetValue(heroKitObject, 5); HeroKitObject targetObject = null; // get the game object that contains the images GameObject imageGroup = GetImageGroup(imageGroupPrefabName); if (imageGroup != null) { // get the game object that contains the image GameObject imageObject = GetImage(imagePrefabName, imageID, imageGroup); if (imageObject != null) { // get the hero kit object targetObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, imageObject); } } // rotate the image uiRotate = targetObject.GetHeroComponent <UIRotate>("UIRotate", true); uiRotate.rotationType = rotationType; uiRotate.speed = speed; uiRotate.degrees = degrees; uiRotate.duration = duration; uiRotate.Initialize(); // set up update for long action eventID = heroKitObject.heroStateData.eventBlock; heroKitObject.heroState.heroEvent[eventID].waiting = wait; updateIsDone = false; heroKitObject.longActions.Add(this); // debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Image ID: " + imageID + "\n" + "Degrees: " + degrees + "\n" + "Duration: " + duration + "\n" + "Speed: " + speed; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get the camera Camera camera = CameraFieldValue.GetValue(heroKitObject, 0, 11); Vector3 position = new Vector3(); int speed = 0; bool runThis = (camera != null); if (runThis) { int moveType = DropDownListValue.GetValue(heroKitObject, 1); position = new Vector3(); // move to position if (moveType == 1) { position.x = BoolValue.GetValue(heroKitObject, 2) ? FloatFieldValue.GetValueA(heroKitObject, 3) : camera.transform.localPosition.x; position.y = BoolValue.GetValue(heroKitObject, 4) ? FloatFieldValue.GetValueA(heroKitObject, 5) : camera.transform.localPosition.y; position.z = BoolValue.GetValue(heroKitObject, 6) ? FloatFieldValue.GetValueA(heroKitObject, 7) : camera.transform.localPosition.z; } // move to object else if (moveType == 2) { SceneObjectValueData sceneObjectData = SceneObjectValue.GetValue(heroKitObject, 8, 9, false); if (sceneObjectData.heroKitObject != null) { position.x = BoolValue.GetValue(heroKitObject, 2) ? sceneObjectData.heroKitObject[0].transform.localPosition.x : camera.transform.localPosition.x; position.y = BoolValue.GetValue(heroKitObject, 4) ? sceneObjectData.heroKitObject[0].transform.localPosition.y : camera.transform.localPosition.y; position.z = BoolValue.GetValue(heroKitObject, 6) ? sceneObjectData.heroKitObject[0].transform.localPosition.z : camera.transform.localPosition.z; } else if (sceneObjectData.gameObject != null) { position.x = BoolValue.GetValue(heroKitObject, 2) ? sceneObjectData.gameObject[0].transform.localPosition.x : camera.transform.localPosition.x; position.y = BoolValue.GetValue(heroKitObject, 4) ? sceneObjectData.gameObject[0].transform.localPosition.y : camera.transform.localPosition.y; position.z = BoolValue.GetValue(heroKitObject, 6) ? sceneObjectData.gameObject[0].transform.localPosition.z : camera.transform.localPosition.z; } } speed = IntegerFieldValue.GetValueA(heroKitObject, 10); // pan the camera cameraPan = heroKitObject.GetGameObjectComponent <CameraPan>("CameraPan", true, camera.gameObject); cameraPan.targetPosition = position; cameraPan.speed = speed; cameraPan.Initialize(); // set up update for long action eventID = heroKitObject.heroStateData.eventBlock; heroKitObject.heroState.heroEvent[eventID].waiting = true; updateIsDone = false; heroKitObject.longActions.Add(this); } // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Camera: " + camera + "\n" + "Target Position: " + position + "\n" + "Speed: " + speed; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } // return value return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { // get values heroKitObject = hko; String imageGroupPrefabName = "HeroKit Image Canvas"; String imagePrefabName = "HeroKit Image Sprite"; int imageID = IntegerFieldValue.GetValueA(heroKitObject, 0); int speed = IntegerFieldValue.GetValueA(heroKitObject, 1); wait = BoolValue.GetValue(heroKitObject, 4); HeroKitObject targetObject = null; Vector3 position = new Vector3(); // get the game object that contains the images GameObject imageGroup = GetImageGroup(imageGroupPrefabName); if (imageGroup != null) { // get the game object that contains the image GameObject imageObject = GetImage(imagePrefabName, imageID, imageGroup); if (imageObject != null) { // get the hero kit object targetObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, imageObject); // get the current position position = targetObject.transform.localPosition; // get the image component on the game object Image image = heroKitObject.GetGameObjectComponent <Image>("Image", false, imageObject); if (image != null) { position.x = FloatFieldValue.GetValueA(heroKitObject, 2); position.y = FloatFieldValue.GetValueA(heroKitObject, 3); } } } // pan the camera uiPan = targetObject.GetHeroComponent <UIPan>("UIPan", true); uiPan.targetPosition = position; uiPan.speed = speed; uiPan.Initialize(); // set up update for long action eventID = heroKitObject.heroStateData.eventBlock; heroKitObject.heroState.heroEvent[eventID].waiting = wait; updateIsDone = false; heroKitObject.longActions.Add(this); // debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Image ID: " + imageID + "\n" + "Target Position: " + position + "\n" + "Speed: " + speed; 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); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get field values HeroKitObject targetObject = heroKitObject; bool useDifferentObject = BoolValue.GetValue(heroKitObject, 0); // get the particle system ParticleSystem particleSystem = null; if (useDifferentObject) { SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 1, 2, false); // object is hero object if (objectData.heroKitObject != null) { // execute action for all objects in list for (int i = 0; i < objectData.heroKitObject.Length; i++) { ExecuteOnHeroObject(objectData.heroKitObject[i]); } } // object is game object else if (objectData.gameObject != null) { // execute action for all objects in list for (int i = 0; i < objectData.gameObject.Length; i++) { ExecuteOnGameObject(objectData.gameObject[i]); } } // object is hero object if (objectData.heroKitObject != null) { particleSystem = objectData.heroKitObject[0].GetHeroComponent <ParticleSystem>("ParticleSystem"); } // object is game object else if (objectData.gameObject != null) { String particleName = objectData.gameObject[0].name + " particlesystem"; particleSystem = heroKitObject.GetGameObjectComponent <ParticleSystem>(particleName, false, objectData.gameObject[0]); } } else { particleSystem = heroKitObject.GetHeroComponent <ParticleSystem>("ParticleSystem"); } // play the particle effect if (particleSystem != null) { particleSystem.Stop(); } // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Particle System: " + particleSystem; 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); }