コード例 #1
0
        internal override void Tick()
        {
            techProgress += 1 + People.PeopleAt(People.Community.construction) / 100;
            if (techProgress > 1000)
            {
                techProgress = 1000;
            }
            float totalWork = People.PeopleAt(People.Community.construction) * constructionSpeed;

            while (totalWork > 0 && tasks.Count != 0)
            {
                if (tasks.Peek().work < totalWork)
                {
                    totalWork -= tasks.Peek().work;
                    tasks.Dequeue().onCompletion();
                }
                else
                {
                    tasks.Peek().work -= totalWork;
                    break;
                }
            }
            float workOnPyramid = Math.Min(totalWork, stock);

            stock     -= workOnPyramid;
            totalWork -= workOnPyramid;
            progress  += workOnPyramid;
            if (progress >= pyramidLevels[God.TheOne.pyramidTracker])
            {
                God.TheOne.AddPyramid();
                progress = 0;
            }
            //if (totalWork > 0) God.TheOne.Console("" + totalWork.ToString("n2") + " tasks worth of work is being wasted by your construction crew.");
        }
コード例 #2
0
        internal override void Tick()
        {
            techProgress += 1 + People.PeopleAt(People.Community.river) / 100;
            if (techProgress > 1000)
            {
                techProgress = 1000;
            }
            boats.ForEach(b => b.Tick());
            while (dockStock > 0)
            {
                Boat next = boats.FindAll(b => b.isInDock && b.IsActive && b.mayLeave).
                            OrderBy(b => { switch (priority)
                                           {
                                           case Priority.smallest: return(b.capacity);

                                           case Priority.fastest: return(b.GetTimeRequired());
                                           }
                                           throw new Exception("invalid priority"); }).
                            FirstOrDefault();
                if (next != null && dockStock > next.capacity)
                {
                    next.Load(next.capacity);
                    dockStock -= next.capacity;
                }
                else
                {
                    break;
                }
            }
        }
コード例 #3
0
 internal override void Tick()
 {
     techProgress += 1 + People.PeopleAt(People.Community.quarry) / 100;
     if (techProgress > 1000)
     {
         techProgress = 1000;
     }
     stock += production;
 }
コード例 #4
0
 internal override void Tick()
 {
     techProgress += 1 + People.PeopleAt(People.Community.military) / 100;
     if (techProgress > 1000)
     {
         techProgress = 1000;
     }
     // Do nthing, I guess
 }
コード例 #5
0
 internal override void Tick()
 {
     techProgress += 1 + People.PeopleAt(People.Community.farm) / 100;
     if (techProgress > 1000)
     {
         techProgress = 1000;
     }
     stock += production;
     if (stock > storageCapacity)
     {
         stock = storageCapacity;
         God.TheOne.Console("Food stock overflow. Stop wasting food!");
     }
 }
コード例 #6
0
        internal override void Tick()
        {
            techProgress += 1 + People.PeopleAt(People.Community.road) / 100;
            if (techProgress > 1000)
            {
                techProgress = 1000;
            }
            int availablePeople = People.PeopleAt(People.Community.road) - teamsOnTheWay.Sum(t => t.people);

            if (availablePeople < 0)
            {
                God.TheOne.Console("Road has negative people!");
            }
            int availableStones = God.TheOne.quarry.HasStones();
            int stonesToBeMoved = Math.Min(availablePeople / teamsize, availableStones);

            if (stonesToBeMoved > 0)
            {
                Team t = new Team(stonesToBeMoved * teamsize, stonesToBeMoved, transportTime);
                teamsOnTheWay.Add(t);
                God.TheOne.roadGO.launchTeam(t.id, t.people);
                if (God.TheOne.quarry.TakeStones(stonesToBeMoved) == false)
                {
                    throw new Exception("Taking non-existing stones");
                }
            }
            for (int i = teamsOnTheWay.Count - 1; i >= 0; i--)
            {
                if (God.random.NextDouble() < People.Productivity(People.Community.road))
                {
                    teamsOnTheWay[i].TimeLeft--;        // If the productivity is to low, somtimes they will not move.
                }
                if (teamsOnTheWay[i].TimeLeft <= 0)
                {
                    God.TheOne.river.newStonesArrive(teamsOnTheWay[i].stones);
                    teamsOnTheWay.RemoveAt(i);
                }
            }
        }
コード例 #7
0
ファイル: RealmOverview.cs プロジェクト: qfeys/PyramidBuilder
        public void TrySetPopulation(People.Community com, float value)
        {
            if (isChanging)
            {
                return;
            }
            isChanging = true;
            var comList = People.communityList;

            for (int i = 0; i < comList.Count; i++) // reset color
            {
                transform.GetChild(i + 1).GetChild(1).GetChild(0).GetChild(0).GetChild(0).GetChild(1).GetChild(0).GetComponent <Image>().color = colorNorm;
            }
            People.TrySetPopulation(com, value);        // Set Values
            for (int i = 0; i < comList.Count; i++)
            {
                transform.GetChild(i + 1).GetChild(1).GetChild(0).GetChild(0).GetChild(0).GetComponent <Slider>().value = People.populationDistribution[comList[i]];
                transform.GetChild(i + 1).GetChild(1).GetChild(0).GetChild(0).GetChild(1).GetComponent <Text>().text    = People.PeopleAt(comList[i]).ToString("# ##0");
            }
            isChanging = false;
        }
コード例 #8
0
ファイル: RealmOverview.cs プロジェクト: qfeys/PyramidBuilder
 public void Init()
 {
     foreach (var com in People.communityList)
     {
         Transform panel = Instantiate(commuityPanel).transform;
         panel.SetParent(transform);
         panel.name = com.ToString();
         panel.GetChild(0).GetChild(0).GetComponent <Text>().text = com.ToString();
         panel.GetChild(1).GetChild(0).GetChild(0).GetChild(1).GetComponent <Text>().text = People.PeopleAt(com).ToString("# ##0");
         var c = com;    // Dont remove, used for actions
         panel.GetChild(1).GetChild(0).GetChild(0).GetChild(0).GetComponent <Slider>().onValueChanged.AddListener((v) => TrySetPopulation(c, v));
         panel.GetChild(1).GetChild(0).GetChild(1).GetChild(0).GetComponent <Slider>().onValueChanged.AddListener((v) => TrySetFood(c, v));
     }
 }
