private void SetPortraitInfo(int portraitID, int changePortrait, int portraitSprite, int flipImage, int changeScale, int newScale, int changeXPos, int newXPos, int changeYPos, int newYPos, int changeZPos, int newZPos) { // get values for left portrait uiDialog.changePortrait[portraitID] = BoolValue.GetValue(heroKitObject, changePortrait); if (uiDialog.changePortrait[portraitID]) { UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, portraitSprite); uiDialog.portraitSprite[portraitID] = (unityObject.value != null) ? (Sprite)unityObject.value : null; uiDialog.flipImage[portraitID] = BoolValue.GetValue(heroKitObject, flipImage); uiDialog.changeScale[portraitID] = BoolValue.GetValue(heroKitObject, changeScale); if (uiDialog.changeScale[portraitID]) { uiDialog.newScale[portraitID] = FloatFieldValue.GetValueA(heroKitObject, newScale) * 0.01f; } uiDialog.changeXPos[portraitID] = BoolValue.GetValue(heroKitObject, changeXPos); if (uiDialog.changeXPos[portraitID]) { uiDialog.newXPos[portraitID] = FloatFieldValue.GetValueA(heroKitObject, newXPos); } uiDialog.changeYPos[portraitID] = BoolValue.GetValue(heroKitObject, changeYPos); if (uiDialog.changeYPos[portraitID]) { uiDialog.newYPos[portraitID] = FloatFieldValue.GetValueA(heroKitObject, newYPos); } uiDialog.changeZPos[portraitID] = BoolValue.GetValue(heroKitObject, changeZPos); if (uiDialog.changeZPos[portraitID]) { uiDialog.newZPos[portraitID] = DropDownListValue.GetValue(heroKitObject, newZPos); } } }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get the hero object where the parameters are stored HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1); UnityObjectField objectData = UnityObjectFieldValue.GetValueA(heroKitObject, 2); string scriptName = (objectData.value != null) ? objectData.value.name : ""; MethodInfo method = MethodValue.GetValue(heroKitObject, 3); string[] debugInfo = new string[targetObject.Length]; bool runThis = (targetObject != null && scriptName != "" && method != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { debugInfo[i] = ExecuteOnTarget(targetObject[i], scriptName, method); } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string strDebugInfo = (debugInfo != null && debugInfo.Length > 0) ? debugInfo[0] : ""; string debugMessage = "MonoScript: " + scriptName + "\n" + "Method: " + method + "\n" + "Parameters: " + strDebugInfo; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { // get values heroKitObject = hko; HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1); UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, 2); AudioClip audioClip = (unityObject.value != null) ? (AudioClip)unityObject.value : null; bool changeSettings = BoolValue.GetValue(heroKitObject, 3); bool runThis = (targetObject != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { ExecuteOnTarget(targetObject[i], audioClip, changeSettings); } // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "BGM: " + audioClip; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get the hero object where the parameters are stored HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1); UnityObjectField objectData = UnityObjectFieldValue.GetValueA(heroKitObject, 2); string scriptName = (objectData.value != null) ? objectData.value.name : ""; bool runThis = (targetObject != null && scriptName != ""); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { ExecuteOnTarget(targetObject[i], scriptName); } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string debugMessage = "MonoScript: " + scriptName; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get object to play particles on HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1); UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, 2); ParticleSystem particlesPrefab = (unityObject.value != null) ? (ParticleSystem)unityObject.value : null; bool changePosition = BoolValue.GetValue(heroKitObject, 3); bool changeRotation = BoolValue.GetValue(heroKitObject, 10); wait = BoolValue.GetValue(heroKitObject, 17); bool runThis = (targetObject != null && particlesPrefab != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { ExecuteOnTarget(targetObject[i], particlesPrefab, changePosition, changeRotation); } // set up the long action eventID = heroKitObject.heroStateData.eventBlock; heroKitObject.heroState.heroEvent[eventID].waiting = wait; updateIsDone = false; heroKitObject.longActions.Add(this); // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Particle System: " + particleObject; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get the hero object where the parameters are stored HeroKitObject targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1)[0]; UnityObjectField objectData = UnityObjectFieldValue.GetValueA(heroKitObject, 2); string scriptName = (objectData.value != null) ? objectData.value.name : ""; bool runThis = (targetObject != null && scriptName != ""); if (runThis) { ExecuteOnTarget(targetObject, scriptName); } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string debugMessage = "MonoScript: " + scriptName + "\n" + "Hero Kit Object: " + targetObject; 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.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); }
// Execute the action public int Execute(HeroKitObject hko) { // get values heroKitObject = hko; HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 4); UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, 1); AudioClip audioClip = (unityObject.value != null) ? (AudioClip)unityObject.value : null; bool fadeBGM = BoolValue.GetValue(heroKitObject, 2); bool fadeBGS = BoolValue.GetValue(heroKitObject, 3); bool changeSettings = BoolValue.GetValue(heroKitObject, 5); bool runThis = (targetObject != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { ExecuteOnTarget(targetObject[i], audioClip, fadeBGM, fadeBGS, changeSettings); } // set up the 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 = "SE: " + audioClip; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // Get the scene object string sceneName = UnityObjectFieldValue.GetValueA(heroKitObject, 0).sceneName; Vector3 cameraPosition = new Vector3(); Vector3 cameraRotation = new Vector3(); bool runThis = (sceneName != ""); if (runThis) { bool useDefaultScene = BoolValue.GetValue(heroKitObject, 1); bool removeNonPersistent = BoolValue.GetValue(heroKitObject, 2); bool saveCurrentScene = !BoolValue.GetValue(heroKitObject, 3); // get position bool getPosition = BoolValue.GetValue(heroKitObject, 4); Vector3 defaultPosition = new Vector3(-999999, -999999, -999999); cameraPosition = (getPosition) ? CoordinatesValue.GetValue(heroKitObject, 5, 6, 7, 8, 9, 10, defaultPosition) : defaultPosition; // get rotation bool getRotation = BoolValue.GetValue(heroKitObject, 11); Vector3 defaultRotation = new Vector3(-999999, -999999, -999999); cameraRotation = (getRotation) ? CoordinatesValue.GetValue(heroKitObject, 12, 13, 14, 15, 16, 17, defaultRotation) : defaultRotation; // Save the current scene if (saveCurrentScene) { SaveScene saveScene = new SaveScene(); saveScene.SaveSceneData(heroKitObject, false); // save scene objects saveScene.SaveSceneData(heroKitObject, true); // save persistent objects } // Load the scene. Load any cached data for the scene. HeroKitCommonScene.LoadScene(sceneName, useDefaultScene, removeNonPersistent, cameraPosition, cameraRotation); // set up update for long action eventID = heroKitObject.heroStateData.eventBlock; heroKitObject.heroState.heroEvent[eventID].waiting = true; updateIsDone = false; heroKitObject.longActions.Add(this); } // debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Scene ID: " + sceneName + "\n" + "Camera Position: " + cameraPosition + "\n" + "Camera Rotation: " + cameraRotation; 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); 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; UnityObjectField storeObjectHere = UnityObjectFieldValue.GetValueB(heroKitObject, 0); UnityObjectField getThisObject = UnityObjectFieldValue.GetValueA(heroKitObject, 1); bool runThis = (storeObjectHere != null && getThisObject != null); if (runThis) { UnityObjectFieldValue.SetValueB(heroKitObject, 0, getThisObject); } // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Unity Object: " + getThisObject; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { // get values heroKitObject = hko; // write messages? bool print = BoolValue.GetValue(heroKitObject, 0); if (print) { HeroKitCommonRuntime.writeMessage = BoolValue.GetValue(heroKitObject, 1); if (HeroKitCommonRuntime.writeMessage) { float messageSpeed = SliderValue.GetValue(heroKitObject, 2); if (messageSpeed < 0) { messageSpeed = 0; } if (messageSpeed > 100) { messageSpeed = 100; } // 0=100, 100=0. Then change to 0 to 1. float waitTime = (100 - messageSpeed) * 0.01f; HeroKitCommonRuntime.messageWaitTime = waitTime; } } // change message alignment? bool changeAlignment = BoolValue.GetValue(heroKitObject, 3); if (changeAlignment) { int alignID = DropDownListValue.GetValue(heroKitObject, 4); switch (alignID) { case 1: HeroKitCommonRuntime.messageAlignment = TextAnchor.UpperLeft; break; case 2: HeroKitCommonRuntime.messageAlignment = TextAnchor.UpperCenter; break; case 3: HeroKitCommonRuntime.messageAlignment = TextAnchor.UpperRight; break; case 4: HeroKitCommonRuntime.messageAlignment = TextAnchor.MiddleLeft; break; case 5: HeroKitCommonRuntime.messageAlignment = TextAnchor.MiddleCenter; break; case 6: HeroKitCommonRuntime.messageAlignment = TextAnchor.MiddleRight; break; case 7: HeroKitCommonRuntime.messageAlignment = TextAnchor.LowerLeft; break; case 8: HeroKitCommonRuntime.messageAlignment = TextAnchor.LowerCenter; break; case 9: HeroKitCommonRuntime.messageAlignment = TextAnchor.LowerRight; break; } } // change background alpha bool changeBackgroundAlpha = BoolValue.GetValue(heroKitObject, 5); if (changeBackgroundAlpha) { // get new alpha float alpha = SliderValue.GetValue(heroKitObject, 6); // keep alpha between 0 - 100 if (alpha > 100) { alpha = 100; } else if (alpha < 0) { alpha = 0; } // switch to 0 - 1 scale alpha *= .01f; // change alpha HeroKitCommonRuntime.messageBackgroundAlpha = alpha; HeroKitCommonRuntime.changeMessageBackgroundTransparency = true; } // change background alpha bool changeButtonAlpha = BoolValue.GetValue(heroKitObject, 19); if (changeButtonAlpha) { // get new alpha float alpha = SliderValue.GetValue(heroKitObject, 20); // keep alpha between 0 - 100 if (alpha > 100) { alpha = 100; } else if (alpha < 0) { alpha = 0; } // switch to 0 - 1 scale alpha *= .01f; // change alpha HeroKitCommonRuntime.messageButtonAlpha = alpha; HeroKitCommonRuntime.changeMessageButtonTransparency = true; } // change background image bool changeBackgroundImage = BoolValue.GetValue(heroKitObject, 7); if (changeBackgroundImage) { UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, 8); HeroKitCommonRuntime.messageBackgroundImage = (unityObject.value != null) ? (Sprite)unityObject.value : null; HeroKitCommonRuntime.changeMessageBackground = true; } // change button image bool changeButtonImage = BoolValue.GetValue(heroKitObject, 9); if (changeButtonImage) { UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, 10); HeroKitCommonRuntime.messageButtonImage = (unityObject.value != null) ? (Sprite)unityObject.value : null; HeroKitCommonRuntime.changeMessageButton = true; } // change button layout bool changeButtonLayout = BoolValue.GetValue(heroKitObject, 11); if (changeButtonLayout) { HeroKitCommonRuntime.messageButtonLayout = DropDownListValue.GetValue(heroKitObject, 12); HeroKitCommonRuntime.changeMessageButtonLayout = true; } // change text color bool changeTextColor = BoolValue.GetValue(heroKitObject, 13); if (changeTextColor) { HeroKitCommonRuntime.messageTextColor = ColorValue.GetValue(heroKitObject, 14); HeroKitCommonRuntime.changeMessageTextColor = true; } // change heading color bool changeHeadingColor = BoolValue.GetValue(heroKitObject, 15); if (changeHeadingColor) { HeroKitCommonRuntime.messageHeadingColor = ColorValue.GetValue(heroKitObject, 16); HeroKitCommonRuntime.changeMessageHeadingColor = true; } // change button text color bool changeButtonTextColor = BoolValue.GetValue(heroKitObject, 17); if (changeButtonTextColor) { HeroKitCommonRuntime.messageButtonTextColor = ColorValue.GetValue(heroKitObject, 18); HeroKitCommonRuntime.changeMessageButtonTextColor = true; } // change active button color bool changeButtonActiveColor = BoolValue.GetValue(heroKitObject, 21); if (changeButtonActiveColor) { HeroKitCommonRuntime.messageButtonActiveColor = ColorValue.GetValue(heroKitObject, 22); HeroKitCommonRuntime.changeMessageButtonActiveColor = true; } if (heroKitObject.debugHeroObject) { Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, (""))); } return(-99); }
// 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); }
// 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; // get the particle to play UnityObjectField unityObject = UnityObjectFieldValue.GetValueA(heroKitObject, 0); ParticleSystem particlePrefab = (unityObject.value != null) ? (ParticleSystem)unityObject.value : null; bool runThis = (particlePrefab != null); if (runThis) { // create a pool for this particle if it doesn't exist string poolName = particlePrefab.transform.name + " particle effects"; if (HeroKitDatabase.GetParticlePool(poolName, false) == null) { HeroKitDatabase.AddParticlePool(poolName, particlePrefab); } // get the positon to use for the particle Vector3 position = particlePrefab.transform.localPosition; bool changePosition = BoolValue.GetValue(heroKitObject, 1); if (changePosition) { position = CoordinatesValue.GetValue(heroKitObject, 2, 3, 4, 5, 6, 7, particlePrefab.transform.localPosition); } // get the rotation to use for the particle Quaternion rotation = particlePrefab.transform.localRotation; bool changeRotation = BoolValue.GetValue(heroKitObject, 8); if (changeRotation) { Vector3 eulerAngles = CoordinatesValue.GetValue(heroKitObject, 9, 10, 11, 12, 13, 14, particlePrefab.transform.localEulerAngles); rotation = Quaternion.Euler(eulerAngles); } // spawn the particle effect particleObject = HeroKitDatabase.SpawnParticle(poolName, position, rotation); // should next action wait until this action is complete? wait = BoolValue.GetValue(heroKitObject, 15); // play the particle effect particleObject.Stop(); particleObject.Play(); // set up the long action eventID = heroKitObject.heroStateData.eventBlock; heroKitObject.heroState.heroEvent[eventID].waiting = wait; updateIsDone = false; heroKitObject.longActions.Add(this); } // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Particle System: " + particleObject; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // Get the hero kit object to move HeroKitObject targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1, false)[0]; // Get the scene object string sceneName = UnityObjectFieldValue.GetValueA(heroKitObject, 2).sceneName; // get new position for target object Vector3 defaultPosition = new Vector3(-999999, -999999, -999999); Vector3 targetPosition = CoordinatesValue.GetValue(heroKitObject, 3, 4, 5, 6, 7, 8, defaultPosition); // get new rotation for target object Vector3 targetDirection = defaultPosition; int directionType = DropDownListValue.GetValue(heroKitObject, 9); switch (directionType) { case 1: // retain break; case 2: // left targetDirection.y = -90f; break; case 3: // right targetDirection.y = 90f; break; case 4: // up targetDirection.y = 0f; break; case 5: // down targetDirection.y = 180f; break; case 6: // custom targetDirection = CoordinatesValue.GetValue(heroKitObject, 10, 11, 12, 13, 14, 15, defaultPosition); break; } // move camera to object's position? bool moveCameraPos = BoolValue.GetValue(heroKitObject, 16); // move camera to object's rotation? bool moveCameraRotation = BoolValue.GetValue(heroKitObject, 17); // scene transition settings bool useDefaultScene = BoolValue.GetValue(heroKitObject, 18); bool removeNonPersistent = BoolValue.GetValue(heroKitObject, 19); bool saveCurrentScene = !BoolValue.GetValue(heroKitObject, 20); bool runThis = (targetObject != null && sceneName != ""); // NEXT STEP: // save current scene, // check if object is persistant. if it is, load next scene, change direction and rotation of object. // if it isn't see what we can do to physically move it from one scene to another. Keep in mind that object could exist in two scenes after this (if it is saved in scene data) // maybe disable it in current scene and create a new verison in the next scene. if (runThis) { // Save the current scene if (saveCurrentScene) { SaveScene saveScene = new SaveScene(); saveScene.SaveSceneData(heroKitObject, false); // save scene objects saveScene.SaveSceneData(heroKitObject, true); // save persistent objects } // Load the scene. Load any cached data for the scene. HeroKitCommonScene.LoadSceneWithObject(sceneName, useDefaultScene, removeNonPersistent, targetPosition, targetDirection, targetObject, moveCameraPos, moveCameraRotation); } if (targetObject == null) { Debug.LogError("There is no object to move to the next scene! Terminating action early."); } // debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Scene: " + sceneName + "\n" + "Move this object: " + targetObject + "\n" + "To this position: " + targetPosition; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } // Return value return(-99); }