public void ExecuteOnTarget(HeroKitObject targetObject) { // get the movement script HeroPathfinding3D moveObject = targetObject.GetHeroComponent <HeroPathfinding3D>("HeroPathfinding3D"); if (moveObject != null) { moveObject.StopNavigation(); } }
public void ExecuteOnTarget(HeroKitObject targetObject) { // get the rigid body Rigidbody rigidbody = targetObject.GetHeroComponent <Rigidbody>("Rigidbody"); if (rigidbody != null) { rigidbody.isKinematic = true; } }
// No actions for the End action public int Execute(HeroKitObject hko) { heroKitObject = hko; if (heroKitObject.debugHeroObject) { Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject)); } return(-99); }
public void ExecuteOnTarget(HeroKitObject targetObject) { // stop the audio clip AudioSource audioSource = targetObject.GetHeroComponent <AudioSource>("AudioSource-BGS", false); if (audioSource != null) { audioSource.Stop(); } }
/// <summary> /// Get the ID of the event. /// </summary> /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param> /// <param name="actionFieldID">ID assigned to action field A.</param> /// <returns>The ID of the event.</returns> public static int GetEventID(HeroKitObject heroKitObject, int actionFieldID) { // Get the action HeroAction action = heroKitObject.heroState.heroEvent[heroKitObject.heroStateData.eventBlock].actions[heroKitObject.heroStateData.action]; // Get the state ID int eventID = action.actionFields[actionFieldID].ints[2]; return(eventID); }
public GameObject ExecuteOnTarget(HeroKitObject targetObject, bool useName, string name, bool useTag, string tag, bool useLayer, int layer) { // go through children and search for match GameObject targetGameObject = null; int children = targetObject.transform.childCount; for (int i = 0; i < children; i++) { Transform childObject = targetObject.transform.GetChild(i); bool haveCorrectName = false; bool haveCorrectTag = false; bool haveCorrectLayer = false; bool needName = false; bool needTag = false; bool needLayer = false; if (useName) { needName = true; if (childObject.name == name) { haveCorrectName = true; } } if (useTag) { needTag = true; if (childObject.tag == tag) { haveCorrectTag = true; } } if (useLayer) { needLayer = true; if (childObject.gameObject.layer == layer) { haveCorrectLayer = true; } } if (needName == haveCorrectName && needTag == haveCorrectTag && needLayer == haveCorrectLayer) { targetGameObject = childObject.gameObject; break; } } // save the game object GameObjectFieldValue.SetValueB(targetObject, 8, targetGameObject); return(targetGameObject); }
/// <summary> /// Get a value from an object field. /// </summary> /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param> /// <param name="actionFieldID">ID assigned to action field A.</param> /// <returns>The value from the object field.</returns> public static Rigidbody GetValue(HeroKitObject heroKitObject, int actionFieldID) { // Get the action HeroAction action = heroKitObject.heroState.heroEvent[heroKitObject.heroStateData.eventBlock].actions[heroKitObject.heroStateData.action]; // Get the value Rigidbody rigidbody = action.actionFields[actionFieldID].component as Rigidbody; // Return the value return(rigidbody); }
/// <summary> /// Get a value from a color field. /// This is for a field that contains Value. /// </summary> /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param> /// <param name="actionFieldID">ID assigned to action field A.</param> /// <returns>The color.</returns> public static Color GetValue(HeroKitObject heroKitObject, int actionFieldID) { // Get the action HeroAction action = heroKitObject.heroState.heroEvent[heroKitObject.heroStateData.eventBlock].actions[heroKitObject.heroStateData.action]; // Get the value Color value = action.actionFields[actionFieldID].colors[0]; // Return the value return(value); }
/// <summary> /// Get a value from an object field. /// </summary> /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param> /// <param name="actionFieldID">ID assigned to action field A.</param> /// <returns>The value from the object field.</returns> public static T GetValue <T>(HeroKitObject heroKitObject, int actionFieldID) where T : Object { // Get the action HeroAction action = heroKitObject.heroState.heroEvent[heroKitObject.heroStateData.eventBlock].actions[heroKitObject.heroStateData.action]; // Get the value T value = action.actionFields[actionFieldID].component as T; // Return the value return(value); }
/// <summary> /// Get a hero kit property. /// </summary> /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param> /// <param name="actionFieldID">ID assigned to action field A.</param> /// <returns>The hero kit property.</returns> public static HeroKitProperty GetValue(HeroKitObject heroKitObject, int actionFieldID) { // Get the action HeroAction action = heroKitObject.heroState.heroEvent[heroKitObject.heroStateData.eventBlock].actions[heroKitObject.heroStateData.action]; // Get the value HeroKitProperty value = action.actionFields[actionFieldID].heroProperties[0]; // Return the value return(value); }
public void ExecuteOnTarget(HeroKitObject targetObject, string animationName) { // get the animator component Animator animator = targetObject.GetHeroChildComponent <Animator>("Animator", HeroKitCommonRuntime.visualsName); // animate the target if (animator != null) { animator.SetBool(animationName, false); } }
/// <summary> /// Load a hero kit object. /// </summary> /// <param name="saveData">Save state data for the hero kit object.</param> public static void LoadHeroKitObject(HeroSaveData saveData) { // get the hero kit object to update HeroKitObject targetObject = HeroKitDatabase.GetHeroKitObject(saveData.heroGUID); // if the hero kit object does not exist, add it to the scene if (targetObject == null) { targetObject = CreateHeroKitObject(saveData); targetObject.gameObject.name = saveData.gameObjectName; } else { // change name of game object in scene targetObject.gameObject.name = saveData.gameObjectName; } // update transform data AddTransform(targetObject, saveData); // add hero object if needed AddHeroObject(targetObject, saveData); // set the state of the hero object targetObject.heroStateData.state = saveData.stateID; // set the variables for the hero object AddVariables(targetObject.heroList.ints.items, saveData.variableInts); AddVariables(targetObject.heroList.floats.items, saveData.variableFloats); AddVariables(targetObject.heroList.bools.items, saveData.variableBools); AddVariables(targetObject.heroList.strings.items, saveData.variableStrings); // set the properties for the hero object int pIntCount = 0; int pFloatCount = 0; int pBoolCount = 0; int pStringCount = 0; for (int i = 0; i < saveData.propertyCount; i++) { AddProperties <IntField, int>(targetObject.heroProperties[i].itemProperties.ints.items, saveData.propertyInts, pIntCount, saveData.pIntCount[i]); AddProperties <FloatField, float>(targetObject.heroProperties[i].itemProperties.floats.items, saveData.propertyFloats, pFloatCount, saveData.pFloatCount[i]); AddProperties <BoolField, bool>(targetObject.heroProperties[i].itemProperties.bools.items, saveData.propertyBools, pBoolCount, saveData.pBoolCount[i]); AddProperties <StringField, string>(targetObject.heroProperties[i].itemProperties.strings.items, saveData.propertyStrings, pStringCount, saveData.pStringCount[i]); pIntCount += saveData.pIntCount[i]; pFloatCount += saveData.pFloatCount[i]; pBoolCount += saveData.pBoolCount[i]; pStringCount += saveData.pStringCount[i]; } // set state of hero kit object targetObject.gameObject.SetActive(saveData.gameObjectEnabled); }
public void ExecuteOnTarget(HeroKitObject targetObject, int speed, int animationType, string walkAnimation, string idleAnimation) { // get the movement script SpaceShooterController3D moveObject = targetObject.GetHeroComponent <SpaceShooterController3D>("SpaceShooterController3D", true); moveObject.settings.animationType = animationType; moveObject.settings.speed = speed; moveObject.settings.moveDefault = walkAnimation; moveObject.settings.lookDefault = idleAnimation; moveObject.enabled = true; }
public string ExecuteOnTarget(HeroKitObject targetObject, string scriptName, MethodInfo method) { //------------------------------------ // get the component that contains the script //------------------------------------ MonoBehaviour component = HeroKitCommonRuntime.GetComponentFromScript(heroKitObject, targetObject, scriptName); //------------------------------------ // get the parameters for the script //------------------------------------ System.Object[] parameters = new System.Object[0]; if (component != null) { parameters = ParameterValue.GetValueA(heroKitObject, 4, method); } else { Debug.LogError(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, "Component does not exist on the game object.")); } //------------------------------------ // invoke the method in the script //------------------------------------ System.Object returnValue = method.Invoke(component, parameters); //------------------------------------ // save the return value in the hero object //------------------------------------ ParameterValue.SetValueB(heroKitObject, 20, 21, returnValue); // debug string string debugInfo = ""; if (heroKitObject.debugHeroObject) { string argumentNames = ""; for (int i = 0; i < parameters.Length; i++) { if (parameters[i] != null) { argumentNames += ", arg[" + i + "]=" + parameters[i].ToString(); } } string returnName = ""; if (returnValue != null) { returnName += ", return=" + returnValue.ToString(); } debugInfo = argumentNames + returnName; } return(debugInfo); }
/// <summary> /// Get a method from a method field. /// </summary> /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param> /// <param name="actionFieldID">ID assigned to action field A.</param> /// <returns>The method.</returns> public static MethodInfo GetValue(HeroKitObject heroKitObject, int actionFieldID) { // Get the action HeroAction action = heroKitObject.heroState.heroEvent[heroKitObject.heroStateData.eventBlock].actions[heroKitObject.heroStateData.action]; // Get the value MethodInfo value = action.actionFields[actionFieldID].method.methodInfo; // Return the value return(value); }
public void CloseSaveMenu() { // get the menu HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.saveMenu, true); if (targetObject != null) { // disable the canvas Canvas canvas = targetObject.GetHeroComponent <Canvas>("Canvas"); canvas.enabled = false; } }
// 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); }
public void ExecuteOnTarget(HeroKitObject targetObject, string animationName) { // get the animator component Animator animator = targetObject.GetHeroChildComponent <Animator>("Animator", HeroKitCommonRuntime.visualsName); if (animator != null) { // get the movement script moveObject = targetObject.GetHeroComponent <HeroMove3D>("HeroMove3D", true); moveObject.settings.moveDefault = animationName; } }
/// <summary> /// Get the GUID of the first hero kit object in a hero object field. /// </summary> /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param> /// <param name="actionFieldID">ID assigned to action field A.</param> /// <returns>The GUID of the first hero kit object in a hero object field.</returns> public static int GetValueD(HeroKitObject heroKitObject, int actionFieldID) { // Get the action HeroAction action = heroKitObject.heroState.heroEvent[heroKitObject.heroStateData.eventBlock].actions[heroKitObject.heroStateData.action]; // Get the game object HeroObjectFieldData goData = new HeroObjectFieldData(); goData.heroGUID = action.actionFields[actionFieldID].ints[4]; return(goData.heroGUID); }
// 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); }
public void ExecuteOnTarget(HeroKitObject targetObject, bool useLayers) { // get the jump script & set values HeroSettings2D moveObject = targetObject.GetHeroComponent <HeroSettings2D>("HeroSettings2D", true); moveObject.useJumpLayermask = useLayers; moveObject.jumpLayermask = LayerMaskValue.GetValue(heroKitObject, 3); //if (!moveObject.haveJumped) //{ // moveObject.enabled = false; //} }
public void ExecuteOnTarget(HeroKitObject targetObject, int speed, int moveType, int animationType) { // get the movement script HeroSettings2D moveSettings = targetObject.GetHeroComponent <HeroSettings2D>("HeroSettings2D", true); moveSettings.animType = (HeroSettings2D.AnimType)(animationType - 1); moveSettings.moveType = (HeroSettings2D.MoveType)(moveType - 1); moveSettings.animator = targetObject.GetHeroChildComponent <Animator>("Animator", HeroKitCommonRuntime.visualsName); moveSettings.moveSpeed = speed; moveSettings.faceDir = HeroSettings2D.FaceDir.down; RpgController2D moveObject = targetObject.GetHeroComponent <RpgController2D>("RpgController2D", true); }
/// <summary> /// Set the target game object for the camera to follow. /// </summary> /// <param name="heroKitObject"></param> private void GetTarget(HeroKitObject heroKitObject) { // exit early if there is no target object for this camera controller if (targetObject == null) { enabled = false; return; } // set up target info target = heroKitObject.transform; targetGUID = heroKitObject.heroGUID; }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; eventID = heroKitObject.heroStateData.eventBlock; int actionCount = heroKitObject.heroState.heroEvent[eventID].actions.Count; if (heroKitObject.debugHeroObject) { Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject)); } return(actionCount); }
public static GameObject Create() { GameObject go = new GameObject("Hero Block"); HeroKitObject heroKitObject = go.AddComponent <HeroKitObject>(); heroKitObject.heroObject = HeroKitCommon.AddHeroObjectToFolder(false); Camera sceneCam = SceneView.lastActiveSceneView.camera; Vector3 spawnPos = sceneCam.ViewportToWorldPoint(new Vector3(0.5f, 0.1f, 2.5f)); go.transform.position = spawnPos; return(go); }
public void ExecuteOnTarget(HeroKitObject targetObject, bool includeChildren, int newLayer) { // set layer targetObject.gameObject.layer = newLayer; if (includeChildren) { Transform[] children = targetObject.gameObject.GetComponentsInChildren <Transform>(true); for (int i = 0; i < children.Length; i++) { children[i].gameObject.layer = newLayer; } } }
/// <summary> /// Add transform data from save file to hero object. /// </summary> /// <param name="targetObject">The hero kit object.</param> /// <param name="saveData">The save data for the hero kit object.</param> private static void AddTransform(HeroKitObject targetObject, HeroSaveData saveData) { Vector3 heroPosition = new Vector3(saveData.heroPosition[0], saveData.heroPosition[1], saveData.heroPosition[2]); targetObject.transform.localPosition = heroPosition; //Vector3 heroRotation = new Vector3(saveData.heroRotation[0], saveData.heroRotation[1], saveData.heroRotation[2]); //targetObject.transform.localEulerAngles = heroRotation; Vector3 heroScale = new Vector3(saveData.heroScale[0], saveData.heroScale[1], saveData.heroScale[2]); targetObject.transform.localScale = heroScale; }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; string valueName = StringFieldValue.GetValueA(heroKitObject, 2); int valueType = DropDownListValue.GetValue(heroKitObject, 0); bool runThis = (PlayerPrefs.HasKey(valueName)); if (runThis) { // integer if (valueType == 1) { int value = PlayerPrefs.GetInt(valueName); IntegerFieldValue.SetValueB(heroKitObject, 1, value); } // float else if (valueType == 2) { float value = PlayerPrefs.GetFloat(valueName); FloatFieldValue.SetValueB(heroKitObject, 1, value); } // bool else if (valueType == 3) { int value = PlayerPrefs.GetInt(valueName); bool newValue = (value == 0) ? true : false; BoolFieldValue.SetValueB(heroKitObject, 1, newValue); } // string else if (valueType == 4) { string value = PlayerPrefs.GetString(valueName); StringFieldValue.SetValueB(heroKitObject, 1, value); } } else { Debug.LogWarning(valueName + " was not found in player preferences."); } // debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Value Type (1=int, 2=float, 3=bool, 4=string): " + valueType + "\n" + "Value Name: " + valueName; 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); GameObject targetObject = HeroObjectFieldValue.GetValueA(heroKitObject, 3)[0].gameObject; List <HeroKitObject> listObjects = HeroObjectFieldValue.GetValueB(heroKitObject, 10); // convert list objects to array HeroKitObject[] arrayObjects = (listObjects != null) ? listObjects.ToArray() : null; bool getX = BoolValue.GetValue(heroKitObject, 4); bool getY = BoolValue.GetValue(heroKitObject, 5); bool getZ = BoolValue.GetValue(heroKitObject, 6); float x = (getX) ? FloatFieldValue.GetValueA(heroKitObject, 7) : 0; float y = (getY) ? FloatFieldValue.GetValueA(heroKitObject, 8) : 0; float z = (getZ) ? FloatFieldValue.GetValueA(heroKitObject, 9) : 0; Vector3 radius = new Vector3(x, y, z); // filter the hero kit objects in the scene List <HeroKitObject> filteredObjects = HeroActionCommonRuntime.GetHeroObjectsDistance(heroKitObject, arrayObjects, objectCount, radius, getX, getY, getZ, targetObject); // assign the hero kit objects to the list HeroActionCommonRuntime.AssignObjectsToList(heroKitObject, getHeroFieldID, filteredObjects, actionType); //----------------------------------------- // debugging stuff //----------------------------------------- if (heroKitObject.debugHeroObject) { string xStr = (getX) ? "X: " + x + " " : ""; string yStr = (getY) ? "Y: " + y + " " : ""; string zStr = (getZ) ? "Z: " + z + " " : ""; string countStr = (filteredObjects != null) ? filteredObjects.Count.ToString() : 0.ToString(); string debugMessage = "Get objects in this radius: " + xStr + yStr + zStr + "\n" + "Objects found: " + countStr; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; HeroKitCommonRuntime.gameIsPaused = true; Time.timeScale = 0; if (heroKitObject.debugHeroObject) { Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject)); } return(-99); }