public static MultiOptionSelector BuildMultiOptionSelector(AssetManager assets, string theme, string selectorName, List<Option> options, MultiOptionArrangement arrangement, Cursor cursor, int initialValue = 0) { TextDictionary assetDictionary = new TextDictionary(assets.GetText("selector")); string selectorTheme = assetDictionary.LookupString(theme, selectorName + "SelectorTheme"); Vector2 selectorPosition = assetDictionary.LookupVector2(theme, selectorName + "SelectorPosition"); Anchor selectorAnchor = Anchor.Center; if (assetDictionary.CheckPropertyExists(theme, selectorName + "SelectorAnchor")) Enum.TryParse<Anchor>(assetDictionary.LookupString(theme, selectorName + "SelectorAnchor"), out selectorAnchor); return new MultiOptionSelector(assets, selectorTheme, selectorPosition, selectorAnchor, options, arrangement, cursor, initialValue); }
public BackgroundParticleSettings(AssetManager assets, int actNumber) { TextDictionary td = new TextDictionary(assets.GetText("particles")); string act = "act" + actNumber; numParticles = td.LookupInt32(act, "numParticles"); if (numParticles > 0) { rotationRateRange = td.LookupVector2(act, "rotationRateRange"); scaleRange = td.LookupVector2(act, "scaleRange"); colorLow = td.LookupColor(act, "colorLow"); colorHigh = td.LookupColor(act, "colorHigh"); texture = assets.GetTexture(td.LookupString(act, "texture")); distance = td.LookupSingle(act, "dist"); } }
public static ParallaxBackgroundSet Build(AssetManager assets, Camera camera, Vector2 seamstressStart, string assetName) { TextDictionary assetDictionary = new TextDictionary(assets.GetText("parallax")); int layers = assetDictionary.LookupInt32(assetName, "layers"); ParallaxBackground[] backgrounds = new ParallaxBackground[layers]; BackgroundParticleSet particles = new BackgroundParticleSet(assets, camera.Dimensions, Convert.ToInt32(assetName.Substring(3))); int particleLayer = -1; for (int i = 0; i < layers; i++) { Texture2D tex; if (assetDictionary.CheckPropertyExists(assetName, "name" + i)) tex = assets.GetTexture(assetDictionary.LookupString(assetName, "name" + i)); else tex = assets.GetTexture(assetName + "_layer" + i); float dist, scale; Vector2 offset, velocity, repeat; Anchor anchor; try { dist = assetDictionary.LookupSingle(assetName, "dist" + i); } catch { dist = 1; } try { offset = assetDictionary.LookupVector2(assetName, "offset" + i); } catch { offset = Vector2.Zero; } try { velocity = assetDictionary.LookupVector2(assetName, "velocity" + i); } catch { velocity = Vector2.Zero; } try { scale = assetDictionary.LookupSingle(assetName, "scale" + i); } catch { scale = 1; } try { repeat = assetDictionary.LookupVector2(assetName, "repeat" + i); } catch { repeat = new Vector2(1, 0); } if (!assetDictionary.CheckPropertyExists(assetName, "anchor" + i) || !Enum.TryParse<Anchor>(assetDictionary.LookupString(assetName, "anchor" + i), out anchor)) anchor = Anchor.BottomLeft; backgrounds[i] = new ParallaxBackground(assets, tex, offset, velocity, dist, scale, anchor, repeat); if (dist > particles.Distance) particleLayer = i; } ParallaxBackgroundSet pbs = new ParallaxBackgroundSet(); pbs.backgrounds = backgrounds; pbs.camera = new Camera(camera.Dimensions, camera.Position, camera.Rotation, camera.Scale); pbs.color = assetDictionary.LookupColor(assetName, "color"); pbs.particleLayer = particleLayer; pbs.particles = particles; pbs.seamstressStart = seamstressStart; return pbs; }
public override void Initialize(List<Option> options, AssetManager assets, string themeName) { TextDictionary assetDictionary = new TextDictionary(assets.GetText("cursor")); base.Initialize(options, assets, themeName); graphic = assets.GetTexture(assetDictionary.LookupString(themeName, "graphic")); try { color = new Color(assetDictionary.LookupVector4(themeName, "color")); } catch { color = new Color(assetDictionary.LookupVector3(themeName, "color")); } offset = assetDictionary.LookupVector2(themeName, "offset"); //optional bool anchorParseSuccess = Enum.TryParse<Anchor>(assetDictionary.LookupString(themeName, "anchor"), out anchor); if (!anchorParseSuccess) anchor = Anchor.TopLeft; try { smoothness = assetDictionary.LookupSingle(themeName, "smoothness"); } catch { smoothness = 0f; } }
/// <summary> /// Constructs a new InputController. /// </summary> /// <param name="assets">The AssetManager object used in the game.</param> public InputController(AssetManager assets) { controllerConnected = GamePad.GetState(PlayerIndex.One).IsConnected; TextDictionary dict = new TextDictionary(assets.GetText("controls")); controls = new InputControl[controlNames.Length]; for (int i = 0; i < controls.Length; i++) { controls[i] = new InputControl(); if (dict.CheckObjectExists(controlNames[i])) { if (dict.CheckPropertyExists(controlNames[i], "key")) { Keys key = (Keys)Enum.Parse(typeof(Keys), dict.LookupString(controlNames[i], "key")); controls[i].AddKey(key); } else { int j = 0; while (dict.CheckPropertyExists(controlNames[i], "key" + j)) { Keys key = (Keys)Enum.Parse(typeof(Keys), dict.LookupString(controlNames[i], "key" + j)); controls[i].AddKey(key); j++; } } if (dict.CheckPropertyExists(controlNames[i], "button")) { Buttons button = (Buttons)Enum.Parse(typeof(Buttons), dict.LookupString(controlNames[i], "button")); controls[i].AddButton(button); } else { int j = 0; while (dict.CheckPropertyExists(controlNames[i], "button" + j)) { Buttons button = (Buttons)Enum.Parse(typeof(Buttons), dict.LookupString(controlNames[i], "button" + j)); controls[i].AddButton(button); j++; } } if (dict.CheckPropertyExists(controlNames[i], "leftjoystick")) { Vector2 dir = dict.LookupVector2(controlNames[i], "leftjoystick"); controls[i].SetLeftJoystick(dir); } if (dict.CheckPropertyExists(controlNames[i], "rightjoystick")) { Vector2 dir = dict.LookupVector2(controlNames[i], "rightjoystick"); controls[i].SetRightJoystick(dir); } if (dict.CheckPropertyExists(controlNames[i], "lefttrigger")) { bool activated = dict.LookupBoolean(controlNames[i], "lefttrigger"); controls[i].SetLeftTrigger(activated); } if (dict.CheckPropertyExists(controlNames[i], "righttrigger")) { bool activated = dict.LookupBoolean(controlNames[i], "righttrigger"); controls[i].SetRightTrigger(activated); } } } var keyNames = Enum.GetValues(typeof(Keys)); allKeys = new InputControl(); foreach (Keys key in keyNames) allKeys.AddKey(key); allKeys.AddButton(Buttons.A); allKeys.AddButton(Buttons.B); allKeys.AddButton(Buttons.Back); allKeys.AddButton(Buttons.LeftShoulder); allKeys.AddButton(Buttons.LeftTrigger); allKeys.AddButton(Buttons.RightShoulder); allKeys.AddButton(Buttons.RightTrigger); allKeys.AddButton(Buttons.Start); allKeys.AddButton(Buttons.X); allKeys.AddButton(Buttons.Y); }