コード例 #9
0
ファイル: Outliner.cs プロジェクト: qfeys/PyramidBuilder
        private void UpdateInfoPanel()
        {
            Transform panel = transform.Find("PanelCommunityInfo");

            if (panel.gameObject.activeSelf == false)
            {
                return;
            }
            panel.GetChild(1).GetChild(1).GetChild(1).GetComponent <Text>().text = People.PeopleAt(currentPanelInfo).ToString("# ##0");
            panel.GetChild(1).GetChild(2).GetChild(1).GetComponent <Text>().text = Mathf.Clamp01(People.unrest[currentPanelInfo]).ToString("##0%");
            panel.GetChild(1).GetChild(3).GetChild(1).GetComponent <Text>().text = (People.PeopleAt(currentPanelInfo) * People.foodAllowance[currentPanelInfo]).ToString("# ##0");
            switch (currentPanelInfo)
            {
            case People.Community.farm:
                Farm f = God.TheOne.farm;
                panel.GetChild(1).Find("Production").GetChild(1).GetComponent <Text>().text   = f.production.ToString("# ##0");
                panel.GetChild(1).Find("Stock").GetChild(1).GetComponent <Text>().text        = f.stock.ToString("# ##0");
                panel.GetChild(1).Find("Capacity").GetChild(1).GetComponent <Text>().text     = f.storageCapacity.ToString("# ##0");
                panel.GetChild(1).Find("TechProgress").GetChild(1).GetComponent <Text>().text = f.techProgress.ToString("# ##0");
                panel.GetChild(2).GetComponent <Button>().interactable = f.techProgress >= 1000;
                break;

            case People.Community.quarry:
                Quarry q = God.TheOne.quarry;
                panel.GetChild(1).Find("Production").GetChild(1).GetComponent <Text>().text   = q.production.ToString("# ##0");
                panel.GetChild(1).Find("Stock").GetChild(1).GetComponent <Text>().text        = q.stock.ToString("# ##0");
                panel.GetChild(1).Find("TechProgress").GetChild(1).GetComponent <Text>().text = q.techProgress.ToString("# ##0");
                panel.GetChild(2).GetComponent <Button>().interactable = q.techProgress >= 1000;
                break;

            case People.Community.construction:
                Construction c = God.TheOne.construction;
                panel.GetChild(1).Find("Production").GetChild(1).GetComponent <Text>().text   = c.workSpeed.ToString("# ##0");
                panel.GetChild(1).Find("Stock").GetChild(1).GetComponent <Text>().text        = c.stock.ToString("# ##0");
                panel.GetChild(1).Find("Progress").GetChild(1).GetComponent <Text>().text     = c.progress.ToString("# ##0");
                panel.GetChild(1).Find("TechProgress").GetChild(1).GetComponent <Text>().text = c.techProgress.ToString("# ##0");
                string taskNames = ""; string taskWork = "";
                foreach (var task in c.tasks)
                {
                    taskNames += task.name + "\n"; taskWork += task.work.ToString("# ##0") + "\n";
                }
                taskNames += "-----"; taskWork += "---";
                panel.GetChild(1).Find("Tasks1").GetChild(0).GetComponent <Text>().text = taskNames;
                panel.GetChild(1).Find("Tasks1").GetChild(1).GetComponent <Text>().text = taskWork;
                panel.GetChild(2).GetComponent <Button>().interactable = c.techProgress >= 1000;
                break;

            case People.Community.road:
                Road ro = God.TheOne.road;
                panel.GetChild(1).Find("Transit").GetChild(1).GetComponent <Text>().text      = ro.stonesInTransit.ToString("# ##0");
                panel.GetChild(1).Find("FreePeople").GetChild(1).GetComponent <Text>().text   = (People.PeopleAt(People.Community.river) - ro.peopleBusy).ToString("# ##0");
                panel.GetChild(1).Find("TechProgress").GetChild(1).GetComponent <Text>().text = ro.techProgress.ToString("# ##0");
                panel.GetChild(2).GetComponent <Button>().interactable = ro.techProgress >= 1000;
                break;

            case People.Community.river:
                River ri = God.TheOne.river;
                panel.GetChild(1).Find("Docks").GetChild(1).GetComponent <Text>().text         = ri.dockStock.ToString("# ##0");
                panel.GetChild(1).Find("Transit").GetChild(1).GetComponent <Text>().text       = ri.stonesInTransit.ToString("# ##0");
                panel.GetChild(1).Find("NumberOfBoats").GetChild(1).GetComponent <Text>().text = ri.boats.Count.ToString("# ##0");
                panel.GetChild(1).Find("FreePeople").GetChild(1).GetComponent <Text>().text    = ri.peopleFree.ToString("# ##0");
                panel.GetChild(1).Find("TechProgress").GetChild(1).GetComponent <Text>().text  = ri.techProgress.ToString("# ##0");
                panel.GetChild(2).GetComponent <Button>().interactable = ri.techProgress >= 1000;
                break;

            case People.Community.military:
                Military m = God.TheOne.military;
                panel.GetChild(1).Find("Supression").GetChild(1).GetComponent <Text>().text   = m.averageSupression.ToString("#0%");
                panel.GetChild(1).Find("Inequality").GetChild(1).GetComponent <Text>().text   = m.inequality.ToString("#0%");
                panel.GetChild(1).Find("Pyramids").GetChild(1).GetComponent <Text>().text     = m.pyramidUnrest.ToString("#0%");
                panel.GetChild(1).Find("TechProgress").GetChild(1).GetComponent <Text>().text = m.techProgress.ToString("# ##0");
                panel.GetChild(2).GetComponent <Button>().interactable = m.techProgress >= 1000;
                break;
            }
        }
コード例 #10
0
ファイル: God.cs プロジェクト: qfeys/PyramidBuilder
 internal void UpdatePeopleDrawn()
 {
     quarryGO.SetNumberOfPersons(People.PeopleAt(People.Community.quarry));
     farmGO.SetNumberOfPersons(People.PeopleAt(People.Community.farm));
     constructionGO.SetNumberOfPersons(People.PeopleAt(People.Community.construction));
 }