本文整理汇总了C#中ConfigFile.GetGroupNames方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigFile.GetGroupNames方法的具体用法?C# ConfigFile.GetGroupNames怎么用?C# ConfigFile.GetGroupNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile.GetGroupNames方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BaseShip
/*** Public ***/
// Standard constructor: needs to have a paried config file name
// which should implement all of the groups and key-value pairs
// found in the ship demo config file
public BaseShip(String ConfigFileName)
{
// Load the ship's properties
this.ConfigFileName = ConfigFileName;
ConfigFile Info = new ConfigFile(ConfigFileName);
/*** General Init. ***/
// Save the health components
ShieldHealth = ShieldMaxHealth = Info.GetKey_Int("General", "Shield");
HullHealth = HullMaxHealth = Info.GetKey_Int("General", "Hull");
// Save velicity limit and default pos to center
MaxVelocity = Info.GetKey_Vector2("General", "MaxVelocity");
ShipAcceleration = new Vector2();
ShipVelocity = new Vector2();
ShipPosition = new Vector3();
// Get all group names to load up specialty geometry
String TextureName = Info.GetKey_String("General", "Texture");
String[] GroupNames = Info.GetGroupNames();
/*** Frame, Shield & Hull ***/
// For each group, look just for "Frame" and "Shield"
foreach(String GroupName in GroupNames)
{
// If shield
if(GroupName.ToLower().StartsWith("shield") == true)
{
// Get animation / frame info
ShieldAnimation = LoadHullType(Info, GroupName);
// Register the sprite with the sprite manager
ShieldSprite = new Sprite("Textures/" + TextureName);
ShieldSprite.SetAnimation(ShieldAnimation.Pos, ShieldAnimation.Size, ShieldAnimation.FrameCount, ShieldAnimation.FrameTime);
ShieldSprite.SetGeometrySize(ShieldSprite.GetSpriteSize());
ShieldSprite.SetRotationCenter(ShieldSprite.GetGeometrySize() / 2.0f);
ShieldSprite.SetDepth(Globals.ShieldDepth);
Globals.WorldView.SManager.AddSprite(ShieldSprite);
}
// Elif base frame
else if(GroupName.ToLower().StartsWith("frame") == true)
{
// Get animation / frame info
FrameAnimation = LoadHullType(Info, GroupName);
// Register the sprite with the sprite manager
FrameSprite = new Sprite("Textures/" + TextureName);
FrameSprite.SetAnimation(FrameAnimation.Pos, FrameAnimation.Size, FrameAnimation.FrameCount, FrameAnimation.FrameTime);
FrameSprite.SetGeometrySize(FrameSprite.GetSpriteSize());
FrameSprite.SetRotationCenter(FrameSprite.GetGeometrySize() / 2.0f);
FrameSprite.SetDepth(Globals.FrameDepth);
Globals.WorldView.SManager.AddSprite(FrameSprite);
}
}
// Load all the hulls
HullList = new List<BaseShip_Hull>();
foreach(String GroupName in GroupNames)
{
if(GroupName.ToLower().StartsWith("hull") == true)
{
BaseShip_Hull Hull = LoadHullType(Info, GroupName);
HullList.Add(Hull);
}
}
// Default to initial hull
HullSprite = new Sprite("Textures/" + TextureName);
HullSkinIndex = 0; // Index grows while health goes down
BaseShip_Hull HullAnimation = HullList[HullSkinIndex];
HullSprite.SetAnimation(HullAnimation.Pos, HullAnimation.Size, HullAnimation.FrameCount, HullAnimation.FrameTime);
HullSprite.SetGeometrySize(HullSprite.GetSpriteSize());
HullSprite.SetRotationCenter(HullSprite.GetGeometrySize() / 2.0f);
HullSprite.SetDepth(Globals.HullDepth);
Globals.WorldView.SManager.AddSprite(HullSprite);
/*** Contrails ***/
// Load all contrails
ContrailList = new List<BaseShip_Contrail>();
foreach(String GroupName in GroupNames)
{
BaseShip_Contrail NewContrail = LoadContrail(Info, GroupName);
if(NewContrail != null)
ContrailList.Add(NewContrail);
}
/*** Weapons ***/
// Load all weapons
WeaponsList = new List<BaseShip_Weapon>();
foreach(String GroupName in GroupNames)
{
//.........这里部分代码省略.........
示例2: Start
// Use this for initialization
void Start()
{
// Load the available audio clips
Info = new ConfigFile("Config/World/AudioConfig");
//Set up the audiosources
NonCombat = Camera.main.gameObject.AddComponent("AudioSource") as AudioSource;
Combat = Camera.main.gameObject.AddComponent("AudioSource") as AudioSource;
//get the count of all the songs for the array capacity
//Set up the song selection array
string[] songs = Info.GetGroupNames();
songChoices = new ArrayList(songs.GetLength(0));
ones = 0;
songIndex = 0;
//Initialize the song selection array
for (int i = 0; i < songChoices.Capacity; i++ )
{
songChoices.Add(0);
}
//Set up and seed our RNG
r = new System.Random((int)System.DateTime.Now.Ticks);
//Set up our transition variables
transitionTime = 3.0f;
transition = false;
isCombat = false;
//set volumes
NonCombat.volume = 100;
Combat.volume = 0;
//pick the initial song
ChangeSong();
}
示例3: LoadConfig
// Load all animations and properties from the configuration file
private void LoadConfig(string FileName)
{
// Load config
Config = new ConfigFile(FileName);
// Get the texture name
TextureName = Config.GetKey_String("General", "Texture");
// Create new animations dictionary, loosing the rest
Animations = new Dictionary<string, SpriteAnimation>();
// Get all group names for the animations set
String[] Groups = Config.GetGroupNames();
foreach(String Group in Groups)
{
// Ignore if non-animation group
if(Group == "general")
continue;
else
{
// Fill a sprite animation struct and save it as the group's name
SpriteAnimation Animation = new SpriteAnimation();
Animation.Name = Group;
Animation.Pos = Config.GetKey_Vector2(Group, "Pos");
Animation.Rotation = Config.GetKey_Float(Group, "Rotation");
Animation.Frame = Config.GetKey_Vector2(Group, "Size");
Animation.FrameCount = Config.GetKey_Int(Group, "Count");
Animation.FrameTime = Config.GetKey_Float(Group, "Time");
// Save
Animations.Add(Group, Animation);
}
}
}
示例4: GetLevelCount
// Returns the number of levels
public static int GetLevelCount()
{
ConfigFile Info = new ConfigFile("Config/World/LevelsConfig");
return Info.GetGroupNames().Length;
}