// Probably want to build a proper, dedicated line-drawing class if you start using this function extensively.
    public void InstantiateDominationLines(Ruler ruler)
    {
        Location        loc           = ruler.GetHomeLocation();
        List <Location> lineLocations = new List <Location>();

        foreach (Location location in ruler.GetControlledLocations())
        {
            lineLocations.Add(location);
        }

        foreach (Location lineloc in lineLocations)
        {
            GameObject   lineObj = Instantiate(linePrefab);
            LineRenderer line    = lineObj.GetComponent <LineRenderer>();
            // Set false to not scale to map holder and go offpos. Alternatively set localscale to 1,1,1 at bottom.
            lineObj.transform.SetParent(MapController.Instance.GetActiveMapHolder().transform, false);
            lineList.Add(lineObj);
            line.startWidth = lineStartSize;
            line.endWidth   = lineEndSize;
            lineObj.transform.localPosition = new Vector3(0, 0, 0);
            line.SetPosition(0, ruler.GetPositionVector());
            line.SetPosition(1, lineloc.GetPositionVector());
            line.startColor = Color.blue;
            line.endColor   = Color.red;
        }
    }
예제 #2
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);
                    }
                }
            }
        }
    }