public void SetElementAt(int x, int y, int z, MapElement element) { CheckIndexes(x, y, z); Elements[x, y, z] = element; UpdateTopElements(element.Coordinates, true); }
static void DrawConnection(Graphics g, MapElement n1, MapElement n2) { if (!n1.IsActive || !n2.IsActive) return; var distance = Math.Sqrt(Math.Pow(n1.X - n2.X, 2) + Math.Pow(n1.Y - n2.Y, 2)); distance = Math.Min(1, distance * 5); var Pen = new Pen(Color.FromArgb((int)(distance * 128 + 120), GetColor(n1.MapX,n1.MapY)),2); g.DrawLine(Pen, n1.DisplayLocation, n2.DisplayLocation); }
public static bool replaceAnteTypes(MapElement mapElementT) { mapElement = mapElementT; anteTypes_current.Clear(); anteTypes_replace.Clear(); Form_ReplaceAnteType dialog = new Form_ReplaceAnteType(); dialog.ShowDialog(); return needUpdate; }
private void AddElement(MapElement element) { MapVisualElement rt = new MapVisualElement(element, ActiveMap, zApi); element.Tag = rt; rt.MouseDown += rectangle1_MouseDown; rt.MouseUp += map_MouseUp; Canvas.SetLeft(rt, element.x); Canvas.SetTop(rt, element.y); mapCanvas.Children.Add(rt); Canvas.SetZIndex(rt, 15); i++; // Index.Content = i.ToString(); }
public void CustomizeBlock(MapElement block) { if (block == null) return; MapBlockDiversityBehaviour blockDiversity = GetComponent<MapBlockDiversityBehaviour>(); if (blockDiversity != null) { BlockDistribution dist = blockDiversity.GetBlock(block.Coordinates.y / (int)map.Size.y); MeshRenderer renderer = block.GetComponent<MeshRenderer>(); if (block != null && renderer != null && dist != null) renderer.material = dist.Material; } }
private static StaticSettings CreateSettingsFromConfig(MapElement map) { return new StaticSettings(map.Sources) { Cached = map.Cached, Expires = map.Expires, MaxAgeExpression = map.MaxAge, DefaultFile = map.DefaultFile, RedirectIfFolderFound = map.RedirectIfFolder, Include = map.Include, Exclude = map.Exclude, AllowHidden = map.AllowHidden }; }
public void kss_refreshUI(MapElement map,int stageID) { if (map == null || stageID < 0 || stageID >= map.stageList.getElementCount()) { return; } //记录之前的选择ID int idCarrier = listBox_Carrier.SelectedIndex; int idKssFile = listBox_Files.SelectedIndex; //开始刷新数据 listBox_Carrier.BeginUpdate(); listBox_Files.BeginUpdate(); listCarrier.Clear(); listFiles.Clear(); listBox_Carrier.Items.Clear(); listBox_Files.Items.Clear(); //加入场景脚本 listCarrier.Add(((StageElement)map.stageList.getElement(stageID)).scriptList); listBox_Carrier.Items.Add("**场景脚本**"); listCarrier[0].setUI(listBox_Files); //加入NPC脚本 for (int i = 0; i < map.getMapW(); i++) { for (int j = 0; j < map.getMapH(); j++) { if (map.mapData[i, j] != null) { TileObjectElement element = map.mapData[i, j].tile_objectList[stageID]; if (element != null && element.NpcID > 0) { listCarrier.Add(element.scriptList); element.scriptList.setUI(listBox_Files); String name = "[NPC_" + MathUtil.getStringOfInt(element.NpcID,4) + "]"; if (element.antetype != null) { name += element.antetype.name; } listBox_Carrier.Items.Add(name); } } } } //还原条目焦点 if (idCarrier < 0) { idCarrier = 0; } if (idCarrier >= listBox_Carrier.Items.Count) { idCarrier = listBox_Carrier.Items.Count - 1; } listBox_Carrier.SelectedIndex = idCarrier; //刷新kss文件列表 listCarrier[idCarrier].refreshUI(listBox_Files); //重新绘制窗口 listBox_Carrier.EndUpdate(); listBox_Files.EndUpdate(); }
//指定的地图方格填充一个指定自动地形编号的图形单元,这个编号是相对于当前的自动地形起始方格的。 private void setAutoTile(MapElement currentMap, int bufW, int bufH, float zoomLevel, short level, bool drawInBuffer, int currentStageID, int idx, int idy, int idTile) { Object oldElement = currentMap.getTile(idx, idy, level, currentStageID); Object element = getGfxTileByAutoID(idTile); currentMap.fillPoint(gMapBuffer, bufW, bufH, zoomLevel, idx, idy, level, element, drawInBuffer, currentStageID); Object newElement = currentMap.getTile(idx, idy, level, currentStageID); FillPointHistory pointCmd = new FillPointHistory(currentMap, oldElement, newElement, idx, idy, level, currentStageID); fillPointsCmd.addPoint(pointCmd); }
public FillPointHistory(MapElement mapElementT, Object tileElement_OrgT, Object tileElement_NewT, int tileIndex_XT, int tileIndex_YT, short tileLevelT, int stageIDT) { mapElement = mapElementT; tileElement_Org = tileElement_OrgT; tileElement_New = tileElement_NewT; tileIndex_X = tileIndex_XT; tileIndex_Y = tileIndex_YT; tileLevel = tileLevelT; stageID = stageIDT; }
/// <summary> /// Get value for target oject /// </summary> /// <param name="target">The object whose property value will be returned</param> /// <returns>Place object</returns> public static Place GetValue( MapElement target ) { return GetValueProperty( target ); }
public virtual void OnMapElementPointerEntered(MapElement element, LatLon pointOnMap, Point pointOnControl) { }
// returns a tuple, of (value, default), // where default is true if set to a default value public static DynValue GetUDMFField(MapElement element, string key, List <UniversalFieldInfo> defaults) { if (key == null) { throw new ScriptRuntimeException("key is nil, can't GetUDMFField() (not enough arguments maybe?)"); } if (element == null) { throw new ScriptRuntimeException("map element is nil, can't GetUDMFField()"); } if (element.IsDisposed) { throw new ScriptRuntimeException("map element is disposed, can't GetUDMFField()"); } DynValue[] output = new DynValue[2]; if (!General.Map.FormatInterface.HasCustomFields) { ScriptContext.context.WarnFormatIncompatible("UDMF fields not supported!"); output[0] = DynValue.NewNumber(0); output[1] = DynValue.NewBoolean(true); return(DynValue.NewTuple(output)); } key = UniValue.ValidateName(key); if (key == "") { output[0] = DynValue.NewNumber(0); output[1] = DynValue.NewBoolean(true); return(DynValue.NewTuple(output)); } if (element.Fields.ContainsKey(key)) { UniValue field = element.Fields[key]; output[0] = DynValue.FromObject(ScriptContext.context.script, field.Value); output[1] = DynValue.NewBoolean(true); return(DynValue.NewTuple(output)); } else { output[0] = DynValue.NewNumber(0); if (defaults != null) { // TODO - for performance, reimplement as an O(1) operation foreach (UniversalFieldInfo d in defaults) { if (d.Name == key) { output[0] = DynValue.FromObject(ScriptContext.context.script, d.Default); } } } output[1] = DynValue.NewBoolean(true); return(DynValue.NewTuple(output)); } }
public MapVisualElement(MapElement element,Map parentMap,ZabbixConnection connection) { InitializeComponent(); // this.ToolTip = element.url ; data = element; map = parentMap; label.Content = data.label; zabbixConnection = connection; StringBuilder tooltip = new StringBuilder(); StringBuilder problems = new StringBuilder(); StringBuilder works = new StringBuilder(); states[0] = new GradientStopCollection(); states[1] = new GradientStopCollection(); states[2] = new GradientStopCollection(); states[3] = new GradientStopCollection(); states[0].Add(new GradientStop(Color.FromArgb(255, 50, 255, 50), 0.0)); states[0].Add(new GradientStop(Color.FromArgb(255, 00, 56, 34), 1.0)); states[1].Add(new GradientStop(Colors.Red, 0.0)); states[1].Add(new GradientStop(Colors.DarkRed, 1.0)); states[2].Add(new GradientStop(Colors.Yellow, 0.0)); states[2].Add(new GradientStop(Colors.OrangeRed, 1.0)); states[3].Add(new GradientStop(Colors.Gray, 0.0)); states[3].Add(new GradientStop(Colors.DarkGray, 1.0)); this.SetState(0); tooltip.Append("Триггеры:\n"); problems.Append("\tПроблемы:\n"); works.Append("\tНет проблем:\n"); if (data.triggers != null) { int WorkTrigger = data.triggers.Length; foreach (Zabbix.Trigger tr in data.triggers) { if (tr.value!="0") { //problems.Append("\t\t" + tr.description.Replace("{HOSTNAME}", tr.host.host) + "[" + tr.lastchangeDateTime.ToString() + "]\n"); tltp.Items.Add(new { text = tr.description.Replace("{HOSTNAME}", tr.host.host), value = tr.value }); } //else { works.Append("\t\t" +tr.description.Replace("{HOSTNAME}", tr.host.host) + "[" + tr.lastchangeDateTime.ToString() + "]\n"); } WorkTrigger -= Int32.Parse(tr.value); } foreach (Zabbix.Trigger tr in data.triggers) { if (tr.value == "0") { //problems.Append("\t\t" + tr.description.Replace("{HOSTNAME}", tr.host.host) + "[" + tr.lastchangeDateTime.ToString() + "]\n"); tltp.Items.Add(new { text = tr.description.Replace("{HOSTNAME}", tr.host.host), value = tr.value }); } //else { works.Append("\t\t" +tr.description.Replace("{HOSTNAME}", tr.host.host) + "[" + tr.lastchangeDateTime.ToString() + "]\n"); } //WorkTrigger -= Int32.Parse(tr.value); } if (WorkTrigger == data.triggers.Length) { SetState(0); }else if (WorkTrigger == 0) { SetState(1); } else { SetState(2); } } if (data.elementtype != "0") { this.SetState(3); } //this.ToolTip = "Триггеры:\n"+problems+works; if (!File.Exists("images/"+data.iconid_off)) { image_on = zabbixConnection.GetImageByID(data.iconid_off); FileStream fl = File.Create("images/" + data.iconid_off); image_on.CopyTo(fl); fl.Close(); } BitmapImage bi = new BitmapImage(); byte[] bytes = File.ReadAllBytes("images/" + data.iconid_off); MemoryStream ms = new MemoryStream(bytes); bi.BeginInit(); bi.StreamSource = ms; bi.EndInit(); image.Source = bi; //myBrush.GradientStops.Add(new GradientStop(Colors.Orange, 0.5)); }
void update_list_tiles() { List <Map> maps = new List <Map>(); List <PlotPoint> points = get_points(SelectedPlot); List <Guid> map_ids = new List <Guid>(); foreach (PlotPoint pp in points) { Encounter enc = pp.Element as Encounter; if (enc != null) { if (enc.MapID != Guid.Empty) { map_ids.Add(enc.MapID); } } MapElement me = pp.Element as MapElement; if (me != null) { map_ids.Add(me.MapID); } } foreach (Guid map_id in map_ids) { Map map = Session.Project.FindTacticalMap(map_id); if (map != null) { maps.Add(map); } } Dictionary <Guid, int> tiles = new Dictionary <Guid, int>(); foreach (Map map in maps) { // Get the tile breakdown for this map Dictionary <Guid, int> map_tiles = new Dictionary <Guid, int>(); foreach (TileData td in map.Tiles) { if (!map_tiles.ContainsKey(td.TileID)) { map_tiles[td.TileID] = 0; } map_tiles[td.TileID] += 1; } // Update the running total foreach (Guid tile_id in map_tiles.Keys) { if (!tiles.ContainsKey(tile_id)) { tiles[tile_id] = 0; } if (map_tiles[tile_id] > tiles[tile_id]) { tiles[tile_id] = map_tiles[tile_id]; } } } List <string> libs = new List <string>(); foreach (Guid tile_id in tiles.Keys) { Tile tile = Session.FindTile(tile_id, SearchType.Global); Library lib = Session.FindLibrary(tile); if (!libs.Contains(lib.Name)) { libs.Add(lib.Name); } } libs.Sort(); TileList.Groups.Clear(); foreach (string lib_name in libs) { TileList.Groups.Add(lib_name, lib_name); } TileList.ShowGroups = (TileList.Groups.Count > 0); TileList.LargeImageList = new ImageList(); TileList.LargeImageList.ImageSize = new Size(64, 64); TileList.Items.Clear(); foreach (Guid tile_id in tiles.Keys) { Tile t = Session.FindTile(tile_id, SearchType.Global); Library lib = Session.FindLibrary(t); ListViewItem lvi = TileList.Items.Add("x " + tiles[tile_id]); lvi.Tag = t; lvi.Group = TileList.Groups[lib.Name]; // Get tile image Image img = t.Image != null ? t.Image : t.BlankImage; Bitmap bmp = new Bitmap(64, 64); if (t.Size.Width > t.Size.Height) { int height = (t.Size.Height * 64) / t.Size.Width; Rectangle rect = new Rectangle(0, (64 - height) / 2, 64, height); Graphics g = Graphics.FromImage(bmp); g.DrawImage(img, rect); } else { int width = (t.Size.Width * 64) / t.Size.Height; Rectangle rect = new Rectangle((64 - width) / 2, 0, width, 64); Graphics g = Graphics.FromImage(bmp); g.DrawImage(img, rect); } TileList.LargeImageList.Images.Add(bmp); lvi.ImageIndex = TileList.LargeImageList.Images.Count - 1; } if (tiles.Keys.Count == 0) { ListViewItem lvi = TileList.Items.Add("None"); lvi.ForeColor = SystemColors.GrayText; } }
public WriteableBitmap GetMapBitmap(bool[] aDrawedLayers) { PresentationSource _ps = PresentationSource.FromVisual(Application.Current.MainWindow); Matrix _m = _ps.CompositionTarget.TransformToDevice; double _dpiX = _m.M11 * 96; double _dpiY = _m.M22 * 96; int _imageHeigth = (this.FMap.WORLD_SIZE + 2) * StructureImage.TileHeight; WriteableBitmap _wbm = new WriteableBitmap( _imageHeigth * 2, _imageHeigth, _dpiX, _dpiY, PixelFormats.Bgra32, null); int _bytePerPixel = _wbm.Format.BitsPerPixel / 8; byte[] _imageData = new byte[_imageHeigth * 2 * _imageHeigth * _bytePerPixel]; for (int aLayerNumber = 0; aLayerNumber < aDrawedLayers.Length; aLayerNumber++) { if (aDrawedLayers[aLayerNumber]) { for (int i = 0; i < this.FMap.WORLD_SIZE; i++) { //for (int i = this.FMap.WORLD_SIZE; i > 0; i--) // for (int j = this.FMap.WORLD_SIZE; j > 0; j--) for (int j = 0; j < this.FMap.WORLD_SIZE; j++) { if (i + j >= 3 * this.FMap.WORLD_SIZE / 2 || i + j <= this.FMap.WORLD_SIZE / 2 || i - j >= this.FMap.WORLD_SIZE / 2 || i - j <= -this.FMap.WORLD_SIZE / 2) { continue; } MapElement _element = this.FMap.Elementes[this.FMap.WORLD_SIZE * j + i]; LevelNode.TileIndex[] _indexes = _element.pLevelNodes[aLayerNumber].tileIndexes; for (int _index = 0; _index < _indexes.Length; _index++) { if (_indexes.Length > _index) { LevelNode.TileIndex _tileIndex = _indexes[_index]; int _subIndex = _tileIndex.usTypeSubIndex - 1; if (this.FMap.MapTileSet.Length > _tileIndex.ubType) { StciIndexed _sti = this.FMap.MapTileSet[_tileIndex.ubType].Sti; if (_sti != null && _sti.Images.Length > _subIndex) { StciSubImage _subImage = _sti.Images[_subIndex]; int _x = (i - j) * StructureImage.TileWidth + _subImage.Header.OffsetX; int _y = (i + j) * StructureImage.TileHeight + _subImage.Header.OffsetY; if (aLayerNumber > 3) // крыша { _y -= 50; } _x += this.FMap.WORLD_SIZE * StructureImage.TileWidth / 2; _y -= this.FMap.WORLD_SIZE * StructureImage.TileHeight / 2; if (_x < 0 || _x + _subImage.Header.Width > _wbm.Width || _y < 0 || _y + _subImage.Header.Height > _wbm.Height) { continue; } for (int l = 0; l < _subImage.ImageData.Length; l++) { if (_subImage.ImageData[l] != 0) { int x = _x + l % _subImage.Header.Width; int y = _y + l / _subImage.Header.Width; int _offset = (int)(y * _wbm.Width + x) * _bytePerPixel; if (_offset + 3 >= _imageData.Length) { continue; } StciColor _color = _sti.ColorPalette[_subImage.ImageData[l]]; _imageData[_offset] = _color.Blue; _imageData[_offset + 1] = _color.Green; _imageData[_offset + 2] = _color.Red; _imageData[_offset + 3] = 255; } } } } } } } } } } Int32Rect _rect = new Int32Rect(0, 0, _imageHeigth * 2, _imageHeigth); int _stride = _imageHeigth * 2 * _bytePerPixel; _wbm.WritePixels(_rect, _imageData, _stride, 0); return(_wbm); }
public void RenderWay(DrawingContext drawingContext, MapElement element) { // do nothing }
public void CreateElementInList() { while (createElementList.Count > 0) { string key = createElementList[0]; createElementList.RemoveAt(0); MapElement elementData = visionElementDic[key]; MapElementInfo elementInfo = elementData.elementInfo; activeObj[elementData.elementKey] = null; GameObject tempObj = GetObjByCache(elementData.elementType); if (tempObj != null) { if (tempObj.activeSelf) { SetElementTransform(tempObj.transform, elementInfo); activeObj[elementData.elementKey] = tempObj; return; } elementLoader.PushCallBack(() => { if (tempObj == null) { return(false); } if (!visionElementDic.ContainsKey(elementData.elementKey)) { activeObj.Remove(elementData.elementKey); return(false); } SetElementTransform(tempObj.transform, elementInfo); tempObj.SetActive(true); activeObj[elementData.elementKey] = tempObj; return(true); }); } else { string elementAssetPath = string.Format(MapDefine.MapElementPath, elementData.elementType); AssetManager.LoadAsset(elementAssetPath, (obj, str) => { elementLoader.PushCallBack(() => { if (obj != null) //&& visionElementDic.ContainsKey(key)) { if (activeObj.ContainsKey(elementData.elementKey)) { if (!visionElementDic.ContainsKey(elementData.elementKey)) { return(false); } GameObject assetTree = obj as GameObject; Transform element = GameObject.Instantiate(assetTree).transform; element.SetParent(data.root); SetElementTransform(element, elementInfo); activeObj[elementData.elementKey] = element.gameObject; return(true); } return(false); } return(false); }); }); } } }
/// <summary> /// Looks for an ExecutionPlan to cover the Property in the given PropertyOwnership relation using the Properties this PropertyManager. /// </summary> /// <param name="propertyOwnershipToCover">The PropertyOwnership to which it is wanted to increase the value.</param> /// <param name="remainingValueToCover">The amount of value that is desired to increase with the obtained ExecutionPlan</param> /// <param name="executer">The MapElement that will execute the ExecutionPlan</param> /// <returns></returns> public ExecutionPlan GetExecutionPlanToCover(PropertyOwnership propertyOwnershipToCover, float remainingValueToCover, MapElement executer) { MapElement target = propertyOwnershipToCover.owner; // Debug.Log($" >>> Searching for an execution plan to cover '{remainingValueToCover}' of '{propertyOwnershipToCover.property}' owned by '{propertyOwnershipToCover.owner}' executed by '{executer}'.\n"); foreach (PropertyOwnership ownedProperty in propertyOwnerships) { foreach (MapEvent mapEvent in ownedProperty.property.mapEvents) { // Debug.Log($" >>> In '{ownedProperty.owner}', checking if mapEvent '{mapEvent}' in property '{ownedProperty.property}' can cover {remainingValueToCover} missing of the property '{propertyOwnershipToCover.property}'.\nTarget: {target}, Executer: {executer}, EventOwner still unknown.\n"); if (!mapEvent.executerMustOwnProperty || (mapEvent.executerMustOwnProperty && ownedProperty.owner == executer)) { MapElement eventOwner = ownedProperty.owner; ExecutionPlan executionPlan = new ExecutionPlan(mapEvent, executer, target, eventOwner, ownedProperty.property); executionPlan.SetExecutionTimesToCover(propertyOwnershipToCover, remainingValueToCover); int executionsToCover = executionPlan.executionTimes; if (executionsToCover < 0) // The executionPlan can not cover the property { continue; } Dictionary <PropertyOwnership, float> mapEventRequirementsNotMet = mapEvent.GetRequirementsNotMet(ownedProperty.property, executer, target, owner, executionPlan.executionTimes); if (mapEvent.tryToCoverRequirementsIfNotMet || (!mapEvent.tryToCoverRequirementsIfNotMet && mapEventRequirementsNotMet.IsNullOrEmpty())) { // If reached here, the mapEvent can be executed - Now choose if it is the appropriate one // Debug.Log($" > The mapEvent '{mapEvent}' can be executed ({mapEventRequirementsNotMet.Count} requirements must be covered before):\n - {mapEventRequirementsNotMet.ToStringAllElements("\n - ")}\n"); if (mapEvent.ConsequencesCover(propertyOwnershipToCover, target, executer, eventOwner, ownedProperty.property)) { Debug.Log($" ● Found Execution Plan: {executionPlan}\n"); return(executionPlan); } } } else { // Debug.Log($" The executer ({executer}) must own the property '{currentOwnedProperty.property}' to execute '{mapEvent}' but it does not. MapEvent owned by '{currentOwnedProperty.ownerMapElement}'.\n"); if (mapEvent.ConsequencesCover(propertyOwnershipToCover, target, executer, executer, ownedProperty.property)) { ExecutionPlan executionPlan = new ExecutionPlan(mapEvent, executer, target, executer, ownedProperty.property); executionPlan.SetExecutionTimesToCover(propertyOwnershipToCover, remainingValueToCover); Debug.Log($" ● Found 'forced' Execution Plan: {executionPlan}\n"); return(executionPlan); } } } } return(null); }
public static T ReadData <T>(this MapElement element) where T : class { return(GetObjectData(element) as T); }
public static object GetObjectData(MapElement obj) { return(obj.GetValue(ObjectDataProperty)); }
/// <summary> /// Set value for a target object /// </summary> /// <param name="target">Represents an element on the map control. The object whose property value will be set</param> /// <param name="value">The new property value.</param> public static void SetValue(MapElement target, Place value) { SetValueProperty(target, value); }
public void Cmd_loadExistMap(MapElement item) { worldMgr.loadExistMapDatas(item); }
public static void AddData(this MapElement element, object data) { SetObjectData(element, data); }
public bool Matches(MapElement mapElement) { return(!RuleTests.Any() || RuleTests.All(rt => rt.Test(mapElement))); }
static void Learning() { for (int i = 0; i<iterationsBetweenDrawing ; i++) learning.Run(Inputs[rnd.Next(Inputs.Length)]); map = new MapElement[task.NetworkWidth, task.NetworkHeight]; int number = 0; for (int x = 0; x < task.NetworkWidth; x++) for (int y = 0; y < task.NetworkHeight; y++) { var neuron = network.Layers[0].Neurons[x * task.NetworkHeight + y]; map[x, y] = new MapElement { X = (float)neuron.Weights[0], Y = (float)neuron.Weights[1], Id = number++ }; } foreach (var e in Inputs) { network.Compute(e); var winner = network.GetWinner(); map[winner / task.NetworkHeight, winner % task.NetworkHeight].IsActive = true; } }
public static Building ReadData(this MapElement element) { return((Building)GetObjectData(element)); }
private void RemoveFromMap(MapElement element) { Map[element.Position.Y].XCells[element.Position.X].ZDepths[element.Position.Z] = null; if (Map[element.Position.Y].XCells.All(line => !line.ZDepths.Any())) // Если вся строка пустая Map.Remove(element.Position.X); }
/// <summary> /// Displays the the information of the given MapElement in the UI /// </summary> /// <param name="selectedMapElement">The MapElement to display the information of in the UI.</param> public void DisplayInformationOf(MapElement selectedMapElement) { mapElementNameText.text = selectedMapElement.name; mapElementDescriptionText.text = $"Description of the selected MapElement:\n {selectedMapElement.ToString()}"; }
// This reads custom fields from a collection and adds them to a map element private void ReadCustomFields(UniversalCollection collection, MapElement element, string elementname) { element.Fields.BeforeFieldsChange(); // Go for all the elements in the collection foreach (UniversalEntry e in collection) { // mxd. Check if uifield if (uifields.ContainsKey(element.ElementType) && uifields[element.ElementType].ContainsKey(e.Key)) { int type = (int)uifields[element.ElementType][e.Key]; //mxd. Check type object value = e.Value; // Let's be kind and cast any int to a float if needed if (type == (int)UniversalType.Float && e.Value is int) { value = (double)(int)e.Value; } else if (!e.IsValidType(e.Value.GetType())) { General.ErrorLogger.Add(ErrorType.Warning, element + ": the value of entry \"" + e.Key + "\" is of incompatible type (expected " + e.GetType().Name + ", but got " + e.Value.GetType().Name + "). If you save the map, this value will be ignored."); continue; } // Make custom field element.Fields[e.Key] = new UniValue(type, value); } // Check if not a managed field else if (!config.SettingExists("managedfields." + elementname + "." + e.Key)) { int type = (int)UniversalType.Integer; //mxd. Try to find the type from configuration if (setknowncustomtypes) { type = General.Map.Options.GetUniversalFieldType(elementname, e.Key, -1); if (type != -1) { object value = e.Value; // Let's be kind and cast any int to a float if needed if (type == (int)UniversalType.Float && e.Value is int) { value = (float)(int)e.Value; } else if (!e.IsValidType(e.Value.GetType())) { General.ErrorLogger.Add(ErrorType.Warning, element + ": the value of entry \"" + e.Key + "\" is of incompatible type (expected " + e.GetType().Name + ", but got " + e.Value.GetType().Name + "). If you save the map, this value will be ignored."); continue; } // Make custom field element.Fields[e.Key] = new UniValue(type, value); continue; } } // Determine default type if (e.Value is int) { type = (int)UniversalType.Integer; } else if (e.Value is double) { type = (int)UniversalType.Float; } else if (e.Value is bool) { type = (int)UniversalType.Boolean; } else if (e.Value is string) { type = (int)UniversalType.String; } // Make custom field element.Fields[e.Key] = new UniValue(type, e.Value); } } }
private void update_list(Plot plot) { List <Map> maps = new List <Map>(); List <PlotPoint> allPlotPoints = plot.AllPlotPoints; List <Guid> guids = new List <Guid>(); foreach (PlotPoint allPlotPoint in allPlotPoints) { Encounter element = allPlotPoint.Element as Encounter; if (element != null && element.MapID != Guid.Empty) { guids.Add(element.MapID); } MapElement mapElement = allPlotPoint.Element as MapElement; if (mapElement == null) { continue; } guids.Add(mapElement.MapID); } foreach (Guid guid in guids) { Map map = Session.Project.FindTacticalMap(guid); if (map == null) { continue; } maps.Add(map); } Dictionary <Guid, int> item = new Dictionary <Guid, int>(); foreach (Map map1 in maps) { Dictionary <Guid, int> guids1 = new Dictionary <Guid, int>(); foreach (TileData tile in map1.Tiles) { if (!guids1.ContainsKey(tile.TileID)) { guids1[tile.TileID] = 0; } Dictionary <Guid, int> item1 = guids1; Dictionary <Guid, int> guids2 = item1; Guid tileID = tile.TileID; item1[tileID] = guids2[tileID] + 1; } foreach (Guid key in guids1.Keys) { if (!item.ContainsKey(key)) { item[key] = 0; } if (guids1[key] <= item[key]) { continue; } item[key] = guids1[key]; } } List <string> strs = new List <string>(); foreach (Guid key1 in item.Keys) { Library library = Session.FindLibrary(Session.FindTile(key1, SearchType.Global)); if (strs.Contains(library.Name)) { continue; } strs.Add(library.Name); } strs.Sort(); this.TileList.Groups.Clear(); foreach (string str in strs) { this.TileList.Groups.Add(str, str); } this.TileList.LargeImageList = new ImageList() { ImageSize = new System.Drawing.Size(64, 64) }; this.TileList.Items.Clear(); foreach (Guid guid1 in item.Keys) { Tile tile1 = Session.FindTile(guid1, SearchType.Global); Library library1 = Session.FindLibrary(tile1); ListViewItem count = this.TileList.Items.Add(string.Concat("x ", item[guid1])); count.Tag = tile1; count.Group = this.TileList.Groups[library1.Name]; Image image = (tile1.Image != null ? tile1.Image : tile1.BlankImage); Bitmap bitmap = new Bitmap(64, 64); if (tile1.Size.Width <= tile1.Size.Height) { System.Drawing.Size size = tile1.Size; System.Drawing.Size size1 = tile1.Size; int width = size.Width * 64 / size1.Height; Rectangle rectangle = new Rectangle((64 - width) / 2, 0, width, 64); Graphics.FromImage(bitmap).DrawImage(image, rectangle); } else { System.Drawing.Size size2 = tile1.Size; System.Drawing.Size size3 = tile1.Size; int height = size2.Height * 64 / size3.Width; Rectangle rectangle1 = new Rectangle(0, (64 - height) / 2, 64, height); Graphics.FromImage(bitmap).DrawImage(image, rectangle1); } this.TileList.LargeImageList.Images.Add(bitmap); count.ImageIndex = this.TileList.LargeImageList.Images.Count - 1; } }
/// <summary> /// Set value for a target object /// </summary> /// <param name="target">Represents an element on the map control. The object whose property value will be set</param> /// <param name="value">The new property value.</param> public static void SetValue( MapElement target, Place value ) { SetValueProperty( target, value ); }
private static Backdrop ParseBackdrop(List <MapElement> levels, MapElement child, MapElement above) { Backdrop backdrop; if (child.Name.Equals("parallax", StringComparison.OrdinalIgnoreCase)) { string id = child.Attr("texture", ""); string a = child.Attr("atlas", "game"); Bitmap texture = null; if (a == "game") { texture = Gameplay.GetImage(id); } Parallax parallax = new Parallax(texture); backdrop = parallax; backdrop.Name = id; string text = ""; if (child.HasAttr("blendmode")) { text = child.Attr("blendmode", "alphablend").ToLower(); } else if (above != null && above.HasAttr("blendmode")) { text = above.Attr("blendmode", "alphablend").ToLower(); } if (text.Equals("additive")) { parallax.BlendState = BlendState.Additive; } } else if (child.Name.Equals("snowfg", StringComparison.OrdinalIgnoreCase)) { backdrop = new Snow(true); } else if (child.Name.Equals("snowbg", StringComparison.OrdinalIgnoreCase)) { backdrop = new Snow(false); } else if (child.Name.Equals("windsnow", StringComparison.OrdinalIgnoreCase)) { backdrop = new WindSnowFG(); } else if (child.Name.Equals("dreamstars", StringComparison.OrdinalIgnoreCase)) { backdrop = new DreamStars(); } else if (child.Name.Equals("stars", StringComparison.OrdinalIgnoreCase)) { backdrop = new StarsBG(); } else if (child.Name.Equals("mirrorfg", StringComparison.OrdinalIgnoreCase)) { backdrop = new MirrorFG(); } else if (child.Name.Equals("reflectionfg", StringComparison.OrdinalIgnoreCase)) { backdrop = new ReflectionFG(); } else if (child.Name.Equals("godrays", StringComparison.OrdinalIgnoreCase)) { backdrop = new Godrays(); } else if (child.Name.Equals("tentacles", StringComparison.OrdinalIgnoreCase)) { backdrop = new Tentacles((Tentacles.Side)Enum.Parse(typeof(Tentacles.Side), child.Attr("side", "Right")), Util.HexToColor(child.Attr("color", "")), child.AttrFloat("offset", 0f)); } else if (child.Name.Equals("northernlights", StringComparison.OrdinalIgnoreCase)) { backdrop = new NorthernLights(); } else if (child.Name.Equals("bossStarField", StringComparison.OrdinalIgnoreCase)) { backdrop = new FinalBossStarfield(); } else if (child.Name.Equals("petals", StringComparison.OrdinalIgnoreCase)) { backdrop = new Petals(); } else if (child.Name.Equals("heatwave", StringComparison.OrdinalIgnoreCase)) { backdrop = new HeatWave(); } else if (child.Name.Equals("corestarsfg", StringComparison.OrdinalIgnoreCase)) { backdrop = new CoreStarsFG(); } else { return(null); } if (child.HasAttr("x")) { backdrop.Position.X = child.AttrFloat("x", 0f); } else if (above != null && above.HasAttr("x")) { backdrop.Position.X = above.AttrFloat("x", 0f); } if (child.HasAttr("y")) { backdrop.Position.Y = child.AttrFloat("y", 0f); } else if (above != null && above.HasAttr("y")) { backdrop.Position.Y = above.AttrFloat("y", 0f); } if (child.HasAttr("scrollx")) { backdrop.Scroll.X = child.AttrFloat("scrollx", 0f); } else if (above != null && above.HasAttr("scrollx")) { backdrop.Scroll.X = above.AttrFloat("scrollx", 0f); } if (child.HasAttr("scrolly")) { backdrop.Scroll.Y = child.AttrFloat("scrolly", 0f); } else if (above != null && above.HasAttr("scrolly")) { backdrop.Scroll.Y = above.AttrFloat("scrolly", 0f); } if (child.HasAttr("speedx")) { backdrop.Speed.X = child.AttrFloat("speedx", 0f); } else if (above != null && above.HasAttr("speedx")) { backdrop.Speed.X = above.AttrFloat("speedx", 0f); } if (child.HasAttr("speedy")) { backdrop.Speed.Y = child.AttrFloat("speedy", 0f); } else if (above != null && above.HasAttr("speedy")) { backdrop.Speed.Y = above.AttrFloat("speedy", 0f); } backdrop.Color = Color.White; if (child.HasAttr("color")) { backdrop.Color = Util.HexToColor(child.Attr("color", "")); } else if (above != null && above.HasAttr("color")) { backdrop.Color = Util.HexToColor(above.Attr("color", "")); } if (child.HasAttr("alpha")) { backdrop.Color = Color.FromArgb((int)(child.AttrFloat("alpha", 0f) * 255), backdrop.Color); } else if (above != null && above.HasAttr("alpha")) { backdrop.Color = Color.FromArgb((int)(above.AttrFloat("alpha", 0f) * 255), backdrop.Color); } if (child.HasAttr("flipx")) { backdrop.FlipX = child.AttrBool("flipx", false); } else if (above != null && above.HasAttr("flipx")) { backdrop.FlipX = above.AttrBool("flipx", false); } if (child.HasAttr("flipy")) { backdrop.FlipY = child.AttrBool("flipy", false); } else if (above != null && above.HasAttr("flipy")) { backdrop.FlipY = above.AttrBool("flipy", false); } if (child.HasAttr("loopx")) { backdrop.LoopX = child.AttrBool("loopx", false); } else if (above != null && above.HasAttr("loopx")) { backdrop.LoopX = above.AttrBool("loopx", false); } if (child.HasAttr("loopy")) { backdrop.LoopY = child.AttrBool("loopy", false); } else if (above != null && above.HasAttr("loopy")) { backdrop.LoopY = above.AttrBool("loopy", false); } string text2 = null; if (child.HasAttr("exclude")) { text2 = child.Attr("exclude", ""); } else if (above != null && above.HasAttr("exclude")) { text2 = above.Attr("exclude", ""); } if (text2 != null) { backdrop.ExcludeFrom = ParseLevelsList(levels, text2); } string text3 = null; if (child.HasAttr("only")) { text3 = child.Attr("only", ""); } else if (above != null && above.HasAttr("only")) { text3 = above.Attr("only", ""); } if (text3 != null) { backdrop.OnlyIn = ParseLevelsList(levels, text3); } string text4 = null; if (child.HasAttr("flag")) { text4 = child.Attr("flag", ""); } else if (above != null && above.HasAttr("flag")) { text4 = above.Attr("flag", ""); } if (text4 != null) { backdrop.OnlyIfFlag = text4; } string text5 = null; if (child.HasAttr("notflag")) { text5 = child.Attr("notflag", ""); } else if (above != null && above.HasAttr("notflag")) { text5 = above.Attr("notflag", ""); } if (text5 != null) { backdrop.OnlyIfNotFlag = text5; } string text6 = null; if (child.HasAttr("always")) { text6 = child.Attr("always", ""); } else if (above != null && above.HasAttr("always")) { text6 = above.Attr("always", ""); } if (text6 != null) { backdrop.AlsoIfFlag = text6; } bool?dreaming = null; if (child.HasAttr("dreaming")) { dreaming = new bool?(child.AttrBool("dreaming", false)); } else if (above != null && above.HasAttr("dreaming")) { dreaming = new bool?(above.AttrBool("dreaming", false)); } if (dreaming != null) { backdrop.Dreaming = dreaming; } if (child.HasAttr("instantIn")) { backdrop.InstantIn = child.AttrBool("instantIn", false); } else if (above != null && above.HasAttr("instantIn")) { backdrop.InstantIn = above.AttrBool("instantIn", false); } if (child.HasAttr("instantOut")) { backdrop.InstantOut = child.AttrBool("instantOut", false); } else if (above != null && above.HasAttr("instantOut")) { backdrop.InstantOut = above.AttrBool("instantOut", false); } string text7 = null; if (child.HasAttr("fadex")) { text7 = child.Attr("fadex", ""); } else if (above != null && above.HasAttr("fadex")) { text7 = above.Attr("fadex", ""); } if (text7 != null) { backdrop.FadeX = new Fader(); string[] array = text7.Split(':'); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(','); if (array2.Length == 2) { string[] array3 = array2[0].Split('-'); string[] array4 = array2[1].Split('-'); float fadeFrom = float.Parse(array4[0], CultureInfo.InvariantCulture); float fadeTo = float.Parse(array4[1], CultureInfo.InvariantCulture); int num = 1; int num2 = 1; if (array3[0][0] == 'n') { num = -1; array3[0] = array3[0].Substring(1); } if (array3[1][0] == 'n') { num2 = -1; array3[1] = array3[1].Substring(1); } backdrop.FadeX.Add((float)(num * int.Parse(array3[0])), (float)(num2 * int.Parse(array3[1])), fadeFrom, fadeTo); } } } string text8 = null; if (child.HasAttr("fadey")) { text8 = child.Attr("fadey", ""); } else if (above != null && above.HasAttr("fadey")) { text8 = above.Attr("fadey", ""); } if (text8 != null) { backdrop.FadeY = new Fader(); string[] array = text8.Split(':'); for (int i = 0; i < array.Length; i++) { string[] array5 = array[i].Split(','); if (array5.Length == 2) { string[] array6 = array5[0].Split('-'); string[] array7 = array5[1].Split('-'); float fadeFrom2 = float.Parse(array7[0], CultureInfo.InvariantCulture); float fadeTo2 = float.Parse(array7[1], CultureInfo.InvariantCulture); int num3 = 1; int num4 = 1; if (array6[0][0] == 'n') { num3 = -1; array6[0] = array6[0].Substring(1); } if (array6[1][0] == 'n') { num4 = -1; array6[1] = array6[1].Substring(1); } backdrop.FadeY.Add((float)(num3 * int.Parse(array6[0])), (float)(num4 * int.Parse(array6[1])), fadeFrom2, fadeTo2); } } } return(backdrop); }
//使用自动地形填充地图 public bool fillPointWithAutoTile(MapElement currentMap, int bufW, int bufH, float zoomLevel, int indexX, int indexY, short level, bool drawInBuffer, int currentStageID,bool blank) { //历史记录 bool changed = false; if (fillPointsCmd != null) { updateVectorEnviroment(indexX, indexY, blank); //得到双倍方格左上角和状态表矢量影响区在地图中对应左上角 int x = indexX; int y = indexY; int xCLT = x - x % 2; int yCLT = y - y % 2; x = xCLT - 2; y = yCLT - 2; for (int iy = 0; iy < 6; iy++) { for (int ix = 0; ix < 6; ix++) { int idx = x + ix; int idy = y + iy; if (idx < 0 || idx >= currentMap.getMapW() || idy < 0 || idy >= currentMap.getMapH()) { continue; } Object oldElement = currentMap.getTile(idx, idy, level, currentStageID); int idTile = getModelID( idx, idy, 1 + ix, 1 + iy); Object element = getGfxTileByAutoID(idTile); bool changedOnce = currentMap.fillPoint(gMapBuffer, bufW, bufH, zoomLevel, idx, idy, level, element, drawInBuffer, currentStageID); Object newElement = currentMap.getTile(idx, idy, level, currentStageID); FillPointHistory pointCmd = new FillPointHistory(currentMap, oldElement, newElement, idx, idy, level, currentStageID); fillPointsCmd.addPoint(pointCmd); if (changedOnce) { changed = true; } } } //再检查内凹角模块 for (int iy = 0; iy < 6; iy++) { for (int ix = 0; ix < 6; ix++) { int idx = x + ix; int idy = y + iy; if (idx < 0 || idx >= currentMap.getMapW() || idy < 0 || idy >= currentMap.getMapH()) { continue; } Object oldElement = currentMap.getTile(idx, idy, level, currentStageID); int idXEn = 1 + ix; int idYEn = 1 + iy; VectorModel model = getVectorInEviroment(idXEn, idYEn); if (model == null) { continue; } if (!model.equalsValue(vZero)) { continue; } bool fillCorner = TSB_fillCorner.Checked; if (isEnviroment(idXEn, idYEn, -1, 0, 0, -1, -1, -1) && ix % 2 == 0 && iy % 2 == 0) { if (!fillCorner) { setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy, 36); } else { setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy, 47); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx-1, idy, 46); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy-1, 41); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx-1, idy-1, 40); } } else if (isEnviroment(idXEn, idYEn, 1, 0, 0, -1, 1, -1) && ix % 2 == 1 && iy % 2 == 0) { if (!fillCorner) { setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy, 37); } else { setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy, 52); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx + 1, idy, 53); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy - 1, 50); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx + 1, idy - 1, 51); } } else if (isEnviroment(idXEn, idYEn, -1, 0, 0, 1, -1, 1) && ix % 2 == 0 && iy % 2 == 1) { if (!fillCorner) { setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy, 42); } else { setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy, 39); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx -1, idy, 38); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx-1, idy + 1, 44); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy + 1, 45); } } else if (isEnviroment(idXEn, idYEn, 1, 0, 0, 1, 1, 1) && ix % 2 == 1 && iy % 2 == 1) { if (!fillCorner) { setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy, 43); } else { setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy, 48); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx + 1, idy, 49); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx + 1, idy + 1, 55); setAutoTile(currentMap, bufW, bufH, zoomLevel, level, drawInBuffer, currentStageID, idx, idy + 1, 54); } } else { continue; } changed = true; } } } return changed; }
public bool BuildMapElement(int row, int column) { if (actMap[row, column] == MapElement.Edge && mapElementFactory.chosedMapElement == MapElement.Joe) { return(false); } if (mapElementFactory.chosedMapElement != MapElement.Box && mapElementFactory.chosedMapElement != MapElement.Joe) { actMap[row, column] = mapElementFactory.chosedMapElement; } GameObject elem = null; Vector3 placePosition = new Vector3(startPosition.x + column * SharedData.widhtUnit + SharedData.widhtUnit / 2, 0, startPosition.z - row * SharedData.widhtUnit - SharedData.widhtUnit / 2); switch (mapElementFactory.chosedMapElement) { case MapElement.Column: elem = Instantiate(columnModel.gameObject, placePosition + new Vector3(0, columnModel.ModelGround, 0), columnModel.GetQuat(), transform); break; case MapElement.Trap: elem = Instantiate(trapModel.gameObject, placePosition + new Vector3(0, trapModel.ModelGround, 0), trapModel.GetQuat(), transform); break; case MapElement.Button: elem = Instantiate(buttonModel.gameObject, placePosition + new Vector3(0, buttonModel.ModelGround, 0), buttonModel.GetQuat(), transform); break; case MapElement.Hole: elem = Instantiate(holeModel.gameObject, placePosition + new Vector3(0, holeModel.ModelGround, 0), holeModel.GetQuat(), transform); break; case MapElement.Door: elem = Instantiate(doorModel.gameObject, placePosition + new Vector3(0, doorModel.ModelGround, 0), doorModel.GetQuat(), transform); GameObject doorEdge1 = Instantiate(doorEdgeModel.gameObject, placePosition + new Vector3(0, doorEdgeModel.ModelGround, SharedData.widhtUnit), doorEdgeModel.GetQuat(), transform); GameObject doorEdge2 = Instantiate(doorEdgeModel.gameObject, placePosition + new Vector3(0, doorEdgeModel.ModelGround, -SharedData.widhtUnit), doorEdgeModel.GetQuat(), transform); webCreator.EnableMapPlace(row + 1, column); webCreator.EnableMapPlace(row - 1, column); MapElementData doorEdge1MED = doorEdge1.GetComponent <MapElementData>(); doorEdge1MED.Row = row - 1; doorEdge1MED.Column = column; MapElementData doorEdge2MED = doorEdge2.GetComponent <MapElementData>(); doorEdge2MED.Row = row + 1; doorEdge2MED.Column = column; actMap[row + 1, column] = MapElement.DoorEdge; actMap[row - 1, column] = MapElement.DoorEdge; objectMap[row + 1, column] = doorEdge2; objectMap[row - 1, column] = doorEdge1; break; case MapElement.Key: elem = Instantiate(keyModel.gameObject, placePosition + new Vector3(0, keyModel.ModelGround, 0), keyModel.GetQuat(), transform); mapElementFactory.ItemPlaced(); itemType = MapElement.Key; break; case MapElement.StoneLifter: elem = Instantiate(stoneLifterModel.gameObject, placePosition + new Vector3(0, stoneLifterModel.ModelGround, 0), stoneLifterModel.GetQuat(), transform); break; case MapElement.RisingStone: elem = Instantiate(risingStoneModel.gameObject, placePosition + new Vector3(0, risingStoneModel.ModelGround, 0), risingStoneModel.GetQuat(), transform); break; case MapElement.LaserGate: elem = Instantiate(laserGateModel.gameObject, placePosition + new Vector3(0, laserGateModel.ModelGround, 0), laserGateModel.GetQuat(), transform); GameObject laserGateEdge1 = Instantiate(laserGateEdgeModel.gameObject, placePosition + new Vector3(0, laserGateEdgeModel.ModelGround, SharedData.widhtUnit), laserGateEdgeModel.GetQuat(), transform); GameObject laserGateEdge2 = Instantiate(laserGateEdgeModel.gameObject, placePosition + new Vector3(0, laserGateEdgeModel.ModelGround, -SharedData.widhtUnit), laserGateEdgeModel.GetQuat(), transform); MapElementData laserGateEdge1MED = laserGateEdge1.GetComponent <MapElementData>(); laserGateEdge1MED.Row = row - 1; laserGateEdge1MED.Column = column; MapElementData laserGateEdge2MED = laserGateEdge2.GetComponent <MapElementData>(); laserGateEdge2MED.Row = row + 1; laserGateEdge2MED.Column = column; webCreator.DisableMapPlace(row + 1, column); webCreator.DisableMapPlace(row - 1, column); actMap[row + 1, column] = MapElement.LaserGateEdge; actMap[row - 1, column] = MapElement.LaserGateEdge; objectMap[row + 1, column] = laserGateEdge2; objectMap[row - 1, column] = laserGateEdge1; break; case MapElement.LaserSwitch: elem = Instantiate(laserSwitchModel.gameObject, placePosition + new Vector3(0, laserSwitchModel.ModelGround, 0), laserSwitchModel.GetQuat(), transform); break; case MapElement.Gem: elem = Instantiate(gemModel.gameObject, placePosition + new Vector3(0, gemModel.ModelGround, 0), gemModel.GetQuat(), transform); mapElementFactory.ItemPlaced(); itemType = MapElement.Gem; break; case MapElement.Relic: elem = Instantiate(relicModel.gameObject, placePosition + new Vector3(0, relicModel.ModelGround, 0), relicModel.GetQuat(), transform); mapElementFactory.ItemPlaced(); itemType = MapElement.Relic; break; case MapElement.Box: MapElementData boxOnIt = objectMap[row, column].GetComponent <MapElementData>(); if (boxOnIt.joeOnIt) { return(true); } GameObject box = Instantiate(boxModel.gameObject, placePosition + new Vector3(0, SharedData.hight_0_Ground + (boxOnIt.Height + boxOnIt.BoxOnItCount) * SharedData.heightUnit + boxAboveElemValue, 0), boxModel.GetQuat(), transform); boxOnIt.BoxOnItCount++; boxes.Add(box); boxOnIt.AddBox(box); MapElementBox mapElementBox = box.GetComponent <MapElementBox>(); mapElementBox.Column = column; mapElementBox.Row = row; mapElementBox.PlaceHeight = SharedData.hight_0_Ground + (boxOnIt.Height + boxOnIt.BoxOnItCount) * SharedData.heightUnit + boxAboveElemValue; return(true); case MapElement.Joe: MapElementData joePlace = objectMap[row, column].GetComponent <MapElementData>(); GameObject joe = Instantiate(joeModel.gameObject, placePosition + new Vector3(0, SharedData.hight_0_Ground + (joePlace.Height + joePlace.BoxOnItCount) * SharedData.heightUnit + joeAboveValue, 0), joeModel.GetQuat(), transform); mapElementFactory.JoePlaced(); joePlace.joeOnIt = joe; MapElementBox joeMEB = joe.GetComponent <MapElementBox>(); joeMEB.Column = column; joeMEB.Row = row; joeMEB.PlaceHeight = SharedData.hight_0_Ground + (joePlace.Height + joePlace.BoxOnItCount) * SharedData.heightUnit + joeAboveValue; this.joeMEB = joeMEB; saveBtn.interactable = true; return(true); default: break; } MapElementData mapElementData = elem.GetComponent <MapElementData>(); mapElementData.Row = row; mapElementData.Column = column; Destroy(objectMap[row, column]); objectMap[row, column] = elem; return(true); }
//点填充地图 public bool fillPoint(MapElement currentMap, int bufW, int bufH, float zoomLevel, int indexX, int indexY, short level, Object element, bool drawInBuffer, int currentStageID) { if (currentMap == null) { return false; } //对于对象层的填充 Graphics g = null; if (level >= Consts.LEVEL_TILE_OBJ) { g = gMapBuffer_Obj; } else { g = gMapBuffer; } //历史记录 bool changed = false; if (inRemTileEdit) { if (fillPointsCmd != null) { Object oldElement = currentMap.getTile(indexX, indexY, level, currentStageID); changed = currentMap.fillPoint(g, bufW, bufH, zoomLevel, indexX, indexY, level, element, drawInBuffer, currentStageID); Object newElement = currentMap.getTile(indexX, indexY, level, currentStageID); FillPointHistory pointCmd = new FillPointHistory(currentMap,oldElement, newElement, indexX, indexY, level,currentStageID); fillPointsCmd.addPoint(pointCmd); //Console.WriteLine(indexX + "," + indexY); } } else { changed = currentMap.fillPoint(g, bufW, bufH, zoomLevel, indexX, indexY, level, element, drawInBuffer, currentStageID); } return changed; }
public void SaveMap() { MapSer map = new MapSer(); map.name = saveName.text; map.Scarab2PartNumber = Convert.ToInt32(scarab2part.text); map.Scarab3PartNumber = Convert.ToInt32(scarab3part.text); int plusEdges = boxes.Count + 1; MapElement[,] mapElements = new MapElement[webCreator.RowCount + 2 * plusEdges, webCreator.ColumnCount + 2 * plusEdges]; for (int i = plusEdges; i < webCreator.RowCount + plusEdges; i++) { for (int j = plusEdges; j < webCreator.ColumnCount + plusEdges; j++) { mapElements[i, j] = actMap[i - plusEdges, j - plusEdges]; } } map.startPosition = new Vector3Ser(startPosition.x - plusEdges * SharedData.widhtUnit, startPosition.y, startPosition.z + plusEdges * SharedData.widhtUnit); Vector3 extraDistance = new Vector3(-1, 0, 1) * plusEdges * SharedData.widhtUnit; float charPositionX = startPosition.x + (joeMEB.Column + plusEdges) * SharedData.widhtUnit + extraDistance.x; float charPositionY = startPosition.y + joeMEB.PlaceHeight; float charPositionZ = startPosition.z - (joeMEB.Row + plusEdges) * SharedData.widhtUnit + extraDistance.z; map.charPosition = new Vector3Ser(charPositionX, charPositionY, charPositionZ); map.mapMatrix = mapElements; map.heigth = map.mapMatrix.GetLength(0); map.width = map.mapMatrix.GetLength(1); map.boxNumber = boxes.Count; map.boxLocations = new Vector3Ser[boxes.Count]; for (int i = 0; i < boxes.Count; i++) { MapElementBox boxME = boxes[i].GetComponent <MapElementBox>(); float boxLocationX = startPosition.x + (boxME.Column + plusEdges) * SharedData.widhtUnit + extraDistance.x; float boxLocationY = startPosition.y + boxME.PlaceHeight; float boxLocationZ = startPosition.z - (boxME.Row + plusEdges) * SharedData.widhtUnit + extraDistance.z; map.boxLocations[i] = new Vector3Ser(boxLocationX, boxLocationY, boxLocationZ); } if (itemType == MapElement.Key) { map.itemType = SharedData.KeyType; } else if (itemType == MapElement.Gem) { map.itemType = SharedData.GemType; } else if (itemType == MapElement.Relic) { map.itemType = SharedData.RelicType; } else { map.itemType = SharedData.DefaultType; } MapCollection.CalculateItemsMapSer(map); Save(map); SceneLoader.LoadSceneStatic(GameStructure.extraSceneName); }
public FillRandomPointsCommand(MapElement mapElementT) { mapElement = mapElementT; }
/// <summary> /// Get value for target oject /// </summary> /// <param name="target">The object whose property value will be returned</param> /// <returns>Place object</returns> public static Place GetValue(MapElement target) { return(GetValueProperty(target)); }
public void OnElementDestroyed(MapElement element) { UpdateTopElements(element.Coordinates, false); }
private string BuildRequest(int imageHeight, int imageWidth, GISEnvelope requestEnvelope, MapElement legendElement, List<GISLayerInfo> layerInfo, Dictionary<string, EsriLayer> layers) { StringBuilder requestString = new StringBuilder(); XmlWriter requestWriter = XmlWriter.Create(requestString); requestWriter.WriteStartElement("ARCXML"); requestWriter.WriteAttributeString("", "VERSION", "", "1.1"); requestWriter.WriteStartElement("REQUEST"); requestWriter.WriteStartElement("GET_IMAGE"); requestWriter.WriteAttributeString("", "auto_resize", "", "true"); requestWriter.WriteAttributeString("", "show", "", "layers"); requestWriter.WriteStartElement("PROPERTIES"); requestWriter.WriteStartElement("IMAGESIZE"); requestWriter.WriteAttributeString("", "width", "", imageWidth.ToString()); requestWriter.WriteAttributeString("", "height", "", imageHeight.ToString()); requestWriter.WriteEndElement(); // IMAGESIZE EsriEnvelope.AsXml(requestWriter, requestEnvelope); // if (layerDefs != null) AddLayerlist(requestWriter, layerDefs); if (legendElement != null) { legendElement.AsXml(requestWriter); } if (layers != null) AddLayers(requestWriter, layers); if (layerInfo != null) AddLayerInfo(requestWriter, layerInfo); requestWriter.WriteEndElement(); // PROPERTIES requestWriter.WriteEndElement(); // GET_IMAGE requestWriter.WriteEndElement(); // REQUEST requestWriter.WriteEndElement(); // ARCXML requestWriter.Flush(); return requestString.ToString(); }
/// <summary> /// Creates settings from the configuration file value /// </summary> /// <param name="map"></param> public Settings(MapElement map) : this(map.Path, CreateSettingsFromConfig(map)) { }
public static MapElement getMapElement(MapsManager manager) { element = new MapElement(manager); SmallDialog_NewMap dialog = new SmallDialog_NewMap("新建地图", manager.tileGfxManager,true); dialog.ShowDialog(); return element; }
public static TrackPoint GetValue(MapElement target) { return GetValueProperty(target); }
// This adds an element public void AddElement(MapElement e) { this.elements.Add(e); }
private string BuildQuery(string queryLayer, int maxFeaturesReturned, MapElement spatialQuery) { StringBuilder queryString = new StringBuilder(); StringWriter messageString = new StringWriter(queryString); XmlWriter queryWriter = XmlWriter.Create(messageString); queryWriter.WriteStartElement("ARCXML"); queryWriter.WriteAttributeString("", "VERSION", "", "1.1"); queryWriter.WriteStartElement("REQUEST"); queryWriter.WriteStartElement("GET_FEATURES"); queryWriter.WriteAttributeString("", "outputmode", "", "xml"); queryWriter.WriteAttributeString("", "geometry", "", "false"); queryWriter.WriteAttributeString("", "envelope", "", "true"); queryWriter.WriteAttributeString("", "beginrecord", "", "0"); queryWriter.WriteAttributeString("", "globalenvelope", "", "true"); queryWriter.WriteAttributeString("", "featurelimit", "", maxFeaturesReturned.ToString()); queryWriter.WriteStartElement("PROPERTIES"); spatialQuery.AsXml(queryWriter); queryWriter.WriteEndElement(); // PROPERTIES queryWriter.WriteEndElement(); // GET_FEATURES queryWriter.WriteEndElement(); // REQUEST queryWriter.WriteEndElement(); // ARCXML return queryString.ToString(); }
public void RegisterMapElement(MapElement element) { if (Elements.Contains(element)) throw new System.Exception(GetType().Name + ".RegisterMapElement(" + element.GetType().Name + "," + element.Position + ") // Элемент уже присутствует в списке."); //Debug.Log(this + ".RegisterMapElement(" + element + ")"); Elements.Add(element); element.transform.parent = this.MapElements.transform; element.transform.localScale = new Vector3(ElementSize.x / element.Size.x, ElementSize.y / element.Size.y); // element.transform.localPosition = MapToWorld(element.Position); Это из Update-а делалось. AddToMap(element); }
//设置地图单元 public static void configMapElement(MapElement elementT) { if (elementT == null) { Console.WriteLine("error in configMapElement"); return; } element = elementT; SmallDialog_NewMap dialog = new SmallDialog_NewMap("设置地图属性", element.mapsManager.tileGfxManager,false); dialog.ShowDialog(); }
public void UnregisterMapElement(MapElement element) { if (!Elements.Contains(element)) throw new System.Exception(GetType().Name + ".UnregisterMapElement(" + element + ") // Элемент отсутствует в списке."); //Debug.Log(this + ".UnregisterMapElement(" + element + ")"); RemoveFromMap(element); Elements.Remove(element); }
static Brush GetBrush(MapElement element) { if (element.Id == selected) return Brushes.Magenta; else if (element.IsActive) return new SolidBrush(GetColor(element.MapX,element.MapY)); else return Brushes.LightGray; }
private void AddToMap(MapElement element) { if (!Map.ContainsKey(element.Position.Y)) Map[element.Position.Y] = new MapLine() { XCells = Enumerable.Range(1, MAP_WIDTH).Select(index => new MapCell()).ToArray() }; Map[element.Position.Y].XCells[element.Position.X].ZDepths[element.Position.Z] = element; }
private void DestroyElementOnMap(MapElement element) { UnregisterMapElement(element); Destroy(element.gameObject); }
public void Cmd_SelectExistMap(MapElement element) { worldMgr.setReadyToStart(); }