void loadNextNow() { currentScene = currentScene >= scenes.Length-1 ? 0:currentScene+1; Debug.Log ("L" + scenes.Length + "C" + currentScene); lastInfo = scenes[currentScene].GetComponent<SceneInfo>(); LoadScene (currentScene); }
public void Refresh(SceneInfo info) { if (info == null) { return; } this.mSceneInfo = info; if (Globals.Instance.Player.GetSceneTimes(this.mSceneInfo.ID) > 0) { this.mBoxCollider.enabled = false; this.mBgSp.spriteName = "awakeBtnGrey"; NGUITools.SetActive(this.mEffect35, false); } else { this.mBoxCollider.enabled = true; this.mBgSp.spriteName = "awakeBtn"; if (Globals.Instance.Player.GetSceneScore(this.mSceneInfo.ID - 1) > 0) { NGUITools.SetActive(this.mEffect35, false); NGUITools.SetActive(this.mEffect35, true); } else { NGUITools.SetActive(this.mEffect35, false); } } }
public bool AddOrUpdateMapTile(SceneInfo sceneInfo, Image mapTile) { if (m_assetClient == null) return false; int zoomLevel = 1; uint x = (uint)sceneInfo.MinPosition.X / 256u; uint y = (uint)sceneInfo.MinPosition.Y / 256u; byte[] pngData; using (MemoryStream stream = new MemoryStream()) { mapTile.Save(stream, System.Drawing.Imaging.ImageFormat.Png); pngData = stream.ToArray(); } Asset asset = new Asset { ContentType = "image/png", CreationDate = DateTime.UtcNow, CreatorID = sceneInfo.ID, Data = pngData, ID = TileNameToUUID(zoomLevel, x, y) }; // TODO: Create and store the other zoom levels return m_assetClient.StoreAsset(asset); }
public static string GetSceneIcon(SceneInfo sceneInfo, bool recommend) { if (sceneInfo == null) { return string.Empty; } if (sceneInfo.Difficulty == 0) { return (!recommend) ? "easy_1" : "easy"; } if (sceneInfo.Difficulty == 1) { return (!recommend) ? "hard_1" : "hard"; } return "dreamland"; }
public void SetScene(SceneInfo scene) { mrtex.updateRenderPasses = scene.updatePasses; noiseGenerator.SetFloat("_S", scene.noiseSpeed); particleUpdater.SetFloat("_Scale", scene.curlScale); particleUpdater.SetFloat("_Speed", scene.curlSpeed); particleUpdater.SetFloat("_Life", scene.pLifeTime); particleUpdater.SetFloat("_EmitRate", scene.emitRate); particleVisualizer.SetColor("_Col0", scene.col0); particleVisualizer.SetColor("_Col1", scene.col1); scene.Init(currentScene); currentScene = scene; }
public void Refresh(SceneInfo info, int sceneScore) { if (info == null) { return; } this.mSceneInfo = info; if (sceneScore == 0) { this.mStarScore[0].SetActive(false); this.mStarScore[1].SetActive(false); this.mStarScore[2].SetActive(false); this.mBkGroudBtn.normalSprite = "Disable"; } else { this.mBkGroudBtn.normalSprite = "hard"; switch (sceneScore) { case 1: this.mStarScore[0].SetActive(true); this.mStarScore[1].SetActive(false); this.mStarScore[2].SetActive(false); this.mStarScore[0].transform.localPosition = new Vector3(0f, -35f, 0f); break; case 2: this.mStarScore[0].SetActive(true); this.mStarScore[1].SetActive(true); this.mStarScore[2].SetActive(false); this.mStarScore[0].transform.localPosition = new Vector3(-20f, -32f, 0f); this.mStarScore[1].transform.localPosition = new Vector3(20f, -32f, 0f); break; case 3: this.mStarScore[0].SetActive(true); this.mStarScore[1].SetActive(true); this.mStarScore[2].SetActive(true); this.mStarScore[0].transform.localPosition = new Vector3(-34f, -26f, 0f); this.mStarScore[1].transform.localPosition = new Vector3(0f, -35f, 0f); this.mStarScore[2].transform.localPosition = new Vector3(34f, -26f, 0f); break; } } this.CreateModel(); this.mNextLevelEffect.SetActive(this.mSceneInfo.ID == this.GetNextUnBattleSceneId()); }
public void InitMapFarmItem(GameUIMapFarm baseScene, int timeIndex, MS2C_PveResult pveData, SceneInfo sceneInfo) { base.transform.FindChild("Sprite/Label").GetComponent<UILabel>().text = string.Format(Singleton<StringManager>.Instance.GetString("FormFinishText"), Singleton<StringManager>.Instance.GetString("FormFinishTimes").Substring(timeIndex, 1)); base.transform.FindChild("money/Label").GetComponent<UILabel>().text = string.Format("{0:#,###0}", pveData.LootMoney); base.transform.FindChild("exp/Label").GetComponent<UILabel>().text = pveData.LootExp.ToString(); Transform transform = base.transform.FindChild("item"); if (sceneInfo.Difficulty == 9) { transform.FindChild("noItemTips").gameObject.SetActive(false); GameObject gameObject = GameUITools.CreateReward(15, sceneInfo.RewardEmblem, 0, transform, true, true, 36f, -7f, -2000f, 20f, 13f, 7f, 0); if (gameObject == null) { return; } gameObject.transform.localScale = Vector3.zero; this.mMapRewardItems.Add(gameObject); } else if (pveData.Items.Count == 0) { transform.FindChild("noItemTips").gameObject.SetActive(true); } if (pveData.Items.Count != 0) { transform.FindChild("noItemTips").gameObject.SetActive(false); int num = 0; while (num < pveData.Items.Count && num < 4) { OpenLootData openLootData = pveData.Items[num]; if (openLootData != null) { GameObject gameObject2 = GameUITools.CreateReward(3, openLootData.InfoID, (int)openLootData.Count, transform, true, true, 0f, 0f, 0f, 255f, 255f, 255f, 0); if (!(gameObject2 == null)) { gameObject2.transform.localScale = Vector3.zero; this.mMapRewardItems.Add(gameObject2); } } num++; } } }
public IIncludedObject Load(Project project, XElement node) { var scene = new SceneInfo(); LoadBase(scene, node, project.BaseDir); scene.Duration = node.GetAttribute<int>("duration"); scene.CanSkip = node.TryAttribute<bool>("canskip"); foreach (var keyNode in node.Elements("Keyframe")) { scene.KeyFrames.Add(LoadKeyFrame(keyNode, project.BaseDir)); } var transferNode = node.Element("Next"); if (transferNode != null) { scene.NextHandler = _transferReader.Load(transferNode); } project.AddScene(scene); return scene; }
public SceneInfo[] SearchScenes(string query, int maxNumber, bool onlyEnabled) { IScene[] scenes = null; if (m_sceneFactory != null) scenes = m_sceneFactory.GetScenes(); SortedList<int, SceneInfo> foundScenes = new SortedList<int, SceneInfo>(); if (scenes != null) { for (int i = 0; i < scenes.Length; i++) { IScene scene = scenes[i]; if (scene.Name.ToLowerInvariant().Contains(query.ToLowerInvariant())) { foundScenes.Add(scene.Name.Length, SceneInfo.FromScene(scene)); if (foundScenes.Count == maxNumber) break; } } } // Copy the (sorted) found scenes to an array SceneInfo[] sceneInfos = new SceneInfo[foundScenes.Count]; for (int i = 0; i < foundScenes.Count; i++) sceneInfos[i] = foundScenes[i]; return sceneInfos; }
public bool TryGetSceneNear(Vector3d position, bool onlyEnabled, out SceneInfo sceneInfo) { IScene[] scenes = null; if (m_sceneFactory != null) scenes = m_sceneFactory.GetScenes(); IScene closestScene = null; double minDist = Double.MaxValue; if (scenes != null) { for (int i = 0; i < scenes.Length; i++) { IScene scene = scenes[i]; // Get the midpoint of this scene Vector3d midpoint = (scene.MaxPosition + scene.MinPosition) * 0.5d; // Compare this distance against the current minimum distance (squared, to avoid an unncessary sqrt) double distance = Vector3d.DistanceSquared(position, midpoint); if (distance < minDist) { minDist = distance; closestScene = scene; } } } if (closestScene != null) { sceneInfo = SceneInfo.FromScene(closestScene); return true; } sceneInfo = null; return false; }
static public Scene GetActive(SceneInfo sceneInfo) { return(GetActive(sceneInfo.SceneName)); }
private void OnEnable() { _target = target as SceneInfo; }
public void SetSceneInfo(SceneInfo info) { this.senceInfo = info; }
public void LoadSceneXML(string XMLFile, string RootPath) { XmlDocument SceneXML; XmlNodeList SceneList, TileList; SceneInfo NewScene; SceneTileInfo NewTile; cSceneList.Clear(); try { SceneXML = new XmlDocument(); SceneXML.Load(XMLFile); } catch (Exception ExErr) { throw new Exception(String.Format("Failed to load XML File {1}{0}Exception {2}{0}Message {3}", Environment.NewLine, XMLFile, ExErr.GetType().ToString(), ExErr.Message)); } SceneList = SceneXML.DocumentElement.SelectNodes(RootPath + "/scene"); foreach (XmlNode SceneNode in SceneList) { //Load all details regarding this scene if (SceneNode.Attributes["name"] != null) { NewScene = new SceneInfo(SceneNode.Attributes["name"].InnerText); } else { throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a scene tag with no name attribute.", Environment.NewLine, XMLFile)); } if (SceneNode.Attributes["tilewidth"] != null) { if (Int32.TryParse(SceneNode.Attributes["tilewidth"].InnerText, out NewScene.TileWidth) == false) { throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a scene tag with an invalid tilewidth attribute.", Environment.NewLine, XMLFile, NewScene.Name)); } } else { throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a scene tag with no tilewidth attribute.", Environment.NewLine, XMLFile, NewScene.Name)); } if (SceneNode.Attributes["tileheight"] != null) { if (Int32.TryParse(SceneNode.Attributes["tileheight"].InnerText, out NewScene.TileHeight) == false) { throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a scene tag with an invalid tileheight attribute.", Environment.NewLine, XMLFile, NewScene.Name)); } } else { throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a scene tag with no tileheight attribute.", Environment.NewLine, XMLFile, NewScene.Name)); } //Load individual tiles to draw in this scene TileList = SceneNode.SelectNodes("tile"); foreach (XmlNode TileNode in TileList) { NewTile = new SceneTileInfo(); //Load all tile details from the XML file if (TileNode.Attributes["setname"] != null) { NewTile.TileSetName = TileNode.Attributes["setname"].InnerText; } else { throw new Exception(String.Format("Failed to load XML File {1}{0}Encountered a tile tag with no name attribute in scene {2}.", Environment.NewLine, XMLFile, NewScene.Name)); } if (TileNode.Attributes["tilecol"] != null) { if (Int32.TryParse(TileNode.Attributes["tilecol"].InnerText, out NewTile.TileCoords.X) == false) { throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with an invalid tilecol attribute.", Environment.NewLine, XMLFile, NewScene.Name)); } } else { NewTile.TileCoords.X = -1; } if (TileNode.Attributes["tilerow"] != null) { if (Int32.TryParse(TileNode.Attributes["tilerow"].InnerText, out NewTile.TileCoords.Y) == false) { throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with an invalid tilerow attribute.", Environment.NewLine, XMLFile, NewScene.Name)); } } else { NewTile.TileCoords.Y = -1; } if (TileNode.Attributes["scenecol"] != null) { if (Int32.TryParse(TileNode.Attributes["scenecol"].InnerText, out NewTile.SceneCoords.X) == false) { throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with an invalid scenecol attribute.", Environment.NewLine, XMLFile, NewScene.Name)); } } else { throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with no scenecol attribute.", Environment.NewLine, XMLFile, NewScene.Name)); } if (TileNode.Attributes["scenerow"] != null) { if (Int32.TryParse(TileNode.Attributes["scenerow"].InnerText, out NewTile.SceneCoords.Y) == false) { throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with an invalid scenerow attribute.", Environment.NewLine, XMLFile, NewScene.Name)); } } else { throw new Exception(String.Format("Failed to load XML File {1}{0}In scene named {2} Encountered a tile tag with no scenerow attribute.", Environment.NewLine, XMLFile, NewScene.Name)); } if (TileNode.Attributes["tilename"] != null) { NewTile.TileNameInSet = TileNode.Attributes["tilename"].InnerText; } else { NewTile.TileNameInSet = ""; } NewScene.TileList.Add(NewTile); } cSceneList.Add(NewScene.Name, NewScene); } }
private void SendRegionOnline(SceneInfo neighbor) { // Build the region/online message uint regionX, regionY; GetRegionXY(m_scene.MinPosition, out regionX, out regionY); OSDMap regionOnline = new OSDMap { { "region_id", OSD.FromUUID(m_scene.ID) }, { "region_name", OSD.FromString(m_scene.Name) }, { "region_x", OSD.FromInteger(regionX) }, { "region_y", OSD.FromInteger(regionY) } }; // Put our public region seed capability into the message Uri publicSeedCap; if (m_scene.TryGetPublicCapability("public_region_seed_capability", out publicSeedCap)) regionOnline["public_region_seed_capability"] = OSD.FromUri(publicSeedCap); else m_log.Warn("Registering scene " + m_scene.Name + " with neighbor " + neighbor.Name + " without a public seed capability"); // Send the hello notification Uri regionOnlineCap; if (neighbor.TryGetCapability("region/online", out regionOnlineCap)) { try { UntrustedHttpWebRequest.PostToUntrustedUrl(regionOnlineCap, OSDParser.SerializeJsonString(regionOnline)); //m_log.Debug(scene.Name + " sent region/online to " + curScene.Name); } catch (Exception ex) { m_log.Warn(m_scene.Name + " failed to send region/online to " + neighbor.Name + ": " + ex.Message); } } else { m_log.Warn("No region/online capability found for " + neighbor.Name + ", " + m_scene.Name + " is skipping it"); } }
public void Add(SceneInfo info) { SceneInfos.Add(info); }
public static void SetLabelTextTo(TranslatedTextMeshPro label, string templateKey, SceneInfo scene) { if ((label != null) && (string.IsNullOrEmpty(templateKey) == false) && (scene != null)) { label.SetTranslationKey(templateKey, scene.DisplayName); } }
public void Generate() { if (_sceneInfoTypeMapping.Count == 0) { throw new InvalidOperationException($"Nothing will be generated. Did you forget to call {nameof(Initialize)}?"); } var scenePaths = AssetDatabaseExt.GetAllScenePaths(relativeToAssetFolder: true); if (scenePaths.Count == 0) { Debug.LogWarning("Nothing to generate because no scene was found."); return; } int count = 0; foreach (var scenePath in scenePaths) { // Get scene name string sceneName = Path.GetFileNameWithoutExtension(scenePath); if (string.IsNullOrWhiteSpace(sceneName)) { throw new InvalidOperationException($"Scene name cannot be null, empty, or whitespace: {scenePath}"); } // Get scene type var sceneAsset = AssetDatabase.LoadMainAssetAtPath(scenePath); var labels = AssetDatabase.GetLabels(sceneAsset).Where(label => !string.IsNullOrEmpty(label) && label.StartsWith(SceneTypeLabelPrefix)).ToList(); if (labels.Count == 0) { continue; } if (labels.Count > 1) { Debug.LogWarning($"Ignoring scene '{sceneName}' because it has {labels.Count} labels instead of 1: {string.Join(", ", labels)}."); } string sceneType = labels.First().Remove(0, SceneTypeLabelPrefix.Length); if (!_sceneInfoTypeMapping.ContainsKey(sceneType)) { Debug.LogWarning($"Unknown label '{sceneType}' on {sceneName}. " + $"Available labels are {string.Join(", ", _sceneInfoTypeMapping.Select(kvp => $"{kvp.Key} (for {kvp.Value.Name})"))}."); continue; } SceneInfo sceneInfo = (SceneInfo)ScriptableObject.CreateInstance(_sceneInfoTypeMapping[sceneType]); SceneReference sceneRef = new SceneReference() { ScenePath = scenePath }; _sceneRefField.SetValue(sceneInfo, sceneRef); AssetDatabase.CreateAsset(sceneInfo, $"Assets/{sceneName}.asset"); count++; } if (count == 0) { Debug.LogWarning("No asset was generated. " + "Did you forget to label your scenes? " + $"For example, put a '{SceneTypeLabelPrefix}Room' label on a Scene " + $"and run this tool again."); } else { Debug.Log($"Generated {count} assets.\nDon't forget to save!"); } }
private static void SetSceneName(SceneInfo sceneInfo, string newName) { sceneInfo.SetPrivateField("_sceneName", newName); }
public void Store(SceneInfo info) { History.Add(info.Id); }
public void LoadSceneInfo () { SceneInformation = GameObject.FindObjectOfType<SceneInfo> (); }
UI_Manager sceneUI;// = FindObjectOfType<UI_Manager>(); //public override void HandleHover() //{ // if(clicked>.5f){ // HandleTrigger(); // } //} //int FindButton(GameObject[] buttons, int j) //{ // int index = -1; // for (int i = 0; i < buttons.Length; i++) // { // if (j == buttons[i].GetComponentInParent<GalleryMenuItem>().info.sceneIndex) // index = i; //buttons[i].GetComponentInParent<GalleryMenuItem>().info.sceneIndex; // } // print("buttonIndex: " + index); // return index; //} public override void HandleTrigger() { base.HandleTrigger(); if (sceneInfo == null) { sceneInfo = FindObjectOfType <SceneInfo>(); } if (sceneUI == null) { sceneUI = FindObjectOfType <UI_Manager>(); } if (toggleVO) { sceneUI.ToggleVO(); } if (setVO) { if (sceneUI == null) { sceneUI = FindObjectOfType <UI_Manager>(); } if (sceneUI != null) { if (VOIsOn) { sceneUI.TurnOnVO(); } else { sceneUI.TurnOffVO(); } } } if (SetVOIntroVisible) { //if (sceneUI.VOIntroIndicator != null) //{ if (VOIntroVisible) { sceneUI.TurnOnVOIntroIndicator(); // VOIntroIndicator.TurnOn(); } else { sceneUI.TurnOffVOIntroIndicator(); //.TurnOff(); } //} } if (setTime) { sceneInfo.time = time; } if (setVolume) { sceneInfo.mainVolume = mainVolume; sceneInfo.ambientVolume = ambientVolume; } //else //{ // sceneInfo.mainVolume = 1; // sceneInfo.ambientVolume = 1; //} if (setMaxScenes) { sceneInfo.maxActiveScenes = maxScenes; } if (setScene) { ManageActiveScenes manager = FindObjectOfType <ManageActiveScenes>();// sceneInfo.GetComponent<ManageActiveScenes>(); manager.SetActiveScenes(scenes); if (GetComponentInParent <ButtonIndicator>() != null) { GetComponentInParent <ButtonIndicator>().TurnOn(); } if (forceButtonsToSceneSettings) { manager.ActivateButtonsBasedOnActiveScenes(); } //sceneInfo.whichScene = scenes[0]; } if (addScene) { ManageActiveScenes manager = sceneInfo.GetComponent <ManageActiveScenes>(); for (int i = 0; i < scenes.Count; i++) { bool flip = manager.AddScene(scenes[i]); if (!flip) { //print(flip); GetComponentInParent <ButtonIndicator>().TurnOff(); } else { GetComponentInParent <ButtonIndicator>().TurnOn(); } } } if (ping) { sceneInfo.ping = true; } if (setGame) { sceneInfo.gameMode = gameIsOn; } if (advanceScene) { sceneUI.SwitchScene(-1); } if (switchScene) { sceneUI.SwitchScene(scenes[0]); } }
private OSDMap RezAvatarRequest(SceneInfo sceneInfo, UserSession session, Vector3 relativeStartPosition, Vector3 lookAt) { string urlFriendlySceneName = WebUtil.UrlEncode(sceneInfo.Name); Uri publicRegionSeedCap = sceneInfo.PublicSeedCapability; // Send a request to the public region seed cap OSDMap publicRegionCaps = null; try { publicRegionCaps = OSDParser.Deserialize(UntrustedHttpWebRequest.GetUntrustedUrl(publicRegionSeedCap)) as OSDMap; if (publicRegionCaps != null) { publicRegionCaps = publicRegionCaps["capabilities"] as OSDMap; } } catch { } if (publicRegionCaps != null) { // Parse the rez_avatar/request cap out Uri rezAvatarRequestCap = publicRegionCaps["rez_avatar/request"].AsUri(); if (rezAvatarRequestCap != null) { string firstName, lastName; Util.GetFirstLastName(session.User.Name, out firstName, out lastName); OSDMap rezAvatarRequest = new OSDMap { { "agent_id", OSD.FromUUID(session.User.ID) }, { "session_id", OSD.FromUUID(session.SessionID) }, { "position", OSD.FromVector3(relativeStartPosition) }, { "look_at", OSD.FromVector3(lookAt) }, { "velocity", OSD.FromVector3(Vector3.Zero) }, { "child", OSD.FromBoolean(false) } }; OSDMap rezAvatarResponse = null; try { rezAvatarResponse = OSDParser.Deserialize(UntrustedHttpWebRequest.PostToUntrustedUrl( rezAvatarRequestCap, OSDParser.SerializeLLSDXmlString(rezAvatarRequest))) as OSDMap; } catch { } if (rezAvatarResponse != null) { // Parse the response data if (rezAvatarResponse["connect"].AsBoolean()) { return(rezAvatarResponse); } else { m_log.Warn("Cannot rez avatar " + session.User.Name + ", rez_avatar/request to " + rezAvatarRequestCap + " failed: " + rezAvatarResponse["message"].AsString()); } } } else { m_log.Warn("Cannot rez avatar " + session.User.Name + ", rez_avatar/request capability not found in public region seed capability: " + publicRegionCaps.ToString()); } } else { m_log.Warn("Cannot rez avatar " + session.User.Name + ", Failed to fetch public region seed capability from " + publicRegionSeedCap); } return(null); }
public static SceneInfo RootCollectionToRSMLScene(RootCollection collection) { SceneInfo scene = new SceneInfo() { Plants = new List <PlantInfo>() }; foreach (RootBase rootBase in collection.RootTree) { // Each rootbase tree represents a plant in this image. if (rootBase is RootGroup) { PlantInfo plant = new PlantInfo() { Roots = new List <RootInfo>(), RelativeID = rootBase.RelativeID }; if (rootBase.Label != "") { plant.Label = rootBase.Label; } RootGroup group = rootBase as RootGroup; // For each primary root foreach (PrimaryRoot primary in group.Children) { RootInfo primaryRootInfo = new RootInfo() { Children = new List <RootInfo>(), RelativeID = primary.RelativeID, RsmlID = primary.RelativeID, Polyline = null, Spline = primary.Spline }; if (primary.Label != "") { primaryRootInfo.Label = primary.Label; } foreach (LateralRoot lateral in primary.Children) { RootInfo lateralRootInfo = new RootInfo() { Children = new List <RootInfo>(), RelativeID = lateral.RelativeID, RsmlID = lateral.RelativeID, Polyline = null, Spline = lateral.Spline }; if (lateral.Label != "") { lateralRootInfo.Label = lateral.Label; } primaryRootInfo.Children.Add(lateralRootInfo); } plant.Roots.Add(primaryRootInfo); } scene.Plants.Add(plant); } } return(scene); }
private bool SendRezAvatarRequest(LLAgent agent, SceneInfo neighbor, bool isChild, out IPAddress simHost, out int simPort, out Uri seedCapability) { simHost = null; simPort = 0; seedCapability = null; Uri rezAvatarRequestCap; if (neighbor.TryGetCapability("rez_avatar/request", out rezAvatarRequestCap)) { string firstName, lastName; Util.GetFirstLastName(agent.Name, out firstName, out lastName); // Find the presence position relative to this neighbor Vector3 relativePosition = agent.ScenePosition - new Vector3(neighbor.MinPosition - m_scene.MinPosition); // Calculate the direction this agent is currently facing Vector3 lookAt = Vector3.UnitY * agent.RelativeRotation; // Create the template rez_avatar/request message OSDMap rezAvatarRequest = new OSDMap { { "agent_id", OSD.FromUUID(agent.ID) }, { "session_id", OSD.FromUUID(agent.SessionID) }, { "position", OSD.FromVector3(relativePosition) }, { "look_at", OSD.FromVector3(lookAt) }, { "velocity", OSD.FromVector3(agent.Velocity) }, { "child", OSD.FromBoolean(isChild) } }; OSDMap rezAvatarResponse = null; try { // Send the message and get a response rezAvatarResponse = OSDParser.Deserialize(UntrustedHttpWebRequest.PostToUntrustedUrl( rezAvatarRequestCap, OSDParser.SerializeJsonString(rezAvatarRequest))) as OSDMap; } catch { } if (rezAvatarResponse != null) { return RezChildAgentReplyHandler(agent, rezAvatarResponse, out simHost, out simPort, out seedCapability); } else { m_log.Warn(m_scene.Name + " failed to create a child agent on " + neighbor.Name + ", rez_avatar/request failed"); } } else { m_log.Warn(neighbor.Name + " does not have a rez_avatar/request capability"); } return false; }
public virtual void LoadSheet(SceneInfo info) { }
void Start() { gData = GameObject.FindGameObjectWithTag ("GlobalData").GetComponent<GlobalData> (); if (!gData.victory) { } blockX = groundPrefabs [0].GetComponent<SpriteRenderer> ().bounds.size.x * 15 / 16; blockY = groundPrefabs [0].GetComponent<SpriteRenderer> ().bounds.size.y * 15 / 16; enemyTypes = new List<Enemy> (); currentSceneInfo = new SceneInfo (); ablePos = new List<Vector3> (); addedPos = new List<Vector3> (); blockList = new List<GameObject> (); itemList = new List<GameObject> (); enemyList = new List<GameObject> (); digList = new List<GameObject> (); blockData = new List<ElementData> (); itemData = new List<ElementData> (); enemyData = new List<ElementData> (); digData = new List<ElementData> (); genPos = new Vector3 (0, 0, 0); int currentFloor = gData.currentFloor; int scenesNum = gData.currentTomb.sceneList.Count; //根据KEY从服务器加载物品掉落列表 //返回挖掘掉落,敌人掉落,棺材掉落列表(key: tombLevel_currentFloor) fallList = getFallList (gData.currentTomb.tombLevel + "_" + gData.currentFloor); getEnemyTypes (gData.currentTomb.tombLevel + "_" + gData.currentFloor); digPrefab = Resources.Load ("Dig", typeof(GameObject)) as GameObject; digSide = digPrefab.GetComponent<SpriteRenderer> ().bounds.size.x; playerSide = player.GetComponent<SpriteRenderer> ().bounds.size.x; uiInput = GameObject.FindGameObjectWithTag ("GameController").GetComponent<UI_Input> (); preEntryPrefab = Resources.Load ("PreEntry", typeof(GameObject)) as GameObject; coffinPrefab = Resources.Load ("Coffin", typeof(GameObject)) as GameObject; //不论是新的场景或是原来保存的场景,通往上一层的入口的位置总是在玩家(0,0,0)的位置,所以这个数据不用保存到全局数据的场景数据里 //在玩家位置生成上一层入口,由于该位置处不应该有敌人或场景物品,所以放在其他元素之前生成 Instantiate (preEntryPrefab, player.position, Quaternion.identity); if (scenesNum >= currentFloor) { GenerateSceneFromSceneInfo (gData.currentTomb.sceneList [currentFloor - 1]); } else { //生成场景 GenerateSceneRandom (); } //场景信息 Transform sceneInfoUI = GameObject.FindGameObjectWithTag ("UI").transform.FindChild ("SceneInfo"); sceneInfoUI.FindChild ("TombName").GetComponent<Text> ().text = gData.currentTomb.tombName; sceneInfoUI.FindChild ("FloorLable").GetComponent<Text> ().text = StringCollection.FLOOR; sceneInfoUI.FindChild ("Floor").GetComponent<Text> ().text = gData.currentFloor.ToString (); //自动上传当前记录 }
/// <summary> /// 填写产品列表 /// </summary> /// <param name="sceneDir">场景目录</param> /// <param name="scene">归属场景</param> private static void FindProduct(CustomDirectoryInfo sceneDir, SceneInfo scene) { errorPath = "FindProduct_" + sceneDir.FullPath; string[] productsDir = Directory.GetDirectories(sceneDir.FullPath); for (int i = 0; i < productsDir.Length; i++) { CustomDirectoryInfo dirItem;// = dirDic[productsDir[i]]; if (!dirDic.TryGetValue(productsDir[i], out dirItem)) { errorPath = productsDir[i]; throw new Exception("未检查到相关key值"); } errorPath = dirItem.FullPath; //去除中间的多余的横线造成的空字数据 string[] productAtt = dirItem.everyPathArr[dirItem.everyPathArr.Length - 1].Split('-'); List <string> productAttList = new List <string>(productAtt); for (int j = productAttList.Count - 1; j >= 0; j--) { if (string.IsNullOrEmpty(productAttList[j])) { productAttList.RemoveAt(j); } } productAtt = productAttList.ToArray(); ProductInfo product = new ProductInfo(); product.Name = productAtt[0]; product.productType = "厨房"; //添加标签 ProductFlagStruct productFlag = new ProductFlagStruct(); productFlag.flagTypeName = productAtt[1]; productFlag.flagValue = productAtt[2]; product.flag.Add(productFlag); //文件名列表,查找缩略图,以及产品介绍路径 string[] filesPath = Directory.GetFiles(dirItem.FullPath); for (int j = 0; j < filesPath.Length; j++) { CustomFileInfo fileInfo; if (fileDic.TryGetValue(filesPath[j], out fileInfo)) { if (fileInfo.ExName == ".jpg" || fileInfo.ExName == ".png" || fileInfo.ExName == ".jpge") { if (fileInfo.FileName.IndexOf("thumb") != -1) { product.ThumbnailPath = fileInfo.FullPath; } else { FindPano(fileInfo, product, scene); } //break; } else if (fileInfo.ExName == ".txt") { product.ProductContentPath = fileInfo.FullPath; } } } product.relatedSceneNames.Add(scene.Name); scene.includeProductNames.Add(product.Name); productList.Add(product); } }
static public void UnloadAsync(SceneInfo sceneInfo) { UnloadAsync(sceneInfo.SceneName); }
/// <summary> /// 填写场景列表 /// </summary> /// <param name="allSceneDir">场景目录</param> private static void FindScene(string allSceneDir) { //设置报错路径 errorPath = "FindScene" + allSceneDir; string[] scenesDir = Directory.GetDirectories(allSceneDir); for (int i = 0; i < scenesDir.Length; i++) { CustomDirectoryInfo dirItem;// = dirDic[scenesDir[i]]; if (!dirDic.TryGetValue(scenesDir[i], out dirItem)) { errorPath = scenesDir[i]; throw new Exception("未检查到相关key值"); } //设置报错路径 errorPath = dirItem.FullPath; //去除中间的多余的横线造成的空字数据 string[] sceneAtt = dirItem.everyPathArr[dirItem.everyPathArr.Length - 1].Split('-'); List <string> sceneAttList = new List <string>(sceneAtt); for (int j = sceneAttList.Count - 1; j >= 0; j--) { if (string.IsNullOrEmpty(sceneAttList[j])) { sceneAttList.RemoveAt(j); } } //获取数据 sceneAtt = sceneAttList.ToArray(); //设置数据 SceneInfo scene = new SceneInfo(); scene.Name = sceneAtt[0]; scene.sceneType.Add("厨房"); //添加标签 SceneFlagStruct flag = new SceneFlagStruct(); flag.flagTypeName = sceneAtt[1]; for (int j = 2; j < sceneAtt.Length; j++) { flag.flagValue += sceneAtt[j]; } scene.flag.Add(flag); //文件名列表,查找缩略图 string[] filesPath = Directory.GetFiles(dirItem.FullPath); for (int j = 0; j < filesPath.Length; j++) { CustomFileInfo fileInfo; if (fileDic.TryGetValue(filesPath[j], out fileInfo)) { if (fileInfo.ExName == ".jpg" || fileInfo.ExName == ".png" || fileInfo.ExName == ".jpge") { scene.ThumbnailPath = fileInfo.FullPath; break; } } } FindProduct(dirItem, scene); errorPath = scene.Name + "找不到全景图"; scene.DefaultPanoName = scene.includePanoNames[0]; sceneList.Add(scene); } }
static public bool IsActive(SceneInfo sceneInfo) { return(IsActive(sceneInfo.SceneName)); }
public EnvSceneInfo(string displayName, SceneInfo sceneInfo) { this.displayName = displayName; this.sceneName = sceneInfo.sceneName; this.sceneInfo = sceneInfo; }
static public void LoadAsync(SceneInfo sceneInfo, Action <Scene> callback = null) { LoadAsync(sceneInfo.SceneName, sceneInfo.LoadMode, callback, sceneInfo.AllowMultiple); }
private void OnSencePreLoad(SceneInfo _senceInfo) { if (this.SencePreLoadEvent != null) { this.SencePreLoadEvent(_senceInfo); } }
private static void MakeGridToString(GameObject terrainGo, SceneInfo sceneInfo) { StringBuilder strinBuilder = new StringBuilder(); if (terrainGo != null) { //生成网格用来寻路 MeshRenderer meshRender = terrainGo.GetComponent <MeshRenderer>(); Vector3 size = meshRender.bounds.size; Vector3 center = meshRender.bounds.center; float allX = size.x; // + Mathf.Abs(center.x)*2f; float allZ = size.z; // + Mathf.Abs(center.z)*2f; int xLength = 0; int zLength = 0; if (allX % 2f != 0f) { xLength = (int)allX + 1; if (xLength % 2 != 0) { xLength++; } } else { xLength = (int)allX; } if (allZ % 2f != 0f) { zLength = (int)allZ + 1; if (zLength % 2 != 0) { zLength++; } } else { zLength = (int)allZ; } byte[,] grids = new byte[xLength, zLength]; strinBuilder.Append(xLength.ToString()); strinBuilder.Append(","); strinBuilder.Append(zLength.ToString()); strinBuilder.Append(","); Debug.Log("xLength:" + xLength + " / zLength:" + zLength); int offsetZ = 0; if (center.z != 0f) { offsetZ = center.z - (int)center.z != 0f ? (int)center.z + (center.z > 0f ? 1 : -1) : (int)center.z; } int offsetX = 0; if (center.x != 0f) { offsetX = center.x - (int)center.x != 0f ? (int)center.x + (center.x > 0f ? 1 : -1) : (int)center.x; } strinBuilder.Append(offsetX.ToString()); strinBuilder.Append(","); strinBuilder.Append(offsetZ.ToString()); strinBuilder.Append("/"); //Debug.Log("offsetZ:" + offsetZ + " / offsetX:" + offsetX); int startX = -xLength / 2 + offsetX; int endX = xLength / 2 + offsetX; //Debug.Log("startX:" + startX + " / endX:" + endX); int startZ = -zLength / 2 + offsetZ; int endZ = zLength / 2 + offsetZ; //Debug.Log("startZ:" + startZ + " / endZ:" + endZ); int x = 0; int j = 0; for (int i = startX; i < endX; ++i) { float xx = i + 0.5f; int y = 0; for (j = startZ; j < endZ; ++j) { float yy = j + 0.5f; //todo 射线检测 //strinBuilder.Append(x.ToString()); //strinBuilder.Append(","); //strinBuilder.Append(y.ToString()); //strinBuilder.Append(","); Vector3 position = Vector3.zero; RaycastHit raycastHit; Vector3 startPosition = new Vector3(xx, 30f, yy); bool isHit = Physics.Raycast(startPosition, Vector3.down * 50f, out raycastHit); if (isHit) { position = raycastHit.point; if (raycastHit.transform.tag == GameObjectTags.Block) { grids[x, y] = 0; } else if (raycastHit.transform.tag == GameObjectTags.Terrain) { //Debug.Log(raycastHit.point); grids[x, y] = 1; } } else { grids[x, y] = 0; } strinBuilder.Append(grids[x, y].ToString()); strinBuilder.Append(","); // strinBuilder.Append(position.x.ToString("0.00")); // strinBuilder.Append(","); strinBuilder.Append(position.y.ToString("0.00")); //strinBuilder.Append(","); //strinBuilder.Append(position.z.ToString("0.00")); if (x == xLength - 1 && y == zLength - 1) { } else { strinBuilder.Append("/"); } //Debug.Log(x + "_" + y + ": " + grids[x, y] + "/" + xx + "/" + yy); y++; } //Debug.Log("y:" + y); x++; } Debug.Log("x:" + x); } sceneInfo.GridsContent = strinBuilder.ToString(); }
private bool BorderCrossLLAgent(LLAgent agent, SceneInfo neighbor) { IPAddress simHost; int simPort; Uri seedCapability; // Send a rez_avatar/request message to create a root agent or upgrade a child agent if (SendRezAvatarRequest(agent, neighbor, false, out simHost, out simPort, out seedCapability)) { // Demote this agent to a child agent agent.IsChildPresence = true; // Calculate our position relative to the new region Vector3 relativePosition = agent.ScenePosition - new Vector3(neighbor.MinPosition - m_scene.MinPosition); // Send the CrossedRegion message over the event queue to the client CrossedRegionMessage crossed = new CrossedRegionMessage(); crossed.AgentID = agent.ID; crossed.SessionID = agent.SessionID; crossed.RegionHandle = Util.PositionToRegionHandle(neighbor.MinPosition); crossed.IP = simHost; crossed.Port = simPort; crossed.Position = relativePosition; crossed.LookAt = agent.CameraAtAxis; // TODO: Get LookAt from the agent's rotation crossed.SeedCapability = seedCapability; m_log.Info("Sending CrossedRegion to " + agent.Name + " from " + m_scene.Name + " to " + neighbor.Name + ", pos=" + relativePosition + ", vel=" + agent.Velocity); agent.EventQueue.QueueEvent("CrossedRegion", crossed.Serialize()); return true; } else { m_log.Warn("Border crossing " + agent.Name + " from " + m_scene.Name + " to " + neighbor.Name + " failed, rez_avatar/request did not succeed"); return false; } }
void Start() { _sceneInfo = FindObjectOfType <SceneInfo>(); }
private void RegionOnlineHandler(IHttpClientContext context, IHttpRequest request, IHttpResponse response) { OSDMap requestMap = null; try { requestMap = OSDParser.Deserialize(request.Body) as OSDMap; } catch { } if (requestMap != null) { Vector3d minPosition = new Vector3d(requestMap["region_x"].AsReal(), requestMap["region_y"].AsReal(), 0.0d); Vector3d maxPosition = new Vector3d(minPosition.X + 256.0d, minPosition.Y + 256.0d, 4096.0d); SceneInfo scene = new SceneInfo { ID = requestMap["region_id"].AsUUID(), Name = requestMap["region_name"].AsString(), MinPosition = minPosition, MaxPosition = maxPosition, PublicSeedCapability = requestMap["public_region_seed_capability"].AsUri() }; //m_log.Debug(m_scene.Name + " adding neighbor " + scene.Name); m_scene.AddNeighbor(scene); } else { m_log.Warn("Failed to parse region/online request"); } }
private static StageInfo GetStage(ClassicStageInfo stage) { StageInfo stageInfo = new StageInfo { stage = Stage.Custom, customStageName = "", }; SceneInfo info = stage.GetComponent <SceneInfo>(); if (!info) { return(stageInfo); } SceneDef scene = info.sceneDef; if (!scene) { return(stageInfo); } switch (scene.sceneName) { case "golemplains": stageInfo.stage = Stage.TitanicPlains; break; case "blackbeach": stageInfo.stage = Stage.DistantRoost; break; case "goolake": stageInfo.stage = Stage.AbandonedAqueduct; break; case "foggyswamp": stageInfo.stage = Stage.WetlandAspect; break; case "frozenwall": stageInfo.stage = Stage.RallypointDelta; break; case "wispgraveyard": stageInfo.stage = Stage.ScorchedAcres; break; case "dampcavesimple": stageInfo.stage = Stage.AbyssalDepths; break; case "shipgraveyard": stageInfo.stage = Stage.SirensCall; break; case "goldshores": stageInfo.stage = Stage.GildedCoast; break; default: stageInfo.stage = Stage.Custom; stageInfo.customStageName = scene.sceneName; break; } return(stageInfo); }
private bool TryGetLoginScene(UserSession session, ref string startLocation, out SceneInfo sceneInfo, out Vector3 sceneStartPosition, out Vector3 lookAt, out IPAddress address, out int port, out Uri seedCap) { sceneInfo = null; sceneStartPosition = Vector3.Zero; lookAt = Vector3.UnitY; if (startLocation.Equals("last", StringComparison.InvariantCultureIgnoreCase)) { m_gridClient.TryGetScene(session.User.LastSceneID, out sceneInfo); sceneStartPosition = session.User.LastPosition; } else if (startLocation.Equals("home", StringComparison.InvariantCultureIgnoreCase)) { m_gridClient.TryGetScene(session.User.HomeSceneID, out sceneInfo); sceneStartPosition = session.User.HomePosition; } else { // Parse the start location into a search query Regex regex = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); Match uriMatch = regex.Match(startLocation); if (uriMatch != null) { // Use our search query through the grid client to find a match string region = uriMatch.Groups["region"].Value; SceneInfo[] results = m_gridClient.SearchScenes(region, 1, true); if (results != null && results.Length > 0) { sceneInfo = results[0]; float x, y, z; Single.TryParse(uriMatch.Groups["x"].Value, out x); Single.TryParse(uriMatch.Groups["y"].Value, out y); Single.TryParse(uriMatch.Groups["z"].Value, out z); sceneStartPosition = new Vector3(x, y, z); } } } // Try to find any valid region to start in if (sceneInfo == null) { m_gridClient.TryGetSceneNear(Vector3d.Zero, true, out sceneInfo); if (sceneInfo != null) { sceneStartPosition = new Vector3((sceneInfo.MinPosition + sceneInfo.MaxPosition) * 0.5d - sceneInfo.MinPosition); sceneStartPosition.Z = 0f; } } if (sceneInfo != null) { // Send a rez_avatar/request message to this scene OSDMap response = RezAvatarRequest(sceneInfo, session, sceneStartPosition, lookAt); if (response != null) { sceneStartPosition = response["position"].AsVector3(); lookAt = response["look_at"].AsVector3(); IPAddress.TryParse(response["sim_host"].AsString(), out address); port = response["sim_port"].AsInteger(); seedCap = response["region_seed_capability"].AsUri(); m_log.Debug("Found scene " + sceneInfo.Name + " for " + session.User.Name + " to login to"); return(true); } else if (startLocation.Equals("last", StringComparison.InvariantCultureIgnoreCase)) { m_log.Info("Could not create a presence for user " + session.User.Name + " in last scene " + sceneInfo.Name + ", trying home starting location"); startLocation = "home"; return(TryGetLoginScene(session, ref startLocation, out sceneInfo, out sceneStartPosition, out lookAt, out address, out port, out seedCap)); } else { m_log.Info("Could not create a presence for user " + session.User.Name + " in home scene " + sceneInfo.Name + ", giving up"); } } else { m_log.Warn("Could not find a starting location for " + session.User.Name + " with requested location " + startLocation); } sceneStartPosition = Vector3.Zero; lookAt = Vector3.Zero; address = null; port = 0; seedCap = null; return(false); }
private bool BorderCrossEntity(ISceneEntity entity, SceneInfo neighbor) { return false; }
void RefreshBuildIndex(SceneInfo t_SI) { t_SI.BuildIndex = LSR.ScenesInBuildSettings.FindIndex(npcString => npcString == t_SI.SceneName); }
private bool CheckForBorderCrossing(ISceneEntity entity, out SceneInfo neighbor) { Vector3 pos = entity.ScenePosition; if (!m_borderCrossAABB.Intersects(pos)) { // We are outside the scene AABB plus threshold, test if we entered into a neighbor // scene SceneInfo[] closestNeighbors = m_scene.GetNeighborsNear(m_scene.MinPosition + new Vector3d(pos), 0.1); if (closestNeighbors.Length > 0 && closestNeighbors[0].ID != m_scene.ID) { neighbor = closestNeighbors[0]; return true; } } neighbor = null; return false; }
private CustomLevelStaticData LoadNewSong(CustomSongInfo song, GameScenesManager gameScenesManager) { CustomLevelStaticData newLevel = null; try { newLevel = ScriptableObject.CreateInstance <CustomLevelStaticData>(); newLevel.jsonPath = song.path; } catch (NullReferenceException) { //LevelStaticData.OnEnable throws null reference exception because we don't have time to set _difficultyLevels } ReflectionUtil.SetPrivateField(newLevel, "_levelId", song.levelId); ReflectionUtil.SetPrivateField(newLevel, "_authorName", song.authorName); ReflectionUtil.SetPrivateField(newLevel, "_songName", song.songName); ReflectionUtil.SetPrivateField(newLevel, "_songSubName", song.songSubName); ReflectionUtil.SetPrivateField(newLevel, "_previewStartTime", song.previewStartTime); ReflectionUtil.SetPrivateField(newLevel, "_previewDuration", song.previewDuration); ReflectionUtil.SetPrivateField(newLevel, "_beatsPerMinute", song.beatsPerMinute); StartCoroutine(LoadSprite("file://" + song.path + "/" + song.coverImagePath, newLevel, "_coverImage")); SceneInfo newSceneInfo = ScriptableObject.CreateInstance <SceneInfo>(); ReflectionUtil.SetPrivateField(newSceneInfo, "_gameScenesManager", gameScenesManager); ReflectionUtil.SetPrivateField(newSceneInfo, "_sceneName", song.environmentName); ReflectionUtil.SetPrivateField(newLevel, "_environmetSceneInfo", newSceneInfo); List <CustomLevelStaticData.CustomDifficultyLevel> difficultyLevels = new List <CustomLevelStaticData.CustomDifficultyLevel>(); foreach (CustomSongInfo.DifficultyLevel diffLevel in song.difficultyLevels) { CustomLevelStaticData.CustomDifficultyLevel newDiffLevel = new CustomLevelStaticData.CustomDifficultyLevel(); try { LevelStaticData.Difficulty difficulty = diffLevel.difficulty.ToEnum(LevelStaticData.Difficulty.Normal); ReflectionUtil.SetPrivateField(newDiffLevel, "_difficulty", difficulty); ReflectionUtil.SetPrivateField(newDiffLevel, "_difficultyRank", diffLevel.difficultyRank); if (!File.Exists(song.path + "/" + diffLevel.jsonPath)) { Logger.Log("Couldn't find difficulty json " + song.path + "/" + diffLevel.jsonPath); continue; } newDiffLevel.jsonPath = song.path + "/" + diffLevel.jsonPath; newDiffLevel.audioPath = song.path + "/" + diffLevel.audioPath; difficultyLevels.Add(newDiffLevel); } catch (Exception e) { Logger.Log("Error parsing difficulty level in song: " + song.path); Logger.Log(e.Message); continue; } } if (difficultyLevels.Count == 0) { return(null); } ReflectionUtil.SetPrivateField(newLevel, "_difficultyLevels", difficultyLevels.ToArray()); return(newLevel); }
private void SendRegionOffline(SceneInfo neighbor) { // Build the region/offline message OSDMap regionOffline = new OSDMap { { "region_id", OSD.FromUUID(m_scene.ID) } }; Uri regionOfflineCap; if (neighbor.TryGetCapability("region/offline", out regionOfflineCap)) { // Send the message try { UntrustedHttpWebRequest.PostToUntrustedUrl(regionOfflineCap, OSDParser.SerializeJsonString(regionOffline)); m_log.Debug(m_scene.Name + " sent region/offline to " + neighbor.Name); } catch (Exception ex) { m_log.Warn(m_scene.Name + " failed to send region/offline to " + neighbor.Name + ": " + ex.Message); } } else { m_log.Warn("No region/offline capability found for " + neighbor.Name + ", " + m_scene.Name + " is skipping it"); } }
private void SetCurrentScene(SceneInfo scene) { _currentScene = scene; InitCurrentSceneController(); }
private bool SendRezAvatarRequest(LLAgent agent, SceneInfo neighbor, bool isChild) { IPAddress simHost; int simPort; Uri seedCapability; return SendRezAvatarRequest(agent, neighbor, isChild, out simHost, out simPort, out seedCapability); }
private void OnGUI() { type = EditorGUILayout.IntPopup("类型", type, new[] { "--请选择--", "加载场景", "加载人物对话 或 CG背景", "加载剧本文件" }, new[] { -1, 0, 1, 2 }); switch (type) { case -1: return; case 0: GUILayout.BeginVertical("Box"); GUILayout.Label("加载场景"); GUILayout.Label(" "); name = EditorGUILayout.TextField("名字:", name); pos = -1; isAssets = GUILayout.Toggle(isAssets, "添加媒体资源"); AddAssets(isAssets); GUILayout.EndVertical(); break; case 1: GUILayout.BeginVertical("Box"); GUILayout.Label("加载人物对话 或 CG背景"); GUILayout.Label(" "); name = EditorGUILayout.TextField("名字:", name); pos = EditorGUILayout.IntPopup("位置", pos, new[] { "左", "中", "右", "莫得人物" }, new[] { 0, 1, 2, -1 }); GUILayout.Label("内容:"); talk = EditorGUILayout.TextArea(talk, GUILayout.Height(50)); isAssets = GUILayout.Toggle(isAssets, "添加媒体资源"); AddAssets(isAssets); GUILayout.EndVertical(); break; case 2: GUILayout.BeginVertical("Box"); GUILayout.Label("加载剧本文件"); GUILayout.Label(" "); scenario = EditorGUILayout.ObjectField("剧本文件", scenario, typeof(TextAsset), true) as TextAsset; GUILayout.EndVertical(); break; } if (GUILayout.Button("添加下一条", GUILayout.Width(510))) { Debug.Log("添加下一条"); switch (type) { case -1: return; case 0: BaseData sceneData = new SceneInfo(); sceneData.type = type; sceneData.name = name; sceneData.pos = pos; if (isAssets) { sceneData.assets = AddAssets(isAssets); } GlobalState.datas.Add(sceneData); break; case 1: BaseData chData = new CharacterItem(); chData.type = type; chData.name = name; chData.pos = pos; chData.talk = talk; if (isAssets) { chData.assets = AddAssets(isAssets); } GlobalState.datas.Add(chData); break; case 2: BaseData snData = new SceneInfo(); snData.type = type; snData.assets.scenario = AssetDatabase.GetAssetPath(scenario); GlobalState.datas.Add(snData); break; default: break; } type = -1; name = ""; pos = -1; talk = ""; bgm = null; voice = null; effectAudio = null; scenario = null; img = null; isAssets = false; } }
public void SendFailLog(SceneInfo sInfo) { if (sInfo == null) { return; } MC2S_CombatLog mC2S_CombatLog = new MC2S_CombatLog(); int type = sInfo.Type; if (type != 6) { if (type != 7) { if (type != 0) { return; } mC2S_CombatLog.Type = 3; } else { mC2S_CombatLog.Type = 5; } } else { mC2S_CombatLog.Type = 4; } mC2S_CombatLog.Log = this.actorMgr.GetCombatLog(); Globals.Instance.CliSession.SendPacket(649, mC2S_CombatLog); }
/// <summary> /// Finds the scene if loaded. /// </summary> /// <returns>True if scene is loaded</returns> public static bool GetSceneIfLoaded(SceneInfo sceneInfo, out Scene editorScene) { editorScene = default(Scene); editorScene = EditorSceneManager.GetSceneByName(sceneInfo.Name); return(editorScene.IsValid() && editorScene.isLoaded); }
//从保存的数据中加载场景 void GenerateSceneFromSceneInfo(SceneInfo sceneInfo) { currentSceneInfo = sceneInfo; blockData = currentSceneInfo.BlockData; itemData = currentSceneInfo.ItemData; enemyData = currentSceneInfo.EnemyData; digData = currentSceneInfo.DigData; //修改玩家位置为保存的位置 player.position = gData.playerPos; gData.playerPos = new Vector3 (0, 0, 0); for (int i=0; i<blockData.Count; i++) { string prefabName = blockData [i].objName.Replace ("(Clone)", ""); object obj = Resources.Load (prefabName, typeof(GameObject)); GameObject blockObj = obj as GameObject; GameObject block = Instantiate (blockObj, blockData [i].pos, Quaternion.identity) as GameObject; block.transform.eulerAngles = blockData [i].eulerAngles; block.GetComponent<SpriteRenderer> ().sortingOrder = blockData [i].order; block.transform.parent = ground; } for (int i=0; i<itemData.Count; i++) { string prefabName = itemData [i].objName.Replace ("(Clone)", ""); object obj = Resources.Load (prefabName, typeof(GameObject)); GameObject itemObj = obj as GameObject; GameObject item = Instantiate (itemObj, itemData [i].pos, Quaternion.identity) as GameObject; item.GetComponent<SpriteRenderer> ().sortingOrder = itemData [i].order; item.transform.parent = groundItem; } //如果是从战斗场景回来,如果胜利,则移除敌人 ElementData enemyNeedToRemove = null; for (int i=0; i<enemyData.Count; i++) { if (!gData.victory || !gData.currentEnemyName.Equals (enemyData [i].objName)) { GameObject enemy = Instantiate (enemyPrefab, enemyData [i].pos, Quaternion.identity) as GameObject; enemy.name = enemyData [i].objName; enemy.GetComponent<SpriteRenderer> ().sortingOrder = enemyData [i].order; enemy.GetComponent<SpriteRenderer> ().sprite = Resources.Load <Sprite> ("_images/_game/" + enemyData [i].objName.Split (new char[]{'@'}) [0]); enemy.transform.parent = enemys; } else if (gData.victory && gData.currentEnemyName.Equals (enemyData [i].objName)) { enemyNeedToRemove = enemyData [i]; } } if (enemyNeedToRemove != null) { //敌人掉落 ItemFall (enemyNeedToRemove.objName.Replace ("(Clone)", "").Split (new char[]{'@'}) [0]); enemyData.Remove (enemyNeedToRemove); } //加载挖掘点 for (int i=0; i<digData.Count; i++) { GameObject dig = Instantiate (digPrefab, digData [i].pos, Quaternion.identity) as GameObject; dig.GetComponent<SpriteRenderer> ().sortingOrder = itemData [i].order; DigInfo di = dig.GetComponent<DigInfo> (); di.deep = ((DigData)digData [i]).deep; di.currentDeep = ((DigData)digData [i]).currentDeep; di.texType = ((DigData)digData [i]).texType; //更换贴图 dig.GetComponent<SpriteRenderer> ().sprite = Resources.Load <Sprite> ("_images/_game/dig_" + di.texType); dig.transform.parent = digs; //为了用于可挖掘位置的判断 digList.Add (dig); } }
void OnLocateScenes() { var info = new DirectoryInfo (Application.dataPath); var sceneFiles = info.GetFiles ("*.unity", SearchOption.AllDirectories); scenes = new SceneInfo[sceneFiles.Length]; for (var i = 0; i < sceneFiles.Length; ++i) { var file = sceneFiles[i]; var seperators = new string[] { "." }; var options = System.StringSplitOptions.RemoveEmptyEntries; var splitName = file.Name.Split (seperators, options); var fileName = splitName[0].ToString (); var filePath = file.FullName; scenes[i] = new SceneInfo (fileName, filePath); } }
/// <summary> /// Adds scene to build settings. /// </summary> /// <param name="sceneObject">Scene object reference.</param> /// <param name="setAsFirst">Sets as first scene to be loaded.</param> public static bool AddSceneToBuildSettings( SceneInfo scene, EditorBuildSettingsScene[] scenes, BuildIndexTarget buildIndexTarget = BuildIndexTarget.None) { if (scene.IsEmpty) { // Can't add a null scene to build settings return(false); } long localID; string managerGuidString; AssetDatabase.TryGetGUIDAndLocalFileIdentifier(scene.Asset, out managerGuidString, out localID); GUID sceneGuid = new GUID(managerGuidString); List <EditorBuildSettingsScene> newScenes = new List <EditorBuildSettingsScene>(scenes); // See if / where the scene exists in build settings int buildIndex = EditorSceneUtils.GetSceneBuildIndex(sceneGuid, newScenes); if (buildIndex < 0) { // It doesn't exist in the build settings, add it now switch (buildIndexTarget) { case BuildIndexTarget.First: // Add it to index 0 newScenes.Insert(0, new EditorBuildSettingsScene(sceneGuid, true)); break; case BuildIndexTarget.None: default: // Just add it to the end newScenes.Add(new EditorBuildSettingsScene(sceneGuid, true)); break; } EditorBuildSettings.scenes = newScenes.ToArray(); return(true); } else { switch (buildIndexTarget) { // If it does exist, but isn't in the right spot, move it now case BuildIndexTarget.First: if (buildIndex != 0) { Debug.LogWarning("Scene '" + scene.Name + "' was not first in build order. Changing build settings now."); newScenes.RemoveAt(buildIndex); newScenes.Insert(0, new EditorBuildSettingsScene(sceneGuid, true)); EditorBuildSettings.scenes = newScenes.ToArray(); } return(true); case BuildIndexTarget.Last: if (buildIndex != EditorSceneManager.sceneCountInBuildSettings - 1) { newScenes.RemoveAt(buildIndex); newScenes.Insert(newScenes.Count - 1, new EditorBuildSettingsScene(sceneGuid, true)); EditorBuildSettings.scenes = newScenes.ToArray(); } return(true); case BuildIndexTarget.None: default: // Do nothing return(false); } } }
public void Init(SceneInfo currentSceneInfo) { }
/// <summary> /// 获取所有选中的场景 /// </summary> /// <param name="ltScenePackage"></param> /// <returns></returns> static bool GetSelectScene(ref List<SceneInfo> ltScene) { if (ltScene == null) return false; UnityEngine.Object[] arrSelectionObject = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.DeepAssets); foreach (UnityEngine.Object obj in arrSelectionObject) { string strAssetPath = AssetDatabase.GetAssetPath(obj); FileInfo fileInfo = new FileInfo(BuilderTools.AssetPathToFullPath(strAssetPath)); if (fileInfo == null || fileInfo.Extension != ".unity") //如果不是场景文件,就要跳过 continue; SceneInfo sceneInfo = new SceneInfo(); sceneInfo.sceneName = obj.name; sceneInfo.scenePath = strAssetPath; ltScene.Add(sceneInfo); } return ltScene.Count > 0; }
static public bool IsBeingLoaded(SceneInfo sceneInfo) { return(IsBeingLoaded(sceneInfo.SceneName)); }
/// <summary> /// 检查一个场景所引用的包 /// </summary> /// <param name="scene"></param> /// <returns></returns> static bool CheckSceneDependence(SceneInfo scene) { //获取所有依赖的包 scene.ltDepPackages = new List<PackageInfo>(); scene.ltUnpackageAsset = new List<string>(); GetDependencePackageList(new string[] { scene.scenePath }, ref scene.ltDepPackages, ref scene.ltUnpackageAsset); return true; }
public void Init(SceneInfo preScene) { if(preScene != null&&preScene.currentCamera!=null) currentCamera = preScene.currentCamera; }
/// <summary> /// 打一个单独的场景包,包的依赖项已经在之前的逻辑中打出来了 /// </summary> /// <param name="scene"></param> /// <returns></returns> static bool BuildScene(SceneInfo scene, BuildTarget buildTarget) { string strOutputPath = scene.GetBundlePath(buildTarget);// BuilderTools.GetOutputPath(buildTarget) + scene.sceneName + BUNDLE_EXT; BuildPipeline.BuildStreamedSceneAssetBundle(new string[] { scene.scenePath }, strOutputPath, buildTarget); //生成信息文件 string strPackageInfoFilePath = scene.GetInfoPath(buildTarget);// BuilderTools.GetOutputPath(buildTarget) + scene.sceneName + PACKAGE_INFO_EXT; WritePackageInfoFile(strPackageInfoFilePath, scene.ltDepPackages); //生成版本信息文件,依赖项信息要做为md5的一部分 string strVersionFilePath = scene.GetVersionPath(buildTarget); string[] arrVerifyAssests = new string[scene.ltUnpackageAsset.Count + 1]; System.Array.Copy(scene.ltUnpackageAsset.ToArray(), arrVerifyAssests, scene.ltUnpackageAsset.Count); arrVerifyAssests[arrVerifyAssests.Length - 1] = strPackageInfoFilePath; // for (int i = 0; i < scene.ltUnpackageAsset.Count; ++i) // { // arrVerifyAssests[i] = scene.ltUnpackageAsset[i]; // } string strVersion = BuilderTools.GetVerifyString(arrVerifyAssests, null); File.WriteAllText(strVersionFilePath, strVersion); //写入统一的dat文件 string strDataFilePath = scene.GetDataPath(buildTarget);// BuilderTools.GetOutputPath(buildTarget) + scene.sceneName + DATA_EXT; CombineFinalPackage(strPackageInfoFilePath, strOutputPath, strDataFilePath); Debug.Log("writed output file: " + strDataFilePath); return true; }
private IEnumerator DoLoadScene(SceneInfo _senceInfo) { this.senceState = SenceState.PrepareLoad; progress = 0f; OnSencePreLoad(_senceInfo); Res.LoadScene(_senceInfo.ResLoc); AsyncIO = Application.LoadLevelAdditiveAsync(_senceInfo.ResLoc); senceState = SenceState.Loading; while(!AsyncIO.isDone) { progress = AsyncIO.progress * 0.96f; yield return 0; } AsyncIO = null; sceneInfo = _senceInfo; senceState = SceneManager.SenceState.Loaded; yield return new WaitForEndOfFrame(); OnSencePreLoaded(); while(!Globals.Instance.ResourceCache.IsAllResourceLoaded()) { yield return new WaitForEndOfFrame(); } SceneManager.DoGCCollect(); OnSenceLoaded(); LoadSceneCoroutine = null; progress = 1f; }