// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1); int speed = IntegerFieldValue.GetValueA(heroKitObject, 2); int moveType = DropDownListValue.GetValue(heroKitObject, 3); // 4-way or 8-way? int animationType = DropDownListValue.GetValue(heroKitObject, 4); // 4-way or 8-way? bool runThis = (targetObject != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { ExecuteOnTarget(targetObject[i], speed, moveType, animationType); } if (heroKitObject.debugHeroObject) { Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject)); } return(-99); }
// Gets objects in a scene that match a certerin criteria public int Execute(HeroKitObject hko) { // Get variables heroKitObject = hko; // Get values HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1); bool useName = BoolValue.GetValue(heroKitObject, 2); string name = (useName) ? StringFieldValue.GetValueA(heroKitObject, 3) : ""; bool useTag = BoolValue.GetValue(heroKitObject, 4); string tag = (useTag) ? TagValue.GetValue(heroKitObject, 5) : ""; bool useLayer = BoolValue.GetValue(heroKitObject, 6); int layer = (useLayer) ? DropDownListValue.GetValue(heroKitObject, 7) - 1 : 0; GameObject[] targetGameObject = new GameObject[targetObject.Length]; bool runThis = (targetObject != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { targetGameObject[i] = ExecuteOnTarget(targetObject[i], useName, name, useTag, tag, useLayer, layer); } //----------------------------------------- // debugging stuff //----------------------------------------- if (heroKitObject.debugHeroObject) { string strLayer = (useLayer) ? layer.ToString() : ""; string strCount = (targetGameObject != null) ? targetGameObject.Length.ToString() : ""; string debugMessage = "Child With Tag: " + tag + "\n" + "Child On Layer: " + strLayer + "\n" + "Child With Name: " + name + "\n" + "Children Found: " + strCount; 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 = heroKitObject.heroStateData.eventBlock; int actionCount = heroKitObject.heroState.heroEvent[eventID].actions.Count; //----------------------------------------- // Get the game objects in the scene that match specific parameters //----------------------------------------- int actionType = DropDownListValue.GetValue(heroKitObject, 0); int getHeroFieldID = 1; int objectCount = IntegerFieldValue.GetValueA(heroKitObject, 2); HeroObject heroType = HeroTypeValue.GetValue(heroKitObject, 3); List <HeroKitObject> listObjects = HeroObjectFieldValue.GetValueB(heroKitObject, 4); // convert list objects to array HeroKitObject[] arrayObjects = (listObjects != null) ? listObjects.ToArray() : null; // filter the hero kit objects in the scene List <HeroKitObject> filteredObjects = HeroActionCommonRuntime.GetHeroObjectsByType(arrayObjects, objectCount, heroType); // assign the hero kit objects to the list HeroActionCommonRuntime.AssignObjectsToList(heroKitObject, getHeroFieldID, filteredObjects, actionType); //----------------------------------------- // debugging stuff //----------------------------------------- if (heroKitObject.debugHeroObject) { string heroTypeStr = (heroType != null) ? heroType.name : ""; string countStr = (filteredObjects != null) ? filteredObjects.Count.ToString() : 0.ToString(); string debugMessage = "Get objects assigned to this hero type: " + heroTypeStr + "\n" + "Objects found: " + countStr; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1); int speed = IntegerFieldValue.GetValueA(heroKitObject, 2); int animationType = DropDownListValue.GetValue(heroKitObject, 3); string walkAnimation = AnimationParameterValue.GetValueA(heroKitObject, 4, 5, 6); string idleAnimation = (animationType == 2) ? AnimationParameterValue.GetValueA(heroKitObject, 7, 8, 9) : ""; bool runThis = (targetObject != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { ExecuteOnTarget(targetObject[i], speed, animationType, walkAnimation, idleAnimation); } if (heroKitObject.debugHeroObject) { Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject)); } return(-99); }
// 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; HeroKitObject value1 = null; HeroKitObject value2 = null; bool evaluation = false; // evaluate the if statement if (heroKitObject.heroState.heroEvent[eventID].messenger != null) { int comparison = DropDownListValue.GetValue(heroKitObject, 2); value1 = heroKitObject.heroState.heroEvent[eventID].messenger.GetComponent <HeroKitObject>(); value2 = HeroObjectFieldValue.GetValueA(heroKitObject, 3)[0]; evaluation = HeroActionCommonRuntime.CompareValues(comparison, value1, value2); } // 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 = "Hero Object A: " + value1 + "\n" + "Hero Object B: " + value2 + "\n" + "Result: " + evaluation; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } // return the action that we want the game loop to think just executed return(thisAction); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1); int newState = DropDownListValue.GetValue(heroKitObject, 2) - 1; bool runThis = (targetObject != null && newState != -1); // note: debug info needs to go first for this action because // if you put it after state is changed, the wrong action is printed to log // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "New State ID: " + newState; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { ExecuteOnTarget(targetObject[i], newState); } return(-89); }
public int Execute(HeroKitObject hko) { heroKitObject = hko; // get field values HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1); int objectState = DropDownListValue.GetValue(heroKitObject, 2); bool runThis = (targetObject != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { ExecuteOnTarget(targetObject[i], objectState); } // debug message if (heroKitObject.debugHeroObject) { Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject)); } // return next action return(-99); }
// Gets objects in a scene that match a certerin criteria public int Execute(HeroKitObject hko) { // Get variables heroKitObject = hko; //----------------------------------------- // Get the game objects in the scene that match specific parameters //----------------------------------------- int actionType = DropDownListValue.GetValue(heroKitObject, 0); int getHeroFieldID = 1; int objectCount = IntegerFieldValue.GetValueA(heroKitObject, 2); int rayDirectionType = DropDownListValue.GetValue(heroKitObject, 4); float rayDistance = IntegerFieldValue.GetValueA(heroKitObject, 5) * 0.1f; int rayType = DropDownListValue.GetValue(heroKitObject, 6); bool debugRay = BoolValue.GetValue(heroKitObject, 9); GameObject originObject = null; HeroKitObject targetObject = null; // ray is on a specific camera if (rayType == 2) { targetObject = HeroObjectFieldValue.GetValueA(heroKitObject, 3)[0]; if (targetObject != null) { originObject = targetObject.gameObject; } } // ray is on hero object else if (rayType == 3) { targetObject = HeroObjectFieldValue.GetValueA(heroKitObject, 3)[0]; string childName = ChildObjectValue.GetValue(heroKitObject, 7, 8); Transform transform = null; if (childName == "") { transform = targetObject.transform; } else { transform = targetObject.GetHeroChildComponent <Transform>("Transform", childName); } originObject = transform.gameObject; } // filter the hero kit objects in the scene List <HeroKitObject> filteredObjects = HeroActionCommonRuntime.GetHeroObjectsRay2D(objectCount, targetObject, originObject, rayType, rayDirectionType, rayDistance, debugRay); // assign the hero kit objects to the list HeroActionCommonRuntime.AssignObjectsToList(heroKitObject, getHeroFieldID, filteredObjects, actionType); //----------------------------------------- // debugging stuff //----------------------------------------- if (heroKitObject.debugHeroObject) { string countStr = (filteredObjects != null) ? filteredObjects.Count.ToString() : 0.ToString(); string debugMessage = "Maximum number of objects to get: " + objectCount + "\n" + "Objects found: " + countStr; 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) { 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); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get the type of object to spawn int spawnType = DropDownListValue.GetValue(heroKitObject, 0); // where are we spawning item? from pool or in scene? bool usePool = BoolValue.GetValue(heroKitObject, 1); string poolName = (usePool) ? StringFieldValue.GetValueA(heroKitObject, 2) : ""; // debug string string debugSpawn = ""; // get the object to spawn (1=hero object, 2=prefab) if (spawnType == 1) { HeroObject heroSpawn = HeroObjectFieldValue.GetValueC(heroKitObject, 3); bool debugHeroSpawn = BoolValue.GetValue(heroKitObject, 4); bool dontSave = BoolValue.GetValue(heroKitObject, 5); Vector3 position = GetPosition(); Quaternion rotation = GetRotation(); HeroKitDatabase.SpawnHeroKitObject(usePool, poolName, position, rotation, heroSpawn, debugHeroSpawn, dontSave); if (heroKitObject.debugHeroObject) { debugSpawn = "Hero Object: " + heroSpawn + "\n" + "Debug: " + debugHeroSpawn + "\n" + "Can Save: " + !dontSave + "\n" + "Position: " + position + "\n" + "Rotation: " + rotation + "\n" + "Use Pool: " + usePool + "\n" + "Pool Name: " + poolName; } } else if (spawnType == 2) { GameObject prefabSpawn = (!usePool) ? PrefabValue.GetValue(heroKitObject, 5) : null; Vector3 position = GetPosition(); Quaternion rotation = GetRotation(); HeroKitDatabase.SpawnPrefab(usePool, poolName, position, rotation, prefabSpawn); if (heroKitObject.debugHeroObject) { debugSpawn = "Game Object: " + prefabSpawn + "\n" + "Position: " + position + "\n" + "Rotation: " + rotation + "\n" + "Use Pool: " + usePool + "\n" + "Pool Name: " + poolName; } } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string debugMessage = debugSpawn; 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 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); }
// Gets objects in a scene that match a certerin criteria public int Execute(HeroKitObject hko) { // Get variables heroKitObject = hko; bool useName = BoolValue.GetValue(heroKitObject, 0); bool useTag = BoolValue.GetValue(heroKitObject, 2); bool useLayer = BoolValue.GetValue(heroKitObject, 4); string name = ""; string tag = ""; int layer = 0; if (useName) { name = StringFieldValue.GetValueA(heroKitObject, 1); } if (useTag) { tag = TagValue.GetValue(heroKitObject, 3); } if (useLayer) { layer = DropDownListValue.GetValue(heroKitObject, 5) - 1; } GameObject targetGameObject = null; GameObject[] gameObjects = UnityEngine.Object.FindObjectsOfType <GameObject>(); if (useName && useTag && useLayer) { for (int i = 0; i < gameObjects.Length; i++) { if (gameObjects[i].name == name && gameObjects[i].layer == layer && gameObjects[i].tag == tag) { targetGameObject = gameObjects[i]; break; } } } else if (useName && useTag && !useLayer) { for (int i = 0; i < gameObjects.Length; i++) { if (gameObjects[i].name == name && gameObjects[i].tag == tag) { targetGameObject = gameObjects[i]; break; } } } else if (useName && !useTag && useLayer) { for (int i = 0; i < gameObjects.Length; i++) { if (gameObjects[i].name == name && gameObjects[i].layer == layer) { targetGameObject = gameObjects[i]; break; } } } else if (!useName && useTag && useLayer) { for (int i = 0; i < gameObjects.Length; i++) { if (gameObjects[i].tag == tag && gameObjects[i].layer == layer) { targetGameObject = gameObjects[i]; break; } } } else if (!useName && !useTag && useLayer) { for (int i = 0; i < gameObjects.Length; i++) { if (gameObjects[i].layer == layer) { targetGameObject = gameObjects[i]; break; } } } else if (!useName && useTag && !useLayer) { for (int i = 0; i < gameObjects.Length; i++) { if (gameObjects[i].tag == tag) { targetGameObject = gameObjects[i]; break; } } } else if (useName && !useTag && !useLayer) { for (int i = 0; i < gameObjects.Length; i++) { if (gameObjects[i].name == name) { targetGameObject = gameObjects[i]; break; } } } GameObjectFieldValue.SetValueB(heroKitObject, 6, targetGameObject); //----------------------------------------- // debugging stuff //----------------------------------------- if (heroKitObject.debugHeroObject) { string strLayer = (useLayer) ? layer.ToString() : ""; string debugMessage = "Game Object With Tag: " + tag + "\n" + "Game Object On Layer: " + strLayer + "\n" + "Game Object With Name: " + name + "\n" + "Game Object Found: " + targetGameObject; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }