public void CreateDropdown(Vector3 localPosition, float w, float h)
    {
        // Create the button
        buildingDropdown               = UIElementFunctions.Dropdown(panel, null, "Select Building", localPosition, new Vector2(w, h));
        buildingDropdown.thisGo.name   = "Building Dropdown Button";
        buildingDropdown.childHeight   = 30;
        buildingDropdown.childFontSize = 16;
        buildingDropdown.CloseButton();

        int ind = 0;

        foreach (string category in buildingManager.buildingCategories)
        {
            buildingDropdown.AddChild();
            buildingDropdown.children[ind].textGo.text           = category;
            buildingDropdown.children[ind].buttonGo.interactable = false;
            buildingDropdown.children[ind].CloseButton();
            int subInd = 0;
            IEnumerable <BuildingDef> theseBuildingDefs = BuildingQueries.ByCategoryNoParent(ManagerBase.buildingDefinitions, category);
            foreach (BuildingDef def in theseBuildingDefs)
            {
                buildingDropdown.children[ind].AddChild();
                buildingDropdown.children[ind].children[subInd].textGo.text = def.name + " (Tier " + def.tier + ")";
                buildingDropdown.children[ind].children[subInd].buttonGo.onClick.AddListener(() => bbcb(def.name));
                buildingDropdown.children[ind].children[subInd].CloseButton();
                subInd++;
            }
            ind++;
        }
    }
Example #2
0
 public List <Building> GetBuildings(Filter filter)
 {
     using (var conn = new SqlConnection(ConnectionStringProvider.GetConnectionString()))
     {
         return(conn.Query <Building>(BuildingQueries.GetBuildingsByFilterQuery(filter))
                .ToList());
     }
 }
Example #3
0
 public Building GetBuildingById(string buildingId)
 {
     using (var conn = new SqlConnection(ConnectionStringProvider.GetConnectionString()))
     {
         var res = conn.QueryFirstOrDefault <Building>(BuildingQueries.GetBuildingByIdQuery(), new { buildingId });
         return(res ?? throw new NullReferenceException($"Building with id : {buildingId} not found."));
     }
 }
Example #4
0
        public List <Building> GetBuildingsByAddress(string address)
        {
            using (var conn = new SqlConnection(ConnectionStringProvider.GetConnectionString()))
            {
                var res = conn.Query <Building>(BuildingQueries.GetBuildingByAddressQuery(), new { Address = $"%{address}%" })
                          .ToList();

                return(res ?? throw new NullReferenceException($"Building with address : {address} not found."));
            }
        }
Example #5
0
    void StartJobButton(JobDef jobSelected)
    {
        thisBuilding = BuildingQueries.ByLocation(ManagerBase.domain.buildings, new Vector2Int(iLoc, jLoc)); // Update the building here
        ResourceJobObj newJob = jobManager.AddJob(jobSelected, thisBuilding);
        ResourceQuantityQualityList jobResources = resourceChoiceDropdown.GetCurrentChoices();

        newJob.SetResources(jobResources);
        newJob.StartJob();
        newJob.AddWorker();
        newJob.AddWorker();
        FocusOnTile(iLoc, jLoc);
    }
Example #6
0
    private JobDef CreateConstructionJobDef(ResourceQuantityQualityList jobResources, string taskName)
    {
        BuildingDef bd = BuildingQueries.ByName(ManagerBase.buildingDefinitions, taskName).ElementAt(0);
        JobDef      constructionJob = new JobDef();

        constructionJob.name           = "Construction of " + taskName;
        constructionJob.description    = "Construction of " + taskName;
        constructionJob.industry       = "Construction";
        constructionJob.skill          = "Building";
        constructionJob.tier           = bd.tier;
        constructionJob.defaultPMUs    = bd.defaultPMUs;
        constructionJob.inputResources = jobResources;
        constructionJob.outputName     = new List <string>();
        constructionJob.outputName.Add(taskName);
        //List<int> defaultOutputQuantity;

        return(constructionJob);
    }
Example #7
0
        public void UpdateBuilding(Building building)
        {
            using (var conn = new SqlConnection(this.ConnectionStringProvider.GetConnectionString()))
            {
                var res = conn.Execute(BuildingQueries.UpdateBuilding(), new
                {
                    building.BuildingId,
                    building.Address,
                    building.Condition,
                    building.Price,
                    building.OpenTime,
                    building.CloseTime,
                    building.Is24Hours
                });

                if (res == 0)
                {
                    throw new InvalidOperationException("Error has occured!");
                }
            }
        }
Example #8
0
    public void FocusOnTile(int i, int j)
    {
        // Set Location
        iLoc = i;
        jLoc = j;

        // Delete buttons
        ClearUIObjects();

        // Surface Panel
        if (SetSurfacePanel(i, j))
        {
            thisBuilding = BuildingQueries.ByLocation(ManagerBase.domain.buildings, new Vector2Int(iLoc, jLoc)); // Get the building here
        }
        // Ground Panel
        SetGroundPanel(i, j);

        // Underground Panel
        SetUndergroundPanel(i, j);

        // Draw Jobs up from the bottom
        DrawActiveJobs(i, j);
    }
Example #9
0
    public void CreateDropdown(Vector3 localPosition, float w, float h, string surfaceType)
    {
        // Create the button
        actionDropdown               = UIElementFunctions.Dropdown(panel, null, "Surface Actions", localPosition, new Vector2(w, h));
        actionDropdown.childHeight   = 30;
        actionDropdown.childFontSize = 16;

        // Demolish
        actionDropdown.AddChild();
        actionDropdown.children[0].textGo.text = "Demolish";
        actionDropdown.children[0].buttonGo.onClick.AddListener(() => demolishCallback("Demolish"));
        actionDropdown.children[0].CloseButton();

        // Upgrades
        int menuInd = actionDropdown.children.Count;

        actionDropdown.AddChild();
        actionDropdown.children[menuInd].textGo.text = "Upgrade";
        //actionDropdown.children[upgradeInd].buttonGo.interactable = false;
        actionDropdown.children[menuInd].CloseButton();

        //Debug.Log(surfaceType);
        IEnumerable <BuildingDef> upgrades = BuildingQueries.ByParent(ManagerBase.buildingDefinitions, surfaceType);
        int ind = 0;

        foreach (BuildingDef def in upgrades)
        {
            actionDropdown.children[menuInd].AddChild();
            actionDropdown.children[menuInd].children[ind].textGo.text = def.name + " (Tier " + def.tier + ")";
            Debug.Log(actionDropdown.children[menuInd].children[ind].textGo.text);
            actionDropdown.children[menuInd].children[ind].buttonGo.onClick.AddListener(() => buildCallback(def.name));
            actionDropdown.children[menuInd].children[ind].CloseButton();
            ind++;
        }

        // Jobs
        if (ManagerBase.buildingIndexOf.ContainsKey(surfaceType))
        {
            menuInd++;

            BuildingDef bldgDef = ManagerBase.buildingDefinitions[ManagerBase.buildingIndexOf[surfaceType]];

            List <JobDef> jobs = new List <JobDef>();

            for (int jeInd = 0; jeInd < bldgDef.jobsEnabled.Count; jeInd++)
            {
                jobs.AddRange(JobQueries.ByNameAndMaxTier(ManagerBase.jobDefinitions, bldgDef.jobsEnabled[jeInd], bldgDef.jobMaxTier[bldgDef.jobsEnabled[jeInd]]));
            }

            Debug.Log(jobs.Count());

            if (jobs.Count() > 0)
            {
                actionDropdown.AddChild();
                actionDropdown.children[menuInd].textGo.text           = "Start Job";
                actionDropdown.children[menuInd].buttonGo.interactable = false;
                actionDropdown.children[menuInd].CloseButton();
                actionDropdown.children[menuInd].Init();

                ind = 0;
                foreach (JobDef job in jobs)
                {
                    string jobString = job.name + " (" + job.outputName[0] + ")";
                    actionDropdown.children[menuInd].AddChild();
                    actionDropdown.children[menuInd].children[ind].textGo.text = jobString;
                    actionDropdown.children[menuInd].children[ind].buttonGo.onClick.AddListener(() => newJobCallback(job.guid));
                    actionDropdown.children[menuInd].children[ind].CloseButton();
                    ind++;
                }
            }
        }
    }