Advertisement
BlackHawke

Tycoon - Map

Jan 16th, 2018
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 KB | None | 0 0
  1. using System;
  2. using System.CodeDom.Compiler;
  3. using System.Runtime.InteropServices;
  4.  
  5. namespace WestWorldTycoon
  6. {
  7.     public class Map
  8.     {
  9.         // Private Attribute :
  10.         private Tile[,] matrix;
  11.  
  12.         // Construcotr :
  13.         public Map(string name)
  14.         {
  15.             matrix = TycoonIO.ParseMap(name);
  16.         }
  17.        
  18.        
  19.         public Map(Map map)
  20.         {
  21.             // BONUS
  22.             throw new NotImplementedException();
  23.         }
  24.  
  25.  
  26.         public bool Build(int i, int j, ref long money, Building.BuildingType type)
  27.         {
  28.             return matrix[i,j].Build(ref money, type);
  29.         }
  30.  
  31.  
  32.         public bool Destroy(int i, int j)
  33.         {
  34.             // BONUS
  35.             throw new NotImplementedException();
  36.         }
  37.  
  38.         public bool Upgrade(int i, int j, ref long money)
  39.         {
  40.             return matrix[i, j].Upgrade(ref money);
  41.         }
  42.        
  43.        
  44.         public long GetAttractiveness()
  45.         {
  46.             long response = 0;
  47.             foreach (Tile tile in matrix)
  48.             {
  49.                 response += tile.GetAttractiveness();
  50.             }
  51.             return response;
  52.         }
  53.  
  54.         public long GetHousing()
  55.         {
  56.             long response = 0;
  57.             foreach(Tile tile in matrix)
  58.             {
  59.                 response += tile.GetHousing();
  60.             }
  61.             return response;
  62.         }
  63.  
  64.  
  65.         public long GetPopulation()
  66.         {
  67.             long housing = GetHousing();
  68.             long attractiveness = GetAttractiveness();
  69.             return (housing < attractiveness) ? housing : attractiveness;
  70.         }
  71.        
  72.        
  73.         public long GetIncome()
  74.         {
  75.             long response = 0;
  76.             foreach(Tile tile in matrix)
  77.             {
  78.                 response += tile.GetIncome(GetPopulation());
  79.             }
  80.             return response;
  81.         }
  82.        
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement