Example #1
0
        public void Load()
        {
            var isCloudSave = Main.ActivePlayerFileData.IsCloudSave;

            if (isCloudSave && SocialAPI.Cloud == null || !Main.mapEnabled)
            {
                return;
            }
            var str1 = Main.playerPathName.Substring(0, Main.playerPathName.Length - 4) +
                       (object)Path.DirectorySeparatorChar;
            string str2;

            if (Main.ActiveWorldFileData.UseGuidAsMapName)
            {
                var str3 = str1;
                str2 = str1 + Main.ActiveWorldFileData.UniqueId.ToString() + ".map";
                if (!FileUtilities.Exists(str2, isCloudSave))
                {
                    str2 = str3 + (object)Main.worldID + ".map";
                }
            }
            else
            {
                str2 = str1 + (object)Main.worldID + ".map";
            }

            if (!FileUtilities.Exists(str2, isCloudSave))
            {
                Main.MapFileMetadata = FileMetadata.FromCurrentSettings(FileType.Map);
            }
            else
            {
                using (var memoryStream = new MemoryStream(FileUtilities.ReadAllBytes(str2, isCloudSave)))
                {
                    using (var fileIO = new BinaryReader((Stream)memoryStream))
                    {
                        try
                        {
                            var release = fileIO.ReadInt32();
                            if (release > 193)
                            {
                                return;
                            }
                            if (release <= 91)
                            {
                                MapHelper.LoadMapVersion1(fileIO, release);
                            }
                            else
                            {
                                MapHelper.LoadMapVersion2(fileIO, release);
                            }
                            Main.clearMap    = true;
                            Main.loadMap     = true;
                            Main.loadMapLock = true;
                            Main.refreshMap  = false;
                        }
                        catch (Exception ex)
                        {
                            using (var streamWriter = new StreamWriter("client-crashlog.txt", true))
                            {
                                streamWriter.WriteLine((object)DateTime.Now);
                                streamWriter.WriteLine((object)ex);
                                streamWriter.WriteLine("");
                            }

                            if (!isCloudSave)
                            {
                                File.Copy(str2, str2 + ".bad", true);
                            }
                            this.Clear();
                        }
                    }
                }
            }
        }
Example #2
0
        public void RecursionTest2([Values] bool useAction)
        {
            var mapper = new MapHelper <RTest2, RTest2>().Map(useAction, new RTest2(), m => m);

            Assert.That(mapper.To, Is.Not.Null);
        }
Example #3
0
 public void InsertSelection(Transform map)
 {
     target = MapHelper.GetMapOccupiedObj(map);
 }
Example #4
0
 public void Save()
 {
     MapHelper.SaveMap();
 }
        public ActionResult Index(int?idg, string nombre = "", int paginado = 40, string UserId = "")
        {
            if (paginado <= 0)
            {
                paginado = 40;
            }


            //paginacion
            int totalPages = 0;
            int totalRows  = 0;
            int pageSize   = paginado;
            int page       = Request.QueryString["page"] == null ? 1 : int.Parse(Request.QueryString["page"]);

            MediaRepository    mediaRepo        = new MediaRepository(context);
            GeneroRepository   generoRepository = new GeneroRepository(context);
            UsuarioRepository  userRepo         = new UsuarioRepository(context);
            FavoritoRepository favRepo          = new FavoritoRepository(context);

            var yo = userRepo.Query(u => u.IdentityId == UserId).FirstOrDefault();

            var misFavoritos = favRepo.Query(f => f.usuarioId == yo.Id);

            var genero = generoRepository.Query(g => g.Eliminado == false);

            Expression <Func <Media, bool> > expr = m => m.estado == EEstatusMedia.VISIBLE;

            int count = 0;

            foreach (var item in misFavoritos)
            {
                if (count == 0)
                {
                    expr = expr.And(m => m.id == item.mediaId);
                    count++;
                }
                else
                {
                    expr = expr.Or(m => m.id == item.mediaId);
                }
            }

            if (idg != null)
            {
                expr = expr.And(x => x.Generos.Any(y => y.Id == idg));
            }

            expr = expr.And(m => m.estado == EEstatusMedia.VISIBLE && m.nombre.Contains(nombre));

            var lst = mediaRepo.QueryPage(expr, out totalPages, out totalRows, "Nombre", page - 1, pageSize);

            var models = MapHelper.Map <IEnumerable <MediaViewModel> >(lst);

            var model = new PaginatorViewModel <MediaViewModel>
            {
                Page       = page,
                TotalPages = totalPages,
                TotalRows  = totalRows,
                PageSize   = pageSize,
                Results    = models
            };

            ViewBag.ListaGenero = GeneroList(genero);
            ViewBag.Nombre      = nombre;
            ViewBag.Idg         = idg + "";
            ViewBag.Paginado    = paginado + "";
            ViewBag.UserId      = UserId;
            ViewBag.numList     = misFavoritos.Count();

            return(View(model));
        }
        private void btncal_Click(object sender, RoutedEventArgs e)
        {
            int    layer = int.Parse(tlayer.Text);
            int    idxwd = int.Parse(tidxwd.Text);
            int    idxjd = int.Parse(tidxjd.Text);
            double minjd = double.Parse(tminjd.Text);
            double minwd = double.Parse(tminwd.Text);
            double maxjd = double.Parse(tmaxjd.Text);
            double maxwd = double.Parse(tmaxwd.Text);

            double spanjd = maxjd - minjd;
            double spanwd = maxwd - minwd;

            //计算最合适的对应层
            int    ycount; double angle, tileLength, xStart, xEnd, yStart, yEnd;
            int    si = 0; double cz = double.PositiveInfinity;
            double divjd = 0, divwd = 0, sxstart = 0, sxend = 0, systart = 0, syend = 0;

            for (int i = 0; i < 18; i++)
            {
                int idxx = 0; int idxy = 0;
                ycount     = (int)Math.Pow(2, i);
                angle      = MapHelper.DegToRad(360.0 / ycount);
                tileLength = 2.0 * Math.PI / Math.Pow(2, i);                                                             //2*pi/power(2,layer)  假定半径为1, 平面地图坐标系下该层划分块的长和宽度
                xStart     = (idxx * angle - Math.PI) / Math.PI * 180;                                                   //  指定索引号块的起始经度
                xEnd       = ((idxx + 1) * angle - Math.PI) / Math.PI * 180;                                             //  指定索引号块的起始经度
                yStart     = (Math.Atan(Math.Exp(Math.PI - (idxy + 1) * tileLength)) * 2 - Math.PI / 2) / Math.PI * 180; //指定索引号块的结束纬度
                yEnd       = (Math.Atan(Math.Exp(Math.PI - idxy * tileLength)) * 2 - Math.PI / 2) / Math.PI * 180;       //atan(exp(PI-idxy*2*pi/power(2,layer)))*2-pi/2  指定索引号块的起始纬度
                double tmp = Math.Abs(xEnd - xStart - spanjd) + Math.Abs(yStart - yEnd - spanwd);
                if (tmp < cz)
                {
                    cz = tmp; si = i;
                }
            }
            //计算合适的瓦片序号
            ycount = (int)Math.Pow(2, si);
            angle  = MapHelper.DegToRad(360.0 / ycount);
            int sidxx = (int)((minjd / 180 * Math.PI + Math.PI) / angle);

            tileLength = 2.0 * Math.PI / Math.Pow(2, si); //2*pi/power(2,layer)  假定半径为1, 平面地图坐标系下该层划分块的长和宽度
            int sidxy = (int)((Math.PI - Math.Log(Math.Tan((minwd / 180 * Math.PI + Math.PI / 2) / 2))) / tileLength);

            //计算合适的瓦片信息
            ycount     = (int)Math.Pow(2, si);
            angle      = MapHelper.DegToRad(360.0 / ycount);
            tileLength = 2.0 * Math.PI / Math.Pow(2, si);                                                             //2*pi/power(2,layer)  假定半径为1, 平面地图坐标系下该层划分块的长和宽度
            xStart     = (sidxx * angle - Math.PI) / Math.PI * 180;                                                   //  指定索引号块的起始经度
            xEnd       = ((sidxx + 1) * angle - Math.PI) / Math.PI * 180;                                             //  指定索引号块的起始经度
            yStart     = (Math.Atan(Math.Exp(Math.PI - (sidxy + 1) * tileLength)) * 2 - Math.PI / 2) / Math.PI * 180; //指定索引号块的结束纬度
            yEnd       = (Math.Atan(Math.Exp(Math.PI - sidxy * tileLength)) * 2 - Math.PI / 2) / Math.PI * 180;       //atan(exp(PI-idxy*2*pi/power(2,layer)))*2-pi/2  指定索引号块的起始纬度
            divjd      = xEnd - xStart; divwd = yEnd - yStart; sxstart = xStart; sxend = xEnd; systart = yStart; syend = yEnd;

            //瓦片信息
            txtTileResult.Text = string.Format("瓦片设置参数earth.earthManager.earthpara:层偏移(tileFileOffsetLI={0}),经度序号偏移(tileFileOffsetXI={1}),纬度序号偏移(tileFileOffsetYI={2})",
                                               layer - si, idxjd - sidxx, idxwd - sidxy);

            //坐标转换信息
            txtCoorResult.Text = string.Format("坐标转换设置参数 earth.coordinateManager:原点经度(orgJD={0}),原点纬度(orgWD={1}),经度缩放比例(scaleJD={2}),纬度缩放比例(scaleJD={3}),经度偏移(offsetJD={4}),纬度偏移(offsetJD={5})",
                                               minjd, minwd, divjd / spanjd, divwd / spanwd, sxstart - minjd, systart - minwd);

            //目标瓦片信息
            txtInfo.Text = string.Format("目标瓦片:{0}-{1}-{2}, {3}-{4}, {5}-{6}", si, sidxx, sidxy, xStart, xEnd, yStart, yEnd);
        }
