コード例 #1
0
 public static bbStructure GenerateStructure(bbStructureType _type, bbPos _pos, ClickType _clickType)
 {
     if (_type == bbStructureType.STRUCTURE_HQ)
     {
         return(new bbStructureHQ(_type, _pos));
     }
     else if (_type == bbStructureType.STRUCTURE_MINE)
     {
         return(new bbStructureMine(_type, _pos));
     }
     else if (_type == bbStructureType.STRUCTURE_FARM)
     {
         return(new bbStructureFarm(_type, _pos));
     }
     else if (_type == bbStructureType.STRUCTURE_HOUSE)
     {
         return(new bbStructureHouse(_type, _pos));
     }
     else if (_type == bbStructureType.STRUCTURE_CONSTRUCTION)
     {
         return(new bbStructureConstruction(_type, _pos, _clickType));
     }
     else
     {
         return(new bbStructureEx(_type, _pos));
     }
 }
コード例 #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
        List <bbStructure> getStructuresOfType(bbStructureType structureType)
        {
            List <bbStructure> structuresOfType = new List <bbStructure>();

            foreach (bbStructure s in game.currentIsland.structures.Values)
            {
                if (s.getType() == structureType)
                {
                    structuresOfType.Add(s);
                }
            }
            return(structuresOfType);
        }
コード例 #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 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);
            }
        }
コード例 #6
0
 public bbStructureConstruction(bbStructureType _type, bbPos _pos, ClickType _clickType)
 {
     pos           = _pos;
     structureType = _type;
     clickType     = _clickType;
 }
コード例 #7
0
 public bbStructureEx(bbStructureType _structureType, bbPos _pos)
 {
     structureType = _structureType;
     pos           = _pos;
 }
コード例 #8
0
 public bbStructureHouse(bbStructureType _type, bbPos _pos)
 {
     pos           = _pos;
     structureType = _type;
     spawned       = false;
 }
コード例 #9
0
 public bbStructureMine(bbStructureType _type, bbPos _pos)
 {
     pos           = _pos;
     structureType = _type;
     hasResource   = false;
 }
コード例 #10
0
 public bbStructureHQ(bbStructureType _type, bbPos _pos)
 {
     pos           = _pos;
     structureType = _type;
 }