private static int GetMaxHappiness(Stack<string> atTable, List<string> free, Conditions conditions) { if (free.Count == 1) { atTable.Push(free.Single()); var table = new Table(atTable.ToList()); var totalHappiness = table.CalcTotalHappiness(conditions); atTable.Pop(); return totalHappiness; } var maxHappiness = 0; for (int i = 0; i < free.Count; i++) { atTable.Push(free[i]); free.RemoveAt(i); var happiness = GetMaxHappiness(atTable, free, conditions); if (happiness > maxHappiness) { maxHappiness = happiness; } var person = atTable.Pop(); free.Insert(i, person); } return maxHappiness; }
public MissionCondition() { _condition = Conditions.None; _checkValue = 0; _name = GetName(_condition); //_mission = null; }
/** * Creates a new ConversationReference * * @param idTarget * the id of the conversation that is referenced */ public ConversationReference(string idTarget) { this.idTarget = idTarget; documentation = null; conditions = new Conditions(); }
public QueryConditionNode(QField lvalue, Conditions conditions, QConst rvalue) : base() { _RValue = rvalue; _Condition = conditions; _LValue = lvalue; }
public static double ApplyCondition(double quality, Conditions condition) { switch(condition) { case Conditions.Poor: { return quality * 0.5; } case Conditions.Normal: { return quality * 1; } case Conditions.Good: { return quality * 1.5; } case Conditions.Excellent: { return quality * 4; } default: { return quality * 1; } } }
public static Conditions GetCondition(Random rng, Conditions previousCondition) { if(previousCondition == Conditions.Excellent) { return Conditions.Poor; } if(previousCondition == Conditions.Good || previousCondition == Conditions.Poor) { return Conditions.Normal; } int seed = rng.Next(1, 101); if(seed > 75) { if(seed > 98) { return Conditions.Excellent; } else { return Conditions.Good; } } else { return Conditions.Normal; } }
/** * Creates a new Resources. */ public ResourcesUni() { assets = new Dictionary<string, string>(); // add the hash map of asset AllElements with asset AllElementsWithAssets.addAsset(assets); conditions = new Conditions(); name = "No name"; }
public ConditionsJson MapConditions2Json(Conditions json) { return new ConditionsJson() { Chop = json.Chop, Flatwater = json.Flatwater, Waves = json.Waves }; }
private Controller() { actionStack = new List<IAction>(); modifierStack = new List<IModifier>(); rng = new Random(); condition = Calc.GetCondition(rng); PopulateActionList(); PopulateModifierList(); }
public Car(string name, string details, int price, string type, string maker, int year, Conditions p):base(name, details, price) { this.Type = type; this.Maker = maker; this.YearMade = year; this.state = p; }
public MissionCondition(Conditions condition, int checkValue, Mission mission = null) { _condition = condition; _checkValue = checkValue; _name = GetName(_condition); //_mission = mission; //if (_mission != null) // _missionId = _mission.MissionId; }
/** * Creates a new Exit * * @param x * The horizontal coordinate of the upper left corner of the exit * @param y * The vertical coordinate of the upper left corner of the exit * @param width * The width of the exit * @param height * The height of the exit */ public Barrier(string id, int x, int y, int width, int height) : base(id) { this.x = x; this.y = y; this.width = width; this.height = height; conditions = new Conditions(); }
/** * Default constructor * * @param id * Id of the rule * @param importance * Importance of the rule */ public TimedAssessmentRule(string id, int importance, bool repeatRule) : base(id, importance, repeatRule) { effects = new List<TimedAssessmentEffect>(); this.endConditions = new Conditions(); usesEndConditions = true; effectIndex = -1; elapsedTime = 0; isDone = false; }
/** * Creates a new ElementReference * * @param idTarget * the id of the element that is referenced * @param x * the horizontal position of the element * @param y * the vertical position of the element */ public ElementReference(string idTarget, int x, int y) { this.idTarget = idTarget; this.x = x; this.y = y; this.scale = 1; this.layer = -1; documentation = null; conditions = new Conditions(); influenceArea = new InfluenceArea(); }
/** * Creates a new Exit * * @param rectangular * * @param x * The horizontal coordinate of the upper left corner of the exit * @param y * The vertical coordinate of the upper left corner of the exit * @param width * The width of the exit * @param height * The height of the exit */ public ActiveArea(string id, bool rectangular, int x, int y, int width, int height) : base(id) { this.rectangular = rectangular; this.x = x; this.y = y; this.width = width; this.height = height; Vector2s = new List<Vector2>(); conditions = new Conditions(); influenceArea = new InfluenceArea(); }
/** * Creates a new NextScene * * @param nextSceneId * the id of the next scene */ public NextScene(string nextSceneId) { this.nextSceneId = nextSceneId; destinyX = int.MinValue; destinyY = int.MinValue; conditions = new Conditions(); effects = new Effects(); postEffects = new Effects(); transitionType = NextSceneEnumTransitionType.NO_TRANSITION; transitionTime = 0; }
public override void ParseElement(XmlElement element) { XmlNodeList names = element.SelectNodes("name"), briefs = element.SelectNodes("brief"), detaileds = element.SelectNodes("detailed"), conditions = element.SelectNodes("condition"); string tmpArgVal; foreach (XmlElement el in names) { string soundPath = ""; tmpArgVal = el.GetAttribute("soundPath"); if (!string.IsNullOrEmpty(tmpArgVal)) { soundPath = tmpArgVal; } description.setNameSoundPath(soundPath); description.setName(el.InnerText); } foreach (XmlElement el in briefs) { string soundPath = ""; tmpArgVal = el.GetAttribute("soundPath"); if (!string.IsNullOrEmpty(tmpArgVal)) { soundPath = tmpArgVal; } description.setDescriptionSoundPath(soundPath); description.setDescription(el.InnerText); } foreach (XmlElement el in detaileds) { string soundPath = ""; tmpArgVal = el.GetAttribute("soundPath"); if (!string.IsNullOrEmpty(tmpArgVal)) { soundPath = tmpArgVal; } description.setDetailedDescriptionSoundPath(soundPath); description.setDetailedDescription(el.InnerText); } foreach (XmlElement el in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(el); this.description.setConditions(currentConditions); } }
public int CalcTotalHappiness(Conditions conditions) { var totalHappiness = 0; for (int i = 0; i < People.Count; i++) { var subjectName = People[i]; string objectNameLeft; string objectNameRight; GetNeighbors(i, out objectNameLeft, out objectNameRight); totalHappiness += conditions.GetBySubjectAndObjectNames(subjectName, objectNameLeft).HappinessUnits; totalHappiness += conditions.GetBySubjectAndObjectNames(subjectName, objectNameRight).HappinessUnits; } return totalHappiness; }
public void CloseResults() { EnsureStateNotAlreadySet(Conditions.Disposed); // We allow some resilience for writers that stream individual results to // the log without explicit opening/closing the results object if ((_writeConditions & Conditions.ResultsInitialized) != Conditions.ResultsInitialized || (_writeConditions & Conditions.ResultsClosed) == Conditions.ResultsClosed) { return; } _jsonWriter.WriteEndArray(); _writeConditions |= Conditions.ResultsClosed; }
public string ExecuteAction(ICraft craft, ICrafter crafter, List<IModifier> activeModifiers, Random rng, Conditions condition) { string result = String.Empty; //Success! wasSuccessful = true; result = ActionName + " used! " + Math.Abs(DurabilityUsed) + " durability restored."; craft.IncrementStep(); craft.UpdateDurability(DurabilityUsed); crafter.UpdateCP(CPCost); this.actionUsed = true; return result; }
public Timer(long time, Conditions init, Conditions end, Effects effect, Effects postEffect) { this.seconds = time; this.initCond = init; this.endCond = end; this.effect = effect; this.postEffect = postEffect; usesEndCondition = true; runsInLoop = true; multipleStarts = true; showTime = false; displayName = "timer"; countDown = true; showWhenStopped = false; }
public string ExecuteAction(ICraft craft, ICrafter crafter, List<IModifier> activeModifiers, Random rng, Conditions condition) { string result = String.Empty; //Success! wasSuccessful = true; double progress = Calc.Progress(craft.RecipeLevel, craft.ItemLevel, crafter.CrafterLevel, crafter.Craftsmanship) * ProgressModifier; result = ActionName + " successful! Progress increased by " + Math.Round(progress, 0, MidpointRounding.ToEven); craft.UpdateProgress(progress); craft.IncrementStep(); craft.UpdateDurability(DurabilityUsed); crafter.UpdateCP(CPCost); this.actionUsed = true; return result; }
public override void ParseElement(XmlElement element) { XmlNodeList conditions = element.SelectNodes("condition"); string tmpArgVal; int x = 0, y = 0, width = 0, height = 0; tmpArgVal = element.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("width"); if (!string.IsNullOrEmpty(tmpArgVal)) { width = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("height"); if (!string.IsNullOrEmpty(tmpArgVal)) { height = int.Parse(tmpArgVal); } barrier = new Barrier(generateId(), x, y, width, height); if (element.SelectSingleNode("documentation") != null) barrier.setDocumentation(element.SelectSingleNode("documentation").InnerText); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); this.barrier.setConditions(currentConditions); } scene.addBarrier(barrier); }
public static Conditions GetCurrentConditions(string location) { Conditions conditions = new Conditions(); XmlDocument xmlConditions = new XmlDocument(); xmlConditions.Load(string.Format("http://www.google.com/ig/api?weather={0}", location)); if (xmlConditions.SelectSingleNode("xml_api_reply/weather/problem_cause") != null) { conditions = null; } else { conditions.City = xmlConditions.SelectSingleNode("/xml_api_reply/weather/forecast_information/city").Attributes["data"].InnerText; conditions.Condition = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/condition").Attributes["data"].InnerText; conditions.TempC = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/temp_c").Attributes["data"].InnerText; conditions.TempF = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/temp_f").Attributes["data"].InnerText; conditions.Humidity = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/humidity").Attributes["data"].InnerText; conditions.Wind = xmlConditions.SelectSingleNode("/xml_api_reply/weather/current_conditions/wind_condition").Attributes["data"].InnerText; } return conditions; }
/// <summary> /// Retrieve the name from condition, to be used for initialization only. /// </summary> /// <param name="condition"></param> /// <returns></returns> private static string GetName(Conditions condition) { switch (condition) { case Conditions.NumberInBagsSuperiorTo: return "if > in Bags"; case Conditions.NumberInBagsSuperiorOrEqualTo: return "if >= in Bags"; case Conditions.KeepNumberInBags: return "Keep in Bags at least"; case Conditions.None: return "Deactivated"; default: GarrisonButler.Diagnostic("This rule has not been implemented!"); break; } return "Not Implemented"; }
private int LoadDescret(int id) { DBWorker dbConnection = new DBWorker(); if (dbConnection.isConnected) { DataTable modelTable = dbConnection.LoadModel(DbSelect.SelectDes, id); if (W.task == null) W.task = new DataPlavka(dbConnection.GetPlavka(DbSelect.Columns, null)); //берем список параметров if (modelTable == null) return -1; if (modelTable.Rows.Count == 0) return 0; W.modelDescret = new DescrModel(id); W.modelDescret.date = Convert.ToDateTime(modelTable.Rows[0]["DATE_DES"]); W.modelDescret.GOST = modelTable.Rows[0]["GOST_ID"].ToString(); W.modelDescret.mark = modelTable.Rows[0]["MARKA"].ToString() + " " + modelTable.Rows[0]["VYTYAZHKA"].ToString(); //W.task.GOST = W.modelDescret.GOST; //W.task.mark = W.modelDescret.mark; W.modelDescret.alpha = Convert.ToDouble(modelTable.Rows[0]["ALPHA"]); W.modelDescret.beta = Convert.ToDouble(modelTable.Rows[0]["BETA"]); W.modelDescret.criteria = Convert.ToDouble(modelTable.Rows[0]["U"]); string ys = modelTable.Rows[0]["YS"].ToString(); string[] ys2 = ys.Split('@'); for (int i = 0; i < ys2.Length; i++) W.modelDescret.y.Add(Convert.ToInt32(ys2[i])); //установили У //формируем массив факторов Х for (int i = 0; i < W.task.xAll.Count; i++) if (modelTable.Rows[0][W.task.xAll[i].name] != System.DBNull.Value) W.modelDescret.x.Add(i); for (int i = 0; i < W.modelDescret.x.Count; i++) { double lower = Convert.ToDouble(modelTable.Rows[0][W.task.xAll[W.modelDescret.x[i]].name + "_MIN"]); double upper = Convert.ToDouble(modelTable.Rows[0][W.task.xAll[W.modelDescret.x[i]].name]); string descr = W.task.xAll[W.modelDescret.x[i]].description; Conditions c = new Conditions(lower, upper, descr); W.modelDescret.xBounds.Add(c); } } dbConnection.CloseConnection(); return 1; }
/*private static ConditionChecker instance; public static ConditionChecker Instance { get { if (this.instance == null) this.instance = new ConditionChecker (); return instance; } }*/ public static bool check(Conditions conditions) { foreach(Condition c in conditions.getSimpleConditions ()){ if (!check (c)) return false; } for(int i = 0; i < conditions.getEitherConditionsBlockCount (); i++){ bool block = false; foreach (Condition c in conditions.getEitherConditions(i)) { block |= check (c); if (block) break; } if (!block) return false; } return true; }
private static void ParseConditions(string[] lines, out List<string> people, out Conditions conditions) { var regex = new Regex(@"^(\w+) .+(gain|lose) (\d+).+to (\w+)\."); var conditionsList = new List<Condition>(); people = new List<string>(); foreach (var line in lines) { var match = regex.Match(line); var groups = match.Groups; var subjectName = groups[1].Value; var happinessSign = groups[2].Value == "gain" ? 1 : -1; var happinesUnitsCount = int.Parse(groups[3].Value); var objectName = groups[4].Value; if (!people.Contains(subjectName)) { people.Add(subjectName); } var condition = new Condition(subjectName, objectName, happinessSign*happinesUnitsCount); conditionsList.Add(condition); } conditions = new Conditions(conditionsList); }
public ActionResult AddCheck(string appName, string tableName, FormCollection fc) { DBApp app = new DBApp() { Name = appName, ConnectionString = (new Entities()).Database.Connection.ConnectionString }; DBTable table = app.GetTable(tableName); foreach (string checkConstraint in table.GetCheckConstraints()) //constraint name control in table { if (checkConstraint == "CHK_" + appName + "_" + tableName + "_" + fc["checkName"]) { TempData["message-error"] = "Check constraint with name " + checkConstraint + " is already exist."; return RedirectToAction("Index", new { @appName = appName }); } } int i = 0; Conditions con = new Conditions(new SqlQuery()); Condition_Operators ope = new Condition_Operators(con); Condition_concat concat = new Condition_concat(con); while (fc["column[" + i + "]"] != null) { DBColumn col = table.columns.SingleOrDefault(x => x.Name == fc["column[" + i + "]"]); object val = table.ConvertValue(col, fc["value[" + i + "]"]); con.column(col.Name); con.isCheck = true; if (i != 0) concat.and(); ope = table.GetConditionOperators(con, fc["conOperator[" + i + "]"], val); i++; } table.AddCheck(fc["checkName"], con); app.SaveChanges(); TempData["message-success"] = "Check constraint " + fc["checkName"] + " was successfully added into table " + tableName + "."; return RedirectToAction("Index", new { @appName = appName }); }
/// <summary> /// Retrieve the name from condition, to be used for initialization only. /// </summary> /// <param name="condition"></param> /// <returns></returns> private static string GetName(Conditions condition) { switch (condition) { case Conditions.NumberPlayerHasSuperiorTo: return "if I have > #"; case Conditions.NumberPlayerHasSuperiorOrEqualTo: return "if I have >= #"; case Conditions.NumberPlayerHasInferiorTo: return "if I have < #"; case Conditions.NumberPlayerHasInferiorOrEqualTo: return "if I have <= #"; case Conditions.NumberRewardSuperiorTo: return "if rewards > #"; case Conditions.NumberRewardSuperiorOrEqualTo: return "if rewards >= #"; case Conditions.NumberRewardInferiorTo: return "if rewards < #"; case Conditions.NumberRewardInferiorOrEqualTo: return "if rewards <= #"; case Conditions.None: return "Deactivated"; default: GarrisonButler.Diagnostic("This mission rule has not been implemented!"); break; } return "Not Implemented"; }
public override void ParseElement(XmlElement element) { XmlNodeList points = element.SelectNodes("point"), descriptionss = element.SelectNodes("description"), actionss = element.SelectNodes("actions"), conditions = element.SelectNodes("condition"); //, //effects = element.SelectNodes("effect"); string tmpArgVal; int x = 0, y = 0, width = 0, height = 0; string id = null; bool rectangular = true; int influenceX = 0, influenceY = 0, influenceWidth = 0, influenceHeight = 0; bool hasInfluence = false; tmpArgVal = element.GetAttribute("rectangular"); if (!string.IsNullOrEmpty(tmpArgVal)) { rectangular = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("width"); if (!string.IsNullOrEmpty(tmpArgVal)) { width = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("height"); if (!string.IsNullOrEmpty(tmpArgVal)) { height = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("id"); if (!string.IsNullOrEmpty(tmpArgVal)) { id = tmpArgVal; } tmpArgVal = element.GetAttribute("hasInfluenceArea"); if (!string.IsNullOrEmpty(tmpArgVal)) { hasInfluence = tmpArgVal.Equals("yes"); } tmpArgVal = element.GetAttribute("influenceX"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceX = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("influenceY"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceY = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("influenceWidth"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceWidth = int.Parse(tmpArgVal); } tmpArgVal = element.GetAttribute("influenceHeight"); if (!string.IsNullOrEmpty(tmpArgVal)) { influenceHeight = int.Parse(tmpArgVal); } activeArea = new ActiveArea((id == null ? generateId() : id), rectangular, x, y, width, height); if (hasInfluence) { InfluenceArea influenceArea = new InfluenceArea(influenceX, influenceY, influenceWidth, influenceHeight); activeArea.setInfluenceArea(influenceArea); } if (element.SelectSingleNode("documentation") != null) { activeArea.setDocumentation(element.SelectSingleNode("documentation").InnerText); } descriptions = new List <Description>(); activeArea.setDescriptions(descriptions); foreach (XmlElement el in descriptionss) { description = new Description(); new DescriptionsSubParser_(description, chapter).ParseElement(el); this.descriptions.Add(description); } foreach (XmlElement el in points) { if (activeArea != null) { int x_ = 0, y_ = 0; tmpArgVal = el.GetAttribute("x"); if (!string.IsNullOrEmpty(tmpArgVal)) { x_ = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("y"); if (!string.IsNullOrEmpty(tmpArgVal)) { y_ = int.Parse(tmpArgVal); } Vector2 point = new Vector2(x_, y_); activeArea.addVector2(point); } } foreach (XmlElement el in actionss) { new ActionsSubParser_(chapter, activeArea).ParseElement(el); } foreach (XmlElement el in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(el); this.activeArea.setConditions(currentConditions); } scene.addActiveArea(activeArea); }
public static Condition ByName(string name) { return(Conditions.FirstOrDefault(a => String.Compare(a.Name, name, true) == 0)); }
public override void ParseElement(XmlElement element) { XmlNodeList resourcess = element.SelectNodes("resources"), descriptionss = element.SelectNodes("description"), assets, conditions, frontcolors, bordercolors, textcolors = element.SelectNodes("textcolor"), conversationsref = element.SelectNodes("conversation-ref"), voices = element.SelectNodes("voice"), actionss = element.SelectNodes("actions"); string tmpArgVal; string characterId = element.GetAttribute("id"); npc = new NPC(characterId); descriptions = new List <Description>(); npc.setDescriptions(descriptions); if (element.SelectSingleNode("documentation") != null) { npc.setDocumentation(element.SelectSingleNode("documentation").InnerText); } foreach (XmlElement el in resourcess) { currentResources = new ResourcesUni(); tmpArgVal = el.GetAttribute("name"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentResources.setName(el.GetAttribute(tmpArgVal)); } assets = el.SelectNodes("asset"); foreach (XmlElement ell in assets) { string type = ""; string path = ""; tmpArgVal = ell.GetAttribute("type"); if (!string.IsNullOrEmpty(tmpArgVal)) { type = tmpArgVal; } tmpArgVal = ell.GetAttribute("uri"); if (!string.IsNullOrEmpty(tmpArgVal)) { path = tmpArgVal; } currentResources.addAsset(type, path); } conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); currentResources.setConditions(currentConditions); } npc.addResources(currentResources); } foreach (XmlElement el in textcolors) { tmpArgVal = el.GetAttribute("showsSpeechBubble"); if (!string.IsNullOrEmpty(tmpArgVal)) { npc.setShowsSpeechBubbles(tmpArgVal.Equals("yes")); } tmpArgVal = el.GetAttribute("bubbleBkgColor"); if (!string.IsNullOrEmpty(tmpArgVal)) { npc.setBubbleBkgColor(tmpArgVal); } tmpArgVal = el.GetAttribute("bubbleBorderColor"); if (!string.IsNullOrEmpty(tmpArgVal)) { npc.setBubbleBorderColor(tmpArgVal); } frontcolors = el.SelectNodes("frontcolor"); foreach (XmlElement ell in frontcolors) { string color = ""; tmpArgVal = ell.GetAttribute("color"); if (!string.IsNullOrEmpty(tmpArgVal)) { color = tmpArgVal; } npc.setTextFrontColor(color); } bordercolors = el.SelectNodes("bordercolor"); foreach (XmlElement ell in bordercolors) { string color = ""; tmpArgVal = ell.GetAttribute("color"); if (!string.IsNullOrEmpty(tmpArgVal)) { color = tmpArgVal; } npc.setTextBorderColor(color); } } foreach (XmlElement el in conversationsref) { string idTarget = ""; tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { idTarget = tmpArgVal; } conversationReference = new ConversationReference(idTarget); conditions = el.SelectNodes("condition"); foreach (XmlElement ell in conditions) { currentConditions = new Conditions(); new ConditionSubParser_(currentConditions, chapter).ParseElement(ell); conversationReference.setConditions(currentConditions); } conversationReference.setDocumentation(el.SelectSingleNode("documentation").InnerText); Action action = new Action(Action.TALK_TO); action.setConditions(conversationReference.getConditions()); action.setDocumentation(conversationReference.getDocumentation()); TriggerConversationEffect effect = new TriggerConversationEffect(conversationReference.getTargetId()); action.getEffects().add(effect); npc.addAction(action); } foreach (XmlElement el in voices) { string voice = ""; string response; bool alwaysSynthesizer = false; tmpArgVal = el.GetAttribute("name"); if (!string.IsNullOrEmpty(tmpArgVal)) { voice = tmpArgVal; } tmpArgVal = el.GetAttribute("synthesizeAlways"); if (!string.IsNullOrEmpty(tmpArgVal)) { response = tmpArgVal; if (response.Equals("yes")) { alwaysSynthesizer = true; } } npc.setAlwaysSynthesizer(alwaysSynthesizer); npc.setVoice(voice); } foreach (XmlElement el in actionss) { new ActionsSubParser_(chapter, npc).ParseElement(el); } foreach (XmlElement el in descriptionss) { description = new Description(); new DescriptionsSubParser_(description, chapter).ParseElement(el); this.descriptions.Add(description); } chapter.addCharacter(npc); }
public Condition EndsWith(Expression expression) => Conditions.EndsWith(this, expression);
internal void Clear() { NodeSet.Clear(); Conditions.Clear(); Addins.Clear(); }
/// <summary> /// 发送消息 /// </summary> /// <param name="msgType"></param> /// <param name="message"></param> public void SendMessage(MsgType msgType, Conditions data) { DataResponsible.SendMsg(msgType, data); }
public void ThirdTaskTest(int a, int b, int c, int [] expected) { //Пользователь вводит 3 числа (A, B и С). Выведите их в консоль в порядке возрастания int[] actual = Conditions.ThirdTask(a, b, c); Assert.AreEqual(expected, actual); }
public Condition LessThanOrEqualTo(Expression rhs) => Conditions.LessThanOrEqualTo(this, rhs);
public Condition GreaterThan(Expression rhs) => Conditions.GreaterThan(this, rhs);
public Condition Matches(Expression expression) => Conditions.Matches(this, expression);
public Condition GreaterThanOEqualTo(Expression rhs) => Conditions.GreaterThanOEqualTo(this, rhs);
public void SetContiditon(Conditions condition) { UnityMainThreadDispatcher.Instance().Enqueue(SetContiditonCoroutine(condition)); }
public StatValueRestriction(Stats stat, Conditions condition, int value) { Stat = stat; Condition = condition; Value = value; }
public Condition IsFalse() => Conditions.IsEqualTo(this, Cypher.LiteralFalse());
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { using (s.EnterOwnerBookmark(this)) { s.StreamAttribute("version", ref Version); using (s.EnterCursorBookmark("Limits")) Limits.Serialize(s); using (var bm = s.EnterCursorBookmarkOpt("SingleEncodings", SingleEncodings, Predicates.HasItems)) if (bm.IsNotNull) { s.StreamableElements("Traits", SingleEncodings); } using (s.EnterCursorBookmark("EnumTypes")) s.StreamableElements("Type", Enums, e => !e.IsCodeEnum); if (s.IsReading) { SingleEncodings.Sort((x, y) => string.CompareOrdinal(x.Name, y.Name)); Enums.Sort((x, y) => string.CompareOrdinal(x.Name, y.Name)); } using (s.EnterCursorBookmark("VariableSets")) s.StreamableElements("Set", VariableSets, "type", MegaloScriptProtoVariableSet.StreamSetType); using (s.EnterCursorBookmark("ValueTypes")) s.StreamElements("Type", ValueTypes, this, SerializeValueType); if (s.IsReading) { ValueTypes.ForEach(type => NameToValueType.Add(ValueTypeNames[type.NameIndex], type)); } using (s.EnterCursorBookmark("VariableReferenceTypes")) s.StreamableElements("Type", VariableRefTypes, "type", MegaloScriptProtoVariableReference.StreamType); using (s.EnterCursorBookmark("Conditions")) s.StreamableElements("Condition", Conditions); using (s.EnterCursorBookmark("ActionTemplates")) s.StreamableElements("Template", ActionTemplates); using (s.EnterCursorBookmark("Actions")) s.StreamableElements("Action", Actions); if (s.IsReading) { mConditionTypeBitLength = Bits.GetMaxEnumBits(Conditions.Count); mActionTypeBitLength = Bits.GetMaxEnumBits(Actions.Count); Conditions.ForEach(cond => NameToConditionMap.Add(cond.Name, cond)); Actions.ForEach(action => NameToActionMap.Add(action.Name, action)); TeamDesignatorValueType = NameToValueType["TeamDesignator"]; ObjectTypeIndexValueType = NameToValueType["ObjectTypeIndex"]; ForEachAction = NameToActionMap["for_each"]; if (Limits.SupportsVirtualTriggers) { BeginAction = NameToActionMap["begin"]; } ObjectReferenceWithPlayerVarIndex.Initialize(this); } } }
public Condition IsNotNull() => Conditions.IsNotNull(this);
protected override void CreateConditions() { this.Conditions.Clear(); Conditions.Add(new Condition() { Day = Constant.WEEKEND_MORNING, Place = PlaceType.Home, CompanyType = CompanyType.Alone }); Conditions.Add(new Condition() { Day = Constant.WEEKEND_MORNING, Place = PlaceType.Outside, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.WEEKEND_MORNING, Place = PlaceType.Place, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.WEEKEND_EVENING, Place = PlaceType.Home, CompanyType = CompanyType.Alone }); Conditions.Add(new Condition() { Day = Constant.WEEKEND_EVENING, Place = PlaceType.Outside, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.WEEKEND_EVENING, Place = PlaceType.Place, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.NIGHT, Place = PlaceType.Home, CompanyType = CompanyType.Alone }); Conditions.Add(new Condition() { Day = Constant.NIGHT, Place = PlaceType.Outside, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.NIGHT, Place = PlaceType.Place, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.WORKDAY_MORNING, Place = PlaceType.Home, CompanyType = CompanyType.Alone }); Conditions.Add(new Condition() { Day = Constant.WORKDAY_MORNING, Place = PlaceType.Outside, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.WORKDAY_MORNING, Place = PlaceType.Place, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.PARA_1, Place = PlaceType.Home, CompanyType = CompanyType.Alone }); Conditions.Add(new Condition() { Day = Constant.PARA_1, Place = PlaceType.Outside, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.PARA_1, Place = PlaceType.Place, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.PARA_2, Place = PlaceType.Home, CompanyType = CompanyType.Alone }); Conditions.Add(new Condition() { Day = Constant.PARA_2, Place = PlaceType.Outside, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.PARA_2, Place = PlaceType.Place, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.PARA_3, Place = PlaceType.Home, CompanyType = CompanyType.Alone }); Conditions.Add(new Condition() { Day = Constant.PARA_3, Place = PlaceType.Outside, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.PARA_3, Place = PlaceType.Place, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.WORKDAY_EVENING, Place = PlaceType.Home, CompanyType = CompanyType.Alone }); Conditions.Add(new Condition() { Day = Constant.WORKDAY_EVENING, Place = PlaceType.Outside, CompanyType = CompanyType.WithGF }); Conditions.Add(new Condition() { Day = Constant.WORKDAY_EVENING, Place = PlaceType.Place, CompanyType = CompanyType.WithGF }); }
public void SaveLayoutToStream(Stream stream) { BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Serialize(stream, Conditions.ToList()); }
public Condition StartsWith(Expression expression) => Conditions.StartsWith(this, expression);
internal override void Verify(string location, StringCollection errors) { VerifyNotEmpty(location + "ExtensionPoint", errors, Path, "path"); NodeSet.Verify(location + "ExtensionPoint (" + Path + ")/", errors); Conditions.Verify(location + "ExtensionPoint (" + Path + ")/", errors); }
public Condition Contains(Expression expression) => Conditions.Contains(this, expression);
public void FromConditions(Conditions conditions) { m_Count = 0; s_TypeIndex = 0; var semanticTagLength = conditions.GetTypeCount(out ISemanticTagCondition[] semanticTagConditions); if (semanticTagLength > 0) { m_Count += semanticTagLength; TypeToIndex[typeof(System.Boolean)] = s_TypeIndex; var list = new List <Dictionary <int, float> >(); list.Fill(semanticTagLength); AllRatings.Add(list); m_SemanticTagListIndex = s_TypeIndex; s_TypeIndex++; } var intLength = conditions.GetTypeCount(out ICondition <System.Int32>[] intConditions); if (intLength > 0) { m_Count += intLength; TypeToIndex[typeof(System.Int32)] = s_TypeIndex; var list = new List <Dictionary <int, float> >(); list.Fill(intLength); AllRatings.Add(list); s_TypeIndex++; } var floatLength = conditions.GetTypeCount(out ICondition <System.Single>[] floatConditions); if (floatLength > 0) { m_Count += floatLength; TypeToIndex[typeof(System.Single)] = s_TypeIndex; var list = new List <Dictionary <int, float> >(); list.Fill(floatLength); AllRatings.Add(list); s_TypeIndex++; } var stringLength = conditions.GetTypeCount(out ICondition <System.String>[] stringConditions); if (stringLength > 0) { m_Count += stringLength; TypeToIndex[typeof(System.String)] = s_TypeIndex; var list = new List <Dictionary <int, float> >(); list.Fill(stringLength); AllRatings.Add(list); s_TypeIndex++; } var poseLength = conditions.GetTypeCount(out ICondition <UnityEngine.Pose>[] poseConditions); if (poseLength > 0) { m_Count += poseLength; TypeToIndex[typeof(UnityEngine.Pose)] = s_TypeIndex; var list = new List <Dictionary <int, float> >(); list.Fill(poseLength); AllRatings.Add(list); s_TypeIndex++; } var vector2Length = conditions.GetTypeCount(out ICondition <UnityEngine.Vector2>[] vector2Conditions); if (vector2Length > 0) { m_Count += vector2Length; TypeToIndex[typeof(UnityEngine.Vector2)] = s_TypeIndex; var list = new List <Dictionary <int, float> >(); list.Fill(vector2Length); AllRatings.Add(list); s_TypeIndex++; } }
public Condition LessThan(Expression rhs) => Conditions.LessThan(this, rhs);
public Condition IsNotEqualTo(Expression rhs) => Conditions.IsNotEqualTo(this, rhs);
public List <Row> ExtractExcelValues(string xlsxFilePath, string sheetName) { Rows = new List <Row>(); using (SpreadsheetDocument myWorkbook = SpreadsheetDocument.Open(xlsxFilePath, true)) { //Access the main Workbook part, which contains data WorkbookPart workbookPart = myWorkbook.WorkbookPart; WorksheetPart worksheetPart = null; var sheets = workbookPart.Workbook.Descendants <Sheet>(); foreach (var sheet in sheets) { if (sheet.Name.ToString().ToLower() == sheetName.ToLower()) { worksheetPart = (WorksheetPart)workbookPart.GetPartById(sheet.Id); } } var columnCount = 0; var stringTablePart = workbookPart.SharedStringTablePart; if (worksheetPart != null) { DocumentFormat.OpenXml.Spreadsheet.Row lastRow = worksheetPart.Worksheet.Descendants <DocumentFormat.OpenXml.Spreadsheet.Row>().LastOrDefault(); DocumentFormat.OpenXml.Spreadsheet.Row firstRow = worksheetPart.Worksheet.Descendants <DocumentFormat.OpenXml.Spreadsheet.Row>().FirstOrDefault(); if (firstRow != null) { foreach (Cell c in firstRow.ChildElements) { columnCount++; var value = GetValue(c, stringTablePart); if (value.StartsWith(_conditionText)) { Conditions.Add(columnCount, new Child() { Name = value.Replace(_conditionText, "") }); } if (value.StartsWith(_actionText)) { Actions.Add(columnCount, new Child() { Name = value.Replace(_actionText, "") }); } } } if (lastRow != null) { for (int i = 2; i <= lastRow.RowIndex; i++) { var row = new Row(); bool empty = true; DocumentFormat.OpenXml.Spreadsheet.Row spreadSheetRow = worksheetPart.Worksheet.Descendants <DocumentFormat.OpenXml.Spreadsheet.Row>().Where(r => i == r.RowIndex).FirstOrDefault(); int j = 0; if (spreadSheetRow != null) { var columnNumber = 0; foreach (Cell c in spreadSheetRow.ChildElements) { columnNumber++; //Get cell value string value = GetValue(c, stringTablePart); if (IsCondition(columnNumber)) { row.Conditions.Add(new Condition { ColumnNumber = columnNumber, Value = value }); AddConditionValue(columnNumber, value); } else { row.Actions.Add(new Action { ColumnNumber = columnNumber, Value = value }); AddActionValue(columnNumber, value); } if (!string.IsNullOrEmpty(value) && value != "") { empty = false; } j++; if (j == columnCount) { break; } } if (empty) { break; } Rows.Add(row); } } } } } return(Rows); }
public void IsTrue(Conditions condition, bool?expectLinux, bool?expect64Bit) { Assert.That(condition.AreTrue(), Is.EqualTo(ExpectedResult(expectLinux, expect64Bit))); }
public Condition Matches(string pattern) => Conditions.Matches(this, Cypher.LiteralOf(pattern));
/// <summary> /// Adds the specified message. /// </summary> /// <param name="message">The message.</param> /// <param name="conditions">The conditions.</param> public static void Add(NetworkMessage message, Conditions conditions) { message.AddPacketType(GamePacketType.SelfConditions); message.AddConditions(conditions); }
public override void Draw() { GUILayout.BeginVertical(GUI.skin.box); { Conditions removeCond = null; int c = 0; EditorGUILayout.Space(); foreach (Conditions cond in list) { GUILayout.BeginVertical(GUI.skin.box); { EditorGUILayout.LabelField("Condition " + (c + 1)); cond.type = (Conditions.CondType)EditorGUILayout.EnumPopup("条件", cond.type); EditorGUILayout.Space(); cond.valueTypeA = (Conditions.ValueType)EditorGUILayout.EnumPopup("値A の 種類", cond.valueTypeA); switch (cond.valueTypeA) { case Conditions.ValueType.Raw: cond.SysTypeA = (Value.ValueType)EditorGUILayout.EnumPopup("値A の タイプ", cond.SysTypeA); switch (cond.SysTypeA) { case Value.ValueType.Int: cond.rawInt = EditorGUILayout.IntField("値(int)", cond.rawInt); break; case Value.ValueType.Float: cond.rawFloat = EditorGUILayout.FloatField("値(float)", cond.rawFloat); break; case Value.ValueType.Bool: cond.rawBool = EditorGUILayout.Toggle("値(bool)", cond.rawBool); break; case Value.ValueType.String: cond.rawString = EditorGUILayout.TextField("値(string)", cond.rawString); break; } break; case Conditions.ValueType.Variable: if (GUILayout.Button("Select ValueA")) { var n = gameObject.transform.FindChild("LocalVariable"); if (n != null) { var values = n.gameObject.GetComponents <Value> (); var menu = new GenericMenu(); var i = 0; foreach (Value v in values) { menu.AddItem(new GUIContent(i + "." + v.valueName), false, GenClickDel, new ArrayList() { "A", cond, v }); i++; } menu.ShowAsContext(); } } if (cond.valueA != null) { EditorGUILayout.LabelField("リンク済み: " + cond.valueA.valueName); } else { EditorGUILayout.HelpBox("条件の接続先が見つかりません。", MessageType.Error); } break; } } if (GUILayout.Button("Select ValueB")) { var n = gameObject.transform.FindChild("LocalVariable"); if (n != null) { var values = n.gameObject.GetComponents <Value> (); var menu = new GenericMenu(); var i = 0; foreach (Value v in values) { menu.AddItem(new GUIContent(i + "." + v.valueName), false, GenClickDel, new ArrayList() { "B", cond, v }); i++; } menu.ShowAsContext(); } } if (cond.valueB != null) { EditorGUILayout.LabelField("リンク済み: " + cond.valueB.valueName); } else { EditorGUILayout.HelpBox("条件の接続先が見つかりません。", MessageType.Error); } GUILayout.BeginHorizontal(GUI.skin.box); { if (GUILayout.Button("削除")) { if (EditorUtility.DisplayDialog("Warning", "Condition " + (c + 1) + "を削除しますか?", "OK", "キャンセル")) { removeCond = cond; } } if (cond.next != null) { if (GUILayout.Button("リンクを解除")) { if (EditorUtility.DisplayDialog("Warning", "Condition " + (c + 1) + "のリンクを解除しますか?", "OK", "キャンセル")) { cond.next = null; } } } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); c++; } if (removeCond != null) { list.Remove(removeCond); } } GUILayout.EndVertical(); if (GUILayout.Button("条件を追加...")) { list.Add(new Conditions()); } }
public Condition IsTrue() => Conditions.IsEqualTo(this, Cypher.LiteralTrue());