Example #1
0
    GameObject FindSuitableModule(ModuleInfo modInfoToSuit)
    {
        bool       typeSuits = false;
        ModuleType modType   = ModuleType.InvalidType;

        while (!typeSuits)
        {
            int typeRand = Random.Range(0, 4); //0 is room, 1 is junction, 2 is corridor

            switch (typeRand)
            {
            case 0:
                modType   = ModuleType.Room;
                typeSuits = modInfoToSuit.CanConnectToModule(modType);
                break;

            case 1:
                modType   = ModuleType.Junction;
                typeSuits = modInfoToSuit.CanConnectToModule(modType);
                break;

            case 2:
                modType   = ModuleType.Corridor;
                typeSuits = modInfoToSuit.CanConnectToModule(modType);
                break;
            }
        }

        return(GetModuleBasedOnType(modType)); //position & rotation are not set!
    }