예제 #1
0
        private void button_Restart_Click(object sender, EventArgs e)
        {
            timerWheat.Stop();
            timerFields.Stop();
            timerLivestock.Stop();
            timerCattleGrids.Stop();
            progressWar.Stop();
            timerPrices.Stop();
            timerNewPrices.Stop();
            timerEvents.Stop();
            progressBarTimer.Stop();

            timeProgress.Value = 0;
            timeProgress2.Value = 0;
            timeWar.Value = 0;

            Gold = new Gold();
            Fields = new Fields();
            People = new People();
            Wheat = new Wheat();
            Livestock = new Livestock();
            Prices = new Prices();
            CattleGrids = new CattleGrids();

            timerWheat.Start();
            timerEvents.Start();
            timerFields.Start();
            timerLivestock.Start();
            progressBarTimer.Start();
            timerPrices.Start();
            timerNewPrices.Start();

            // Currencies
            label_Gold.Text = "Gold: " + Gold.Count;

            // Peoples
            label_Family.Text = "Family: " + People.Family;
            label_PeopleInWar.Text = "In War: " + People.InWar;
            label_Shelter.Text = "Shelter: " + People.Shelter;

            // Farmables
            label_Wheat.Text = "Wheat: " + Wheat.Count;
            label_Livestock.Text = "Livestock: " + Livestock.Count;

            // Places
            label_Fields.Text = "Fields: " + Fields.Count;
            label_CattleGrids.Text = "Cattle Grids: " + CattleGrids.Count;

            // Prices
            label_buyWheat.Text = "...for " + Prices.buyWheat + " gold.";
            label_sellWheat.Text = "...for " + Prices.sellWheat + " gold.";
            label_buyFields.Text = "...for " + Prices.buyFields + " gold.";
            label_sellFields.Text = "...for " + Prices.sellFields + " gold.";
            label_buyLivestock.Text = "...for " + Prices.buyLivestock + " gold.";
            label_sellLivestock.Text = "...for " + Prices.sellLivestock + " gold.";
            label_buyCattleGrids.Text = "...for " + Prices.buyCattleGrid + " gold.";
            label_sellCattleGrids.Text = "...for " + Prices.sellCattleGrid + " gold.";

            // Statistics
            stats_WheatBought.Text = "You bought " + Wheat.Bought + " wheat.";
            stats_WheatSold.Text = "You sold " + Wheat.Sold + " wheat.";
            stats_FieldsBought.Text = "You bought " + Fields.Bought + " fields.";
            stats_FieldsSold.Text = "You sold " + Fields.Sold + " fields.";
            stats_LivestockBought.Text = "You bought " + Livestock.Bought + " livestock.";
            stats_LivestockSold.Text = "You sold " + Livestock.Sold + " livestock.";
            stats_CattleGridsBought.Text = "You bought " + CattleGrids.Bought + " cattle grids.";
            stats_CattleGridsSold.Text = "You sold " + CattleGrids.Sold + " cattle grids.";
        }
예제 #2
0
        private void button_Load_Click(object sender, EventArgs e)
        {
            timerWheat.Stop();
            timerFields.Stop();
            timerLivestock.Stop();
            timerCattleGrids.Stop();
            progressWar.Stop();
            timerPrices.Stop();
            timerNewPrices.Stop();
            timerEvents.Stop();
            progressBarTimer.Stop();

            timeProgress.Value = 0;
            timeProgress2.Value = 0;
            timeWar.Value = 0;

            Gold = new Gold();
            Fields = new Fields();
            People = new People();
            Wheat = new Wheat();
            Livestock = new Livestock();
            Prices = new Prices();
            CattleGrids = new CattleGrids();

            OpenFileDialog openFile = new OpenFileDialog();
            openFile.Filter = "Farming Game Save|*.fgs";
            openFile.Title = "Load your Progress";
            openFile.ShowDialog();

            if (openFile.FileName != "")
            {
                using (StreamReader sr = new StreamReader(openFile.OpenFile()))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        string[] split = line.Split('=');
                        try
                        {
                            switch (split[0].ToString())
                            {
                                case "GoldCount":
                                    Gold.Count = Convert.ToInt32(split[1]);
                                    break;
                                case "WheatCount":
                                    Wheat.Count = Convert.ToInt32(split[1]);
                                    break;
                                case "WheatConsumed":
                                    Wheat.Consumed = Convert.ToInt32(split[1]);
                                    break;
                                case "WheatProduced":
                                    Wheat.Produced = Convert.ToInt32(split[1]);
                                    break;
                                case "WheatSold":
                                    Wheat.Sold = Convert.ToInt32(split[1]);
                                    break;
                                case "WheatBought":
                                    Wheat.Bought = Convert.ToInt32(split[1]);
                                    break;
                                case "LivestockCount":
                                    Livestock.Count = Convert.ToInt32(split[1]);
                                    break;
                                case "LivestockConsumed":
                                    Livestock.Consumed = Convert.ToInt32(split[1]);
                                    break;
                                case "LivestockProduced":
                                    Livestock.Produced = Convert.ToInt32(split[1]);
                                    break;
                                case "LivestockSold":
                                    Livestock.Sold = Convert.ToInt32(split[1]);
                                    break;
                                case "LivestockBought":
                                    Livestock.Bought = Convert.ToInt32(split[1]);
                                    break;
                                case "FieldsCount":
                                    Fields.Count = Convert.ToInt32(split[1]);
                                    break;
                                case "FieldsSold":
                                    Fields.Sold = Convert.ToInt32(split[1]);
                                    break;
                                case "FieldsBought":
                                    Fields.Bought = Convert.ToInt32(split[1]);
                                    break;
                                case "CattleGridsCount":
                                    CattleGrids.Count = Convert.ToInt32(split[1]);
                                    break;
                                case "CattleGridsSold":
                                    CattleGrids.Sold = Convert.ToInt32(split[1]);
                                    break;
                                case "CattleGridsBought":
                                    CattleGrids.Bought = Convert.ToInt32(split[1]);
                                    break;
                                case "PeopleFamily":
                                    People.Family = Convert.ToInt32(split[1]);
                                    break;
                                case "PeopleInWar":
                                    People.InWar = Convert.ToInt32(split[1]);
                                    break;
                                case "PeopleShelter":
                                    People.Shelter = Convert.ToInt32(split[1]);
                                    break;
                                case "PriceBuyWheat":
                                    Prices.buyWheat = Convert.ToInt32(split[1]);
                                    break;
                                case "PriceSellWheat":
                                    Prices.sellWheat = Convert.ToInt32(split[1]);
                                    break;
                                case "PriceBuyLivestock":
                                    Prices.buyLivestock = Convert.ToInt32(split[1]);
                                    break;
                                case "PriceSellLivestock":
                                    Prices.sellLivestock = Convert.ToInt32(split[1]);
                                    break;
                                case "PriceBuyFields":
                                    Prices.buyFields = Convert.ToInt32(split[1]);
                                    break;
                                case "PriceSellFields":
                                    Prices.sellFields = Convert.ToInt32(split[1]);
                                    break;
                                case "PriceBuyCattleGrids":
                                    Prices.buyCattleGrid = Convert.ToInt32(split[1]);
                                    break;
                                case "PriceSellCattleGrids":
                                    Prices.sellCattleGrid = Convert.ToInt32(split[1]);
                                    break;
                            }

                        }
                        catch
                        {
                            Console.WriteLine("failed:" + line);
                        }
                    }
                }

            }

            // Currencies
            label_Gold.Text = "Gold: " + Gold.Count;

            // Peoples
            label_Family.Text = "Family: " + People.Family;
            label_PeopleInWar.Text = "In War: " + People.InWar;
            label_Shelter.Text = "Shelter: " + People.Shelter;

            // Farmables
            label_Wheat.Text = "Wheat: " + Wheat.Count;
            label_Livestock.Text = "Livestock: " + Livestock.Count;

            // Places
            label_Fields.Text = "Fields: " + Fields.Count;
            label_CattleGrids.Text = "Cattle Grids: " + CattleGrids.Count;

            // Prices
            label_buyWheat.Text = "...for " + Prices.buyWheat + " gold.";
            label_sellWheat.Text = "...for " + Prices.sellWheat + " gold.";
            label_buyFields.Text = "...for " + Prices.buyFields + " gold.";
            label_sellFields.Text = "...for " + Prices.sellFields + " gold.";
            label_buyLivestock.Text = "...for " + Prices.buyLivestock + " gold.";
            label_sellLivestock.Text = "...for " + Prices.sellLivestock + " gold.";
            label_buyCattleGrids.Text = "...for " + Prices.buyCattleGrid + " gold.";
            label_sellCattleGrids.Text = "...for " + Prices.sellCattleGrid + " gold.";

            // Statistics
            stats_WheatBought.Text = "You bought " + Wheat.Bought + " wheat.";
            stats_WheatSold.Text = "You sold " + Wheat.Sold + " wheat.";
            stats_FieldsBought.Text = "You bought " + Fields.Bought + " fields.";
            stats_FieldsSold.Text = "You sold " + Fields.Sold + " fields.";
            stats_LivestockBought.Text = "You bought " + Livestock.Bought + " livestock.";
            stats_LivestockSold.Text = "You sold " + Livestock.Sold + " livestock.";
            stats_CattleGridsBought.Text = "You bought " + CattleGrids.Bought + " cattle grids.";
            stats_CattleGridsSold.Text = "You sold " + CattleGrids.Sold + " cattle grids.";

            timerWheat.Start();
            timerEvents.Start();
            timerFields.Start();
            timerLivestock.Start();
            progressBarTimer.Start();
            timerPrices.Start();
            timerNewPrices.Start();
        }