public EditFlagsFieldCommand(Lazy <HexBufferFileServiceFactory> hexBufferFileServiceFactory, FlagInfo flagInfo, bool isFlag) : base(hexBufferFileServiceFactory) { if (flagInfo.IsEnumName) { throw new ArgumentOutOfRangeException(nameof(flagInfo)); } this.flagInfo = flagInfo; this.isFlag = isFlag; }
/// <summary> /// Reads the xml commands. /// </summary> /// <returns>The xml commands as List<Commands>.</returns> public List<CommandInfo> readXmlCommands() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml: textDB.text); XmlNodeList commandTempList = xmlDoc.GetElementsByTagName(name: "Command"); //run for each command in the XML file foreach(XmlNode command in commandTempList) { CommandInfo newCommandInfo = new CommandInfo(name: command.Attributes["name"].Value); XmlNodeList commandSections = command.ChildNodes; //run for each section inside the command foreach(XmlNode commandInfo in commandSections) { switch(commandInfo.Name) { case "description": string rawDescription = commandInfo.InnerText; rawDescription = rawDescription.Trim(trimChars: new char[]{'\n', '\r', '\t', ' '}); //rawDescription.Replace(' ', '*'); //rawDescription.Replace('\t', '*'); newCommandInfo.setDescription(description: rawDescription); break; case "flags": //run for each one of the flags associated with the command XmlNodeList flags = commandInfo.ChildNodes; foreach(XmlNode flag in flags) { FlagInfo newFlagInfo = new FlagInfo(name: flag.Attributes["name"].Value); newFlagInfo.setDescription(description: flag.InnerText); newCommandInfo.addFlag(flagInfo: newFlagInfo); } break; default: break; } } commandList.Add(item: newCommandInfo); } return commandList; }
// --------- IEnumerator HighlightObject(GUIBase_Widget sprite, FlagInfo info) { while (true) { if (info.Color != info.ChangingToColor) { sprite.Color = info.ChangingToColor; yield return(new WaitForSeconds(0.1f)); sprite.Color = info.Color; yield return(new WaitForSeconds(0.5f)); } else { yield return(new WaitForSeconds(0.4f)); } if (!info.CoroutineActive) { //Debug.LogWarning( " ### HighLight out unusual ! ### "); break; } } }
internal void Process() { Console.WriteLine("Receiving Zone assets"); //Get the packet data ZoneInfo info = new ZoneInfo(); info.AllowPrivateArena = msg.ReadBoolean(); info.CashShareRadius = msg.ReadInt32(); info.enemyShowAlias = msg.ReadBoolean(); info.enemyShowBounty = msg.ReadBoolean(); info.enemyShowEnergy = msg.ReadBoolean(); info.enemyShowHealth = msg.ReadBoolean(); info.ExperienceShareRadius = msg.ReadInt32(); info.FixedBounty = msg.ReadInt32(); info.FixedCash = msg.ReadInt32(); info.FixedExperience = msg.ReadInt32(); info.FixedPoints = msg.ReadInt32(); info.LOSAngle = msg.ReadInt32(); info.LOSDistance = msg.ReadInt32(); info.LOSShare = msg.ReadBoolean(); info.MaxArenas = msg.ReadInt32(); info.MaxPlayers = msg.ReadInt32(); info.PercentBountyToAssit = msg.ReadInt32(); info.PercentBountyToKiller = msg.ReadInt32(); info.PercentCashToAssit = msg.ReadInt32(); info.PercentCashToKiller = msg.ReadInt32(); info.PercentExperienceToAssit = msg.ReadInt32(); info.PercentExperienceToKiller = msg.ReadInt32(); info.PercentPointsToAssit = msg.ReadInt32(); info.PercentPointsToKiller = msg.ReadInt32(); info.playerShowAlias = msg.ReadBoolean(); info.playerShowBounty = msg.ReadBoolean(); info.playerShowEnergy = msg.ReadBoolean(); info.playerShowHealth = msg.ReadBoolean(); info.PointsShareRadius = msg.ReadInt32(); info.spectatorShowEnergy = msg.ReadBoolean(); info.spectatorShowEnergyShowAlias = msg.ReadBoolean(); info.spectatorShowEnergyShowBounty = msg.ReadBoolean(); info.spectatorShowEnergyShowHealth = msg.ReadBoolean(); info.Teams.AllowPrivateTeams = msg.ReadBoolean(); info.Teams.AllowTeamKills = msg.ReadBoolean(); info.Teams.AllowTeamSwitch = msg.ReadBoolean(); info.Teams.EnergyRequiredToSwitch = msg.ReadInt32(); info.Teams.ForceEvenTeams = msg.ReadBoolean(); info.Teams.MaxPrivatePlayers = msg.ReadInt32(); info.Teams.MaxPublicPlayers = msg.ReadInt32(); count = msg.ReadInt32(); for (int i = 0; i < count; i++) { TeamInfo.Team t = new TeamInfo.Team(); t.Color = msg.ReadString(); t.Name = msg.ReadString(); info.Teams.PublicTeams.Add(t); } count = msg.ReadInt32(); for (int i = 0; i < count; i++) { FlagInfo f = new FlagInfo(0); //f.DrawScale = msg.ReadInt32(); f.ID = msg.ReadInt32(); //f.ModelID = msg.ReadInt32(); f.Name = msg.ReadString(); f.Position.X = msg.ReadInt32(); f.Position.Y = msg.ReadInt32(); f.Position.Z = msg.ReadInt32(); info.Flags.Add(f); } /* info.Flags = msg.ReadBoolean(); * info.GameTypes = msg.ReadBoolean(); * info.Teams = msg.ReadBoolean(); * info.Terrains = msg.ReadBoolean(); * info.Warps = msg.ReadBoolean(); */ AssetInfo.zone = info; }
public ExtendedFlagInfo(FlagInfo flagInfo) { FlagData = Common.TrimArray(flagInfo.FlagData, flagInfo.NumBytes); Owner = flagInfo.Owner; FlagName = flagInfo.FlagName; }
static FlagsController() { flags = new Dictionary <string, FlagInfo>(); var type = typeof(T); foreach (var propertyInfo in type.GetProperties()) { var flag_attribute = propertyInfo.GetCustomAttribute <CustomFlagAttribute>(); if (flag_attribute == null) { continue; } var child_attribute = propertyInfo.GetCustomAttribute <SubFlagsAttribute>(); var flag = new FlagInfo() { Name = flag_attribute.FlagName, Setter = (obj, value) => propertyInfo.SetValue(obj, value), ChildFlags = child_attribute?.Childs }; flags[flag.Name] = flag; } if (flags.Count == 0) { Control.LogError($"{type} cannot be used as CustomFlags, no flags"); } foreach (var flagInfo in flags) { var child = flagInfo.Value.ChildFlags; if (child == null || child.Length == 0) { flagInfo.Value.Childs = null; } else { flagInfo.Value.Childs = child .Select(i => flags.TryGetValue(i, out var f) ? f : null) .Where(i => i != null) .ToList(); } } foreach (var minfo in type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic)) { var setter_attribute = minfo.GetCustomAttribute <CustomSetterAttribute>(); if (setter_attribute == null) { continue; } if (!flags.TryGetValue(setter_attribute.Flag, out var f)) { Control.LogError( $"{minfo.Name} marked as setter for {setter_attribute.Flag} but there is not such tag"); continue; } if (minfo.ReturnType != typeof(bool)) { Control.LogError( $"{minfo.Name} marked as setter for {setter_attribute.Flag} but not return Boolean"); continue; } var prams = minfo.GetParameters(); if (prams.Length != 1) { Control.LogError( $"{minfo.Name} marked as setter for {setter_attribute.Flag} but have wrong parameters"); continue; } if (prams[0].ParameterType != typeof(MechComponentDef)) { Control.LogError( $"{minfo.Name} marked as setter for {setter_attribute.Flag} but have wrong parameters"); continue; } f.CustomSetter = (obj, item) => (bool)minfo.Invoke(obj, new[] { item }); } }
public static void setLoggedInUserID(string psUserID) { HttpContext.Current.Session["AppUsrID"] = psUserID; HttpContext.Current.Session["AppIsLoggedIn"] = FlagInfo.getFlagValid(); }
protected override void DoStart(MonoRandom rnd) { // RULE SEED if (rnd.Seed != _lastGeneratedRuleSeed || _lastGeneratedFlags == null) { _lastGeneratedTextures = new Texture2D[40]; _lastGeneratedRuleSeed = rnd.Seed; _lastGeneratedFlags = GenerateFlags(rnd); _table = new int[2 * 10 * _numSlots]; for (var i = 0; i < 2 * _numSlots; i++) { var nums = Enumerable.Range(0, 10).ToArray(); rnd.ShuffleFisherYates(nums); Array.Copy(nums, 0, _table, 10 * i, 10); } DebugLog("Generated table for rule seed {0}: {1}", rnd.Seed, _table.Join(", ")); } // END OF RULE SEED _leftMaterial = LeftFlag.sharedMaterial = LeftFlag2.sharedMaterial = new Material(FlagMaterial); _rightMaterial = RightFlag.sharedMaterial = RightFlag2.sharedMaterial = new Material(FlagMaterial); var iter = 0; var flagInfos = new HashSet <FlagInfo>(); tryAgain: iter++; flagInfos.Clear(); var hasDummy = false; while (flagInfos.Count < _numSlots) { var fi = FlagInfo.Generate(hasDummy); if (fi.IsDummy) { hasDummy = true; } flagInfos.Add(fi); } if (!hasDummy) { goto tryAgain; } _flagInfos = flagInfos.ToArray().Shuffle(); var values = new List <int>(); for (var i = 0; i < _numSlots; i++) { var fi = _flagInfos[i]; var val = 0; if (fi.IsDummy) { if (fi.LeftMaritime >= 26) { val += fi.LeftMaritime - 26; } if (fi.RightMaritime >= 26) { val += fi.RightMaritime - 26; } } else if (fi.LeftMaritime < fi.Semaphore) { val += _table[20 * i + 10 - (fi.Semaphore - fi.LeftMaritime)]; val += _table[20 * i + 9 + (fi.RightMaritime - fi.Semaphore)]; } else { val += _table[20 * i + 10 - (fi.Semaphore - fi.RightMaritime)]; val += _table[20 * i + 9 + (fi.LeftMaritime - fi.Semaphore)]; } values.Add(val); } _solution = (values.Sum() + _numSlots - 1) % _numSlots; // −1 to compensate for the player’s 1-based counting if (_flagInfos[_solution].IsDummy) { goto tryAgain; } var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; for (var i = 0; i < _numSlots; i++) { Log("Position {0}: Left Maritime = {1}, Right Maritime = {2}, Semaphore = {3} (+{4}){5}", i + 1, alphabet[_flagInfos[i].LeftMaritime], alphabet[_flagInfos[i].RightMaritime], alphabet[_flagInfos[i].Semaphore], values[i], i == _solution ? " (SOLUTION)" : _flagInfos[i].IsDummy ? " (DUMMY)" : ""); } setPos(0, true); LeftButton.OnInteract += ButtonPress(LeftButton, -1); RightButton.OnInteract += ButtonPress(RightButton, 1); StartCoroutine(CheckTP()); }