public HouseObject(Texture2D currMapObjectTex, Vector2 currObjectPosition, ContentManager Content, int height, int width) : base(currMapObjectTex, currObjectPosition, type.House) { locationMap = new MapLoader(); locationMap.loadContent(Content, height, width); locationMap.loadMap("content/houseMap.txt"); }
void LoadMap() { if(GameObject.Find("Map Mesh")) { mapLoader = GameObject.Find ("Map Mesh").GetComponent <MapLoader>(); } mapLoader.SetupScene (isSquare); }
public static bool Prefix(MapLoader __instance, ref string map, Il2CppSystem.Action <MapModel> loadedCallback) { lastMap = map; //Console.WriteLine(lastMap); //Console.WriteLine(listOfMaps.Where(x => x.name == lastMap).Count()); if (isCustom(lastMap)) { map = "MuddyPuddles"; } return(true); }
public static void SendInfo(EnumMyAction tag) { switch (tag) { case EnumMyAction.GameBoardReady: MapLoader ml = new MapLoader(); ml.Setup(); ml.LoadLogicalLevel(); ml.LoadVisualLevel(); InitPlayers(); break; } }
public static CollideMaterial FromOffset(Pointer offset) { MapLoader l = MapLoader.Loader; for (int i = 0; i < l.collideMaterials.Count; i++) { if (offset == l.collideMaterials[i].offset) { return(l.collideMaterials[i]); } } return(null); }
public IEnumerable <MapFile> GetMaps() { var mapsLoader = new MapLoader(); foreach (string file in GetFiles(mapsPath, "*.sgb", SearchOption.TopDirectoryOnly)) { MapFile?mapFile = LoadMap(mapsLoader, file); if (mapFile != null) { yield return(mapFile); } } }
public static Script Read(EndianBinaryReader reader, Pointer offset) { MapLoader l = MapLoader.Loader; Script s = new Script(offset); s.off_script = Pointer.Read(reader); if (s.off_script != null) { Pointer off_current = Pointer.Goto(ref reader, s.off_script); bool endReached = false; while (!endReached) { ScriptNode sn = ScriptNode.Read(reader, Pointer.Current(reader)); s.scriptNodes.Add(sn); bool waypointRef = false; if (l.mode == MapLoader.Mode.Rayman2PC) { if (R2AIFunctionTypes.getNodeType(sn.type) == R2AIFunctionTypes.NodeType.WayPointRef) { waypointRef = true; } } else if (l.mode == MapLoader.Mode.Rayman3PC) { if (R3AIFunctionTypes.getNodeType(sn.type) == R3AIFunctionTypes.NodeType.WayPointRef) { waypointRef = true; } } if (waypointRef) { Pointer off_wp = sn.param_ptr; Pointer original = Pointer.Goto(ref reader, off_wp); WayPoint waypoint = WayPoint.Read(reader, off_wp); l.print("Waypoint at " + waypoint.position.x + ", " + waypoint.position.y + ", " + waypoint.position.z); Pointer.Goto(ref reader, original); } if (sn.indent == 0) { endReached = true; } } Pointer.Goto(ref reader, off_current); } return(s); }
void createMapLoadButton(GameObject mapLoadContentGO, AvailableMap map, MapLoader loader) { Transform panelPrefab = getTransformByNameAndRoot("Panel", SuperController.singleton.mainMenuUI); Transform buttonPrefab = getTransformByNameAndRoot("Quit Button", SuperController.singleton.mainMenuUI); Transform textPrefab = getTransformByNameAndRoot("Text", SuperController.singleton.mainMenuUI); RectTransform buttonPrefabRT = buttonPrefab.GetComponent <RectTransform>(); RectTransform textPrefabRT = textPrefab.GetComponent <RectTransform>(); Image imagePrefab = buttonPrefab.GetComponent <Image>(); string style = buttonPrefab.GetComponent <UIStyleButton>().styleName; RectTransform mapLoadContentRT = mapLoadContentGO.GetComponent <RectTransform>(); GameObject mapLoadButtonGO = new GameObject("mapLoadButtonGO"); mapLoadButtonGO.transform.localScale = panelPrefab.localScale; mapLoadButtonGO.transform.SetParent(mapLoadContentGO.transform, false); Button mapLoadButtonUI = mapLoadButtonGO.AddComponent <Button>(); Image mapLoadButtonImage = mapLoadButtonGO.AddComponent <Image>(); UIStyleButton mplbStyle = mapLoadButtonGO.AddComponent <UIStyleButton>(); UIStyleImage mpliStyle = mapLoadButtonGO.AddComponent <UIStyleImage>(); RectTransform mapButtonRT = mapLoadButtonGO.GetComponent <RectTransform>(); //Copy values from existing components. CopyImageValues(imagePrefab, mapLoadButtonImage); mplbStyle.styleName = style; mpliStyle.styleName = style; CopyRectTransformValues(buttonPrefabRT, mapButtonRT); //Create new gameobject and ui for button text GameObject mapLoadTextGO = new GameObject("MapLoadText"); mapLoadTextGO.transform.localScale = textPrefab.localScale; mapLoadTextGO.transform.SetParent(mapLoadButtonGO.transform, false); Text mapLoadText = mapLoadTextGO.AddComponent <Text>(); UIStyleText mpltStyle = mapLoadButtonGO.AddComponent <UIStyleText>(); RectTransform mapTextRT = mapLoadTextGO.GetComponent <RectTransform>(); //Copy values from existing components. CopyRectTransformValues(textPrefabRT, mapTextRT); CopyTextValues(textPrefab.GetComponent <Text>(), mapLoadText); mpltStyle.styleName = style; mapLoadContentRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, mapLoadContentRT.rect.height + mapButtonRT.rect.height); //Update new components with adjusted values. mapLoadText.text = loader.Mapkey() + " - " + map.displayName; mapLoadButtonUI.onClick.AddListener(() => { LoadMap(map, loader); }); }
static public void LoadMap(ref string file_name) { MapLoader.SavedMapToMap(ref file_name, out currMap); //InfoWriter.BLOutputData2 = discRooms.Count().ToString(); //InfoWriter.TLOutputData = MapGenHelper.roomCounter.ToString(); maxMEngVportBounds.X = currMap.widthTiles * Globals.tileSize; maxMEngVportBounds.Y = currMap.heightTiles * Globals.tileSize; LoadMapTextures(); InfoWriter.ReInitialize(); }
private void Start() { if (currentSceneName == "CreateMapScene") { if (Filebrowser.folder._FilePath != null) { if (_Map != null && _Map.IsLoaded) { _Map.UnLoad(false); } if (_MapInfo == null) { MapLoader.SetJsonMapInfo(Filebrowser.folder.FileName); } if (_Map == null) { MapLoader.SetJsonMap(_MapInfo.songName, _MapInfo.currentDifficulty.difficulty); } } inputSongName = GameObject.Find("inputSongName").GetComponent <InputField>(); inputSongSubname = GameObject.Find("inputSongSubname").GetComponent <InputField>(); inputAuthorName = GameObject.Find("inputAuthorName").GetComponent <InputField>(); inputBPM = GameObject.Find("inputBPM").GetComponent <InputField>(); txtImageFileName = GameObject.Find("txtImageFilename").GetComponent <Text>(); txtAudioFilename = GameObject.Find("txtAudioFilename").GetComponent <Text>(); dropdownDifficulty = GameObject.Find("dropdownDifficulty").GetComponent <Dropdown>(); inputStartOffset = GameObject.Find("inputStartOffset").GetComponent <InputField>(); inputNoteJumpSpeed = GameObject.Find("inputNoteJumpSpeed").GetComponent <InputField>(); // Happens when creating a new map if (_MapInfo == null) { _MapInfo = new MapInfo(); } if (_Map == null) { _Map = new Map(); } UpdateInputFields(); } else if (currentSceneName == "EditingScene") { _Map.Load(notePrefab, bombSpherePrefab, blueCubePrefab, redCubePrefab); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); MapLoader myTarget = (MapLoader)target; if (GUILayout.Button("LoadFromXls")) { myTarget.LoadMap(myTarget.levelId); } if (GUILayout.Button("LoadFromDes")) { myTarget.LoadDesMap(myTarget.desFile); } }
private void LoadMap(bool lose = false) { Map loadedMap = loader.GetMap(); card = MapLoader.OneDToTwoDArray(loadedMap.map, loadedMap.mapWidth); targeti = MapLoader.OneDToTwoDArray(loadedMap.targets, 2); targets = targeti; startPos = loadedMap.startPos; currentDirection = loadedMap.direction; if (lose) { loader.OnMapUpdate(card, targeti); } }
private void frmOptions_Load(object sender, EventArgs e) { var settings = Settings.Load(); txtBlue.Text = settings.PlayerBlueDll; txtRed.Text = settings.PlayerRedDll; cboRed.SelectedItem = settings.PlayerRedTypeName; cboBlue.SelectedItem = settings.PlayerBlueTypeName; cboMap.Items.AddRange(MapLoader.GetMapNames().ToArray()); cboMap.SelectedItem = settings.MapName; }
void Awake() { instance = this; map = FindObjectOfType <MapLoader>(); levels = FindObjectOfType <LevelManager>(); collectibleSpawner = FindObjectOfType <CollectibleSpawner>(); blockSpawners = FindObjectsOfType <BlockSpawner>(); spawnManager = FindObjectOfType <SpawnManager>(); playerController = FindObjectOfType <PlayerController>(); camCon = FindObjectOfType <CameraController>(); bar = FindObjectOfType <BarManager>(); }
public void LoadMap(MapFile mapFile) { Debug.Log($"Load mapFile: {mapFile}"); Map = MapLoader.Load(mapFile); //Create map texture DomEdit.I.Ui.Get <MapPicture>().LoadMap(Map); //Open menus DomEdit.I.Ui.Get <SearchMenu>().Show(); DomEdit.I.Ui.Get <PlayersMenu>().Show(); DomEdit.I.Ui.Get <ControlButtonsMenu>().Show(); }
public static SKSurface Render(MapLoader mapLoader, float scale) { var tilesetLoader = new TilesetLoader($"data/maps/{mapLoader.TilesetName}.png", mapLoader.TileSize); int backgroundHeight = (int)Math.Round(mapLoader.MapPixelHeight * scale); int backgroundWidth = (int)Math.Round(mapLoader.MapPixelWidth * scale); var background = SKSurface.Create(new SKImageInfo(backgroundHeight, backgroundWidth)); DrawBackgroundLayer(background, mapLoader, tilesetLoader, 0, scale); DrawBackgroundLayer(background, mapLoader, tilesetLoader, 1, scale); return(background); }
public void Start(string imagePath) { Bitmap map = new Bitmap(imagePath); Width = map.Width; Height = map.Height; Dictionary <Point, BoundingBox> mapData = MapLoader.Loader(map); List <Point> points = mapData.Keys.Select(x => x).ToList(); foreach (Point pt in points) { Console.WriteLine($"Point: {pt} Type: {mapData[pt]} Name: {mapData[pt].Name} Health: {mapData[pt].Health}"); } }
private WebJSON.Message GetSelectionMessageJSON(bool includeLists, bool includeBrain) { MapLoader l = MapLoader.Loader; WebJSON.Message selectionJSON = new WebJSON.Message() { Type = WebJSON.MessageType.Selection, Selection = new WebJSON.Selection() { Perso = GetPersoJSON(selector.selectedPerso, includeLists: includeLists, includeBrain: includeBrain) } }; return(selectionJSON); }
/// <summary> /// Initializes the MapLoader /// </summary> private void Init() { if (s_Instance == null) { s_Instance = this; } else { Destroy(gameObject); } // Load all the maps' data LoadAllMapsData(); }
private void ParseSettingsJSON(JSONNode msg) { MapLoader l = MapLoader.Loader; if (msg["viewCollision"] != null) { controller.viewCollision = msg["viewCollision"].AsBool; } if (msg["luminosity"] != null) { controller.lightManager.luminosity = msg["luminosity"].AsFloat; } if (msg["saturate"] != null) { controller.lightManager.saturate = msg["saturate"].AsBool; } if (msg["viewGraphs"] != null) { controller.viewGraphs = msg["viewGraphs"].AsBool; } if (msg["enableLighting"] != null) { controller.lightManager.enableLighting = msg["enableLighting"].AsBool; } if (msg["enableFog"] != null) { controller.lightManager.enableFog = msg["enableFog"].AsBool; } if (msg["viewInvisible"] != null) { controller.viewInvisible = msg["viewInvisible"].AsBool; } if (msg["displayInactive"] != null) { controller.sectorManager.displayInactiveSectors = msg["displayInactive"].AsBool; } if (msg["playAnimations"] != null) { controller.playAnimations = msg["playAnimations"].AsBool; } if (msg["playTextureAnimations"] != null) { controller.playTextureAnimations = msg["playTextureAnimations"].AsBool; } if (msg["showPersos"] != null) { controller.showPersos = msg["showPersos"].AsBool; } }
public static ScriptNode Read(Reader reader, Pointer offset, Script script) { MapLoader l = MapLoader.Loader; ScriptNode sn = new ScriptNode(offset); sn.script = script; sn.param = reader.ReadUInt32(); sn.param_ptr = Pointer.GetPointerAtOffset(offset); // if parameter is pointer if (Settings.s.platform == Settings.Platform.DC) reader.ReadUInt32(); if (Settings.s.mode == Settings.Mode.Rayman3GC) { reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); sn.type = reader.ReadByte(); reader.ReadByte(); reader.ReadByte(); sn.indent = reader.ReadByte(); reader.ReadByte(); } else { reader.ReadByte(); reader.ReadByte(); sn.indent = reader.ReadByte(); sn.type = reader.ReadByte(); } sn.nodeType = NodeType.Unknown; if (Settings.s.aiTypes != null) sn.nodeType = Settings.s.aiTypes.GetNodeType(sn.type); if (sn.param_ptr != null && sn.nodeType != NodeType.Unknown) { //l.print("ScriptNode " + offset + " - " + sn.nodeType + " (" + sn.type + ") - " + sn.param_ptr); if (sn.nodeType == NodeType.WayPointRef) { WayPoint waypoint = WayPoint.FromOffsetOrRead(sn.param_ptr, reader); } else if (sn.nodeType == NodeType.String) { Pointer.DoAt(ref reader, sn.param_ptr, () => { string str = reader.ReadNullDelimitedString(); l.strings[sn.param_ptr] = str; }); } else if (sn.nodeType == NodeType.ObjectTableRef) { // In R2 some objects have object tables that aren't listed normally, but are referenced through scripts. } else if (sn.nodeType == NodeType.Button) { EntryAction.FromOffsetOrRead(sn.param_ptr, reader); } else if (sn.nodeType == NodeType.GameMaterialRef) { GameMaterial.FromOffsetOrRead(sn.param_ptr, reader); } else if (sn.nodeType == NodeType.VisualMaterial) { VisualMaterial.FromOffsetOrRead(sn.param_ptr, reader); } } return sn; }
public static GeometricObjectElementCollideSpheres Read(Reader reader, Pointer offset, GeometricObjectCollide geo) { MapLoader l = MapLoader.Loader; GeometricObjectElementCollideSpheres s = new GeometricObjectElementCollideSpheres(offset, geo); if (Settings.s.engineVersion > Settings.EngineVersion.Montreal) { s.off_spheres = Pointer.Read(reader); s.num_spheres = reader.ReadUInt16(); s.ind_parallelBox = reader.ReadInt16(); // -1 } else { s.num_spheres = (ushort)reader.ReadUInt32(); s.off_spheres = Pointer.Read(reader); } if (s.off_spheres != null) { Pointer off_current = Pointer.Goto(ref reader, s.off_spheres); s.spheres = new IndexedSphere[s.num_spheres]; for (uint i = 0; i < s.num_spheres; i++) { s.spheres[i] = new IndexedSphere(); if (Settings.s.engineVersion > Settings.EngineVersion.Montreal) { s.spheres[i].debug_radiusAddress = Pointer.Current(reader); s.spheres[i].radius = reader.ReadSingle(); s.spheres[i].off_material = Pointer.Read(reader); s.spheres[i].centerPoint = reader.ReadUInt16(); reader.ReadUInt16(); } else { s.spheres[i].centerPoint = reader.ReadUInt16(); reader.ReadUInt16(); s.spheres[i].debug_radiusAddress = Pointer.Current(reader); s.spheres[i].radius = reader.ReadSingle(); s.spheres[i].off_material = Pointer.Read(reader); } if (!geo.isBoundingVolume) { s.spheres[i].gameMaterial = GameMaterial.FromOffsetOrRead(s.spheres[i].off_material, reader); } } Pointer.Goto(ref reader, off_current); } return(s); }
public void moveEnemy(int nextColumn, int nextRow) { Vector3 currentPosition = transform.position; Vector2 nextPositionXY = MapLoader.MapCoordsToWorldCoordsFloat(new Vector2(nextColumn + 0.5f, nextRow + 0.5f)); Vector3 nextPosition = new Vector3(nextPositionXY.x, currentPosition.y, nextPositionXY.y); Vector3 distanceVector = nextPosition - currentPosition; Vector3 newPosition = Vector3.MoveTowards(transform.position, currentPosition + transform.forward, GetComponent <TankMovementParameters>().TankMovementSpeed *Time.deltaTime); if (!vectorEquals(newPosition, transform.position)) { transform.position = newPosition; transform.forward = Vector3.RotateTowards(transform.forward, distanceVector, GetComponent <TankMovementParameters>().TankRotationSpeed *Time.deltaTime, 0.0f); } }
public void LoadMap(AvailableMap map, MapLoader loader) { if (currentLoadedScene != null) { currentLoader.unloadMap(currentLoadedScene); } currentLoadedScene = loader.loadMap(map); currentLoader = loader; if (lm) { lm.am = currentLoadedScene; } }
private MapFile?LoadMap(MapLoader mapLoader, SgaRawFile scenario) { MapFile?mapFile = null; try { mapFile = mapLoader.Load(new MemoryStream(scenario.Data), scenario.Name); } catch (IOException ex) { logger.Write(ex, $"Failed to load {scenario.Name}", LogLevel.Warn); } return(mapFile); }
private void Update() { if (HUD.lastwidth != (float)Screen.width) { HUD.lastwidth = (float)Screen.width; base.gameObject.BroadcastMessage("OnResize", SendMessageOptions.DontRequireReceiver); HUD.currwidth = (float)Screen.width; HUD.currheight = (float)Screen.height; MapLoader.UpdateReflectionProbe(); } if (Input.GetKeyDown(KeyCode.F9)) { Options.ToggleFullScreen(); } }
public static Pointer GetPointerAtOffset(Pointer pointer) { MapLoader l = MapLoader.Loader; if (pointer.file.pointers.ContainsKey(pointer.offset)) { Pointer ptr = pointer.file.pointers[pointer.offset]; if (ptr.offset == 0) { return(null); } return(ptr); } return(null); }
// Use this for initialization void Start() { spriteRenderer.sprite = frontAnimations[0]; currentBehaviour = (Behaviours)Random.Range(0, 2); currentDirection = (Directions)Random.Range(0, 3); actionCount = Random.Range(0, 5); if (!mapLoader) { mapLoader = GameObject.Find("Map Loader").GetComponent <MapLoader>(); } playerCharacter = GameObject.Find("PlayerSprite(Clone)"); }
public ETC(Stream stream, int width, int height, bool hasAlpha) { MapLoader l = MapLoader.Loader; this.width = width; this.height = height; this.hasAlpha = hasAlpha; texture = UntoldUnpack.Graphics.Texture.ToTexture2D( UntoldUnpack.Graphics.PicaDataTypes.UnsignedByte, hasAlpha ? UntoldUnpack.Graphics.PicaPixelFormats.ETC1AlphaRGB8A4NativeDMP : UntoldUnpack.Graphics.PicaPixelFormats.ETC1RGB8NativeDMP, width, height, stream); }
private static List <GeoPoint> filterParkingPoints(List <GeoPoint> points) { var result = new List <GeoPoint>(); var graph = MapLoader.Load("Beijing_trust_oneside_no_dev"); foreach (var point in points) { var vertices = graph.VertexRangeQuery(point, 50); if (vertices.Count > 0) { result.Add(point); } } return(result); }
/// <summary> /// This method draws the floor only which causes no problems /// </summary> /// <param name="g"></param> public static Bitmap DrawBackgroundImage() { Bitmap returnBitmap = new Bitmap(window.Width, window.Height); using (Graphics gfx = Graphics.FromImage(returnBitmap)) { gfx.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; gfx.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.GammaCorrected; gfx.DrawImage(Model.Backgrounds[0], 0, 0, MainWindow.RightBound, MainWindow.LowerBound); MapLoader.DrawLevelFloor(gfx); gfx.Save(); } return(returnBitmap); }
private void InsertMapLevel(int ind, List <LvlButtonController> lvlButtonControllers) { Vector2 position = GetInterpolatedPosition(ind, lvlButtonControllers); MapLoader mapLoader = FindObjectOfType <MapLoader>(); LvlButtonController mapLevel = CreateMapLevel(ind, mapLoader.lvlBtnPrefab); mapLevel.transform.SetParent(_lvlButtonController.transform.parent, false); mapLevel.transform.SetSiblingIndex(ind); mapLevel.transform.position = position; lvlButtonControllers.Insert(ind, mapLevel); UpdateLevelsNumber(lvlButtonControllers); Selection.activeGameObject = mapLevel.gameObject; }
public Room(string name) { _name = name; MapLoader loader = new MapLoader(name); ArrayList layers = loader.Layers; ArrayList parsedLayers = new ArrayList(); CSVParser parser = CSVParser.Instance; foreach (string layer in layers) { parsedLayers.Add(CSVParser.ParseCSV(layer)); } // Dynamic objects (e.g. doors) DynamicObjects = loader.DynamicObjects; if (parsedLayers.Count != 0) { Layers = parsedLayers; } LoadDoorInfo(); }
public override void LoadContent() { main = ScreenSystem.Content.Load<SpriteFont>(@"Fonts/menu"); levelinfosmall = ScreenSystem.Content.Load<SpriteFont>(@"Fonts/LevelSelectSmall"); levelinfolarge = ScreenSystem.Content.Load<SpriteFont>(@"Fonts/LevelSelectLarge"); selectText = new Text("Select a map", main); selectText.Position = new Vector2(border.X, border.Y - selectText.Dimensions.Y); ml = ScreenSystem.Content.Load<MapLoader>("Maps\\MapLoader"); numberOfLevelsText = new Text(String.Format("[{0} maps]", ml.Maps.Count), main); numberOfLevelsText.Position = new Vector2(border.X + selectText.Dimensions.X + 10, border.Y - numberOfLevelsText.Dimensions.Y); previousMap = null; selectedMap = ml.Maps[index]; nextMap = (index + 1) < ml.Maps.Count ? ml.Maps[index + 1] : null; MapLoader.Singleton = ml; background = ScreenSystem.Content.Load<Texture2D>(@"Textures/Menu/MainMenuBackground"); pixel = new Texture2D(ScreenSystem.GraphicsDevice, 1, 1); Color[] cArray = new Color[] { Color.Black }; pixel.SetData<Color>(cArray); }
void Awake() { instance = this; }
public override void LoadContent() { ContentManager content = ScreenSystem.Content; SpriteFont = content.Load<SpriteFont>(@"Fonts/menu"); Texture2D entryTexture = content.Load<Texture2D>(@"Textures/Menu/MenuEntries"); BackgroundTexture = content.Load<Texture2D>(@"Textures/Menu/MainMenuBackground"); //Loads the title texture. TitleTexture = content.Load<Texture2D>(@"Textures/Menu/LogoWithText"); //Enable Mouse EnableMouse(content.Load<Texture2D>(@"Textures/Menu/mouse")); //Sets the title position InitialTitlePosition = TitlePosition = new Vector2((ScreenSystem.Viewport.Width - TitleTexture.Width) / 2, 50); //Initialize is called before LoadContent, so if you want to //use relative position with the line spacing like below, //you need to do it after load content and spritefont for (int i = 0; i < MenuEntries.Count; i++) { MenuEntries[i].AddTexture(entryTexture, 2, 1, new Rectangle(0, 0, entryTexture.Width / 2, entryTexture.Height), new Rectangle(entryTexture.Width / 2, 0, entryTexture.Width / 2, entryTexture.Height)); MenuEntries[i].AddPadding(14, 0); if (i == 0) MenuEntries[i].SetPosition(new Vector2(180, 250), true); else { int offsetY = MenuEntries[i - 1].EntryTexture == null ? SpriteFont.LineSpacing : 8; MenuEntries[i].SetRelativePosition(new Vector2(0, offsetY), MenuEntries[i - 1], true); } } ml = ScreenSystem.Content.Load<MapLoader>("Maps\\MapLoader"); selectedMap = ml.Maps[0]; }
// Use this for initialization void Start() { spriteRenderer.sprite = frontAnimations[0]; currentBehaviour = (Behaviours)Random.Range(0, 2); currentDirection = (Directions)Random.Range(0, 3); actionCount = Random.Range(0, 5); if (!mapLoader){ mapLoader = GameObject.Find("Map Loader").GetComponent<MapLoader>(); } playerCharacter = GameObject.Find("PlayerSprite(Clone)"); }
/* * Funcion: Start() * * En Unity, la funcion Start() de cualquier script que herede de MonoBehaviour se ejecuta automaticamente al inicio del programa. * * -Guarda el mapa de alturas seleccionado como dato persistente, para que permanezca a traves del cambio de escenas desde "inicio" * hasta "simulacion" * -Carga el mapa de alturas seleccionado. * -Carga e inicializa el renderer y el espacio de simulacion. */ void Start() { controlador = this; if (PersistentData.GlobalData != null && PersistentData.GlobalData.heightmapSelected) { heightmap = PersistentData.GlobalData.heightmap; } map_loader = new MapLoader (tamano_y, tamano_x, tamano_z, getHeightmapUrl(heightmap)); esp_renderer = GameObject.Find ("Renderer").GetComponent<EspRenderer> (); esp_renderer.inicializarScheduledCells (); Espacio esp = new Espacio(tamano_x, tamano_y, tamano_z, sensibilidad); espacio.rend = esp_renderer; esp_renderer.inicializar (espacio); //GameObject combinedTerrainObj = Instantiate(Resources.Load("CeldaTerreno", typeof(GameObject))) as GameObject; //esp_renderer.CombineTerrain(combinedTerrainObj); }
public MainWindow(EditorModel model) : base(Gtk.WindowType.Toplevel) { //Set the model, and add this window as a listener to the model this.model = model; model.AddListener(this); tileChooserWindow = new TileChooser(model); objectChooserWindow = new ObjectChooser(model); tileChooserWindow.Visible = false; objectChooserWindow.Visible = false; //Build window from design Build(); Title = WINDOW_TITLE; #region Event handlers #region Radio buttons //Set up event handlers radioDrawTiles.Toggled += delegate { if (radioDrawTiles.Active) { model.CurrentTool = EditorModel.Tool.DrawTile; tileChooserWindow.Visible = true; } else tileChooserWindow.Visible = false; }; radioCreateObjects.Toggled += delegate { if (radioCreateObjects.Active) { model.CurrentTool = EditorModel.Tool.CreateObject; objectChooserWindow.Visible = true; } else objectChooserWindow.Visible = false; }; radioSelectObjects.Toggled += delegate { if (radioSelectObjects.Active) { model.CurrentTool = EditorModel.Tool.SelectObject; } }; radioDrawTiles.Toggle(); #endregion #region Background, draw-to-layer spin comboBackgrounds.Changed += delegate(object sender, EventArgs e) { model.Background = ((ComboBox)sender).ActiveText; Log.Write("Changed background to " + ((ComboBox)sender).ActiveText); }; spinDrawToLayer.Changed += delegate { model.DrawToLayer = spinDrawToLayer.ValueAsInt; }; entryMapID.Changed += delegate { model.MapID = entryMapID.Text; }; #endregion #region Grid snapping // default value for snapping spinGridOffsetX.Value = 0; spinGridOffsetY.Value = 0; model.SnapToGrid = checkSnapToGrid.Active; model.GridSizeX = spinGridSizeX.ValueAsInt; model.GridSizeY = spinGridSizeY.ValueAsInt; model.GridOffsetX = spinGridOffsetX.ValueAsInt; model.GridOffsetY = spinGridOffsetY.ValueAsInt; checkSnapToGrid.Toggled += delegate { model.SnapToGrid = checkSnapToGrid.Active; }; spinGridSizeX.Changed += delegate { model.GridSizeX = spinGridSizeX.ValueAsInt; }; spinGridSizeY.Changed += delegate { model.GridSizeY = spinGridSizeY.ValueAsInt; }; spinGridOffsetX.Changed += delegate { model.GridOffsetX = spinGridOffsetX.ValueAsInt; }; spinGridOffsetY.Changed += delegate { model.GridOffsetY = spinGridOffsetY.ValueAsInt; }; #endregion //Set up event handlers for menu actions #region File->New NewAction.Activated += delegate { bool continueNew = false; //Used to stop the new map action if the user presses "cancel" on the question on wether or not to save //Check if the map has been changed. If so, ask the user if he/she would like to save. if (model.Changed) QuerySave(delegate { continueNew = true; SaveAction.Activate(); }, delegate {continueNew = true;}); else continueNew = true; //If continueNew is false, the user pressed cancel and we should therefor stop creating a new map. if (continueNew) { NewMapDialog newMapDialog = new NewMapDialog(model); newMapDialog.Response += delegate(object o, ResponseArgs args) { switch (args.ResponseId) { case ResponseType.Ok: NewMapDialog dlg = (NewMapDialog)o; MapEditorState.Schedule(delegate { model.CurrentTileset = model.ResourceManager.GetTileset(dlg.Tileset); model.TileMap = new TileMap(model.Display, model.CurrentTileset, dlg.MapWidth, dlg.MapHeight, dlg.MapDepth, dlg.XOffset, dlg.YOffset, dlg.TileSize); model.Display.CameraX = 0; model.Display.CameraY = 0; model.Display.Zoom = 100; model.Changed = false; model.Filename = ""; model.Objects.Clear(); model.DrawToLayer = 1; model.Background = ""; }); break; case ResponseType.Cancel: //Do nothing break; } }; newMapDialog.Run(); newMapDialog.Destroy(); } }; #endregion #region File->Open OpenAction.Activated += delegate { bool continueOpen = false; //Used to stop the new map action if the user presses "cancel" on the question on wether or not to save //Check if the map has been changed. If so, ask the user if he/she would like to save. if (model.Changed) QuerySave(delegate { continueOpen = true; SaveAction.Activate(); }, delegate {continueOpen = true;}); else continueOpen = true; //If continueOpen is false, the user pressed cancel and we should therefor stop opening another map. if (continueOpen) { FileChooserDialog dlg = new FileChooserDialog("Open map", this, FileChooserAction.Open, "Open", ResponseType.Ok, "Cancel", ResponseType.Cancel); FileFilter f = new FileFilter(); f.AddPattern("*.xml"); dlg.Filter = f; dlg.Response += delegate(object o, ResponseArgs args) { switch (args.ResponseId) { case ResponseType.Ok: string filename = dlg.Filename; MapEditorState.Schedule(delegate{ try { MapDescriptor mapDescriptor = new MapLoader().LoadResource(filename, ""); TileMap newTm = new TileMap(model.Display, model.ResourceManager, mapDescriptor); model.MapID = mapDescriptor.MapID; model.CurrentTileset = newTm.Tileset; model.TileMap = newTm; model.Objects.Clear(); foreach (MapDescriptor.MapObject obj in mapDescriptor.Objects) { Log.Write("Spawning object " + obj.Name); MapObject newObj = new MapObject(model.ResourceManager.GetObjectDescriptor(obj.Name), model.ResourceManager, model.Display.Renderer, new Vector(obj.X, obj.Y)); model.Objects.Add(newObj); } model.Filename = filename; model.Changed = false; model.DrawToLayer = 1; model.Background = mapDescriptor.Background; foreach (KeyValuePair<string, string> p in mapDescriptor.ExtraProperties) model.ExtraProperties.Add(p.Key, p.Value); } catch (Exception e) { Application.Invoke(delegate { Log.Write("Unable to open map " + filename + ": " + e.Message,Log.ERROR); MessageDialog mdlg = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, false, "Unable to open map " + filename + ": " + e.Message); mdlg.Run(); mdlg.Destroy(); }); } }); break; case ResponseType.Cancel: break; } }; dlg.Run(); dlg.Destroy(); } }; #endregion #region File->Save SaveAction.Activated += delegate { if (!string.IsNullOrEmpty(model.Filename)) { SaveMap(model.Filename); model.Changed = false; } else { ShowSaveAs(); } }; #endregion #region File->Save As SaveAsAction.Activated += delegate { ShowSaveAs(); }; #endregion #region File->Quit QuitAction.Activated += delegate { bool continueQuit = false; //Used to stop the new map action if the user presses "cancel" on the question on wether or not to save //Check if the map has been changed. If so, ask the user if he/she would like to save. if (model.Changed) QuerySave(delegate { continueQuit = true; SaveAction.Activate(); }, delegate {continueQuit = true;}); else continueQuit = true; if (continueQuit) { model.Running = false; Application.Quit(); } }; #endregion #endregion int pos = 0; foreach (string texture in model.ResourceManager.Textures) { comboBackgrounds.InsertText(pos, texture); pos++; } }