Example #7
0
 private void frmMagnifierWindows_ItemAdded(object Item)
 {
     MapHelper.CopyMap(this.m_pMap, this.axMapControl1.Map, false, false);
 }
Example #8
0
        public override void Generate(MapHelper hmap, BackgroundWorker worker)
        {
            baseFloorCA  = new CellularAutomata(Generator.GenRandom, Generator.BOUNDARY);
            denseFloorCA = new CellularAutomata(Generator.GenRandom, Generator.BOUNDARY);
            // Stage1: Base floor
            currentAction = "Generating sparse grass";
            baseFloorCA.SetupCA(2, 1, 0.048f);
            int ticks = 23;            // 23-25

            for (int i = 0; i < ticks; i++)
            {
                baseFloorCA.DoSimulationTick();
                worker.ReportProgress(GeneratorUtil.CalcPercent(i, ticks));
            }
            // Stage2: Copy floor onto map
            currentAction        = "Importing generated tiles";
            bool[,] baseFloorMap = baseFloorCA.GetCellMap();
            hmap.SetTileMaterial(BASE_FLOOR);
            for (int x = 0; x < Generator.BOUNDARY; x++)
            {
                worker.ReportProgress(GeneratorUtil.CalcPercent(x, Generator.BOUNDARY));
                for (int y = 0; y < Generator.BOUNDARY; y++)
                {
                    if (baseFloorMap[x, y])
                    {
                        hmap.PlaceTileSnap(x, y);
                    }
                }
            }
            // Stage3: Generate sparse grass
            currentAction = "Generating dense grass";
            denseFloorCA.SetupCA(6, 5, 0.75f);
            ticks = 18;
            for (int i = 0; i < ticks; i++)
            {
                denseFloorCA.DoSimulationTick();
                worker.ReportProgress(GeneratorUtil.CalcPercent(i, ticks));
            }
            // Stage4: Import sparse grass
            bool[,] grassMap = denseFloorCA.GetCellMap();
            hmap.SetTileMaterial(DENSE_FLOOR);
            for (int x = 0; x < Generator.BOUNDARY; x++)
            {
                worker.ReportProgress(GeneratorUtil.CalcPercent(x, Generator.BOUNDARY));
                for (int y = 0; y < Generator.BOUNDARY; y++)
                {
                    if (grassMap[x, y] && baseFloorMap[x, y])
                    {
                        hmap.PlaceTileSnap(x, y);
                    }
                }
            }
            // Stage5: Make pathes
            currentAction = "Generating pathes";
            baseFloorCA.SetCellMap(baseFloorMap);
            baseFloorCA.BirthCellLimit = 9;
            baseFloorCA.DeathCellLimit = 6;
            ticks = 20;
            for (int i = 0; i < ticks; i++)
            {
                baseFloorCA.DoSimulationTick();
                worker.ReportProgress(GeneratorUtil.CalcPercent(i, ticks));
            }
            // Stage6: Import pathes
            currentAction     = "Importing generated tiles";
            bool[,] pathesMap = baseFloorCA.GetCellMap();
            hmap.SetTileMaterial(PATH_FLOOR);
            for (int x = 0; x < Generator.BOUNDARY; x++)
            {
                worker.ReportProgress(GeneratorUtil.CalcPercent(x, Generator.BOUNDARY));
                for (int y = 0; y < Generator.BOUNDARY; y++)
                {
                    if (pathesMap[x, y] && baseFloorMap[x, y])
                    {
                        hmap.PlaceTileSnap(x, y);
                    }
                }
            }
            // Stage7: Blend pathes
            currentAction = "Blending (Path)";
            hmap.SetTileMaterial(PATH_FLOOR);
            hmap.SetEdgeMaterial(BLEND_EDGE);
            hmap.SetAutoblendIgnore(DENSE_FLOOR);             // Densegrass overrides
            GeneratorUtil.BlendAllTiles(hmap);
            // Stage8: Blend dense grass
            currentAction = "Blending (Dense grass)";
            hmap.SetTileMaterial(DENSE_FLOOR);
            hmap.SetEdgeMaterial(BLEND_EDGE);
            hmap.SetAutoblendIgnore(null);
            GeneratorUtil.BlendAllTiles(hmap);
            // Stage9: Scan tiles
            currentAction = "Scanning area (floodfill)";
            // This array will be used later for generating polygons
            List <HashSet <Point> > TileGroupedArea = new List <HashSet <Point> >();

            for (int x = 0; x <= Generator.BOUNDARY; x++)
            {
                worker.ReportProgress(GeneratorUtil.CalcPercent(x, Generator.BOUNDARY));
                for (int y = 0; y <= Generator.BOUNDARY; y++)
                {
                    if (hmap.GetTile(x, y) != null)
                    {
                        bool search = true;
                        foreach (HashSet <Point> list in TileGroupedArea)
                        {
                            if (list.Contains(new Point(x, y)))
                            {
                                search = false;
                                break;
                            }
                        }
                        if (search)
                        {
                            FloodFill fill = new FloodFill(hmap);
                            fill.PerformFloodFill(x, y);

                            // Ignore tile groups with less than 200 tiles
                            if (fill.GetResult().Count < 200)
                            {
                                fill.DeleteResultTiles();
                            }
                            else
                            {
                                TileGroupedArea.Add(fill.GetResult());
                            }
                        }
                    }
                }
            }
            // Stage10: Build walls
            currentAction = "Building void walls";
            hmap.SetWallMaterial(WALL1);
            GeneratorUtil.MakeWallsAroundTiles(hmap);
            // Stage11: Smooth walls
            currentAction = "Smoothing walls";
            GeneratorUtil.ReorientWalls2(hmap, Generator.GenConfig.Allow3SideWalls);
            // Stage12: Populate (optional)
            if (Generator.GenConfig.PopulateMap)
            {
                currentAction = "Populating (objects)";
                Populate.PopulateCrossroad(hmap);
            }
            // Finish: return
        }
