Example #1
0
    public DesignedBuilding(SocialStructure socialStructure)
    {
        maxSocialTier = GetMaxSocialTier(socialStructure);
        var livingQuarters = GetLivingQuarters(socialStructure);
        var commonSpaces   = GetCommonSpaces(socialStructure);

        DetermineSize(livingQuarters);
        DetermineSize(commonSpaces);
        foreach (var room in livingQuarters)
        {
            rooms.Add(room);
        }
        foreach (var room in commonSpaces)
        {
            rooms.Add(room);
        }
        var bossRoom = new BossRoom()
        {
            size = 100
        };

        rooms.Add(bossRoom);
        socialStructure.population[0].quality         = 4;
        socialStructure.population[0].associatedRooms = new List <Room> {
            bossRoom
        };
        layout = new DesignedBuildingLayout(this);
        layout.LayoutRooms();
    }
Example #2
0
    private int GetMaxSocialTier(SocialStructure socialStructure)
    {
        int maximum = 0;

        foreach (var node in socialStructure.hierarchy.allNodes)
        {
            maximum = Mathf.Max(node.GetDepth(), maximum);
        }
        return(maximum);
    }
Example #3
0
    private List <MonsterData> GetMonstersForNode(SocialNode node, SocialStructure socialStructure)
    {
        var output = new List <MonsterData>();

        foreach (var monster in socialStructure.population)
        {
            if (monster.node == node)
            {
                output.Add(monster);
            }
        }
        return(output);
    }
Example #4
0
    private int FetchPopulationCount(SocialStructure socialStructure, SocialNode node)
    {
        int count = 0;

        foreach (var mob in socialStructure.population)
        {
            if (mob.node == node)
            {
                count++;
            }
        }
        return(count);
    }
Example #5
0
    private List <LivingQuarters> GetLivingQuarters(SocialStructure socialStructure)
    {
        var output = new List <LivingQuarters>();

        foreach (var node in socialStructure.hierarchy.allNodes)
        {
            var temp = GetSpecificLivingQuarters(node, socialStructure);
            foreach (var node2 in temp)
            {
                output.Add(node2);
            }
        }
        return(output);
    }
Example #6
0
    private List <CommonSpace> GetCommonSpaces(SocialStructure socialStructure)
    {
        var output = new List <CommonSpace>();

        foreach (var node in socialStructure.hierarchy.allNodes)
        {
            var temp = GetSpecificCommonSpace(node, socialStructure);
            foreach (var node2 in temp)
            {
                output.Add(node2);
            }
        }
        return(output);
    }
Example #7
0
    private void AssignInhabitants <T>(SocialStructure socialStructure, SocialNode node, List <T> rooms, int numberPerRoom) where T : AssignedRoom
    {
        var mobList        = GetMonstersForNode(node, socialStructure);
        int currentMonster = 0;

        foreach (var room in rooms)
        {
            while (room.inhabitants.Count < numberPerRoom && currentMonster < mobList.Count)
            {
                var monster = mobList[currentMonster];
                room.inhabitants.Add(monster);
                monster.associatedRooms.Add(room);
                currentMonster++;
            }
        }
    }
 public static void InstantiateMonsters(int floor, DesignedBuilding layout, SocialStructure socialStructure, LevelGen levelGen)
 {
     //if (!NetworkServer.active) return;
     foreach (var monster in socialStructure.population)
     {
         int roll = Random.Range(0, monster.associatedRooms.Count);
         var room = monster.associatedRooms[roll];
         if (room.floor != floor)
         {
             continue;
         }
         float xRoll = Random.Range(5f * room.x, 5f * (room.x + room.xSize - 1));
         float yRoll = Random.Range(5f * room.y, 5f * (room.y + room.ySize - 1));
         if (monster.quality == 4)
         {
             xRoll = (room.x + (room.xSize / 2)) * 4;
             yRoll = (room.y + (room.ySize / 2)) * 4;
         }
         InstantiateMonster(monster, xRoll, yRoll, levelGen);
     }
 }
Example #9
0
    private List <T> GetSpecificRooms <T>(SocialNode node, SocialStructure socialStructure, int roomPopulationScale) where T : AssignedRoom, new()
    {
        var   output            = new List <T>();
        var   numTiers          = maxSocialTier + 1;
        float grandiosity       = ((float)numTiers - (float)node.GetDepth()) / (float)numTiers;
        float numberPerRoomRoll = Random.Range(grandiosity / 2, grandiosity * 1.5f);
        int   numberPerRoom     = (int)(roomPopulationScale - (numberPerRoomRoll * roomPopulationScale));

        numberPerRoom = Mathf.Max(numberPerRoom, 1);
        int numRooms = (int)(Mathf.Ceil((float)FetchPopulationCount(socialStructure, node) / (float)numberPerRoom));

        for (int i = 0; i < numRooms; i++)
        {
            grandiosity = Random.Range(grandiosity / 2, grandiosity * 1.5f);
            T room = new T {
                grandiosity = grandiosity,
                socialTier  = node.GetDepth()
            };
            output.Add(room);
        }
        AssignInhabitants(socialStructure, node, output, numberPerRoom);
        return(output);
    }
Example #10
0
 private List <CommonSpace> GetSpecificCommonSpace(SocialNode node, SocialStructure socialStructure)
 {
     return(GetSpecificRooms <CommonSpace>(node, socialStructure, 80));
 }
Example #11
0
 private List <LivingQuarters> GetSpecificLivingQuarters(SocialNode node, SocialStructure socialStructure)
 {
     return(GetSpecificRooms <LivingQuarters>(node, socialStructure, 20));
 }
Example #12
0
 public static void InstantiateMonsters(int floor, DesignedBuilding layout, SocialStructure socialStructure, LevelGen levelGen)
 {
     ActiveCastleGen.InstantiateMonsters(floor, layout, socialStructure, levelGen);
 }