示例#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;
     }
 }
示例#2
0
        public void AddStructure(bbStructureType t, float x, float y, ClickType _clickType)
        {
            bbLoc       l = new bbLoc(x, y);
            bbStructure s = bbStructureFactory.GenerateStructure(t, pathMap[l.key()], _clickType);

            structures[s.getPos()] = s;
            //Debug.Log("Added Structure at " + s.getPos().getName());
        }
示例#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);
        }
示例#4
0
        public bbStructure findClosestStructureByRange(bbStructureType structureType)
        {
            List <bbStructure> structuresOfType = getStructuresOfType(structureType);
            float       minDistance             = float.PositiveInfinity;
            bbStructure closestStructure        = structuresOfType[0];

            foreach (bbStructure s in structuresOfType)
            {
                float sDistance = DistanceMinkowski(this, s.getPos());
                if (sDistance < minDistance)
                {
                    minDistance      = sDistance;
                    closestStructure = s;
                }
            }
            return(closestStructure);
        }
示例#5
0
 public bbAgent(string _name, bbPos _pos, BaseBuilderMVP _game, bbStructure _myHouse)
 {
     alive     = true;
     animating = false;
     name      = _name;
     //Debug.Log("Created Agent named " + name);
     pos       = _pos;
     game      = _game;
     myHouse   = _myHouse;
     jobQueue  = new List <bbJob>();
     needTimer = new Dictionary <ItemType, int> {
         { ItemType.ITEM_FOOD, 50 }
     };
     needQuantity = new Dictionary <ItemType, int> {
         { ItemType.ITEM_FOOD, 1 }
     };
     inventory = new Dictionary <ItemType, int> {
         { ItemType.ITEM_FOOD, 0 }, { ItemType.ITEM_GOLD, 0 }
     };
     needsAddressing = new List <ItemType>();
 }
示例#6
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);
            }
        }
示例#7
0
        public bool findClosestStructureByPath(bbStructureType structureType, ref bbStructure closestStructure)
        {
            List <bbStructure> structuresOfType = getStructuresOfType(structureType);

            if (structuresOfType.Count != 0)
            {
                closestStructure = structuresOfType[0];
                float minDistance = float.PositiveInfinity;
                foreach (bbStructure s in structuresOfType)
                {
                    float sDistance = DistancePath(this, s.getPos());
                    if (sDistance < minDistance)
                    {
                        minDistance      = sDistance;
                        closestStructure = s;
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#8
0
 public bbJobUseStructure(bbStructure _structure)
 {
     structure   = _structure;
     jobComplete = false;
 }
示例#9
0
 public void DrawEffectResource(bbStructure s)
 {
     DrawEffect(effectResource, goStructures[s].transform);
 }