Example #9
0
        private void button2_Click(object sender, EventArgs e)
        {
            _path = txtPath.Text;
            if (_path.Equals(""))
            {
                MessageBox.Show("请选择存储路径!");
                return;
            }
            if (numZoom.Value > numZoomEnd.Value)
            {
                MessageBox.Show("地图级别设置不对!");
                return;
            }

            int zoomStart = (int)numZoom.Value;
            int zoomEnd   = (int)numZoomEnd.Value;

            int thread = (int)numThread.Value;

            _waittodownload.Clear();
            for (int zoom = zoomStart; zoom <= zoomEnd; ++zoom)
            {
                PointF point1 = MapHelper.GetLocationByLatLng(p1, zoom); //将第一个点经纬度转换成平面2D坐标
                PointF point2 = MapHelper.GetLocationByLatLng(p2, zoom); //将第二个点经纬度转换成平面2D坐标

                int startX = (int)point1.X / 256;                        //起始列
                int endX   = (int)point2.X / 256;                        //结束列
                if (endX == Math.Pow(2, zoom))                           //结束列超出范围
                {
                    endX--;
                }
                int startY = (int)point1.Y / 256; //起始行
                int endY   = (int)point2.Y / 256; //结束行
                if (endY == Math.Pow(2, zoom))    //结束行超出范围
                {
                    endY--;
                }

                _totalwidth  = (endX - startX + 1) * 256; //合并图的宽度
                _totalheight = (endY - startY + 1) * 256; //合并图的高度

                int threadId = 0;

                for (int y = startY; y <= endY; y++)
                {
                    for (int x = startX; x <= endX; x++)
                    {
                        RectInfo ri = new RectInfo();
                        ri.threadId  = threadId; //分别由不同的线程下载
                        ri.x         = x;
                        ri.y         = y;
                        ri.z         = zoom;
                        ri.bComplete = false;
                        _waittodownload.Add(ri);            //将每个小方块放入待下载集合
                        threadId = (threadId + 1) % thread; //由thread个不同线程下载图片
                    }
                }
            }

            if (MessageBox.Show("共有" + _waittodownload.Count + "张图片需要下载,确定下载吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
            {
                _thread  = thread;
                _zoom    = zoomStart;
                _zoomEnd = zoomEnd;

                _downloadnum = 0;

                _normal         = radioButton1.Checked;
                button2.Enabled = false;
                rchOuput.Clear();
                groupBox2.Text = "输出(" + _waittodownload.Count + "张)";
                _startTime     = DateTime.Now;
                for (int i = 1; i <= thread; ++i)
                {
                    Thread t = new Thread(new ParameterizedThreadStart(DownloadThreadProc));
                    t.Start(i);  //开启下载线程
                }
            }
        }
        public override void OnDrawInterface()
        {
            if (Main.gameMenu || Main.ingameOptionsWindow || Main.playerInventory || Main.mapFullscreen)
            {
                return;
            }

            if (_navigatorMode == 0)
            {
                return;
            }

            int    tileID;
            Player player = Main.player[Main.myPlayer];

            if (_navigatorMode == 1 && player.accOreFinder)
            {
                tileID = player.bestOre;
            }
            else if (_navigatorMode == 2)
            {
                tileID = _valuableTiles[_valuableIndex];
            }
            else
            {
                tileID = -1;
            }

            bool   found = false;
            string text = "Navigator: ";
            int    x0 = (int)player.Center.X / 16; // int x = (int)Main.MouseWorld.X / 16;
            int    y0 = (int)player.Center.Y / 16; // int y = (int)Main.MouseWorld.Y / 16;
            int    x1 = 0, y1 = 0;
            int    distance = 0;

            if (tileID != -1)
            {
                found = TryGetNearestTileV0(tileID, x0, y0, 80, out x1, out y1);
                if (found)
                {
                    text += GetDirectionAndDistance(x0, y0, x1, y1, out distance) + " / " + Lang.mapLegend[MapHelper.TileToLookup(tileID, 0)];
                }
                else
                {
                    text += "--- / " + Lang.mapLegend[MapHelper.TileToLookup(tileID, 0)];
                }
            }
            else
            {
                text += "---";
            }

            Vector2 size, position;

            size     = Main.fontMouseText.MeasureString(text);
            position = new Vector2((float)(Main.screenWidth - size.X - 4), (float)Main.screenHeight - 24);
            Main.spriteBatch.DrawString(Main.fontMouseText, text, position, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

            if (!found || distance < 2 || _navigationArrow == null)
            {
                return;
            }

            float angle = (float)(180 - (Math.Atan2(y0 - y1, x0 - x1)) * 180 / Math.PI);

            angle %= 360;
            angle  = (float)(Math.Round(angle / 5, MidpointRounding.AwayFromZero) * 5);

            text     = "angle: " + angle.ToString();
            size     = Main.fontMouseText.MeasureString(text);
            position = new Vector2((float)(Main.screenWidth - size.X - 4), (float)Main.screenHeight - 48);
            Main.spriteBatch.DrawString(Main.fontMouseText, text, position, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);

            Texture2D texture = _navigationArrow;

            Main.spriteBatch.Draw(texture,
                                  new Vector2((float)(Main.screenWidth - 26), (float)Main.screenHeight - 72),
                                  new Rectangle?(new Rectangle(0, 0, texture.Width, texture.Height)),
                                  Color.White,
                                  -(float)(Math.PI * angle / 180.0),
                                  new Vector2(texture.Width / 2, texture.Height / 2), 1f, SpriteEffects.None, 0f);
        }
Example #11
0
 /// <summary>
 /// Calculate the distance between two geocodes. Defaults to using Kilometers.
 /// </summary>
 public static double CalcDistance(this BasicGeoposition loc1, BasicGeoposition loc2)
 {
     return(MapHelper.CalcDistance(loc1.Latitude, loc1.Longitude, loc2.Latitude, loc2.Longitude));
 }
Example #12
0
 public void ZoomToSelectedFeatures(IFeatureLayer featureLayer)
 {
     MapHelper.Zoom2SelectedFeature(_activeView, featureLayer);
 }
Example #13
0
        public IFeature FindNearestFeature(ICoordinate worldPos, float limit, out ILayer outLayer, Func <ILayer, bool> condition)
        {
            IFeature nearestFeature = null;

            outLayer = null;

            // Since we are only interested in one geometry object start with the topmost trackersLayer and stop
            // searching the lower layers when an object is found.

            foreach (ILayer mapLayer in Map.GetAllVisibleLayers(true).OrderBy(l => l.RenderOrder))
            {
                if (mapLayer is DiscreteGridPointCoverageLayer)
                {
                    try
                    {
                        var curvilinearGridLayer = (DiscreteGridPointCoverageLayer)mapLayer;
                        var coverage             = (IDiscreteGridPointCoverage)curvilinearGridLayer.Coverage;

                        var nearestFeatures = coverage.GetFeatures(worldPos.X, worldPos.Y, limit);

                        if (nearestFeatures != null)
                        {
                            if (!curvilinearGridLayer.ShowFaces)
                            {
                                nearestFeatures = nearestFeatures.Where(f => !(f is IGridFace));
                            }

                            if (!curvilinearGridLayer.ShowVertices)
                            {
                                nearestFeatures = nearestFeatures.Where(f => !(f is IGridVertex));
                            }
                        }

                        nearestFeature = nearestFeatures.FirstOrDefault();

                        outLayer = curvilinearGridLayer;
                    }
                    catch (Exception)
                    {
                        // GetCoordinateAtPosition will throw exception if x, y is not within the coverage
                    }
                }
                if (mapLayer is VectorLayer)
                {
                    var       vectorLayer = mapLayer as VectorLayer;
                    IEnvelope envelope;
                    float     localLimit = limit;

                    if ((!vectorLayer.IsSelectable) || ((null != condition) && (!condition(vectorLayer))))
                    {
                        continue;
                    }
                    // Adjust the marge limit for Layers with a symbol style and if the size of the symbol exceeds
                    // the minimum limit. Ignore layers with custom renderers
                    if ((vectorLayer.Style.Symbol != null) && (0 == vectorLayer.CustomRenderers.Count))
                    {
                        ICoordinate size = MapHelper.ImageToWorld(MapControl.Map,
                                                                  vectorLayer.Style.Symbol.Width,
                                                                  vectorLayer.Style.Symbol.Height);
                        if ((size.X > localLimit) || (size.Y > localLimit))
                        {
                            envelope   = MapHelper.GetEnvelope(worldPos, size.X, size.Y);
                            localLimit = (float)Math.Max(envelope.Width, envelope.Height);
                        }
                        else
                        {
                            envelope = GetEnvelope(worldPos, localLimit);
                        }
                    }
                    else
                    {
                        envelope = GetEnvelope(worldPos, localLimit);
                    }

                    if (vectorLayer.DataSource != null)
                    {
                        // Get features in the envelope
                        var objectsAt = vectorLayer.GetFeatures(envelope).ToList();

                        // Mousedown at new position
                        if (null != objectsAt)
                        {
                            IFeature feature = null;
                            if (objectsAt.Count == 1)
                            {
                                feature = objectsAt.First();
                            }
                            else if (objectsAt.Count > 1)
                            {
                                double localDistance;
                                feature = FindNearestFeature(vectorLayer, objectsAt.Distinct(), worldPos, localLimit, out localDistance);
                            }

                            if (null != feature)
                            {
                                nearestFeature = feature;
                                outLayer       = vectorLayer;
                                break;
                            }
                        }
                    }
                }
                else if (mapLayer is IRegularGridCoverageLayer)
                {
                    try
                    {
                        IRegularGridCoverageLayer regularGridCoverageLayer = (IRegularGridCoverageLayer)mapLayer;
                        IRegularGridCoverage      regularGridCoverage      = (IRegularGridCoverage)regularGridCoverageLayer.Coverage;

                        nearestFeature = regularGridCoverage.GetRegularGridCoverageCellAtPosition(worldPos.X, worldPos.Y);
                        outLayer       = regularGridCoverageLayer;
                    }
                    catch (Exception)
                    {
                        // GetCoordinateAtPosition will throw exception if x, y is not within the coverage
                    }
                }
            }
            return(nearestFeature);
        }
Example #14
0
 public double ImageToWorld(float imageSize)
 {
     return(MapHelper.ImageToWorld(Map, imageSize));
 }
Example #15
0
    public void MoveToGrid(Vector2Int grid)
    {
        Vector3 position = MapHelper.GridToScenePoint(grid);

        m_CameraCenter.transform.position = position;
    }
Example #16
0
 private void pAVEnt_ItemDeleted(object Item)
 {
     this.AddLayer();
     this.SetLayerVisible(MapHelper.GetMapScale(this.m_pMainMapControl.Map));
     this.DrawRectangle(this.axMapControl1.ActiveView);
 }
 private void HookCurrentModelToView(View view, ViewGroup upperView)
 {
     view.LayoutParameters = MapHelper.GetLayoutParams(upperView, _model.Map.MapService.Map, _model.CurrentLocation);
 }
Example #18
0
        public async void OnMapReady(GoogleMap googleMap)
        {
            mMap = googleMap;

            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            builder.Include(originLatLng);
            builder.Include(destLatLng);
            LatLngBounds bounds = builder.Build();

            int          padding = 100; // offset from edges of the map in pixels
            CameraUpdate cu      = CameraUpdateFactory.NewLatLngBounds(bounds, padding);

            // Add markers to oriign and destination
            mMap.AddMarker(new MarkerOptions().SetPosition(originLatLng).SetTitle("Origin"));
            mMap.AddMarker(new MarkerOptions().SetPosition(destLatLng).SetTitle("Destination"));

            // Combine Google Direction API string
            string urlGoogleDirection = MapHelper.GoogleDirectionAPIAddress(iTrip.originLatLng, iTrip.destinationLatLng);
            string strGoogleDirection = await MapHelper.DownloadStringAsync(urlGoogleDirection);

            var    googleDirectionAPIRoute = JsonConvert.DeserializeObject <GoogleDirectionAPI>(strGoogleDirection);
            string encodedPoints           = googleDirectionAPIRoute.routes[0].overview_polyline.points;
            var    lstDecodedPoints        = MapHelper.DecodePolylinePoint(encodedPoints);
            //convert list of location point to array of latlng type

            var latLngPoints   = lstDecodedPoints.ToArray();
            var polylineoption = new PolylineOptions();

            polylineoption.InvokeColor(Android.Graphics.Color.SkyBlue);
            polylineoption.Geodesic(true);
            polylineoption.Add(latLngPoints);
            mMap.AddPolyline(polylineoption);
            mMap.AnimateCamera(cu);

            // Call google matrix api
            string urlGoogleMatrix = MapHelper.GoogleDistanceMatrixAPIAddress(iTrip.originLatLng, iTrip.destinationLatLng);
            string strGoogleMatrix = await MapHelper.DownloadStringAsync(urlGoogleMatrix);

            var googleDirectionMatrix = JsonConvert.DeserializeObject <GoogleDistanceMatrixAPI>(strGoogleMatrix);

            txtviewDistance.Text = googleDirectionMatrix.rows[0].elements[0].distance.text.ToString();
            txtviewDuration.Text = googleDirectionMatrix.rows[0].elements[0].duration.text.ToString();
            distanceValue        = double.Parse(googleDirectionMatrix.rows[0].elements[0].distance.value.ToString());
            durationValue        = int.Parse(googleDirectionMatrix.rows[0].elements[0].duration.value.ToString());

            double cost;

            if (iMember.type.Equals("Driver"))
            {
                cost = Math.Round(dblDriverCostKM * googleDirectionMatrix.rows[0].elements[0].distance.value, 2);
            }
            else
            {
                cost = Math.Round(dblPassengerCostKM * googleDirectionMatrix.rows[0].elements[0].distance.value, 2);
            }
            txtviewCost.Text = string.Format("RM{0:0.00}", cost);

            RunOnUiThread(() =>
            {
                progress.Dismiss();
            });
        }
Example #19
0
        public CompositionFranchiseModel GetCompositionFranchise(Func <CompositionFranchise, bool> predicate)
        {
            var mapper = MapHelper.Mapping <CompositionFranchiseModel, CompositionFranchise>();

            return(mapper.Map <CompositionFranchiseModel>(this.repository.FirstorDefault(predicate)));
        }
Example #20
0
 //in Terraria.Main.DrawInventory replace
 //  Lang.mapLegend[MapHelper.TileToLookup(Main.recipe[Main.availableRecipe[num60]].requiredTile[num62], 0)]
 //  with Lang.mapLegend.FromType(Main.recipe[Main.availableRecipe[num60]].requiredTile[num62])
 //in Terraria.Main.DrawInfoAccs replace Lang.mapLegend[MapHelper.TileToLookup(Main.player[Main.myPlayer].bestOre, 0)]
 //  with Lang.mapLegend.FromType(Main.player[Main.myPlayer].bestOre)
 public LocalizedText FromType(int type)
 {
     return(this[MapHelper.TileToLookup(type, 0)]);
 }
Example #21
0
        public IFeature FindNearestFeature(ICoordinate worldPos, float limit, out ILayer outLayer,
                                           Func <ILayer, bool> condition)
        {
            IFeature nearestFeature = null;

            outLayer = null;
            // Since we are only interested in one geometry object start with the topmost trackersLayer and stop
            // searching the lower layers when an object is found.

            foreach (ILayer mapLayer in MapHelper.GetAllMapLayers(Map.Layers, false))
            {
                if (mapLayer is VectorLayer)
                {
                    var       vectorLayer = mapLayer as VectorLayer;
                    IEnvelope envelope;
                    float     localLimit = limit;

                    if ((!vectorLayer.IsSelectable) || ((null != condition) && (!condition(vectorLayer))))
                    {
                        continue;
                    }
                    // Adjust the marge limit for Layers with a symbol style and if the size of the symbol exceeds
                    // the minimum limit. Ignore layers with custom renderers
                    if ((vectorLayer.Style.Symbol != null) && (0 == vectorLayer.CustomRenderers.Count))
                    {
                        ICoordinate size = MapControlHelper.ImageToWorld(MapControl.Map, vectorLayer.Style.Symbol.Width,
                                                                         vectorLayer.Style.Symbol.Height);
                        if ((size.X > localLimit) || (size.Y > localLimit))
                        {
                            envelope   = MapControlHelper.GetEnvelope(worldPos, size.X, size.Y);
                            localLimit = (float)Math.Max(envelope.Width, envelope.Height);
                        }
                        else
                        {
                            envelope = GetEnvelope(worldPos, localLimit);
                        }
                    }
                    else
                    {
                        envelope = GetEnvelope(worldPos, localLimit);
                    }

                    IFeatureProvider featureProvider = vectorLayer.DataSource;
                    if (null != featureProvider)
                    {
                        // Get features in the envelope
                        IList objectsAt;

                        if (vectorLayer.CustomRenderers.Count > 0)
                        {
                            objectsAt = vectorLayer.CustomRenderers[0].GetFeatures(envelope, vectorLayer);
                        }
                        else
                        {
                            objectsAt = featureProvider.GetFeatures(envelope);
                        }
                        // Mousedown at new position
                        if ((null != objectsAt) && (objectsAt.Count > 0))
                        {
                            double   localDistance;
                            IFeature feature = FindNearestFeature(vectorLayer, objectsAt, worldPos, localLimit,
                                                                  out localDistance);
                            if (null != feature)
                            {
                                nearestFeature = feature;
                                outLayer       = vectorLayer;
                                break;
                            }
                        }
                    }
                }
                else if (mapLayer is IRegularGridCoverageLayer)
                {
                    try
                    {
                        IRegularGridCoverageLayer regularGridCoverageLayer = (IRegularGridCoverageLayer)mapLayer;
                        IRegularGridCoverage      regularGridCoverage      = (IRegularGridCoverage)regularGridCoverageLayer.Coverage;

                        nearestFeature = regularGridCoverage.GetRegularGridCoverageCellAtPosition(worldPos.X, worldPos.Y);

                        outLayer = regularGridCoverageLayer;
                    }
                    catch (Exception)
                    {
                        // GetCoordinateAtPosition will throw exception if x, y is not within the coverage
                    }
                }
            }

            return(nearestFeature);
        }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            string msg = Check();

            if (!string.IsNullOrWhiteSpace(msg))
            {
                MessageBox.Show(msg, "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            try
            {
                ArcGIS.Common.Editor.Editor.StartEditOperation();
                foreach (KeyValuePair <int, IGeometry> keyValuePair in _envelopDictionary)
                {
                    //}
                    //foreach (BoundFeatureInfo boundFeatureInfo in _envelopList)
                    //{
                    ISpatialFilter spatialFilter = new SpatialFilterClass();
                    spatialFilter.Geometry   = keyValuePair.Value;
                    spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    spatialFilter.OutputSpatialReference[PipeLayer.FeatureClass.ShapeFieldName] =
                        _context.FocusMap.SpatialReference;
                    spatialFilter.GeometryField = PipeLayer.FeatureClass.ShapeFieldName;
                    IFeatureCursor polygonFeatureCursor = RoadLayer.Search(spatialFilter, false);
                    IFeature       polygonFeature;
                    while ((polygonFeature = polygonFeatureCursor.NextFeature()) != null)
                    {
                        object objRoadName = polygonFeature.Value[_idxPolyRoadField];
                        if (objRoadName is DBNull || objRoadName == null)
                        {
                            continue;
                        }
                        spatialFilter.Geometry = polygonFeature.ShapeCopy;
                        IFeatureCursor pipeFeatureCursor = PipeLayer.FeatureClass.Update(spatialFilter, false);
                        IFeature       pipeFeature;
                        while ((pipeFeature = pipeFeatureCursor.NextFeature()) != null)
                        {
                            pipeFeature.Value[_idxPipeRoadField] = objRoadName;
                            pipeFeatureCursor.UpdateFeature(pipeFeature);
                            pipeFeature.Store();
                        }
                        Marshal.ReleaseComObject(pipeFeatureCursor);
                    }
                    Marshal.ReleaseComObject(polygonFeatureCursor);

                    ISpatialFilter spatialFilter2 = new SpatialFilterClass();
                    spatialFilter2.Geometry   = keyValuePair.Value;
                    spatialFilter2.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    IQueryFilter queryFilter = spatialFilter2 as IQueryFilter;
                    queryFilter.WhereClause = string.Format(" {0} is Null or {0} = '' ", ucField_PipeRoadName.Field.Name);
                    IFeatureCursor featureCursor = PipeLayer.FeatureClass.Update(queryFilter, false);
                    IFeature       feature;
                    while ((feature = featureCursor.NextFeature()) != null)
                    {
                        ITopologicalOperator pTopologicalOperator = feature.ShapeCopy as ITopologicalOperator;
                        if (pTopologicalOperator == null)
                        {
                            continue;
                        }
                        IPolygon        polygon  = pTopologicalOperator.Buffer((double)numSearchRadius.Value) as IPolygon;
                        List <IFeature> features = MapHelper.GetAllFeaturesFromPolygonInGeoFeatureLayer(polygon,
                                                                                                        (IGeoFeatureLayer)RoadLayer, _context.ActiveView);
                        if (features.Count <= 0)
                        {
                            continue;
                        }
                        IFeature pFeature = MapHelper.GetMinDistanceFeature(features, feature.ShapeCopy);
                        if (pFeature == null)
                        {
                            continue;
                        }
                        object obj = pFeature.Value[_idxPolyRoadField];
                        if (obj is DBNull || string.IsNullOrEmpty(obj.ToString()))
                        {
                            continue;
                        }
                        feature.Value[_idxPipeRoadField] = obj;
                        featureCursor.UpdateFeature(feature);
                        feature.Store();
                    }
                    Marshal.ReleaseComObject(featureCursor);
                }

                MessageBox.Show("执行完成");
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
            finally
            {
                ArcGIS.Common.Editor.Editor.StopEditOperation();
            }
        }
Example #23
0
    //Main GUI goes here
    void OnGUI()
    {
        GUI.depth           = 1;
        GUI.backgroundColor = Color.clear;
        GUI.color           = new Color(1.0f, 1.0f, 1.0f, _mainAlpha);

        if (MainGuiShow)
        {
            if (currentSelect.chess != null)
            {
                CurrentChess = currentSelect.chess;
            }
            if (CurrentChess != null)
            {
                CharacterProperty chessProperty = CurrentChess.GetComponent <CharacterProperty>();
                // move button
                if (chessProperty.Moved)
                {
                    GUI.enabled = false;
                }
                else
                {
                    GUI.enabled = true;
                }
                if (GUI.Button(posMoveBt, MoveTex))
                {
                    MainGuiFade = false;
                    SubGuiFade  = true;
                    moveShow    = true;
                    currentSelect.moveCommand(CurrentChess);
                    currentSelect.MoveCommandNetwork();
                    if (InTutorial)
                    {
                        init.ShowMoveCmd = false;
                        GameObject.Find("InitStage").transform.GetComponent <Tutorial>().AfterMove();
                        init.ShowMap = true;
                    }
                }
                GUI.enabled = true;
                //roll over move button
                if (!chessProperty.Moved && !InTutorial)
                {
                    if (posMoveBt.Contains(mousePos))
                    {
                        GUI.DrawTexture(posMoveBt, MoveTex);
                        GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + 16, 100, 30), "move", mainStyle);
                    }
                }
                // summon button
                if (!chessProperty.Summoner || init.stage == 1)
                {
                    GUI.enabled = false;
                }
                else
                {
                    GUI.enabled = true;
                }

                if (GUI.Button(posSummonBt, SummonTex))
                {
                    MainGuiFade = false;
                    SubGuiFade  = true;
                    summonShow  = true;
                }
                GUI.enabled = true;
                //roll over summon button
                if (chessProperty.Summoner && init.stage != 1)
                {
                    if (posSummonBt.Contains(mousePos))
                    {
                        GUI.DrawTexture(posSummonBt, SummonTex);
                        GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment + 16, 100, 30), "summon", mainStyle);
                    }
                }
                // Attack button
                if (chessProperty.Attacked || !MapHelper.Attackable(CurrentChess))
                {
                    GUI.enabled = false;
                }
                else
                {
                    GUI.enabled = true;
                }

                if (GUI.Button(posAttackBt, AttackTex))
                {
                    MainGuiFade = false;
                    SubGuiFade  = true;
                    attackShow  = true;
                    currentSelect.attackCommand(CurrentChess);
                    currentSelect.AttackCommandNetwork();
                    if (InSecondTutor)
                    {
                        init.ShowAtk = false;
                    }
                }
                GUI.enabled = true;
                //roll over attack button
                if (!chessProperty.Attacked && MapHelper.Attackable(CurrentChess))
                {
                    if (posAttackBt.Contains(mousePos))
                    {
                        GUI.DrawTexture(posAttackBt, AttackTex);
                        GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 2 + 16, 100, 30), "attack", mainStyle);
                    }
                }
                // skill button
                if (chessProperty.Activated || init.stage == 1)
                {
                    GUI.enabled = false;
                }
                else
                {
                    GUI.enabled = true;
                }
                if (GUI.Button(posSkillBt, SkillTex))
                {
                    MainGuiFade = false;
                    SubGuiFade  = true;
                    skillShow   = true;
                }
                GUI.enabled = true;
                //roll over skill button
                if (!chessProperty.Activated && init.stage != 1)
                {
                    if (posSkillBt.Contains(mousePos))
                    {
                        GUI.DrawTexture(posSkillBt, SkillTex);
                        GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 3 + 16, 100, 30), "skill", mainStyle);
                    }
                }
                //Defense button

                if (chessProperty.Attacked || init.ShowBuff || InSecondTutor)
                {
                    GUI.enabled = false;
                }
                else
                {
                    GUI.enabled = true;
                }

                if (GUI.Button(posDefenseBt, DefenseTex))
                {
                    DefenseCmd(CurrentChess);
                    if (init.ShowDef)
                    {
                        init.ShowDef  = false;
                        InTutorial    = false;
                        InSecondTutor = true;
                    }
                }
                GUI.enabled = true;
                //roll over defense button
                if (!chessProperty.Attacked)
                {
                    if (posDefenseBt.Contains(mousePos))
                    {
                        GUI.DrawTexture(posDefenseBt, DefenseTex);
                        GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 4 + 16, 100, 30), "defence", mainStyle);
                    }
                }
                // End turn button
                if (InTutorial)
                {
                    GUI.enabled = false;
                }
                else
                {
                    GUI.enabled = true;
                }

                if (GUI.Button(posEndTurnBt, EndTurnTex))
                {
                    MainGuiFade = false;
                    //SubGuiFade = true;
                    chessProperty.Activated       = true;
                    chessProperty.Attacked        = true;
                    chessProperty.Moved           = true;
                    chessProperty.TurnFinished    = true;
                    CurrentChess.gameObject.layer = 10;
                    currentSelect.MoveToLayer(CurrentChess, 10);
                    currentSelect.EndTurnNetwork();
                }

                GUI.enabled = true;

                //roll over end turn button
                if (!InTutorial)
                {
                    if (posEndTurnBt.Contains(mousePos))
                    {
                        GUI.DrawTexture(posEndTurnBt, EndTurnTex);
                        GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 5 + 13, 100, 30), "end turn", mainStyle);
                    }
                }
            }
        }
        GUI.color = new Color(1.0f, 1.0f, 1.0f, _subAlpha);

        if (moveShow)
        {
            GUI.DrawTexture(posMoveBt, MoveTex);
            GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + 16, 100, 30), "move", mainStyle);
            if (Input.GetMouseButtonDown(0) && posMoveBt.Contains(mousePos))
            {
                Cancel      = true;
                MainGuiFade = true;
                SubGuiFade  = false;
                TurnFinished(CurrentChess);
            }
        }
        if (attackShow)
        {
            GUI.DrawTexture(posAttackBt, AttackTex);
            GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 2 + 16, 100, 30), "attack", mainStyle);
            if (Input.GetMouseButtonDown(0) && posAttackBt.Contains(mousePos))
            {
                Cancel      = true;
                MainGuiFade = true;
                SubGuiFade  = false;
                TurnFinished(CurrentChess);
            }
        }
        if (summonShow)
        {
            Rect posSummonList = new Rect(posSummonBt.x + posSummonBt.width / 2, posSummonBt.y + posSummonBt.height / 2, 200.0f, 200.0f);
            GUI.DrawTexture(posSummonList, SubWindow);
            GUI.DrawTexture(posSummonBt, SummonTex);
            GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment + 16, 100, 30), "summon", mainStyle);
            if (Input.GetMouseButtonDown(0) && posSummonBt.Contains(mousePos))
            {
                Cancel      = true;
                MainGuiFade = true;
                SubGuiFade  = false;
            }
            IList soldiers = new List <Transform>();
            if (CurrentChess.GetComponent <CharacterProperty>().Player == 1)
            {
                foreach (Transform gf in players.PlayerAChesses)
                {
                    if (!gf.GetComponent <CharacterProperty>().Summoner)
                    {
                        soldiers.Add(gf);
                    }
                }
            }
            else if (CurrentChess.GetComponent <CharacterProperty>().Player == 2)
            {
                foreach (Transform gf in players.PlayerBChesses)
                {
                    if (!gf.GetComponent <CharacterProperty>().Summoner)
                    {
                        soldiers.Add(gf);
                    }
                }
            }
            int seg = 0;
            foreach (Transform gf in soldiers)
            {
                CharacterProperty gfp = gf.GetComponent <CharacterProperty>();
                if (gfp.Ready && (gfp.summonCost <= currentSelect.player.GetComponent <ManaCounter>().Mana) && gfp.death)
                {
                    GUI.enabled = true;
                }
                else
                {
                    GUI.enabled = false;
                }
                Rect posGFBt = CreateGFBt(gf, seg);
                if (posGFBt.Contains(mousePos))
                {
                    infoUI.CreatedGFRollOver(gf, subStyle);
                }
                if (GUI.Button(posGFBt, "", subStyle))
                {
                    currentSelect.summonCommand(CurrentChess, gf);
                    //update network UI
                    currentSelect.SummonNetwork();
                }
                seg += 1;
            }
        }
        if (skillShow)
        {
            Rect posSkillsBt = new Rect(posSkillBt.x + posSkillBt.width / 2, posSkillBt.y + posSkillBt.height / 2, 200.0f, 100.0f);
            GUI.DrawTexture(posSkillsBt, SubWindow);
            GUI.DrawTexture(posSkillBt, SkillTex);
            GUI.Label(new Rect(btSize + leftMargin + 5, topMargin + segment * 3 + 16, 100, 30), "skill", mainStyle);
            if (Input.GetMouseButtonDown(0) && posSkillBt.Contains(mousePos))
            {
                Cancel      = true;
                MainGuiFade = true;
                SubGuiFade  = false;
            }
            Transform[] skills = CurrentChess.GetComponent <SkillSets>().Skills;
            int         seg    = 0;
            if (skills.Length > 0)
            {
                foreach (Transform skill in skills)
                {
                    if (currentSelect.player.GetComponent <ManaCounter>().Mana >= skill.GetComponent <SkillProperty>().SkillCost)
                    {
                        GUI.enabled = true;
                    }
                    else
                    {
                        GUI.enabled = false;
                    }
                    Rect skillBtRect = CreateSkillBt(skill, seg);
                    if (skillBtRect.Contains(mousePos))
                    {
                        ShowSkillInfo(skill);
                    }
                    if (GUI.Button(skillBtRect, "", subStyle))
                    {
                        currentSelect.SkillUINetwork();
                        if (!skill.GetComponent <SkillProperty>().NeedToSelect)
                        {
                            skill.GetComponent <SkillProperty>().GetRealSkillRate();
                            skill.GetComponent <SkillProperty>().PassSkillRate = MapHelper.Success(skill.GetComponent <SkillProperty>().SkillRate);
                            skill.GetComponent <SkillProperty>().ActivateSkill();
                            currentSelect.player.GetComponent <ManaCounter>().Mana   -= skill.GetComponent <SkillProperty>().SkillCost;
                            CurrentChess.GetComponent <CharacterProperty>().Activated = true;
                            currentSelect.AnimStateNetWork(CurrentChess, AnimVault.AnimState.skill);
                            SubGuiFade = false;
                            TurnFinished(CurrentChess);
                            //update network
                            currentSelect.SkillCmdNetwork(CurrentChess, skill);
                        }
                        else
                        {
                            currentSelect.skillCommand(skill);
                        }
                    }
                    seg        += 1;
                    GUI.enabled = true;
                }
            }
        }
    }
Example #24
0
 public static void InitMapConfig()
 {
     MapConfig = MapHelper.ParseCurrentMap();
 }
Example #25
0
    public void UpdateAttackResult(AttackType mode)
    {
        dFX = Camera.mainCamera.GetComponent <DeathFX>();
        if (mode == AttackType.physical)
        {
            if (Attacker.GetComponent <CharacterPassive>().PassiveDict[PassiveType.SuddenDeath])
            {
                if (!targetProperty.Tower && MapHelper.Success(10))
                {
                    targetProperty.Hp = 0;
                }
                else
                {
                    targetProperty.Hp     -= attackerProperty.Damage;
                    targetProperty.Damaged = true;
                    ShowDamageUI(Target, attackerProperty.Damage, Attacker);
                }
            }            /*else if(Attacker.GetComponent<CharacterPassive>().PassiveDict[PassiveType.MultiArrow]){
                          *     IList targetList = new List<Transform>();
                          *     foreach(Transform unit in GetAttackableTarget(Attacker)){
                          *             targetList.Add(MapHelper.GetMapOccupiedObj(unit));
                          *     }
                          *     if(targetList.Contains(Target))
                          *             targetList.Remove(Target);
                          *     if(CriticalHit){
                          *             targetProperty.Hp -= attackerProperty.Damage*2;
                          *             ShowDamageUI(Target, attackerProperty.Damage*2, Attacker);
                          *             Debug.Log("Critical Hit!");
                          *     }else{
                          *             targetProperty.Hp -= attackerProperty.Damage;
                          *             ShowDamageUI(Target, attackerProperty.Damage, Attacker);
                          *     }
                          *
                          *     Transform[] tArray = new Transform[targetList.Count];
                          *     targetList.CopyTo(tArray,0);
                          *     if(tArray.Length > 1){
                          *             for(int i=0;i<2;i++){
                          *                     tArray[i].GetComponent<CharacterProperty>().Hp -= 1;
                          *                     ShowDamageUI(tArray[i], 1, Attacker);
                          *             }
                          *     }else if(tArray.Length < 2){
                          *             for(int i=0;i<tArray.Length;i++){
                          *                     tArray[i].GetComponent<CharacterProperty>().Hp -= 1;
                          *                     ShowDamageUI(tArray[i], 1, Attacker);
                          *             }
                          *     }
                          *
                          * }*/
            else if (CriticalHit)
            {
                targetProperty.Hp     -= attackerProperty.Damage * 2;
                targetProperty.Damaged = true;
                ShowDamageUI(Target, attackerProperty.Damage * 2, Attacker);
                Debug.Log("Critical Hit!");
            }
            else
            {
                targetProperty.Hp     -= attackerProperty.Damage;
                targetProperty.Damaged = true;
                ShowDamageUI(Target, attackerProperty.Damage, Attacker);
            }

            if (Attacker.GetComponent <CharacterPassive>().PassiveDict[PassiveType.WoundBite])
            {
                targetProperty.UnStatusCounter[UnnormalStatus.Wounded]     = 1;
                targetProperty.LastUnStatusCounter[UnnormalStatus.Wounded] = 2;
            }
        }
        else if (mode == AttackType.magical)
        {
            if (CriticalHit)
            {
                targetProperty.Hp     -= attackerProperty.Damage * 2;
                targetProperty.Damaged = true;
                Debug.Log("Critical Hit!");
            }
            else
            {
                print("damage!!");
                targetProperty.Hp     -= attackerProperty.Damage;
                targetProperty.Damaged = true;
                ShowDamageUI(Target, attackerProperty.Damage, Attacker);
            }
        }

        /*
         * if(Attackable()){
         *      attackerProperty.Hp -= targetProperty.Damage;
         * }*/

        if (attackerProperty.Hp <= 0)
        {
            //attackerProperty.death = true;
            //dFX.SetDeathSequence(Attacker);
            attackerProperty.Ready      = false;
            attackerProperty.WaitRounds = attackerProperty.StandByRounds;
        }

        if (targetProperty.Hp <= 0)
        {
            if (!targetProperty.Tower)
            {
                //dFX.SetDeathSequence(Target);
                //targetProperty.Ready = false;
                //targetProperty.WaitRounds = targetProperty.StandByRounds;
                chessUI.DelayFadeOut    = true;
                targetProperty.Attacked = true;
                if (chessUI.playerSide == 1)
                {
                    chessUI.MainFadeIn = false;
                }
                else
                {
                    chessUI.TargetFadeIn = false;
                }
            }
            else
            {
                targetProperty.death = true;
            }
        }
        else
        {
            if (fightBack)
            {
                fb.SetFightBack(Target, Attacker);
                targetProperty.Attacked = true;
            }
        }
        attackerProperty.Attacked = true;
        sUI.FadeInUI = true;
    }
