Beispiel #1
0
    public void OnEnable()
    {
        SmallButtonLayout = new GUILayoutOption[] { GUILayout.Width(20.0f), GUILayout.Height(20.0f) };

        Target = (FactionTypeInfo)target;

        SOTarget = new SerializedObject(Target);
    }
Beispiel #2
0
        //init the faction slot and update the faction attributes
        public void Init(string name, FactionTypeInfo typeInfo, Color color, bool playerControlled, int population, NPCTypeInfo npcType, FactionManager factionMgr, int factionID, GameManager gameMgr)
        {
            this.name             = name;
            this.typeInfo         = typeInfo;
            this.color            = color;
            this.PlayerControlled = playerControlled;

            this.npcType = this.PlayerControlled ? null : npcType;

            Init(factionID, factionMgr, gameMgr);

            UpdateMaxPopulation(population, false);
        }
        private static IEnumerable <FactionTypeInfo> factionTypes = null; //holds currently available FactionTypeInfo asset files.
        /// <summary>
        /// Gets the cached FactionTypeInfo assets in the project and refreshes the cache if necessary.
        /// </summary>
        /// <param name="requireTest">When true, a test will determine whether testFactionType is cached or not. If already cached, the cache will not be refreshed.</param>
        /// <param name="testFactionType">The FactionTypeInfo instance to test.</param>
        /// <returns>Diciontary instance where each key is the code cached FactionTypeInfo assets and each value is the actual asset instance that matches the key type</returns>
        public static Dictionary <string, FactionTypeInfo> GetFactionTypes(bool requireTest = false, FactionTypeInfo testFactionType = null)
        {
            //only refresh if..
            if (factionTypes == null || //cache hasn't been assigned yet.
                (requireTest == true && !factionTypes.Contains(testFactionType)))     //or test is required while test faction type is not in the cached list
            {
                CacheAssetFiles(out factionTypes, "t:FactionTypeInfo");
            }

            return(factionTypes.ToDictionary(type => type == null ? "Unassigned" : type.GetCode()));
        }
Beispiel #4
0
 /// <summary>
 /// Gets a NPCUnitRegulatorData instance that suits the input requirements.
 /// </summary>
 /// <param name="factionType">FactionTypeInfo instance that defines the faction type of the regulator data.</param>
 /// <param name="npcManagerCode">The NPCManager instance code that defines the NPC Manager type.</param>
 /// <returns>NPCUnitRegulatorData instance if both requirements are met.</returns>
 public NPCUnitRegulatorData GetRegulatorData(FactionTypeInfo factionType, string npcManagerCode)
 {
     return(regulatorData.Filter(factionType, npcManagerCode));
 }
Beispiel #5
0
 /// <summary>
 /// Gets the NPCManager prefab that can be used for the input FactionTypeInfo asset file.
 /// </summary>
 /// <param name="factionType">FactionTypeInfo instance to search a match for.</param>
 /// <returns>NPCManager prefab that manages the NPC type with the given faction type.</returns>
 public NPCManager GetNPCManagerPrefab(FactionTypeInfo factionType)
 {
     return(npcManagers.Filter(factionType));
 }