private void LoadSessionResources()
 {
     if (Session["Resource"] != null)
     {
         res = (BLResource)Session["Resource"];
     }
 }
 public void BuyBuilding(String buildingName)
 {
     LoadSessionResources();
     if (building.IsRequirementsMetForBuilding(buildingName, res))
     {
         res = building.BuyBuilding(buildingName, res);
         Session["Resource"] = res;
         Session["Building"] = building;
     }
 }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Session["Resource"] != null)
        {
            res = (BLResource)Session["Resource"];
        }
        res.ResetResourceValues();

        Session["Day"] = 0;
        Session["Resource"] = res;
    }
Пример #4
0
        public BLResource BuyBuilding(String name, BLResource resources)
        {
            Building building = GetBuilding(name);

            foreach (ReqResource req in building.requirements)
            {
                resources.GetResource(req.resName).value -= req.value;
            }
            IncrementBuildingPrice("Hut");
            return resources;
        }
Пример #5
0
        public Boolean IsRequirementsMetForBuilding(String name, BLResource resources)
        {
            Building building = GetBuilding(name);

            foreach (ReqResource req in building.requirements)
            {
                if(req.value > resources.GetResource(req.resName).value)
                {
                    return false;
                }
            }
            return true;
        }