コード例 #1
0
ファイル: Island.cs プロジェクト: TerisseNicolas/Archip3l-WPF
 //give a stock of "quantity" of the ressource named "name" to "island"
 public void giveRessourceToIsland(string name, int quantity, Island island)
 {
     RessourceManager rm = new RessourceManager();
     int quantityWithdrawn = rm.withdrawRessource(name, this, quantity);
     //we give to "island" the quantity withdrawn from the current island
     if (quantityWithdrawn != 0)
     {
         rm.giveRessource(name, island, quantityWithdrawn);
         System.Diagnostics.Debug.WriteLine("L'ile " + this.id.ToString() + " donne " + quantityWithdrawn.ToString() + " " + name + " à l'ile " + island.id.ToString());
     }
     else
         System.Diagnostics.Debug.WriteLine("La ressource " + name + " n'est plus disponible sur l'ile " + island.id.ToString());
 }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            islands = new List<Island>
            {
                new MajorIsland(0),
                new MinorIsland(1),
                new MinorIsland(2),
                new MinorIsland(3),
                new MinorIsland(4)
            };

            /*----------- Tests -------------*/
            RessourceManager rm = new RessourceManager();
            rm.giveRessource("or", islands[1], 50);
            islands[1].createBuilding("scierie", 200, 100, CanIsl1);    //200 & 100 got by position of touch event
            toto();


            /*-------------------------------*/
        }
コード例 #3
0
 //consume the ressourceNeedded and produce the ressourceProduced (only if there was still a stock of ressourceNeedded)
 //method called by an Island, each 10 seconds while the state of the building is 1
 public void consume_produce(Island island)
 {
     RessourceManager rm = new RessourceManager();
     //checks if the ressourceNeeded exists and if there is enough of its stock
     if ((island.getRessource(ressourceNeeded) != null) && (island.getRessource(ressourceNeeded).stock >= consumptionCost))  
     {
         rm.withdrawRessource(ressourceNeeded, island, consumptionCost); //consumption
         rm.giveRessource(ressourceProduced, island, productionCost);    //production
         System.Diagnostics.Debug.WriteLine("Le batiment " + this.name + " utilise " + this.consumptionCost.ToString() + " " + this.ressourceNeeded + " et produit " + this.productionCost.ToString() + " " + this.ressourceProduced + " sur l'ile " + island.id.ToString());
     }    
     else
     {
         System.Diagnostics.Debug.WriteLine("Le batiment " + this.name + " ne peut plus produire de " + this.ressourceProduced + " car il ne reste pas assez de " + ressourceNeeded + " sur l'ile " + island.id.ToString());
     }        
 }