コード例 #1
0
        private static void Init()
        {
            SurvivorCatalog.survivorDefs = new SurvivorDef[10];
            SurvivorCatalog.RegisterSurvivor(SurvivorIndex.Commando, new SurvivorDef
            {
                bodyPrefab       = BodyCatalog.FindBodyPrefab("CommandoBody"),
                displayPrefab    = Resources.Load <GameObject>("Prefabs/CharacterDisplays/CommandoDisplay"),
                descriptionToken = "COMMANDO_DESCRIPTION",
                primaryColor     = new Color(0.92941177f, 0.5882353f, 0.07058824f)
            });
            SurvivorCatalog.RegisterSurvivor(SurvivorIndex.Huntress, new SurvivorDef
            {
                bodyPrefab       = BodyCatalog.FindBodyPrefab("HuntressBody"),
                displayPrefab    = Resources.Load <GameObject>("Prefabs/CharacterDisplays/HuntressDisplay"),
                primaryColor     = new Color(0.8352941f, 0.23529412f, 0.23529412f),
                descriptionToken = "HUNTRESS_DESCRIPTION",
                unlockableName   = "Characters.Huntress"
            });
            SurvivorCatalog.RegisterSurvivor(SurvivorIndex.Toolbot, new SurvivorDef
            {
                bodyPrefab       = BodyCatalog.FindBodyPrefab("ToolbotBody"),
                displayPrefab    = Resources.Load <GameObject>("Prefabs/CharacterDisplays/ToolbotDisplay"),
                descriptionToken = "TOOLBOT_DESCRIPTION",
                primaryColor     = new Color(0.827451f, 0.76862746f, 0.3137255f),
                unlockableName   = "Characters.Toolbot"
            });
            SurvivorCatalog.RegisterSurvivor(SurvivorIndex.Engi, new SurvivorDef
            {
                bodyPrefab       = BodyCatalog.FindBodyPrefab("EngiBody"),
                displayPrefab    = Resources.Load <GameObject>("Prefabs/CharacterDisplays/EngiDisplay"),
                descriptionToken = "ENGI_DESCRIPTION",
                primaryColor     = new Color(0.37254903f, 0.8862745f, 0.5254902f),
                unlockableName   = "Characters.Engineer"
            });
            SurvivorCatalog.RegisterSurvivor(SurvivorIndex.Mage, new SurvivorDef
            {
                bodyPrefab       = BodyCatalog.FindBodyPrefab("MageBody"),
                displayPrefab    = Resources.Load <GameObject>("Prefabs/CharacterDisplays/MageDisplay"),
                descriptionToken = "MAGE_DESCRIPTION",
                primaryColor     = new Color(0.96862745f, 0.75686276f, 0.99215686f),
                unlockableName   = "Characters.Mage"
            });
            SurvivorCatalog.RegisterSurvivor(SurvivorIndex.Merc, new SurvivorDef
            {
                bodyPrefab       = BodyCatalog.FindBodyPrefab("MercBody"),
                displayPrefab    = Resources.Load <GameObject>("Prefabs/CharacterDisplays/MercDisplay"),
                descriptionToken = "MERC_DESCRIPTION",
                primaryColor     = new Color(0.42352942f, 0.81960785f, 0.91764706f),
                unlockableName   = "Characters.Mercenary"
            });
            SurvivorCatalog.RegisterSurvivor(SurvivorIndex.Treebot, new SurvivorDef
            {
                bodyPrefab       = BodyCatalog.FindBodyPrefab("TreebotBody"),
                displayPrefab    = Resources.Load <GameObject>("Prefabs/CharacterDisplays/TreebotDisplay"),
                descriptionToken = "TREEBOT_DESCRIPTION",
                primaryColor     = new Color(0.5254902f, 0.61960787f, 0.32941177f),
                unlockableName   = "Characters.Treebot"
            });
            SurvivorCatalog.RegisterSurvivor(SurvivorIndex.Loader, new SurvivorDef
            {
                bodyPrefab       = BodyCatalog.FindBodyPrefab("LoaderBody"),
                displayPrefab    = Resources.Load <GameObject>("Prefabs/CharacterDisplays/LoaderDisplay"),
                descriptionToken = "LOADER_DESCRIPTION",
                primaryColor     = new Color(0.40392157f, 0.4392157f, 0.87058824f),
                unlockableName   = "Characters.Loader"
            });
            SurvivorCatalog.RegisterSurvivor(SurvivorIndex.Croco, new SurvivorDef
            {
                bodyPrefab       = BodyCatalog.FindBodyPrefab("CrocoBody"),
                displayPrefab    = Resources.Load <GameObject>("Prefabs/CharacterDisplays/CrocoDisplay"),
                descriptionToken = "CROCO_DESCRIPTION",
                primaryColor     = new Color(0.7882353f, 0.9490196f, 0.3019608f),
                unlockableName   = "Characters.Croco"
            });
            for (SurvivorIndex survivorIndex = SurvivorIndex.Commando; survivorIndex < SurvivorIndex.Count; survivorIndex++)
            {
                if (SurvivorCatalog.survivorDefs[(int)survivorIndex] == null)
                {
                    Debug.LogWarningFormat("Unregistered survivor {0}!", new object[]
                    {
                        Enum.GetName(typeof(SurvivorIndex), survivorIndex)
                    });
                }
            }
            List <SurvivorDef>           list   = new List <SurvivorDef>();
            Action <List <SurvivorDef> > action = SurvivorCatalog.getAdditionalSurvivorDefs;

            if (action != null)
            {
                action(list);
            }
            Array.Resize <SurvivorDef>(ref SurvivorCatalog.survivorDefs, SurvivorCatalog.survivorDefs.Length + list.Count);
            for (int i = 0; i < list.Count; i++)
            {
                SurvivorCatalog.RegisterSurvivor(SurvivorIndex.Count + i, list[i]);
            }
            SurvivorCatalog.survivorIndexToBodyIndex = new int[SurvivorCatalog.survivorCount];
            SurvivorCatalog.bodyIndexToSurvivorIndex = new SurvivorIndex[BodyCatalog.bodyCount];
            HGArrayUtilities.SetAll <int>(SurvivorCatalog.survivorIndexToBodyIndex, -1);
            HGArrayUtilities.SetAll <SurvivorIndex>(SurvivorCatalog.bodyIndexToSurvivorIndex, SurvivorIndex.None);
            for (int j = 0; j < SurvivorCatalog.survivorDefs.Length; j++)
            {
                SurvivorDef survivorDef = SurvivorCatalog.survivorDefs[j];
                int         num         = (survivorDef != null) ? survivorDef.bodyPrefab.GetComponent <CharacterBody>().bodyIndex : -1;
                SurvivorCatalog.survivorIndexToBodyIndex[j] = num;
                if (num != -1)
                {
                    SurvivorCatalog.bodyIndexToSurvivorIndex[num] = (SurvivorIndex)j;
                }
            }
            SurvivorCatalog._allSurvivorDefs = (from v in SurvivorCatalog.survivorDefs
                                                where v != null
                                                select v).ToArray <SurvivorDef>();
            ViewablesCatalog.Node node = new ViewablesCatalog.Node("Survivors", true, null);
            using (IEnumerator <SurvivorDef> enumerator = SurvivorCatalog.allSurvivorDefs.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    SurvivorCatalog.< > c__DisplayClass22_0 CS$ < > 8__locals1 = new SurvivorCatalog.< > c__DisplayClass22_0();
                    CS$ < > 8__locals1.survivorDef = enumerator.Current;
                    ViewablesCatalog.Node survivorEntryNode = new ViewablesCatalog.Node(CS$ < > 8__locals1.survivorDef.survivorIndex.ToString(), false, node);
                    survivorEntryNode.shouldShowUnviewed = ((UserProfile userProfile) => !userProfile.HasViewedViewable(survivorEntryNode.fullName) && userProfile.HasSurvivorUnlocked(CS$ < > 8__locals1.survivorDef.survivorIndex) && !string.IsNullOrEmpty(CS$ < > 8__locals1.survivorDef.unlockableName));
                }
            }
            ViewablesCatalog.AddNodeToRoot(node);
        }