Exemplo n.º 1
0
    // Specific TileMap names, called from TileMapBuilder, are manually created here


    public void BuildRuleMap(TileMap givenMap)
    {
        Location loc        = LocationController.Instance.GetSelectedLocation();
        Ruler    localRuler = loc.localRuler;

        for (int x = 0; x < givenMap.xSize; x += 1)
        {
            for (int y = 0; y < givenMap.ySize; y += 1)
            {
                givenMap.GetTileAt(x, y).SetTileEcoBlockType(EcoBlock.BlockType.Unassigned);
            }
        }

        int xPos = 5;
        int yPos = 0;

        Territory terr = TerritoryController.Instance.GetTerritoryAtLocation(loc);

        if (terr != null)
        {
            givenMap.GetTileAt(xPos, yPos).SetTileEcoBlockType(EcoBlock.BlockType.Territory);
            givenMap.GetTileAt(xPos, yPos).SetLinkedEcoBlock(terr);
        }

        foreach (Population pop in PopulationController.Instance.GetPopulationsAtLocation(loc))
        {
            if (pop != null)
            {
                xPos += 2;
                givenMap.GetTileAt(xPos, yPos).SetTileEcoBlockType(EcoBlock.BlockType.Population);
                givenMap.GetTileAt(xPos, yPos).SetLinkedEcoBlock(pop);
            }
        }
        xPos = 5;
        yPos = 2;
        givenMap.GetTileAt(xPos, yPos).SetLinkedLocation(loc);
        xPos = 5;
        yPos = 4;


        // Add secondary rulers
        foreach (Ruler ruler in EconomyController.Instance.GetLocationRulers(loc))
        {
            if (ruler != null && ruler.isLocalRuler == false)
            {
                xPos += 2;
                givenMap.GetTileAt(xPos, yPos).SetLinkedEcoBlock(ruler);
            }
        }

        // Add local ruler
        if (localRuler != null)
        {
            if (localRuler.rulerHierarchy == Ruler.Hierarchy.Dominating)
            {
                xPos = 5;
                yPos = 6;
                givenMap.GetTileAt(xPos, yPos).SetLinkedEcoBlock(localRuler);
                foreach (Location contloc in localRuler.GetControlledLocations())
                {
                    xPos += 2;
                    givenMap.GetTileAt(xPos, yPos).SetLinkedLocation(contloc);
                }
            }
            else if (localRuler.rulerHierarchy == Ruler.Hierarchy.Independent)
            {
                xPos = 5;
                yPos = 4;
                givenMap.GetTileAt(xPos, yPos).SetLinkedEcoBlock(localRuler);
            }

            else if (localRuler.rulerHierarchy == Ruler.Hierarchy.Dominated)
            {
                xPos = 5;
                yPos = 4;
                givenMap.GetTileAt(xPos, yPos).SetLinkedEcoBlock(localRuler);
                yPos = 6;
                givenMap.GetTileAt(xPos, yPos).SetLinkedEcoBlock(localRuler.GetController());
                xPos += 2;
                givenMap.GetTileAt(xPos, yPos).SetLinkedLocation(localRuler.GetController().GetHomeLocation());
                foreach (Location contloc in localRuler.GetController().GetControlledLocations())
                {
                    xPos += 2;
                    givenMap.GetTileAt(xPos, yPos).SetLinkedLocation(contloc);
                }
            }
        }
        else if (loc.dominatingRuler != null)
        {
            xPos = 5;
            yPos = 6;
            givenMap.GetTileAt(xPos, yPos).SetLinkedEcoBlock(loc.dominatingRuler);
            xPos += 2;
            givenMap.GetTileAt(xPos, yPos).SetLinkedLocation(loc.dominatingRuler.GetHomeLocation());
            foreach (Location contloc in loc.dominatingRuler.GetControlledLocations())
            {
                xPos += 2;
                givenMap.GetTileAt(xPos, yPos).SetLinkedLocation(contloc);
            }
        }

        xPos = 5;
        yPos = 2;


        foreach (Warband warband in WarbandController.Instance.GetWarbandsAtLocation(loc))
        {
            if (warband != null)
            {
                xPos -= 2;
                givenMap.GetTileAt(xPos, yPos).SetLinkedEcoBlock(warband);
            }
        }
        xPos = 5;
        yPos = 4;
        if (localRuler != null)
        {
            foreach (Warband warband in localRuler.GetControlledWarbands())
            {
                if (warband != null)
                {
                    xPos -= 2;
                    givenMap.GetTileAt(xPos, yPos).SetLinkedEcoBlock(warband);
                }
            }
            xPos = 5;
            yPos = 6;
            if (localRuler.rulerHierarchy == Ruler.Hierarchy.Dominated)
            {
                foreach (Warband warband in localRuler.GetController().GetControlledWarbands())
                {
                    if (warband != null)
                    {
                        xPos -= 2;
                        givenMap.GetTileAt(xPos, yPos).SetLinkedEcoBlock(warband);
                    }
                }
            }
        }
    }