Example #26
0
 public void Update(int x, int y, byte light)
 {
     this._tiles[x, y] = MapHelper.CreateMapTile(x, y, light);
 }
Example #27
0
 private MKPolylineRenderer OnOverlayRenderer(MKMapView mapView, IMKOverlay overlay)
 {
     return(MapHelper.GetPolylineRenderer(overlay));
 }
Example #28
0
        public void MapInnerObject1([Values] bool useAction)
        {
            var map = new MapHelper <Class3, Class4>().Map(useAction, m => m);

            Assert.That(map.To.Class.Field, Is.EqualTo(map.From.Class.Field));
        }
Example #29
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);

            if (Visible && IsMouseInside())
            {
                Main.LocalPlayer.mouseInterface = true;
                Main.LocalPlayer.showItemIcon   = false;
            }

            if (Visible && Recipe.numRecipes > recipeView.allRecipeSlot.Length)
            {
                //			ErrorLogger.Log("New " + Recipe.numRecipes + " " + recipeView.allRecipeSlot.Length);

                recipeView.allRecipeSlot = new RecipeSlot[Recipe.numRecipes];
                for (int i = 0; i < recipeView.allRecipeSlot.Length; i++)
                {
                    recipeView.allRecipeSlot[i] = new RecipeSlot(i);
                }

                this.InitializeRecipeCategories();

                recipeView.selectedCategory = RecipeBrowserWindow.categories[0].ToArray();
                recipeView.activeSlots      = recipeView.selectedCategory;
                recipeView.ReorderSlots();
            }

            float   x      = Main.fontMouseText.MeasureString(UIView.HoverText).X;
            Vector2 vector = new Vector2((float)Main.mouseX, (float)Main.mouseY) + new Vector2(16f);

            if (vector.Y > (float)(Main.screenHeight - 30))
            {
                vector.Y = (float)(Main.screenHeight - 30);
            }
            if (vector.X > (float)Main.screenWidth - x)
            {
                vector.X = (float)(Main.screenWidth - 460);
            }
            Utils.DrawBorderStringFourWay(spriteBatch, Main.fontMouseText, UIView.HoverText, vector.X, vector.Y, new Color((int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor), Color.Black, Vector2.Zero, 1f);

            float  positionX = this.X + spacing;
            float  positionY = this.Y + 270;           //320;
            string text4;

            if (selectedRecipe != null && Visible)
            {
                Color color3 = new Color((int)((byte)((float)Main.mouseTextColor)), (int)((byte)((float)Main.mouseTextColor)), (int)((byte)((float)Main.mouseTextColor)), (int)((byte)((float)Main.mouseTextColor)));

                text4 = Lang.inter[21] + " " + Main.guideItem.Name;
                spriteBatch.DrawString(Main.fontMouseText, Lang.inter[22].Value, new Vector2((float)positionX, (float)(positionY)), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                //	int num60 = Main.focusRecipe;
                int num61 = 0;
                int num62 = 0;
                while (num62 < Recipe.maxRequirements)
                {
                    int num63 = (num62 + 1) * 26;
                    if (selectedRecipe.requiredTile[num62] == -1)
                    {
                        if (num62 == 0 && !selectedRecipe.needWater && !selectedRecipe.needHoney && !selectedRecipe.needLava)
                        {
                            spriteBatch.DrawString(Main.fontMouseText, Lang.inter[23].Value, new Vector2((float)positionX, (float)(positionY + num63)), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                            break;
                        }
                        break;
                    }
                    else
                    {
                        num61++;
                        spriteBatch.DrawString(Main.fontMouseText, Lang.GetMapObjectName(MapHelper.TileToLookup(selectedRecipe.requiredTile[num62], 0)), new Vector2((float)positionX, (float)(positionY + num63)), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                        num62++;
                    }
                }
                if (selectedRecipe.needWater)
                {
                    int num64 = (num61 + 1) * 26;
                    spriteBatch.DrawString(Main.fontMouseText, Lang.inter[53].Value, new Vector2((float)positionX, (float)(positionY + num64)), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                }
                if (selectedRecipe.needHoney)
                {
                    int num65 = (num61 + 1) * 26;
                    spriteBatch.DrawString(Main.fontMouseText, Lang.inter[58].Value, new Vector2((float)positionX, (float)(positionY + num65)), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                }
                if (selectedRecipe.needLava)
                {
                    int num66 = (num61 + 1) * 26;
                    spriteBatch.DrawString(Main.fontMouseText, Lang.inter[56].Value, new Vector2((float)positionX, (float)(positionY + num66)), color3, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
                }
            }
            //else
            //{
            //	text4 = Lang.inter[24];
            //}
            //spriteBatch.DrawString(Main.fontMouseText, text4, new Vector2((float)(positionX + 50), (float)(positionY + 12)), new Microsoft.Xna.Framework.Color((int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor, (int)Main.mouseTextColor), 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
        }
Example #30
0
        public void ByteArrayTest([Values] bool useAction)
        {
            var mapper = new MapHelper <ByteTestClass, ByteTestClass>().Map(useAction, new ByteTestClass(), m => m);

            Assert.That(mapper.To, Is.Not.Null);
        }
        /// <summary>
        /// This function takes care of a number of things including: 
        ///  - Check if we've been given SkyDrive access
        ///  - If yes, setup Archive folder for storing videos 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            // See if we can connect to SkyDrive 
            // If the user has given us permission to use SkyDrive... 
            //LiveLoginResult result = await authClient.LoginAsync(scopes);

            //if (result.Status == LiveConnectSessionStatus.Connected)
            //{
            //    Is_SkyDrive_Enabled = true;
            //    cxnClient = new LiveConnectClient(authClient.Session);

            //    // Get hold of the root folder from SkyDrive. 
            //    // NB: this does not traverse the network and get the full folder details.
            //    root = new SkyDriveFolder(
            //      cxnClient, SkyDriveWellKnownFolder.Root);

            //    // This *does* traverse the network and get those details.
            //    await root.LoadAsync();


            //    // Try to open the Archive folder 
            //    try
            //    {
            //        archiveSkyDriveFolder = await root.GetFolderAsync("Archive");
            //    }
            //    catch { }


            //    if (archiveSkyDriveFolder == null)
            //        archiveSkyDriveFolder = await root.CreateFolderAsync("Archive");
            //}


            location_string = "";
            try
            {
                string bing_maps_key = "AsU97otKt6mDgr4kQR8HxTUiHzzzxy08NBR1iLqssnnzllYMxT4zQQ84J5Rbr9fh";
                Geolocator gl = new Geolocator();
                gl.PositionChanged += (s, args) => { /* empty */ };

                Geoposition gp = await gl.GetGeopositionAsync();
                var latitude = gp.Coordinate.Latitude;
                var longitude = gp.Coordinate.Longitude;
                var helper = new MapHelper(bing_maps_key);
                var location = await helper.FindLocationByPointAsync(latitude, longitude);
                var my_address = location.First().address;

                location_string = string.Format("{0}, {1}",
                   my_address.locality, my_address.adminDistrict);

                locationTxtBlock.Text = location_string;
            }
            catch (Exception ex)
            {
                // Do something here... 
            }



        }