// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get field values SceneObjectValueData data = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); GameObject[] targetObject = HeroKitCommonRuntime.GetGameObjectsFromSceneObjects(data); string tag = TagValue.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], tag); } // debug info if (heroKitObject.debugHeroObject) { string debugMessage = "Tag: " + tag; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get field values SceneObjectValueData data = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); GameObject[] targetObject = HeroKitCommonRuntime.GetGameObjectsFromSceneObjects(data); bool runThis = (targetObject != null && targetObject.Length > 0); // get value from first game object in list if (runThis) { StringFieldValue.SetValueB(heroKitObject, 2, targetObject[0].name); } // debug info if (heroKitObject.debugHeroObject) { string strName = (targetObject != null && targetObject.Length > 0 && targetObject[0] != null) ? targetObject[0].name : ""; string debugMessage = "Name: " + strName; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; // get field values SceneObjectValueData data = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); string childName = ChildObjectValue.GetValue(heroKitObject, 2, 3); string componentName = StringFieldValue.GetValueA(heroKitObject, 4); // get the game object to work with GameObject[] targetObject = HeroKitCommonRuntime.GetGameObjectsFromSceneObjects(data); bool runThis = (targetObject != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { ExecuteOnTarget(targetObject[i], childName, componentName); } // debug info if (heroKitObject.debugHeroObject) { string debugMessage = "Component: " + componentName + "\n" + "Child (if updating component on child): " + childName; 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; // get field values SceneObjectValueData data = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); GameObject[] targetObject = HeroKitCommonRuntime.GetGameObjectsFromSceneObjects(data); Vector3 position = new Vector3(); bool changeX = false; bool changeY = false; bool changeZ = false; bool runThis = (targetObject != null && targetObject.Length > 0); // get value from first game object in list if (runThis) { position = targetObject[0].transform.localEulerAngles; changeX = BoolValue.GetValue(heroKitObject, 2); if (changeX) { FloatFieldValue.SetValueB(heroKitObject, 3, position.x); } changeY = BoolValue.GetValue(heroKitObject, 4); if (changeY) { FloatFieldValue.SetValueB(heroKitObject, 5, position.y); } changeZ = BoolValue.GetValue(heroKitObject, 6); if (changeZ) { FloatFieldValue.SetValueB(heroKitObject, 7, position.z); } } //----------------------------------------- // debugging stuff //----------------------------------------- if (heroKitObject.debugHeroObject) { string xStr = (changeX) ? "X: " + position.x + " " : ""; string yStr = (changeY) ? "Y: " + position.y + " " : ""; string zStr = (changeZ) ? "Z: " + position.z + " " : ""; string debugMessage = "Rotation coordinates: " + xStr + yStr + zStr; 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); Color endColor = ColorValue.GetValue(heroKitObject, 2); float duration = (float)(IntegerFieldValue.GetValueA(heroKitObject, 3) * 0.10); wait = BoolValue.GetValue(heroKitObject, 4); // get the text component if (objectData.heroKitObject != null) { // execute action for all objects in list for (int i = 0; i < objectData.heroKitObject.Length; i++) { ExecuteOnHeroObject(objectData.heroKitObject[i], endColor, duration); } } 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], endColor, duration); } } // set up update for long action eventID = heroKitObject.heroStateData.eventBlock; heroKitObject.heroState.heroEvent[eventID].waiting = wait; updateIsDone = false; heroKitObject.longActionsFixed.Add(this); //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string debugMessage = "Color: " + endColor + "\n" + "Duration: " + duration; 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; 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) { // 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) { 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) { 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; // 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) { heroKitObject = hko; // get field values bool useDifferentObject = BoolValue.GetValue(heroKitObject, 0); bool changePosition = BoolValue.GetValue(heroKitObject, 3); bool changeRotation = BoolValue.GetValue(heroKitObject, 10); wait = BoolValue.GetValue(heroKitObject, 17); ParticleSystem particleObject = null; // get the particle system 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], changePosition, changeRotation); } } // 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], changePosition, changeRotation); } } } else { particleObject = heroKitObject.GetHeroComponent <ParticleSystem>("ParticleSystem"); if (particleObject != null) { ExecuteOnTarget(particleObject, 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); }