Esempio n. 1
0
 public override void TakeTurn()
 {
     if (!hasResource)
     {
         resourceTimer++;
         if (resourceTimer >= resourceCooldown)
         {
             resourceTimer = 0;
             hasResource   = true;
             jobQueued     = false;
         }
     }
     if (hasResource && !jobQueued)
     {
         pos.game.gameManager.drawer.DrawEffectResource(this);
         List <bbJob> jobQueue   = new List <bbJob>();
         bbJobMoveTo  moveToHere = new bbJobMoveTo(getPos());
         jobQueue.Add(moveToHere);
         bbJobUseStructure useThis = new bbJobUseStructure(this);
         jobQueue.Add(useThis);
         bbStructure trystruct = new bbStructureDummy();
         if (pos.findClosestStructureByPath(bbStructureType.STRUCTURE_HQ, ref trystruct))
         {
             bbStructure hq       = trystruct;
             bbJobMoveTo moveToHQ = new bbJobMoveTo(hq.getPos());
             jobQueue.Add(moveToHQ);
             bbJobUseStructure useHQ = new bbJobUseStructure(hq);
             jobQueue.Add(useHQ);
         }
         pos.game.playerJobQueue.Add(jobQueue);
         jobQueued = true;
     }
 }
Esempio n. 2
0
 public void doJobTurn(bbAgent agent)
 {
     if (structure.getPos() == agent.pos)
     {
         jobComplete = structure.UseStructure(agent);
     }
     else
     {
         bbJobMoveTo move = new bbJobMoveTo(structure.getPos());
         agent.jobQueue.Insert(0, move);
     }
 }
Esempio n. 3
0
        public bool HandleClick(bbPos pos, bool leftClick, bool rightClick)
        {
            bool clickDidSomething = false;

            if (leftClick)
            {
                if (!currentIsland.structures.ContainsKey(pos))
                {
                    if (CheckBuildable(pos))
                    {
                        if (currentClickType == ClickType.SETTLE_HQ || currentClickType == ClickType.SETTLE_HOUSE)
                        {
                            if (currentClickType == ClickType.SETTLE_HQ)
                            {
                                currentIsland.AddStructure(bbStructureType.STRUCTURE_HQ, pos.gridLoc.x(), pos.gridLoc.y(), currentClickType);
                                currentClickType = ClickType.SETTLE_HOUSE;
                            }
                            else if (currentClickType == ClickType.SETTLE_HOUSE)
                            {
                                currentIsland.AddStructure(bbStructureType.STRUCTURE_HOUSE, pos.gridLoc.x(), pos.gridLoc.y(), currentClickType);
                                currentClickType = ClickType.NONE;
                                paused           = false;
                            }
                            clickDidSomething = true;
                        }
                        else if (playerResources[ItemType.ITEM_GOLD] >= STRUCTURE_COST)
                        {
                            playerResources[ItemType.ITEM_GOLD] -= STRUCTURE_COST;
                            ClickType buildingType = ClickType.BUILD_HOUSE;
                            buildingType = currentIsland.lands[pos].terrainFeature == bbTerrainFeature.ARABLE ? ClickType.BUILD_FARM : buildingType;
                            buildingType = currentIsland.lands[pos].terrainFeature == bbTerrainFeature.MINEABLE ? ClickType.BUILD_MINE : buildingType;
                            currentIsland.AddStructure(bbStructureType.STRUCTURE_CONSTRUCTION, pos.gridLoc.x(), pos.gridLoc.y(), buildingType);
                            List <bbJob> jobs       = new List <bbJob>();
                            bbStructure  site       = currentIsland.structures[pos];
                            bbJobMoveTo  moveToMine = new bbJobMoveTo(site.getPos());
                            jobs.Add(moveToMine);
                            bbJobUseStructure useMine = new bbJobUseStructure(site);
                            jobs.Add(useMine);
                            playerJobQueue.Add(jobs);
                            clickDidSomething = true;
                        }
                    }
                }
            }


            if (rightClick)
            {
                gameManager.drawer.HighlightTile(pos);
            }

            return(clickDidSomething);
        }
Esempio n. 4
0
        void AssertNeed(ItemType needType)
        {
            //Debug.Log("Need for " + needType.ToString() + " assigned");
            List <bbJob> needJobs = new List <bbJob>();

            needsAddressing.Add(needType);
            bbJobMoveTo moveToHouse = new bbJobMoveTo(myHouse.getPos());

            needJobs.Add(moveToHouse);
            bbJobUseStructure useHouse = new bbJobUseStructure(myHouse);

            needJobs.Add(useHouse);
            needJobs.AddRange(jobQueue);
            jobQueue = needJobs;
        }
Esempio n. 5
0
        void AssignDefaultJob(bbStructure assignedStructure)
        {
            bbStructure mine = assignedStructure;
            // Move To Mine
            bbJobMoveTo moveToMine = new bbJobMoveTo(mine.getPos());

            jobQueue.Add(moveToMine);
            // Use Mine
            bbJobUseStructure useMine = new bbJobUseStructure(mine);

            jobQueue.Add(useMine);
            // Move To HQ
            bbStructure trystruct = new bbStructureDummy();

            if (pos.findClosestStructureByPath(bbStructureType.STRUCTURE_HQ, ref trystruct))
            {
                bbStructure hq       = trystruct;
                bbJobMoveTo moveToHQ = new bbJobMoveTo(hq.getPos());
                jobQueue.Add(moveToHQ);
                // Use HQ
                bbJobUseStructure useHQ = new bbJobUseStructure(hq);
                jobQueue.Add(useHQ);
            }
        }