BlackHawke

Tycoon - Tiles

Jan 16th, 2018
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.44 KB | None | 0 0
  1. using System;
  2. using System.Xml.Schema;
  3.  
  4. namespace WestWorldTycoon
  5. {
  6.     public class Tile
  7.     {
  8.         // Attribute Public :
  9.         public enum Biome
  10.         {
  11.             SEA, MOUNTAIN, PLAIN
  12.         }
  13.  
  14.         // Attribute Private :
  15.         #region AttributePrivate
  16.         private Biome biome;
  17.         private Building building;
  18.         #endregion
  19.  
  20.         // Construcotr :
  21.         public Tile(Biome b)
  22.         {
  23.             biome = b;
  24.             building = null;
  25.         }
  26.  
  27.         // Getters & Setters :
  28.         #region GetAndSet
  29.         public Biome GetBiome
  30.         {
  31.             get { return biome; }
  32.         }
  33.         #endregion
  34.  
  35.  
  36.         public Tile(Tile tile)
  37.         {
  38.             // BONUS
  39.             throw new NotImplementedException();
  40.         }
  41.  
  42.        
  43.         public bool Build(ref long money, Building.BuildingType type)
  44.         {
  45.             bool response = false;
  46.             if(biome == Biome.PLAIN && building == null){
  47.                 switch (type)
  48.                 {
  49.                     case Building.BuildingType.HOUSE:
  50.                         response = money >= House.BUILD_COST;
  51.                         if (response)
  52.                         {
  53.                             building = new House();
  54.                             money -= House.BUILD_COST;
  55.                         }
  56.                         break;
  57.                     case Building.BuildingType.ATTRACTION:
  58.                         response = money >= Attraction.BUILD_COST;
  59.                         if (response)
  60.                         {
  61.                             building = new Attraction();
  62.                             money -= Attraction.BUILD_COST;
  63.                         }
  64.                         break;
  65.                     case Building.BuildingType.SHOP:
  66.                         response = money >= Shop.BUILD_COST;
  67.                         if (response)
  68.                         {
  69.                             building = new Shop();
  70.                             money -= Shop.BUILD_COST;
  71.                         }
  72.                         break;
  73.                 }
  74.             }
  75.             return response;
  76.         }
  77.  
  78.  
  79.         public bool Upgrade(ref long money)
  80.         {
  81.             bool response = false ;
  82.             if (building != null)
  83.             {
  84.                 switch (building.Type)
  85.                 {
  86.                     case Building.BuildingType.HOUSE:
  87.                         House house = (House)building;
  88.                         response = house.Upgrade(ref money);
  89.                         if (response) { building = house; }
  90.                         break;
  91.                     case Building.BuildingType.ATTRACTION:
  92.                         Attraction attraction = (Attraction)building;
  93.                         response = attraction.Upgrade(ref money);
  94.                         if (response) { building = attraction; }
  95.                         break;
  96.                     case Building.BuildingType.SHOP:
  97.                         Shop shop = (Shop)building;
  98.                         response = shop.Upgrade(ref money);
  99.                         if (response) { building = shop; }
  100.                         break;
  101.                 }
  102.             }
  103.             return response;
  104.         }
  105.        
  106.        
  107.         public long GetHousing()
  108.         {
  109.             long response = 0;
  110.             if (building != null && building.Type == Building.BuildingType.HOUSE)
  111.             {
  112.                 House house = (House)building;
  113.                 response = house.Housing();
  114.             }
  115.             return response;
  116.         }
  117.        
  118.        
  119.         public long GetAttractiveness()
  120.         {
  121.             long response = 0;
  122.             if(building != null && building.Type == Building.BuildingType.ATTRACTION)
  123.             {
  124.                 Attraction attraction = (Attraction)building;
  125.                 response = attraction.Attractiveness();
  126.             }
  127.             return response;
  128.         }
  129.        
  130.        
  131.         public long GetIncome(long population)
  132.         {
  133.             long response = 0;
  134.             if(building != null && building.Type == Building.BuildingType.SHOP)
  135.             {
  136.                 Shop shop = (Shop)building;
  137.                 response = shop.Income(population);
  138.             }
  139.             return response;
  140.         }
  141.  
  142.  
  143.         public bool Destroy()
  144.         {
  145.             // BONUS
  146.             throw new NotImplementedException();
  147.         }
  148.        
  149.        
  150.     }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment