public void CreateEmptyTemplateNoPath() { Assert.Throws <Exception>(() => { var sceneTemplate = SceneTemplate.CreateSceneTemplate(""); }); }
private static Tuple <string, SceneTemplateAsset> CreateTemplateFromScene(SceneAsset sourceScene) { var templatePath = Path.Combine(TestUtils.k_TestGeneratedFolder, "CreateTemplateFromSceneTest_template.asset").Replace("\\", "/"); var sceneTemplate = SceneTemplate.CreateTemplateFromScene(sourceScene, templatePath); return(Tuple.Create(templatePath, sceneTemplate)); }
public ActionResult ExportTemplate(string title, long sceneId) { if (string.IsNullOrWhiteSpace(title)) { ModelState.AddModelError("EmptyTemplate", "Template name cannot be empty"); } if (ModelState.IsValid) { // create scene template first var template = new SceneTemplate { Id = Guid.NewGuid(), Title = title }; db.SceneTemplates.Add(template); // find source scene and clone it var scene = db.Scenes.First(s => s.Id == sceneId).Clone(); // update owner id of cloned scene scene.OwnerGuidId = template.Id; // add new scene to context and save it db.Scenes.Add(scene); db.SaveChanges(); } return View("~/WebExtracted/Ms.Cms/Views/Scene/Empty.cshtml"); }
public void OnSceneComplete(uint sceneInstanceID) { if (!HasScene(sceneInstanceID)) { return; } if (_isDebuggingScenes) { GetPlayer().SendSysMessage(CypherStrings.CommandSceneDebugComplete, sceneInstanceID); } SceneTemplate sceneTemplate = GetSceneTemplateFromInstanceId(sceneInstanceID); // Must be done before removing aura RemoveSceneInstanceId(sceneInstanceID); if (sceneTemplate.SceneId != 0) { RemoveAurasDueToSceneId(sceneTemplate.SceneId); } Global.ScriptMgr.OnSceneComplete(GetPlayer(), sceneInstanceID, sceneTemplate); if (sceneTemplate.PlaybackFlags.HasAnyFlag(SceneFlags.CancelAtEnd)) { CancelScene(sceneInstanceID, false); } }
public override void OnSceneComplete(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate) { SmartScript smartScript = new SmartScript(); smartScript.OnInitialize(sceneTemplate); smartScript.ProcessEventsFor(SmartEvents.SceneComplete, player); }
private void DrawSceneConfigSection() { EditorGUILayout.Space(spacerSize); EditorGUILayout.LabelField("New Scene Configuration"); EditorGUILayout.Space(spacerSize); sceneName = EditorGUILayout.TextField(new GUIContent("Scene Name", "This will be the name of the scene asset file."), sceneName); currentTemplate = (SceneTemplate)EditorGUILayout.EnumPopup(new GUIContent("Choose Template", "Choose to have either day or night by default in the level."), currentTemplate); }
public uint PlaySceneByPackageId(uint sceneScriptPackageId, SceneFlags playbackflags = SceneFlags.Unk16, Position position = null) { SceneTemplate sceneTemplate = new SceneTemplate(); sceneTemplate.SceneId = 0; sceneTemplate.ScenePackageId = sceneScriptPackageId; sceneTemplate.PlaybackFlags = playbackflags; sceneTemplate.ScriptId = 0; return(PlaySceneByTemplate(sceneTemplate, position)); }
public void CreateEmptyTemplateWithPath() { var sceneTemplatePath = AssetDatabase.GenerateUniqueAssetPath(TestUtils.k_TestGeneratedTemplateFolder + "/EmptySceneTemplate.asset"); var sceneTemplate = SceneTemplate.CreateSceneTemplate(sceneTemplatePath); Assert.NotNull(sceneTemplate); var validateTemplatePath = AssetDatabase.GetAssetPath(sceneTemplate); Assert.AreEqual(validateTemplatePath, sceneTemplatePath, "sceneTemplatePath"); Assert.IsNull(sceneTemplate.templateScene); // Test template is selected Assert.AreSame(sceneTemplate, Selection.activeObject); }
public void Init() { TestUtils.CreateFolder(TestUtils.k_TestGeneratedFolder); // Create a new scene and a scene template for it var newScene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single); EditorSceneManager.SaveScene(newScene, TestUtils.k_AssetsTempScene); var newSceneAsset = AssetDatabase.LoadAssetAtPath <SceneAsset>(TestUtils.k_AssetsTempScene); var sceneTemplateAsset = SceneTemplate.CreateTemplateFromScene(newSceneAsset, TestUtils.k_AssetsTempSceneTemplate); sceneTemplateAsset.templateName = "Test title"; sceneTemplateAsset.description = "Test description"; sceneTemplateAsset.preview = Texture2D.whiteTexture; }
public void OnSceneTrigger(uint sceneInstanceID, string triggerName) { if (!HasScene(sceneInstanceID)) { return; } if (_isDebuggingScenes) { GetPlayer().SendSysMessage(CypherStrings.CommandSceneDebugTrigger, sceneInstanceID, triggerName); } SceneTemplate sceneTemplate = GetSceneTemplateFromInstanceId(sceneInstanceID); Global.ScriptMgr.OnSceneTrigger(GetPlayer(), sceneInstanceID, sceneTemplate, triggerName); }
private static Tuple <Scene, SceneAsset, string> InstantiateSceneFromTemplate(string sceneTemplateAssetPath, string newSceneName, bool additive = false) { EditorSceneManager.NewScene(NewSceneSetup.EmptyScene); var sceneTemplate = AssetDatabase.LoadAssetAtPath <SceneTemplateAsset>(sceneTemplateAssetPath); Assert.NotNull(sceneTemplate, $"sceneTemplate {sceneTemplateAssetPath} doesn't exist"); var sceneTemplatePath = AssetDatabase.GetAssetPath(sceneTemplate); Assert.AreEqual(sceneTemplateAssetPath, sceneTemplatePath); var newScenePath = Path.Combine(TestUtils.k_TestGeneratedFolder, newSceneName).Replace("\\", "/"); var instantiationResult = SceneTemplate.Instantiate(sceneTemplate, additive, newScenePath); return(new Tuple <Scene, SceneAsset, string>(instantiationResult.Item1, instantiationResult.Item2, newScenePath)); }
public static void HandlePlayScene(Packet packet) { var sceneId = packet.ReadInt32("SceneID"); SceneTemplate scene = new SceneTemplate { SceneID = (uint)sceneId }; scene.Flags = (uint)packet.ReadInt32("PlaybackFlags"); packet.ReadInt32("SceneInstanceID"); scene.ScriptPackageID = (uint)packet.ReadInt32("SceneScriptPackageID"); packet.ReadPackedGuid128("TransportGUID"); packet.ReadVector3("Pos"); packet.ReadSingle("Facing"); Storage.Scenes.Add(scene, packet.TimeSpan); }
public uint PlaySceneByTemplate(SceneTemplate sceneTemplate, Position position = null) { if (sceneTemplate == null) { return(0); } SceneScriptPackageRecord entry = CliDB.SceneScriptPackageStorage.LookupByKey(sceneTemplate.ScenePackageId); if (entry == null) { return(0); } // By default, take player position if (position == null) { position = GetPlayer(); } uint sceneInstanceID = GetNewStandaloneSceneInstanceID(); if (_isDebuggingScenes) { GetPlayer().SendSysMessage(CypherStrings.CommandSceneDebugPlay, sceneInstanceID, sceneTemplate.ScenePackageId, sceneTemplate.PlaybackFlags); } PlayScene playScene = new PlayScene(); playScene.SceneID = sceneTemplate.SceneId; playScene.PlaybackFlags = (uint)sceneTemplate.PlaybackFlags; playScene.SceneInstanceID = sceneInstanceID; playScene.SceneScriptPackageID = sceneTemplate.ScenePackageId; playScene.Location = position; playScene.TransportGUID = GetPlayer().GetTransGUID(); GetPlayer().SendPacket(playScene); AddInstanceIdToSceneMap(sceneInstanceID, sceneTemplate); Global.ScriptMgr.OnSceneStart(GetPlayer(), sceneInstanceID, sceneTemplate); return(sceneInstanceID); }
//加入房间的prefab public void initMapScenes(mapinfo mapInfo) { foreach (roominfo roomInfo in mapInfo.mRoomInfos) { SceneTemplate template = getSceneTemplate(roomInfo.mSceneIndex); if (roomInfo.mRoomType == constant.RoomType.Item) { int itemNum = 1; List <Vector3> poss = new List <Vector3>(); foreach (Vector3 v in template.BaseItemPos) { poss.Add(v); } for (int i = 0; i < itemNum; ++i) { itemtemplate item = constant.getItemFactory().getRandomTemplate(roomInfo, mapInfo); int index = Random.Range(0, poss.Count - 1); Vector3 v = poss[index]; poss.RemoveAt(index); roomInfo.addItemPrefabs(item, v); } } else if (roomInfo.mRoomType == constant.RoomType.Monster) { int monsterNum = 1; List <Vector3> poss = new List <Vector3>(); foreach (Vector3 v in template.BaseMonsterPos) { poss.Add(v); } //Debug.Log("count:" + poss.Count); for (int i = 0; i < monsterNum; ++i) { monstertemplate monster = constant.getMonsterFactory().getRandomTemplate(roomInfo, mapInfo); int index = Random.Range(0, poss.Count - 1); Vector3 v = poss[index]; poss.RemoveAt(index); roomInfo.addMonsterPrefabs(monster, v); } } } }
public static void HandlePlayScene(Packet packet) { var sceneId = packet.ReadInt32("SceneID"); SceneTemplate scene = new SceneTemplate { SceneID = (uint)sceneId }; scene.Flags = (uint)packet.ReadInt32("PlaybackFlags"); packet.ReadInt32("SceneInstanceID"); scene.ScriptPackageID = (uint)packet.ReadInt32("SceneScriptPackageID"); packet.ReadPackedGuid128("TransportGUID"); packet.ReadVector3("Pos"); packet.ReadSingle("Facing"); if (sceneId != 0) // SPELL_EFFECT_195 plays scenes by SceneScriptPackageID and sets SceneID = 0 (there are no Scenes which have SceneID = 0) { Storage.Scenes.Add(scene, packet.TimeSpan); } }
public static SceneObject CreateSceneObject(uint sceneId, Unit creator, Position pos, ObjectGuid privateObjectOwner) { SceneTemplate sceneTemplate = Global.ObjectMgr.GetSceneTemplate(sceneId); if (sceneTemplate == null) { return(null); } ulong lowGuid = creator.GetMap().GenerateLowGuid(HighGuid.SceneObject); SceneObject sceneObject = new(); if (!sceneObject.Create(lowGuid, SceneType.Normal, sceneId, sceneTemplate != null ? sceneTemplate.ScenePackageId : 0, creator.GetMap(), creator, pos, privateObjectOwner)) { sceneObject.Dispose(); return(null); } return(sceneObject); }
private static bool GenerateNoCloneSceneSetup() { var sceneTemplateAsset = AssetDatabase.LoadAssetAtPath <SceneTemplateAsset>(TestUtils.k_NoCloneGeneratedTemplate); if (sceneTemplateAsset != null) { return(true); } var inProjectTestScenePath = Path.Combine(TestUtils.k_TestGeneratedTemplateFolder, TestUtils.k_NoCloneSceneName); var result = AssetDatabase.CopyAsset(TestUtils.k_NoCloneScene, inProjectTestScenePath); if (!result) { return(false); } var sceneAsset = AssetDatabase.LoadAssetAtPath <SceneAsset>(inProjectTestScenePath); if (sceneAsset == null) { return(false); } SceneTemplate.CreateTemplateFromScene(sceneAsset, TestUtils.k_NoCloneGeneratedTemplate); sceneTemplateAsset = AssetDatabase.LoadAssetAtPath <SceneTemplateAsset>(TestUtils.k_NoCloneGeneratedTemplate); if (sceneTemplateAsset == null) { return(false); } foreach (var dep in sceneTemplateAsset.dependencies) { dep.instantiationMode = TemplateInstantiationMode.Reference; } EditorUtility.SetDirty(sceneTemplateAsset); AssetDatabase.SaveAssets(); return(true); }
//生成房间的道具或者怪物的prefabs的gameobject public void initRoomSceneInfo(roominfo info) { //Debug.Log ("info.mItemPrefabs:" +info.mItemPrefabs.Count); //Debug.Log ("info.mMonsterPrefabs:" +info.mMonsterPrefabs.Count); SceneTemplate scentemplate = constant.getMapFactory().getSceneTemplate(info.mSceneIndex); if (scentemplate.ScenePrefab != null) { GameObject clone = (GameObject)GameObject.Instantiate(Resources.Load(scentemplate.ScenePrefab), new Vector3(0, 0, 0), Quaternion.identity); } foreach (KeyValuePair <itemtemplate, Vector3> pair in info.mItemPrefabs) { Vector3 v = pair.Value; GameObject clone = (GameObject)GameObject.Instantiate(Resources.Load(pair.Key.PrefabPath), v, Quaternion.identity); } foreach (KeyValuePair <monstertemplate, Vector3> pair in info.mMonsterPrefabs) { Vector3 v = pair.Value; GameObject clone = (GameObject)GameObject.Instantiate(Resources.Load(pair.Key.PrefabPath), v, Quaternion.identity); } }
// Called when a player start a scene public virtual void OnSceneStart(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate) { }
public uint PlayScene(uint sceneId, Position position = null) { SceneTemplate sceneTemplate = Global.ObjectMgr.GetSceneTemplate(sceneId); return(PlaySceneByTemplate(sceneTemplate, position)); }
// Use this for initialization void Start() { gui = (SceneTemplate)FindObjectOfType(typeof(SceneTemplate)); }
void AddInstanceIdToSceneMap(uint sceneInstanceID, SceneTemplate sceneTemplate) { _scenesByInstance[sceneInstanceID] = sceneTemplate; }
// Called when a player receive trigger from scene public override void OnSceneTriggerEvent(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate, string triggerName) { if (triggerName == "BURN PLAYER") { player.CastSpell(player, SceneSpells.DeathwingSimulator, true); // Deathwing Simulator Burn player } }
// Called when a player receive trigger from scene public virtual void OnSceneTriggerEvent(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate, string triggerName) { }
public override void OnSceneTriggerEvent(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate, string triggerName) { SmartScript smartScript = new(); smartScript.OnInitialize(null, null, sceneTemplate); smartScript.ProcessEventsFor(SmartEvents.SceneTrigger, player, 0, 0, false, null, null, triggerName); }
// Called when a scene is completed public virtual void OnSceneComplete(Player player, uint sceneInstanceID, SceneTemplate sceneTemplate) { }