// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; GameObject menuTemplate = PrefabValue.GetValue(heroKitObject, 0); bool runThis = (menuTemplate != null); if (runThis) { // if new prefab is not in scene, delete the old one from scene and attach new prefab to settings. GameObject prefab = HeroKitCommonRuntime.settingsInfo.dialogBox; if (prefab != null && prefab != menuTemplate) { HeroKitCommonRuntime.DeletePrefabFromScene(prefab, true); HeroKitCommonRuntime.settingsInfo.dialogBox = menuTemplate; } } if (heroKitObject.debugHeroObject) { Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; GameObject prefab = PrefabValue.GetValue(heroKitObject, 0); GameObject parent = GameObjectFieldValue.GetValueA(heroKitObject, 1); int count = IntegerFieldValue.GetValueA(heroKitObject, 2); bool incrementItemID = BoolValue.GetValue(heroKitObject, 3); HeroKitObject notifications = HeroObjectFieldValue.GetValueA(heroKitObject, 4)[0]; int stateID = EventValue.GetStateID(heroKitObject, 5); int eventID = EventValue.GetEventID(heroKitObject, 5); bool runThis = (prefab != null && parent != null); if (runThis) { CreateUIObjects(prefab, parent, count, incrementItemID, notifications, stateID, eventID, false); } //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string debugMessage = "Parent Game Object: " + parent + "\n" + "Object to Duplicate: " + prefab + "\n" + "Number of Duplicates: " + count + "\n" + "Increment Item ID: " + incrementItemID + "\n" + "Send Notifications Here: " + notifications + "\n" + "Notification State ID: " + stateID + "\n" + "Notification Event ID: " + eventID; 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); bool changePrefab = BoolValue.GetValue(heroKitObject, 2); GameObject prefab = (changePrefab) ? PrefabValue.GetValue(heroKitObject, 3) : null; bool changeRigidbody = BoolValue.GetValue(heroKitObject, 4); Rigidbody rigidbody = (changeRigidbody) ? RigidbodyValue.GetValue(heroKitObject, 5) : null; bool changeHidden = BoolValue.GetValue(heroKitObject, 6); int isHidden = (changeHidden) ? DropDownListValue.GetValue(heroKitObject, 7) : 0; bool runThis = (targetObject != null); // execute action for all objects in list for (int i = 0; runThis && i < targetObject.Length; i++) { ExecuteOnTarget(targetObject[i], changePrefab, prefab, changeRigidbody, rigidbody, changeHidden, isHidden); } // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Result: " + prefab + " " + rigidbody; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; string poolName = StringFieldValue.GetValueA(heroKitObject, 0); int itemCount = IntegerFieldValue.GetValueA(heroKitObject, 1); int objectType = DropDownListValue.GetValue(heroKitObject, 2); // ------------------------------------------------ // Get the prefab that will populate the pool // ------------------------------------------------ GameObject prefab = null; bool isHeroKitObject = false; // hero object if (objectType == 1) { prefab = Resources.Load <GameObject>("Hero Templates/Components/HeroKit Default Object"); isHeroKitObject = true; } // prefab else if (objectType == 2) { prefab = PrefabValue.GetValue(heroKitObject, 3); } // ------------------------------------------------ // Create the pool // ------------------------------------------------ HeroKitDatabase.AddPool(poolName, prefab, itemCount, isHeroKitObject); //------------------------------------ // debug message //------------------------------------ if (heroKitObject.debugHeroObject) { string debugMessage = "Pool Name: " + poolName + "\n" + "Items to add: " + itemCount + "\n" + "Item: " + prefab; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } // normal return 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); }