Ejemplo n.º 1
0
 private void buildButton_Click(object sender, RoutedEventArgs e)
 {
     try {
         String    buildName = (String)buildsList.SelectedItem;
         int       x         = Int32.Parse(xField.Text);
         int       y         = Int32.Parse(yField.Text);
         MapEnum   menum     = null;
         MapObject mobj      = null;
         try
         {
             menum = BuildType.VALUES.Where(type => type.getName() == buildName).First();
             if (menum != null)
             {
                 mobj = new Build((BuildType)menum);
             }
         }
         catch (Exception) { }
         try
         {
             menum = ReliefType.VALUES.Where(type => type.getName() == buildName).First();
             if (menum != null)
             {
                 mobj = new Relief((ReliefType)menum);
             }
         }
         catch (Exception) { }
         model.game.create(mobj, x, y);
         drawMap();
         generateResources();
         generateBuilds();
     } catch (Exception)
     {
     }
 }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Code,DescriptionRU,DescriptionKK,DescriptionEN")] Relief relief)
        {
            if (id != relief.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(relief);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReliefExists(relief.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(relief));
        }
Ejemplo n.º 3
0
        public int GetMovementCost(Vector2D position)
        {
            Tile tmp          = Tiles[position.x][position.y];
            int  movementCost = TileBaseType.GetBaseType(tmp.Type).MovementCost;

            movementCost += Relief.GetRelief(tmp.Relief).MovementCost;
            movementCost += Vegetation.GetVegetation(tmp.Vegetation).MovementCost;
            return(movementCost);
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Relief relief = await db.Reliefs.FindAsync(id);

            db.Reliefs.Remove(relief);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public override double?GetAltitude(HealCoor basin)
        {
            var altitude = Relief.GetAltitude(basin);

            if (altitude == 0)
            {
                altitude = ReliefBed.GetAltitude(basin);
            }
            return(altitude);
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Code,Description")] Relief relief)
        {
            if (ModelState.IsValid)
            {
                db.Entry(relief).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(relief));
        }
Ejemplo n.º 7
0
        public Task <ActionResult <ReliefViewModel> > PostAsync([FromBody] ReliefInputModel inputModel)
        => ExecuteAsync <ReliefViewModel>(async() =>
        {
            var userId = User.UserId();
            var user   = await _usersRepository.GetByIdAsync(userId);
            var relief = new Relief(user, inputModel.Description, inputModel.Icon);

            await _reliefsRepository.AddAsync(relief);

            return(Ok((ReliefViewModel)relief));
        });
Ejemplo n.º 8
0
        public override double?GetAltitude(HealCoor basin)
        {
            var surface = Relief.GetAltitude(basin);

            if (surface > 0)
            {
                // lakes in ice are ignored
                return(1);
            }
            return(0);
        }
Ejemplo n.º 9
0
        public override double?GetAltitude(HealCoor basin)
        {
            var altitude      = Relief.GetAltitude(basin);
            var altitudeShape = ReliefBed.GetAltitude(basin) + Earth2014Manager.Radius2Add;

            var thetaTan   = Math.Tan(basin.Beta.Value); /* may be out of range */
            var undulation = altitudeShape - altitude
                             - Ellipsoid.Radius(Ellipsoid.CalcVarPhi(thetaTan));

            return(undulation);
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> Create([Bind("Id,Code,DescriptionRU,DescriptionKK,DescriptionEN")] Relief relief)
        {
            if (ModelState.IsValid)
            {
                _context.Add(relief);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(relief));
        }
Ejemplo n.º 11
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Code,Description")] Relief relief)
        {
            if (ModelState.IsValid)
            {
                db.Reliefs.Add(relief);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(relief));
        }
Ejemplo n.º 12
0
        public override double?GetAltitude(HealCoor basin)
        {
            var surface = Relief.GetAltitude(basin);

            if (surface > 0)
            {
                _landPixelsCount++;
            }

            var middle = HealpixManager.Npix / 2d;

            return(Math.Abs(basin.P - middle) <= middle * _percentageOfLand / 100d ? 1 : 0);
        }
Ejemplo n.º 13
0
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Relief relief = await db.Reliefs.FindAsync(id);

            if (relief == null)
            {
                return(HttpNotFound());
            }
            return(View(relief));
        }
Ejemplo n.º 14
0
 private void Relief_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (filteredImage.Source == null)
         {
             FillStaticProperties(originalImage, filteredImage);
             Matrix = KernelMatrix(BmpImage.Width, BmpImage.Height);
         }
         Relief.Filter();
     }
     catch (OriginalImageDontExistException exception)
     {
         MessageBox.Show(exception.Message);
     }
 }
        public static MainWindowDataModel Load()
        {
            if (File.Exists(DataPath))
            {
                MainWindowDataModel model = DataSerializer.DeserializeItem(DataPath);
                ResourceList        list  = new ResourceList();
                model.resources.ForEach(r => list.add(new Resource(ResourceType.VALUES.Where(type => type.getName() == r.resource).First(), r.count)));
                Map map = new Map(10, 10);
                model.map.ForEach(item => {
                    MapEnum menum  = null;
                    MapObject mobj = null;
                    try
                    {
                        menum = BuildType.VALUES.Where(type => type.getName() == item.build).First();
                        if (menum != null)
                        {
                            mobj = new Build((BuildType)menum);
                            if (item.sleep)
                            {
                                mobj.sleep();
                            }
                            if (item.recondition)
                            {
                                mobj.recondition();
                            }
                        }
                    } catch (Exception) { }
                    try {
                        menum = ReliefType.VALUES.Where(type => type.getName() == item.build).First();
                        if (menum != null)
                        {
                            mobj = new Relief((ReliefType)menum);
                        }
                    } catch (Exception) { }

                    if (mobj != null)
                    {
                        map.set(mobj, item.x, item.y);
                    }
                });
                model.game = new Game(map, list);
                return(model);
            }
            return(new MainWindowDataModel());
        }
Ejemplo n.º 16
0
        protected override void OnModelCreating(ModelBuilder builder)
        {
            base.OnModelCreating(builder);

            builder.Entity <IdentityUser>().ToTable("User").Property(p => p.Id).HasColumnName("UserId");

            var roomType1 = new RoomType()
            {
                Id = 1, Type = "Small"
            };
            var roomType2 = new RoomType()
            {
                Id = 2, Type = "Medium"
            };
            var roomType3 = new RoomType()
            {
                Id = 3, Type = "Large"
            };

            builder.Entity <RoomType>().HasData(
                roomType1,
                roomType2,
                roomType3);

            var room1 = new Room()
            {
                Id = 1, PeopleCount = 1, RoomTypeId = 1
            };
            var room2 = new Room()
            {
                Id = 2, PeopleCount = 2, RoomTypeId = 2
            };
            var room3 = new Room()
            {
                Id = 3, PeopleCount = 4, RoomTypeId = 3
            };

            builder.Entity <Room>().HasData(
                room1,
                room2,
                room3
                );

            var relife1 = new Relief()
            {
                Id = 1, Discount = 20, Code = "Summer"
            };
            var relife2 = new Relief()
            {
                Id = 2, Discount = 10, Code = "2019"
            };
            var relife3 = new Relief()
            {
                Id = 3, Discount = 30, Code = "Holiday"
            };

            builder.Entity <Relief>().HasData(
                relife1,
                relife2,
                relife3);

            var customer1 = new Customer()
            {
                Id = 1, FirstName = "Adam", LastName = "Gruszczynski"
            };
            var customer2 = new Customer()
            {
                Id = 2, FirstName = "Krzysztof", LastName = "Nowak"
            };
            var customer3 = new Customer()
            {
                Id = 3, FirstName = "Mateusz", LastName = "Kowalski", Address = "ul. Krakowska 10, 50-301 Wrocław"
            };
            var customer4 = new Customer()
            {
                Id = 4, FirstName = "Jolanta", LastName = "Szpak"
            };

            builder.Entity <Customer>().HasData(
                customer1,
                customer2,
                customer3,
                customer4
                );


            var payment1 = new Payment()
            {
                Id = Guid.NewGuid().ToString(), Price = 300, ReliefId = 3, CustomerId = 2
            };
            var payment2 = new Payment()
            {
                Id = Guid.NewGuid().ToString(), Price = 500, ReliefId = 1, CustomerId = 4
            };
            var payment3 = new Payment()
            {
                Id = Guid.NewGuid().ToString(), Price = 1000, ReliefId = 2, CustomerId = 1
            };

            builder.Entity <Payment>().HasData(
                payment1,
                payment2,
                payment3
                );

            var reservation1 = new Reservation()
            {
                Id = 1, RoomId = 1, PaymentId = payment1.Id, StartDate = new DateTime(2019, 5, 20), EndDate = new DateTime(2019, 5, 22)
            };
            var reservation2 = new Reservation()
            {
                Id = 2, RoomId = 2, PaymentId = payment2.Id, StartDate = new DateTime(2019, 1, 24), EndDate = new DateTime(2019, 1, 28)
            };
            var reservation3 = new Reservation()
            {
                Id = 3, RoomId = 3, PaymentId = payment3.Id, StartDate = new DateTime(2019, 2, 10), EndDate = new DateTime(2019, 2, 15)
            };

            builder.Entity <Reservation>().HasData(
                reservation1,
                reservation2,
                reservation3);
        }
Ejemplo n.º 17
0
        private List <Relief> reliefs = new List <Relief>();//t: type, c: cell, x: centerX, y: centerY, s: size;
        private void generateReliefIcons()
        {
            //var msg = new List<string>();

            var density = Options.terrainDensity;
            var size    = Options.terrainSize * 1.6;
            var mod     = .2 * size;

            var cells = pack.cells;

            foreach (var i in cells.i)
            {
                var height = cells.h[i];
                if (height < 20)
                {
                    continue; // no icons on water
                }
                if (0 != cells.r[i])
                {
                    continue; // no icons on rivers
                }
                var b = cells.biome[i];
                if (height < 50 && biomesData.iconsDensity[b] == 0)
                {
                    continue; // no icons for this biome
                }
                var polygon = pack.getGridPolygon(i);
                var x       = D3.extent(polygon.map(p => p[0]));
                var y       = D3.extent(polygon.map(p => p[1]));
                var e       = new double[] { Math.Ceiling(x[0]), Math.Ceiling(y[0]), Math.Floor(x[1]), Math.Floor(y[1]) }; // polygon box

                if (height < 50)
                {
                    placeBiomeIcons();
                }
                else
                {
                    placeReliefIcons();
                }

                void placeBiomeIcons()
                {
                    var iconsDensity = biomesData.iconsDensity[b] / 100d;
                    var radius       = 2d / iconsDensity / density;

                    if (Random.NextDouble() > iconsDensity * 10)
                    {
                        return;
                    }

                    var poisson = poissonDiscSampler(e[0], e[1], e[2], e[3], radius);

                    foreach (var pp in poisson)
                    {
                        double cx = pp[0], cy = pp[1];
                        if (!D3.polygonContains(polygon, pp))
                        {
                            continue;
                        }
                        var h    = rn((4 + Random.NextDouble()) * size, 2);
                        var icon = getBiomeIcon(i, biomesData.icons[b]);
                        if (icon == "#relief-grass-1")
                        {
                            h *= 1.3f;
                        }

                        var d = new Relief()
                        {
                            i = icon, x = (float)rn(cx - h, 2), y = (float)rn(cy - h, 2), s = (float)h * 2
                        };
                        reliefs.push(d);
                        //msg.push($"{i} {b} {d.i} {d.x},{d.y} {d.s}");
                    }
                }

                void placeReliefIcons()
                {
                    var    radius = 2d / density;
                    string icon;
                    double h;

                    getReliefIcon(i, height, out icon, out h);

                    var poisson = poissonDiscSampler(e[0], e[1], e[2], e[3], radius);

                    foreach (var pp in poisson)
                    {
                        double cx = pp[0], cy = pp[1];
                        if (!D3.polygonContains(polygon, pp))
                        {
                            continue;
                        }

                        var d = new Relief()
                        {
                            i = icon, x = (float)rn(cx - h, 2), y = (float)rn(cy - h, 2), s = (float)h * 2
                        };
                        reliefs.push(d);
                        //msg.push($"{i} {height} {d.i} {d.x},{d.y} {d.s}");
                    }
                }
            }
            //Debug.SaveArray("drawReliefIcons.txt", msg);

            void getReliefIcon(int i, int h, out string icon, out double outSize)
            {
                var temp = grid.cells.temp[pack.cells.g[i]];
                var type = h > 70 && temp < 0 ? "mountSnow" : h > 70 ? "mount" : "hill";

                icon    = getIcon(type);
                outSize = h > 70 ? (h - 45) * mod : Math.Min(Math.Max((h - 40) * mod, 3), 6);
            }
        }