Beispiel #1
0
        public void ListToBuildings(Island island)
        {
            Buildings buildings1 = island.Buildings;

            buildings1.RezydencjaFarmerow = buildings[0].Number;
            buildings1.ChatkaRybacka      = buildings[1].Number;
            buildings1.ChatkaDrwala       = buildings[2].Number;
            buildings1.Tartak             = buildings[3].Number;
            buildings1.FarmaOwiec         = buildings[4].Number;
            buildings1.ZakladTkaczy       = buildings[5].Number;
            buildings1.FarmaZiemniakow    = buildings[6].Number;
            buildings1.DestylarniaSznapsu = buildings[7].Number;
        }
Beispiel #2
0
        public void CalculateMaxBuildings(Island island, List <Building> buildings)
        {
            MaxBuildings = new List <int>();
            int sum = 0;

            foreach (Building building in buildings)
            {
                sum += building.Number;
            }
            foreach (Building building in buildings)
            {
                MaxBuildings.Add(building.HowManyCanYouBuild(island.Resources, Coins, island.Place - sum));
            }
        }
Beispiel #3
0
        public BuildingList(Island island)
        {
            Buildings buildings1 = island.Buildings;

            buildings = new List <Building> {
                new RezydencjaFarmerow(buildings1.Farmerzy, buildings1.RezydencjaFarmerow),
                new ChatkaRybacka(buildings1.ChatkaRybacka),
                new ChatkaDrwala(buildings1.ChatkaDrwala),
                new Tartak(buildings1.Tartak),
                new FarmaOwiec(buildings1.FarmaOwiec),
                new ZakladTkaczy(buildings1.ZakladTkaczy),
                new FarmaZiemniakow(buildings1.FarmaZiemniakow),
                new DestylarniaSznapsu(buildings1.DestylarniaSznapsu)
            };
        }
Beispiel #4
0
        public List <Island> InitializeGame(List <UserGameProperty> properties)
        {
            IsBegan = true;
            Update  = DateTime.Now;
            Random        rand = new Random();
            List <Island> islands = new List <Island>();
            int           x, y;
            int           wielkoscMapy = MaxPlayers * 5;
            bool          positionOk;

            //losowanie wysp graczy
            for (int i = 0; i < MaxPlayers; i++)
            {
                //losujemy współrzędne tak by wyspa nie znajdowała sie za blisko innej
                do
                {
                    positionOk = true;
                    x          = rand.Next(0, wielkoscMapy);
                    y          = rand.Next(0, wielkoscMapy);
                    foreach (Island item in islands)
                    {
                        if (Island.Distance(x, item.X, y, item.Y) < 2)
                        {
                            positionOk = false;
                            break;
                        }
                    }
                }while (!positionOk);
                Resources resources = new Resources();
                resources.InitialResources();
                Island island = new Island
                {
                    Name      = "Wyspa " + properties[i].Player.UserName,
                    Place     = 500,
                    X         = x,
                    Y         = y,
                    Resources = resources,
                    Ziemniaki = true,
                    Chmiel    = true,
                    Zboze     = false,
                    Papryka   = false,
                    Glinianka = 2,
                    Zelazo    = 2,
                    Property  = properties[i],
                    Game      = this
                };
                island.Buildings = new Buildings();
                island.Buildings.FarmersSatisfaction = new Resources();
                islands.Add(island);
            }
            //losowanie pustych wysp
            for (int i = 0; i < MaxPlayers * 4; i++)
            {
                do
                {
                    positionOk = true;
                    x          = rand.Next(0, wielkoscMapy);
                    y          = rand.Next(0, wielkoscMapy);
                    foreach (Island item in islands)
                    {
                        if (Island.Distance(x, item.X, y, item.Y) < 2)
                        {
                            positionOk = false;
                            break;
                        }
                    }
                }while (!positionOk);
                Resources resources = new Resources();
                resources.ZeroResources();
                int glinianka = rand.Next(-1, 4);
                glinianka = (glinianka == -1) ? 0 : glinianka;
                int zelazo = rand.Next(-1, 4);
                zelazo = (zelazo == -1) ? 0 : zelazo;
                Island island = new Island
                {
                    Name      = "Wyspa " + (i + 1),
                    Place     = rand.Next(300, 601),
                    X         = x,
                    Y         = y,
                    Resources = resources,
                    Ziemniaki = rand.Next(1, 9) <= 3,
                    Chmiel    = rand.Next(1, 9) <= 3,
                    Zboze     = rand.Next(1, 9) <= 5,
                    Papryka   = rand.Next(1, 9) <= 5,
                    Glinianka = glinianka,
                    Zelazo    = zelazo,
                    Property  = null,
                    Game      = this
                };
                island.Buildings = new Buildings();
                islands.Add(island);
            }
            return(islands);
        }
Beispiel #5
0
 public static double Distance(Island islandA, Island islandB)
 {
     return(Island.Distance(islandA.X, islandB.X, islandA.Y, islandB.Y));
 }