/// <summary> /// 借錢動作 /// </summary> /// <param name="amount"></param> /// <param name="customAct"></param> private void LendAction(string amount, CustomAction customAct) { txtResult.Text = string.Empty; //決定要借出的金額 string finalAmount; //我們不需要知道這個customAct到底是什麼 //反正他跑完會回傳一個我們要的東西就對了 //在這裡回傳的就是最終借出金額 finalAmount = customAct(amount); string commonRes; if (!string.IsNullOrEmpty(finalAmount)) { commonRes = string.Format("借出{0}元", finalAmount); } else { commonRes = "掉頭就走"; } txtResult.Text += commonRes; }
private void CustomActionPageOnAccept(object sender, CustomAction e) { if (e == null) { return; } if (_lastPressedMenu == Devices.L) { _lastLeftOption = TouchOption.Universal.OtherL; LeftOption.TextDetail = $"{Loc.GetString("touchoption_custom_prefix")} {e}"; Settings.Default.LeftCustomAction = (int)e.Action; Settings.Default.LeftCustomActionParameter = e.Parameter; BluetoothService.Instance.SendAsync(SPPMessageBuilder.Touch.SetOptions(TouchOption.Universal.OtherL, _lastRightOption)); } else { _lastRightOption = TouchOption.Universal.OtherR; RightOption.TextDetail = $"{Loc.GetString("touchoption_custom_prefix")} {e}"; Settings.Default.RightCustomAction = (int)e.Action; Settings.Default.RightCustomActionParameter = e.Parameter; BluetoothService.Instance.SendAsync(SPPMessageBuilder.Touch.SetOptions(_lastLeftOption, TouchOption.Universal.OtherR)); } Settings.Default.MinimizeTray = true; AutoStartHelper.Enabled = true; Settings.Default.Save(); }
public override void OnPageShown() { LoadingSpinner.Visibility = Visibility.Hidden; ActionBorder.ContextMenu = GenerateMenu(ActionBorder); Action.TextDetail = "Not set"; _action = null; }
public ConfigurationManager AddConfig(TabPage page) { var subControls = page.Controls.OfType <Control>(); var config = new Configuration() { ConfigurationName = page.Text, Authentication = subControls.Where(c => c.Name == $"txtAuthentication_{page.Text}") .Select( c => c.Text) .FirstOrDefault(), Url = subControls.Where(c => c.Name == $"txtUrl_{page.Text}") .Select(c => c.Text) .FirstOrDefault(), StopMoney = subControls.Where(c => c.Name == $"txtMoneyWarning_{page.Text}") .Select(c => c.Text) .FirstOrDefault(), IsMoneyWarning = (subControls.Where(c => c.Name == $"cbMoneyWarning_{page.Text}") .FirstOrDefault() as MaterialSkin.Controls.MaterialCheckBox).Checked, IsCycle = (subControls.Where(c => c.Name == $"cblblIsCycle_{page.Text}") .FirstOrDefault() as MaterialSkin.Controls.MaterialCheckBox).Checked, Proxy = new Proxy() { IP = subControls.Where(c => c.Name == $"pnlProxy_{page.Text}") .Select(c => c.Controls) .FirstOrDefault() .OfType <System.Windows.Forms.Control>() .Where(c => c.Name == $"txtIP_{page.Text}") .Select(c => c.Text).FirstOrDefault(), Port = subControls.Where(c => c.Name == $"pnlProxy_{page.Text}") .Select(c => c.Controls) .FirstOrDefault() .OfType <System.Windows.Forms.Control>() .Where(c => c.Name == $"txtPort_{page.Text}") .Select(c => c.Text).FirstOrDefault() }, Action = new List <CustomAction>() }; var listView = subControls.Where(c => c.Name == $"mlvData_{page.Text}") .FirstOrDefault() as MaterialSkin.Controls.MaterialListView; if (listView != null) { foreach (ListViewItem item in listView.Items) { CustomAction action = new CustomAction() { ActionIndex = item.SubItems[0].Text, BetType = CustomAction.ToBet(item.SubItems[1].Text), Delay = item.SubItems[2].Text, Money = item.SubItems[3].Text }; config.Action.Add(action); } } this.Configs[page.Text] = config; return(this); }
private static void SetCustomActionResourceValues(TokenParser parser, CustomAction customAction, UserCustomAction uca) { if (uca != null) { bool isDirty = false; #if !ONPREMISES if (!string.IsNullOrEmpty(customAction.Title) && customAction.Title.ContainsResourceToken()) { if (uca.TitleResource.SetUserResourceValue(customAction.Title, parser)) { isDirty = true; } } if (!string.IsNullOrEmpty(customAction.Description) && customAction.Description.ContainsResourceToken()) { if (uca.DescriptionResource.SetUserResourceValue(customAction.Description, parser)) { isDirty = true; } } #endif if (isDirty) { uca.Update(); uca.Context.ExecuteQueryRetry(); } } }
/// <summary> /// Определяет, можно ли выполнить Custom Action /// </summary> /// <param name="code"></param> /// <returns></returns> internal static bool CanExecute(int entityId, CustomAction customAction) => ResolveStatus(customAction.Action.EntityType.Code, entityId, 0, new[] { new BackendActionStatus { Code = customAction.Action.Code, Visible = true } }) .Single().Visible;
public EditCustomActions(Area area, List <CustomAction> actions) { _area = area; InitializeComponent(); Type types = typeof(CustomAction.ActionTriggerType); CustomAction.ActionTriggerType[] vals = (CustomAction.ActionTriggerType[])Enum.GetValues(types); foreach (CustomAction.ActionTriggerType i in vals) { this.cbTriggers.Items.Add(CustomAction.WhenString(i)); } cbTriggers.SelectedIndex = 0; types = typeof(CustomAction.ActionType); CustomAction.ActionType[] vals2 = (CustomAction.ActionType[])Enum.GetValues(types); foreach (CustomAction.ActionType i in vals2) { this.cbActions.Items.Add(CustomAction.ActionString(i)); } cbActions.SelectedIndex = 0; if (actions != null) { foreach (CustomAction action in actions) { lstCustomActions.Items.Add(action); } } }
public override void AgentAction(float[] vectorAction, string textAction, CustomAction customAction) { _playerController.horizontalMovement = Mathf.Clamp(vectorAction[0], -1, 1); _playerController.verticalMovement = Mathf.Clamp(vectorAction[1], -1, 1); _playerController.isFiring = vectorAction[2] > 0; _playerController.rsHorizontalMovement = Mathf.Clamp(vectorAction[3], -1, 1); }
public AModifier(int _parentID, string _name, CustomAction _action, int _order) { parentID = _parentID; name = _name; val = 0; order = _order; action = _action; }
public ActionEditor_Custom PopulateForm(CustomAction model) { _model = model; TxtBoxName.Text = _model.Name; return(this); }
public AModifier(int _parentID, string _name, float _val, int _order) { parentID = _parentID; name = _name; val = _val; order = _order; action = null; }
// Use this for initialization protected void Start() { spriteRenderer = GetComponent <SpriteRenderer>(); if (this.action.getType() == Action.CUSTOM) { actionName = ((CustomAction)action).getName(); CustomAction ca = action as CustomAction; foreach (ResourcesUni ru in ca.getResources()) { if (ConditionChecker.check(ru.getConditions())) { this.resource = ru; } } } else { /*resource = new ResourcesUni (); * CustomButton button = Game.Instance.getButton (ActionNameWrapper.Names [action.getType ()],DescriptorData.NORMAL_BUTTON); * CustomButton highlighted = Game.Instance.getButton (ActionNameWrapper.Names [action.getType ()],DescriptorData.HIGHLIGHTED_BUTTON); * * if (button == null || highlighted == null) { * button = Game.Instance.getButton (ActionNameWrapper.AuxNames [action.getType ()], DescriptorData.NORMAL_BUTTON); * highlighted = Game.Instance.getButton (ActionNameWrapper.AuxNames [action.getType ()], DescriptorData.HIGHLIGHTED_BUTTON); * } * * resource.addAsset (DescriptorData.NORMAL_BUTTON, button.getPath()); * resource.addAsset (DescriptorData.HIGHLIGHTED_BUTTON, highlighted.getPath());*/ resource = GUIManager.Instance.Provider.getButton(this.action); actionName = ConstantNames.L["ES"].Actions[action.getType()]; } Sprite tmp; if (this.action.getType() == Action.CUSTOM) { tmp = Game.Instance.ResourceManager.getSprite(resource.getAssetPath("buttonNormal")); } else { tmp = Game.Instance.ResourceManager.getSprite(resource.getAssetPath(DescriptorData.NORMAL_BUTTON)); } spriteRenderer.sprite = tmp; if (InventoryManager.Instance.Opened) { this.gameObject.AddComponent <BoxCollider2D>(); } else { this.gameObject.AddComponent <BoxCollider>(); } //this.transform.localScale = new Vector3(tmp.width / 75f, tmp.height / 75f, 1); }
public void ManipulateCellsByCondition(CustomAction action, CellCondition condition) { ProgressMax = _tileMap.Map.MapData.Count; ProgressCounter = 0; var cellsToManipulate = (from cell in _tileMap.Map.MapData where condition(cell.Key) select cell.Key).ToList(); cellsToManipulate.ForEach(cell => action(cell)); }
public void Modify_Custom(Object obj, string name, CustomAction action, int order = 0) { if (AlreadyCreated(ModifierType.Custom, obj.GetInstanceID(), name, 0, action, order)) { return; } Create(ModifierType.Custom, obj.GetInstanceID(), name, 0, action, order); gottaProcess = true; }
public void Test_Add_Action_To_Day() { Day day = new Day(DAY_NAME); CustomAction customAction = new CustomAction(); day.AddAction(customAction); Assert.Equal <int>(1, day.CustomActions.Count); }
public override void OnPageShown() { LoadingSpinner.Visibility = Visibility.Hidden; ActionBorder.ContextMenu = GenerateMenu(ActionBorder); Header.Content = $"{Loc.GetString("cact_header")} ({Loc.GetString(CurrentSide == Devices.L ? "left" : "right")})"; _action = null; }
public override CustomAction Do(CustomAction customAction) { CustomAction customAction1 = new CustomAction(() => { Console.WriteLine("另一个执行前的方法。"); customAction.Invoke(); }); return(customAction1); }
public void AttackHero(Card attacker, Hero target, CustomAction action) { if (attacker.canPlay) { target.health -= attacker.damage; attacker.health -= target.damage; action(); } }
public void addActionQueueItem(CustomAction a, GameObject t = null, int id = 0) { ActionQueueItem aqi = new ActionQueueItem(); aqi.action = a; aqi.target = t; aqi.id = id; this.actionQueue.Add(aqi); }
public ActionResult Edit(CustomAction customAction) { if (ModelState.IsValid) { customAction.IsDeleted = false; UnitOfWork.CustomActionRepository.Update(customAction); UnitOfWork.Save(); return(RedirectToAction("Index")); } return(View(customAction)); }
public CustomTuple verificatioResult(CustomTuple _actions, CustomTuple _tuple) { CustomTuple _result = new CustomTuple(); for (int i = 0; i < _actions.getSize(); i++) { CustomAction _action = (CustomAction)_actions.getElement(i); _result.add(verificatioResult(_action, _tuple)); } return(_result); }
} //Magic public void AddToMonster(Card magic, Card target, bool addhistory, CustomAction action) { if (magic.canPlay) { target.attack += magic.AddedAttack; target.health += magic.AddedHealth; action(); //if (addhistory) //Complete.GameManager.gm.AddHistory(magic, target); } } //Magic
public void SetBasePermissionsTest() { CustomAction ca = new CustomAction(); BasePermissions bp = new BasePermissions(); bp.Set(PermissionKind.ApplyStyleSheets); bp.Set(PermissionKind.BrowseUserInfo); ca.Rights = bp; ca.RightsValue = 29; }
public static void Run() { var factory = new DelegateFactory(); var action = new CustomAction<int>(delegate { }); // begin var d = factory.Create(action); // end d.DynamicInvoke(42); }
public Effect(int i) { action = (card, player) => { Console.WriteLine($"{card}, {player} Effect activated"); }; TargetCard = null; TargetPlayer = PlayerType.Player; pos = i; id = random.Next(); effectString = "Generic effect"; effectText = HelperFunctions.NewText("Generic effect", 10, new Vector2f(10, 230 + 20 * pos), Color.Black); //AddButton(); }
} //Magic public void AddToEnemies(Card magic, List <GameObject> targets, bool addhistory, CustomAction action) { if (magic.canPlay) { foreach (var target in targets) { AddToMonster(magic, target.GetComponent <Card>(), addhistory, delegate { }); } action(); } } //Magic
public CustomAction Save(CustomAction customAction, int[] selectedActionsIds) { if (customAction == null) { throw new ArgumentNullException(nameof(customAction)); } customAction = Normalize(customAction, selectedActionsIds); customAction = CustomActionRepository.Save(customAction); return(customAction); }
public static void Run() { var factory = new DelegateFactory(); var action = new CustomAction <int>(delegate { }); // begin var d = factory.Create(action); // end d.DynamicInvoke(42); }
} //Attack public void AttackHero(Card attacker, Player target, bool addhistory, CustomAction action) { if (attacker.canPlay) { target.health -= attacker.attack; attacker.health -= target.attack; action(); //if (addhistory) //BoardBehaviourScript.instance.AddHistory(attacker, target); } } //Attack
public void SetBasePermissionsTest() { CustomAction ca = new CustomAction(); BasePermissions bp = new BasePermissions(); bp.Set(PermissionKind.ApplyStyleSheets); bp.Set(PermissionKind.BrowseUserInfo); ca.Rights = bp; ca.RightsValue = 29; }
void Create(ModifierType type, int id, string name, float val, CustomAction action, int order) { ClearOne(id, name); if (type == ModifierType.Custom) { allModifiers[(int)type].Add(new AModifier(id, name, action, order)); } else { allModifiers[(int)type].Add(new AModifier(id, name, val, order)); } allModifiers[(int)type].Sort((x, y) => x.order - y.order); }
private void ReadCustomActions(XDocument xDoc) { Logger.Log("Parsing custom actions..."); List <CustomAction> customActionList = new List <CustomAction>(); var elements = xDoc.Descendants().Where(a => a.Name.LocalName == "Action"); foreach (var xElement in elements) { var tCustomAction = new CustomAction(xElement); customActionList.Add(tCustomAction); Logger.Log($"Custom Action '{tCustomAction.Name}' parsed"); } CustomActions = customActionList; }
private CustomAction CopyUserCustomAction(UserCustomAction userCustomAction) { var customAction = new CustomAction(); customAction.Description = userCustomAction.Description; customAction.Enabled = true; customAction.Group = userCustomAction.Group; customAction.ImageUrl = userCustomAction.ImageUrl; customAction.Location = userCustomAction.Location; customAction.Name = userCustomAction.Name; customAction.Rights = userCustomAction.Rights; customAction.ScriptBlock = userCustomAction.ScriptBlock; customAction.ScriptSrc = userCustomAction.ScriptSrc; customAction.Sequence = userCustomAction.Sequence; customAction.Title = userCustomAction.Title; customAction.Url = userCustomAction.Url; customAction.RegistrationId = userCustomAction.RegistrationId; customAction.RegistrationType = userCustomAction.RegistrationType; customAction.CommandUIExtension = !System.String.IsNullOrEmpty(userCustomAction.CommandUIExtension) ? XElement.Parse(userCustomAction.CommandUIExtension) : null; return customAction; }
// Performs actions for dying state. IList<IAction> Die() { // Delimit time of skeleton GameObject destruction. float destructionTime = Time.time + DyingTime; // Create single-step action triggering die animation. IAction goDying = new CustomAction( () => { // Set current state to dying. this.state = SkeletonState.Dying; // Set die animation. this.animation.CrossFade("die"); // Remove collider component. Destroy(collider); }); // Create continuous action doing nothing. IAction dying = new CustomAction( () => { }, // Does nothing but waiting for termination condition come into being. // Action is active while: () => !this.IsTimeOut(destructionTime)); // dying timeout doesn't occured. // Create single-step action destructing current skeleton. IAction destroy = new CustomAction( () => { // Destroy current skeleton GameObject. Destroy(gameObject); }); return new List<IAction> { goDying, dying, destroy }; }
// Performs actions for pursuing state. IList<IAction> Pursue() { // Set current state to pursuing. SkeletonState currentState = SkeletonState.Pursuing; // Remember players height level. float height = this.Player.transform.position.y; // Create single-step action triggering run animation. IAction goPursue = new CustomAction( () => { // Set current state to pursuing. this.state = currentState; // Set animation to run. this.animation.CrossFade("run"); }); // Create continuous action steering skeleton motion. IAction pursuing = new CustomAction( () => { // Obtain current player position. Vector3 targetPosition = this.Player.transform.position; // Evaluate rotation sign for obtain rotation spin. float targetSign = this.EvaluateAxisSign(targetPosition); // Move skeleton position and rotation approxiamting to the target. this.StepToTarget(targetPosition, targetSign); }, // Action is active while: () => this.IsInCurrentState(currentState) // state of skeleton hasn't been modified, && this.IsOnTheSamePlatform(height) // player remains on the same platform, && this.IsPlayerNear()); // player remains in near distance. // Create single-step action choosing next state. IAction next = new CustomAction( () => { // If skeleton has remained in pursuing state if(this.IsInCurrentState(currentState)) { // then go into idle. this.actionQueue.Enqueue(this.Stop()); // If skeleton has got hit } else if (this.state == SkeletonState.Hit) { // then go into dying state. this.actionQueue.Enqueue(this.Die()); } else { throw new InvalidProgramException("Unreachable code"); } }); return new List<IAction> { goPursue, pursuing, next }; }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#startElement(java.lang.string, java.lang.string, * java.lang.string, org.xml.sax.XmlAttribute) */ public override void startElement(string namespaceURI, string sName, string qName, Dictionary<string, string> attrs) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is an examine, use or grab tag, create new conditions and effects if (qName.Equals("examine") || qName.Equals("grab") || qName.Equals("use") || qName.Equals("talk-to")) { foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("needsGoTo")) currentNeedsGoTo = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("keepDistance")) currentKeepDistance = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("not-effects")) activateNotEffects = entry.Value.ToString().Equals("yes"); } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); currentDocumentation = null; reading = READING_ACTION; } // If it is an use-with or give-to tag, create new conditions and effects, and store the idTarget else if (qName.Equals("use-with") || qName.Equals("give-to") || qName.Equals("drag-to")) { foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) currentIdTarget = entry.Value.ToString(); if (entry.Key.Equals("needsGoTo")) currentNeedsGoTo = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("keepDistance")) currentKeepDistance = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("not-effects")) activateNotEffects = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("click-effects")) activateClickEffects = entry.Value.ToString().Equals("yes"); } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); currentDocumentation = null; reading = READING_ACTION; } else if (qName.Equals("custom") || qName.Equals("custom-interact")) { foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("idTarget")) currentIdTarget = entry.Value.ToString(); if (entry.Key.Equals("name")) currentName = entry.Value.ToString(); if (entry.Key.Equals("needsGoTo")) currentNeedsGoTo = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("keepDistance")) currentKeepDistance = int.Parse(entry.Value.ToString()); if (entry.Key.Equals("not-effects")) activateNotEffects = entry.Value.ToString().Equals("yes"); if (entry.Key.Equals("click-effects")) activateClickEffects = entry.Value.ToString().Equals("yes"); } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); currentDocumentation = null; if (qName.Equals("custom")) currentCustomAction = new CustomAction(Action.CUSTOM); else currentCustomAction = new CustomAction(Action.CUSTOM_INTERACT); reading = READING_ACTION; } // If it is a resources tag, create the new resources and switch the state else if (qName.Equals("resources")) { currentResources = new ResourcesUni(); foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("name")) currentResources.setName(entry.Value.ToString()); } reading = READING_RESOURCES; } // If it is an asset tag, read it and add it to the current resources else if (qName.Equals("asset")) { string type = ""; string path = ""; foreach (KeyValuePair<string, string> entry in attrs) { if (entry.Key.Equals("type")) type = entry.Value.ToString(); if (entry.Key.Equals("uri")) path = entry.Value.ToString(); } // If the asset is not an special one // if( !AssetsController.isAssetSpecial( path ) ) currentResources.addAsset(type, path); } // If it is a condition tag, create new conditions and switch the state else if (qName.Equals("condition")) { currentConditions = new Conditions(); subParser = new ConditionSubParser(currentConditions, chapter); subParsing = SUBPARSING_CONDITION; } // If it is a effect tag, create new effects and switch the state else if (qName.Equals("effect")) { subParser = new EffectSubParser(currentEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a not-effect tag, create new effects and switch the state else if (qName.Equals("not-effect")) { subParser = new EffectSubParser(currentNotEffects, chapter); subParsing = SUBPARSING_EFFECT; } // If it is a click-effect tag, create new effects and switch the state else if (qName.Equals("click-effect")) { subParser = new EffectSubParser(currentClickEffects, chapter); subParsing = SUBPARSING_EFFECT; } } // If it is reading an effect or a condition, spread the call if (subParsing != SUBPARSING_NONE) { subParser.startElement(namespaceURI, sName, qName, attrs); } }
private static ListInstance ExtractUserCustomActions(Web web, List siteList, ListInstance list, ProvisioningTemplateCreationInformation creationInfo, ProvisioningTemplate template) { foreach (var userCustomAction in siteList.UserCustomActions.AsEnumerable()) { web.Context.Load(userCustomAction); web.Context.ExecuteQueryRetry(); var customAction = new CustomAction { Title = userCustomAction.Title, Description = userCustomAction.Description, Enabled = true, Name = userCustomAction.Name, //RegistrationType = userCustomAction.RegistrationType, //RegistrationId = userCustomAction.RegistrationId, Url = userCustomAction.Url, ImageUrl = userCustomAction.ImageUrl, Rights = userCustomAction.Rights, Sequence = userCustomAction.Sequence, ScriptBlock = userCustomAction.ScriptBlock, ScriptSrc = userCustomAction.ScriptSrc, CommandUIExtension = !System.String.IsNullOrEmpty(userCustomAction.CommandUIExtension) ? XElement.Parse(userCustomAction.CommandUIExtension) : null, Group = userCustomAction.Group, Location = userCustomAction.Location, }; #if !ONPREMISES if (creationInfo.PersistMultiLanguageResources) { siteList.EnsureProperty(l => l.Title); var listKey = siteList.Title.Replace(" ", "_"); var resourceKey = userCustomAction.Name.Replace(" ", "_"); if (UserResourceExtensions.PersistResourceValue(userCustomAction.TitleResource, string.Format("List_{0}_CustomAction_{1}_Title", listKey, resourceKey), template, creationInfo)) { var customActionTitle = string.Format("{{res:List_{0}_CustomAction_{1}_Title}}", listKey, resourceKey); customAction.Title = customActionTitle; } if (UserResourceExtensions.PersistResourceValue(userCustomAction.DescriptionResource, string.Format("List_{0}_CustomAction_{1}_Description", listKey, resourceKey), template, creationInfo)) { var customActionDescription = string.Format("{{res:List_{0}_CustomAction_{1}_Description}}", listKey, resourceKey); customAction.Description = customActionDescription; } } #endif list.UserCustomActions.Add(customAction); } return list; }
public override void ParseElement(XmlElement element) { string tmpArgVal; XmlElement tmpXmlEl; if (element.SelectSingleNode ("documentation") != null) { this.element.setDocumentation (element.SelectSingleNode ("documentation").InnerText); element.RemoveChild (element.SelectSingleNode ("documentation")); } foreach (XmlElement action in element.ChildNodes) { //First we parse the elements every action haves: tmpArgVal = action.GetAttribute("needsGoTo"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentNeedsGoTo = tmpArgVal.Equals("yes"); } tmpArgVal = action.GetAttribute("keepDistance"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentKeepDistance = int.Parse(tmpArgVal); } tmpArgVal = action.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateNotEffects = tmpArgVal.Equals("yes"); } tmpArgVal = action.GetAttribute("click-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateClickEffects = tmpArgVal.Equals("yes"); } tmpArgVal = action.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentIdTarget = tmpArgVal; } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); tmpXmlEl = (XmlElement) action.SelectSingleNode ("condition"); if (tmpXmlEl != null) new ConditionSubParser_ (currentConditions, chapter).ParseElement (tmpXmlEl); tmpXmlEl = (XmlElement) action.SelectSingleNode ("effect"); if (tmpXmlEl != null) new EffectSubParser_ (currentEffects, chapter).ParseElement (tmpXmlEl); tmpXmlEl = (XmlElement) action.SelectSingleNode ("click-effect"); if (tmpXmlEl != null) new EffectSubParser_ (currentClickEffects, chapter).ParseElement (tmpXmlEl); tmpXmlEl = (XmlElement) action.SelectSingleNode ("not-effect"); if (tmpXmlEl != null) new EffectSubParser_ (currentNotEffects, chapter).ParseElement (tmpXmlEl); //Then we instantiate the correct action by name. //We also parse the elements that are unique of that action. Action currentAction = new Action(0); switch (action.Name) { case "examines": currentAction = new Action(Action.EXAMINE, currentConditions, currentEffects, currentNotEffects); break; case "grabs": currentAction = new Action(Action.GRAB, currentConditions, currentEffects, currentNotEffects); break; case "use": currentAction = new Action(Action.USE, currentConditions, currentEffects, currentNotEffects); break; case "talk-to": currentAction = new Action(Action.TALK_TO, currentConditions, currentEffects, currentNotEffects); break; case "use-with": currentAction = new Action(Action.USE_WITH, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break; case "give-to": currentAction = new Action(Action.GIVE_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break; case "drag-to": currentAction = new Action (Action.DRAG_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); break; case "custom": case "custom-interact": CustomAction customAction = new CustomAction ((action.Name == "custom") ? Action.CUSTOM : Action.CUSTOM_INTERACT); tmpArgVal = action.GetAttribute ("name"); if (!string.IsNullOrEmpty (tmpArgVal)) { currentName = tmpArgVal; } customAction.setName (currentName); tmpXmlEl = (XmlElement) action.SelectSingleNode ("resources"); if (tmpXmlEl != null) customAction.addResources (parseResources (tmpXmlEl)); currentAction = customAction; break; } //Finally we set al the attributes to the action; currentAction.setConditions(currentConditions); currentAction.setEffects(currentEffects); currentAction.setNotEffects(currentNotEffects); currentAction.setKeepDistance(currentKeepDistance); currentAction.setNeedsGoTo(currentNeedsGoTo); currentAction.setActivatedNotEffects(activateNotEffects); currentAction.setClickEffects(currentClickEffects); currentAction.setActivatedClickEffects(activateClickEffects); this.element.addAction(currentAction); } /*foreach (XmlElement el in examines) { tmpArgVal = el.GetAttribute("needsGoTo"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentNeedsGoTo = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("keepDistance"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentKeepDistance = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateNotEffects = tmpArgVal.Equals("yes"); } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); Action examineAction = new Action(Action.EXAMINE, currentConditions, currentEffects, currentNotEffects); examineAction.setKeepDistance(currentKeepDistance); examineAction.setNeedsGoTo(currentNeedsGoTo); examineAction.setActivatedNotEffects(activateNotEffects); examineAction.setActivatedClickEffects(activateClickEffects); this.element.addAction(examineAction); } foreach (XmlElement el in grabs) { tmpArgVal = el.GetAttribute("needsGoTo"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentNeedsGoTo = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("keepDistance"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentKeepDistance = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateNotEffects = tmpArgVal.Equals("yes"); } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); Action grabAction = new Action(Action.GRAB, currentConditions, currentEffects, currentNotEffects); grabAction.setKeepDistance(currentKeepDistance); grabAction.setNeedsGoTo(currentNeedsGoTo); grabAction.setActivatedNotEffects(activateNotEffects); grabAction.setActivatedClickEffects(activateClickEffects); this.element.addAction(grabAction); } foreach (XmlElement el in uses) { tmpArgVal = el.GetAttribute("needsGoTo"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentNeedsGoTo = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("keepDistance"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentKeepDistance = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateNotEffects = tmpArgVal.Equals("yes"); } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); Action useAction = new Action(Action.USE, currentConditions, currentEffects, currentNotEffects); useAction.setNeedsGoTo(currentNeedsGoTo); useAction.setKeepDistance(currentKeepDistance); useAction.setActivatedNotEffects(activateNotEffects); useAction.setActivatedClickEffects(activateClickEffects); this.element.addAction(useAction); } foreach (XmlElement el in talksto) { tmpArgVal = el.GetAttribute("needsGoTo"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentNeedsGoTo = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("keepDistance"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentKeepDistance = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateNotEffects = tmpArgVal.Equals("yes"); } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); Action talkToAction = new Action(Action.TALK_TO, currentConditions, currentEffects, currentNotEffects); talkToAction.setNeedsGoTo(currentNeedsGoTo); talkToAction.setKeepDistance(currentKeepDistance); talkToAction.setActivatedNotEffects(activateNotEffects); talkToAction.setActivatedClickEffects(activateClickEffects); this.element.addAction(talkToAction); } foreach (XmlElement el in useswith) { tmpArgVal = el.GetAttribute("needsGoTo"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentNeedsGoTo = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("keepDistance"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentKeepDistance = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateNotEffects = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("click-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateClickEffects = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentIdTarget = tmpArgVal; } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); Action useWithAction = new Action(Action.USE_WITH, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); useWithAction.setKeepDistance(currentKeepDistance); useWithAction.setNeedsGoTo(currentNeedsGoTo); useWithAction.setActivatedNotEffects(activateNotEffects); useWithAction.setActivatedClickEffects(activateClickEffects); this.element.addAction(useWithAction); } foreach (XmlElement el in dragsto) { tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentIdTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("needsGoTo"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentNeedsGoTo = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("keepDistance"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentKeepDistance = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateNotEffects = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("click-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateClickEffects = tmpArgVal.Equals("yes"); } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); Action useWithAction = new Action(Action.DRAG_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); useWithAction.setKeepDistance(currentKeepDistance); useWithAction.setNeedsGoTo(currentNeedsGoTo); useWithAction.setActivatedNotEffects(activateNotEffects); useWithAction.setActivatedClickEffects(activateClickEffects); this.element.addAction(useWithAction); } foreach (XmlElement el in givesto) { tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentIdTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("needsGoTo"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentNeedsGoTo = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("keepDistance"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentKeepDistance = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateNotEffects = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("click-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateClickEffects = tmpArgVal.Equals("yes"); } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); Action giveToAction = new Action(Action.GIVE_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); giveToAction.setKeepDistance(currentKeepDistance); giveToAction.setNeedsGoTo(currentNeedsGoTo); giveToAction.setActivatedNotEffects(activateNotEffects); giveToAction.setActivatedClickEffects(activateClickEffects); this.element.addAction(giveToAction); } foreach (XmlElement el in customs) { tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentIdTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("name"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentName = tmpArgVal; } tmpArgVal = el.GetAttribute("needsGoTo"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentNeedsGoTo = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("keepDistance"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentKeepDistance = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateNotEffects = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("click-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateClickEffects = tmpArgVal.Equals("yes"); } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); tmpXmlEl = el.SelectSingleNode ("condition"); if (tmpXmlEl != null) new ConditionSubParser_ (currentConditions, chapter).ParseElement (tmpXmlEl); tmpXmlEl = el.SelectSingleNode ("effect"); if (tmpXmlEl != null) new EffectSubParser_ (currentEffects, chapter).ParseElement (tmpXmlEl); tmpXmlEl = el.SelectSingleNode ("click-effect"); if (tmpXmlEl != null) new EffectSubParser_ (currentClickEffects, chapter).ParseElement (tmpXmlEl); tmpXmlEl = el.SelectSingleNode ("not-effect"); if (tmpXmlEl != null) new EffectSubParser_ (currentNotEffects, chapter).ParseElement (tmpXmlEl); currentCustomAction = new CustomAction(Action.CUSTOM); currentCustomAction.setName(currentName); currentCustomAction.setConditions(currentConditions); currentCustomAction.setEffects(currentEffects); currentCustomAction.setNotEffects(currentNotEffects); currentCustomAction.setKeepDistance(currentKeepDistance); currentCustomAction.setNeedsGoTo(currentNeedsGoTo); currentCustomAction.setActivatedNotEffects(activateNotEffects); currentCustomAction.setClickEffects(currentClickEffects); currentCustomAction.setActivatedClickEffects(activateClickEffects); XmlElement res = (XmlElement) el.SelectSingleNode ("resources"); if (res != null) currentCustomAction.addResources(parseResources(res)); this.element.addAction(currentCustomAction); currentCustomAction = null; } foreach (XmlElement el in customsinteract) { tmpArgVal = el.GetAttribute("idTarget"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentIdTarget = tmpArgVal; } tmpArgVal = el.GetAttribute("name"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentName = tmpArgVal; } tmpArgVal = el.GetAttribute("needsGoTo"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentNeedsGoTo = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("keepDistance"); if (!string.IsNullOrEmpty(tmpArgVal)) { currentKeepDistance = int.Parse(tmpArgVal); } tmpArgVal = el.GetAttribute("not-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateNotEffects = tmpArgVal.Equals("yes"); } tmpArgVal = el.GetAttribute("click-effects"); if (!string.IsNullOrEmpty(tmpArgVal)) { activateClickEffects = tmpArgVal.Equals("yes"); } currentConditions = new Conditions(); currentEffects = new Effects(); currentNotEffects = new Effects(); currentClickEffects = new Effects(); currentCustomAction = new CustomAction(Action.CUSTOM_INTERACT); currentCustomAction.setConditions(currentConditions); currentCustomAction.setEffects(currentEffects); currentCustomAction.setNotEffects(currentNotEffects); currentCustomAction.setName(currentName); currentCustomAction.setTargetId(currentIdTarget); currentCustomAction.setKeepDistance(currentKeepDistance); currentCustomAction.setNeedsGoTo(currentNeedsGoTo); currentCustomAction.setActivatedNotEffects(activateNotEffects); currentCustomAction.setClickEffects(currentClickEffects); currentCustomAction.setActivatedClickEffects(activateClickEffects); XmlElement res = (XmlElement) el.SelectSingleNode ("resources"); if (res != null) currentCustomAction.addResources(parseResources(res)); this.element.addAction(currentCustomAction); currentCustomAction = null; } foreach (XmlElement el in effects) { currentEffects = new Effects(); new EffectSubParser_(currentEffects, chapter).ParseElement(el); } foreach (XmlElement el in notseffect) { currentNotEffects = new Effects(); new EffectSubParser_(currentNotEffects, chapter).ParseElement(el); } foreach (XmlElement el in effects) { currentClickEffects = new Effects(); new EffectSubParser_(currentClickEffects, chapter).ParseElement(el); }*/ }
public void StartAssigningAction(CustomAction action) { assigningAction = action; }
// Performs actions for running in random direction state. IList<IAction> Run() { // Set current state to running. SkeletonState currentState = SkeletonState.Running; // Random target in radius specified by MaxRandomTargetDistance. Vector3 targetPosition = this.RandomTargetPosition(MaxRandomTargetIterations); // Evaluate rotation sign for constant rotation spin. float targetSign = this.EvaluateAxisSign(targetPosition); // Create single-step action triggering run animation. IAction goRun = new CustomAction( () => { // Set current state to running. this.state = currentState; // Set animation to run. this.animation.CrossFade("run"); }); // Create continuous action steering skeleton motion. IAction running = new CustomAction( () => { // Move skeleton position and rotation approxiamting to the target. this.StepToTarget(targetPosition, targetSign); }, // Action is active while: () => this.IsInCurrentState(currentState) // state of skeleton hasn't been modified, && !this.IsTargetReached(targetPosition) // target hasn't been reached yet, && !this.IsPlayerNear()); // player is not in near distance. // Create single-step action choosing next state. IAction next = new CustomAction( () => { // If skeleton has remained in running state if(this.IsInCurrentState(currentState)) { // and player has came near if(this.IsPlayerNear()) { // then go into warning state this.actionQueue.Enqueue(this.Warn()); // when there is no player around } else { // then go into idle. this.actionQueue.Enqueue(this.Stop()); } // If skeleton has got hit } else if (state == SkeletonState.Hit) { // then go into dying state. this.actionQueue.Enqueue(this.Die()); } else { throw new InvalidProgramException("Unreachable code"); } }); return new List<IAction> { goRun, running, next }; }
// Performs actions for idle state. IList<IAction> Stop() { // Delimit time of idle state expiration. float stopTime = Time.time + this.RandomTimeSpan(this.AverageIdleTime); // Set current state to idle. SkeletonState currentState = SkeletonState.Idle; // Create single-step action triggering idle animation. IAction goIdle = new CustomAction( () => { // Set current state to idle. this.state = currentState; // Set animation to idle. this.animation.CrossFade("idle"); }); // Create continuous action doing nothing. IAction beingIdle = new CustomAction( () => { }, // Does nothing but waiting for termination condition come into being. // Action is active while: () => this.IsInCurrentState(currentState) // state of skeleton hasn't been modified, && !this.IsTimeOut(stopTime) // idle timeout doesn't occured, && !this.IsPlayerNear()); // player is not in near distance. // Create single-step action choosing next state. IAction next = new CustomAction( () => { // If skeleton has remained in idle state if(this.IsInCurrentState(currentState)) { // and player has came near if(this.IsPlayerNear()) { // then go into warning state this.actionQueue.Enqueue(this.Warn()); // when there is no player around } else { // then go into running in random direction. this.actionQueue.Enqueue(this.Run()); } // If skeleton has got hit } else if (state == SkeletonState.Hit) { // then go into dying state. this.actionQueue.Enqueue(this.Die()); } else { throw new InvalidProgramException("Unreachable code"); } }); return new List<IAction> { goIdle, beingIdle, next }; }
// Performs actions for warning state. IList<IAction> Warn() { // Set current state to warning. SkeletonState currentState = SkeletonState.Warning; // Delimit time of warning state expiration. float warningTime = Time.time + WarningTime; // Create single-step action triggering waiting for battle animation. IAction goWarn = new CustomAction( () => { // Set current state to warning. this.state = currentState; // Set waiting for battle animation. this.animation.CrossFade("waitingforbattle"); }); // Create continuous action doing nothing. IAction warning = new CustomAction( () => { }, // Does nothing but waiting for termination condition come into being. // Action is active while: () => this.IsInCurrentState(currentState) // state of skeleton hasn't been modified, && !this.IsTimeOut(warningTime) // warning timeout doesn't occured, && this.IsPlayerNear() // player is in near distance, && !this.IsPlayerVeryClose()); // but hasn't came too close. // Create single-step action choosing next state. IAction next = new CustomAction( () => { // If skeleton has remained in warning state if(this.IsInCurrentState(currentState)) { // and player has remained near if(this.IsPlayerNear()) { // then pursue him, this.actionQueue.Enqueue(this.Pursue()); // when player has drifted away } else { // then go into idle. this.actionQueue.Enqueue(this.Stop()); } // If skeleton has got hit } else if (state == SkeletonState.Hit) { // then go into dying state. this.actionQueue.Enqueue(this.Die()); } else { throw new InvalidProgramException("Unreachable code"); } }); return new List<IAction> { goWarn, warning, next }; }
// Performs actions for tracing state. IList<IAction> Trace() { // Delimit time of tracing state expiration. float explosionTime = Time.time + this.LifeTime; // Set current state to tracing. ProjectileState currentState = ProjectileState.Tracing; // Create single-step action triggering tracing action on. IAction goTrace = new CustomAction( () => { // Set current state to tracing. this.state = currentState; // Stop audio source. this.audio.Stop(); }); // Create continuous action steering projectile motion. IAction tracing = new CustomAction( () => { // Moves projectile position to approximate target point. this.StepToTarget(); }, // Action is active while: () => this.IsInCurrentState(currentState) // state of projectile hasn't been modified, && !this.IsTimeOut(explosionTime)); // tracing timeout doesn't occured. // Create single-step action choosing next state. IAction next = new CustomAction( () => { // If skeleton has remained in flying state if (this.IsInCurrentState(currentState) // or got hit || this.state == ProjectileState.Hit) { // then explode. this.actionQueue.Enqueue(this.Explode()); } else { throw new InvalidProgramException("Unreacheable code"); } }); return new List<IAction> { goTrace, tracing, next }; }
// Performs actions for exploding state. IList<IAction> Explode() { // Delimit time of exploding state expiration. float destructionTime = Time.time + this.TimeToDestroy; // Set current state to exploding. ProjectileState currentState = ProjectileState.Exploding; // Create single-step action triggering explode action on. IAction goExploding = new CustomAction( () => { // Set current state to exploding. this.state = currentState; // Obtain emmiter of smoke trail effect. ParticleEmitter emitter = GameObject.Find("/Projectile/Smoke Trail").particleEmitter; // Shut the emmision down. emitter.minEmission = 0; emitter.maxEmission = 0; // Obtain emmiter of fireworks effect. emitter = GameObject.Find("/Projectile/Fireworks").particleEmitter; // Turn the emmision on. emitter.minEmission = 200; emitter.maxEmission = 300; // Play explosion sound. audio.Play(); }); // Create continuous action doing nothing. IAction exploding = new CustomAction( () => { }, // Does nothing but waiting for termination condition come into being. // Action is active while: () => this.IsInCurrentState(currentState) // state of projectile hasn't been modified, && !this.IsTimeOut(destructionTime)); // exploding timeout doesn't occured. // Create single-step action destructing current projectile. IAction destroy = new CustomAction( () => { // Destroy current projectile GameObject. Destroy(gameObject); }); return new List<IAction> { goExploding, exploding, destroy }; }
/* * (non-Javadoc) * * @see es.eucm.eadventure.engine.cargador.subparsers.SubParser#endElement(java.lang.string, java.lang.string, * java.lang.string) */ public override void endElement(string namespaceURI, string sName, string qName) { // If no element is being subparsed if (subParsing == SUBPARSING_NONE) { // If it is a resources tag, add it to the object if (qName.Equals("resources")) { if (reading == READING_RESOURCES) { currentCustomAction.addResources(currentResources); reading = READING_NONE; } } // If it is a documentation tag, hold the documentation in the current element else if (qName.Equals("documentation")) { currentDocumentation = currentstring.ToString().Trim(); } // If it is a examine tag, store the new action in the object else if (qName.Equals("examine")) { Action examineAction = new Action(Action.EXAMINE, currentConditions, currentEffects, currentNotEffects); examineAction.setDocumentation(currentDocumentation); examineAction.setKeepDistance(currentKeepDistance); examineAction.setNeedsGoTo(currentNeedsGoTo); examineAction.setActivatedNotEffects(activateNotEffects); examineAction.setActivatedClickEffects(activateClickEffects); element.addAction(examineAction); reading = READING_NONE; } // If it is a grab tag, store the new action in the object else if (qName.Equals("grab")) { Action grabAction = new Action(Action.GRAB, currentConditions, currentEffects, currentNotEffects); grabAction.setDocumentation(currentDocumentation); grabAction.setKeepDistance(currentKeepDistance); grabAction.setNeedsGoTo(currentNeedsGoTo); grabAction.setActivatedNotEffects(activateNotEffects); grabAction.setActivatedClickEffects(activateClickEffects); element.addAction(grabAction); reading = READING_NONE; } // If it is an use tag, store the new action in the object else if (qName.Equals("use")) { Action useAction = new Action(Action.USE, currentConditions, currentEffects, currentNotEffects); useAction.setDocumentation(currentDocumentation); useAction.setNeedsGoTo(currentNeedsGoTo); useAction.setKeepDistance(currentKeepDistance); useAction.setActivatedNotEffects(activateNotEffects); useAction.setActivatedClickEffects(activateClickEffects); element.addAction(useAction); reading = READING_NONE; } // If it is an use tag, store the new action in the object else if (qName.Equals("talk-to")) { Action talkToAction = new Action(Action.TALK_TO, currentConditions, currentEffects, currentNotEffects); talkToAction.setDocumentation(currentDocumentation); talkToAction.setNeedsGoTo(currentNeedsGoTo); talkToAction.setKeepDistance(currentKeepDistance); talkToAction.setActivatedNotEffects(activateNotEffects); talkToAction.setActivatedClickEffects(activateClickEffects); element.addAction(talkToAction); reading = READING_NONE; } // If it is an use-with tag, store the new action in the object else if (qName.Equals("use-with")) { Action useWithAction = new Action(Action.USE_WITH, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); useWithAction.setDocumentation(currentDocumentation); useWithAction.setKeepDistance(currentKeepDistance); useWithAction.setNeedsGoTo(currentNeedsGoTo); useWithAction.setActivatedNotEffects(activateNotEffects); useWithAction.setActivatedClickEffects(activateClickEffects); element.addAction(useWithAction); reading = READING_NONE; } // If it is an use-with tag, store the new action in the object else if (qName.Equals("drag-to")) { Action useWithAction = new Action(Action.DRAG_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); useWithAction.setDocumentation(currentDocumentation); useWithAction.setKeepDistance(currentKeepDistance); useWithAction.setNeedsGoTo(currentNeedsGoTo); useWithAction.setActivatedNotEffects(activateNotEffects); useWithAction.setActivatedClickEffects(activateClickEffects); element.addAction(useWithAction); reading = READING_NONE; } // If it is a give-to tag, store the new action in the object else if (qName.Equals("give-to")) { Action giveToAction = new Action(Action.GIVE_TO, currentIdTarget, currentConditions, currentEffects, currentNotEffects, currentClickEffects); giveToAction.setDocumentation(currentDocumentation); giveToAction.setKeepDistance(currentKeepDistance); giveToAction.setNeedsGoTo(currentNeedsGoTo); giveToAction.setActivatedNotEffects(activateNotEffects); giveToAction.setActivatedClickEffects(activateClickEffects); element.addAction(giveToAction); reading = READING_NONE; } // If it is a custom tag, store the new custom action in the object else if (qName.Equals("custom")) { currentCustomAction.setName(currentName); currentCustomAction.setConditions(currentConditions); currentCustomAction.setEffects(currentEffects); currentCustomAction.setNotEffects(currentNotEffects); currentCustomAction.setDocumentation(currentDocumentation); currentCustomAction.setKeepDistance(currentKeepDistance); currentCustomAction.setNeedsGoTo(currentNeedsGoTo); currentCustomAction.setActivatedNotEffects(activateNotEffects); currentCustomAction.setClickEffects(currentClickEffects); currentCustomAction.setActivatedClickEffects(activateClickEffects); // customAction.addResources(currentResources); element.addAction(currentCustomAction); currentCustomAction = null; reading = READING_NONE; } // If it is a custom-interact tag, store the new custom interact action in the object else if (qName.Equals("custom-interact")) { currentCustomAction.setConditions(currentConditions); currentCustomAction.setEffects(currentEffects); currentCustomAction.setNotEffects(currentNotEffects); currentCustomAction.setName(currentName); currentCustomAction.setTargetId(currentIdTarget); currentCustomAction.setDocumentation(currentDocumentation); currentCustomAction.setKeepDistance(currentKeepDistance); currentCustomAction.setNeedsGoTo(currentNeedsGoTo); currentCustomAction.setActivatedNotEffects(activateNotEffects); currentCustomAction.setClickEffects(currentClickEffects); currentCustomAction.setActivatedClickEffects(activateClickEffects); // customAction.addResources(currentResources); element.addAction(currentCustomAction); currentCustomAction = null; reading = READING_NONE; } // Reset the current string currentstring = string.Empty; } // If a condition is being subparsed else if (subParsing == SUBPARSING_CONDITION) { // Spread the call subParser.endElement(namespaceURI, sName, qName); // If the condition tag is being closed if (qName.Equals("condition")) { // Store the conditions in the resources if (reading == READING_RESOURCES) currentResources.setConditions(currentConditions); // Switch state subParsing = SUBPARSING_NONE; } } // If an effect is being subparsed else if (subParsing == SUBPARSING_EFFECT) { // Spread the call subParser.endElement(namespaceURI, sName, qName); // If the effect tag is being closed, switch the state if (qName.Equals("effect")) { subParsing = SUBPARSING_NONE; } // If the not-effect tag is being closed, switch the state else if (qName.Equals("not-effect")) { subParsing = SUBPARSING_NONE; } // If the not-effect tag is being closed, switch the state else if (qName.Equals("click-effect")) { subParsing = SUBPARSING_NONE; } } }
public void CustomAction_Should_Be_An_Id_Provider() { var sut = new CustomAction(); Assert.That(sut.IsIdProvider, Is.True); }
internal static void UpdateCustomAction(TokenParser parser, PnPMonitoredScope scope, CustomAction customAction, UserCustomAction existingCustomAction) { var isDirty = false; // Otherwise we update it if (customAction.CommandUIExtension != null) { if (existingCustomAction.CommandUIExtension != parser.ParseString(customAction.CommandUIExtension.ToString())) { scope.LogPropertyUpdate("CommandUIExtension"); existingCustomAction.CommandUIExtension = parser.ParseString(customAction.CommandUIExtension.ToString()); isDirty = true; } } else { // Required to allow for a delta action to blank out the CommandUIExtension attribute existingCustomAction.CommandUIExtension = null; } if (existingCustomAction.Description != customAction.Description) { scope.LogPropertyUpdate("Description"); existingCustomAction.Description = customAction.Description; isDirty = true; } #if !ONPREMISES if (customAction.Description.ContainsResourceToken()) { if (existingCustomAction.DescriptionResource.SetUserResourceValue(customAction.Description, parser)) { isDirty = true; } } #endif if (existingCustomAction.Group != customAction.Group) { scope.LogPropertyUpdate("Group"); existingCustomAction.Group = customAction.Group; isDirty = true; } if (existingCustomAction.ImageUrl != parser.ParseString(customAction.ImageUrl)) { scope.LogPropertyUpdate("ImageUrl"); existingCustomAction.ImageUrl = parser.ParseString(customAction.ImageUrl); isDirty = true; } if (existingCustomAction.Location != customAction.Location) { scope.LogPropertyUpdate("Location"); existingCustomAction.Location = customAction.Location; isDirty = true; } if (existingCustomAction.RegistrationId != customAction.RegistrationId) { scope.LogPropertyUpdate("RegistrationId"); existingCustomAction.RegistrationId = customAction.RegistrationId; isDirty = true; } if (existingCustomAction.RegistrationType != customAction.RegistrationType) { scope.LogPropertyUpdate("RegistrationType"); existingCustomAction.RegistrationType = customAction.RegistrationType; isDirty = true; } if (existingCustomAction.ScriptBlock != parser.ParseString(customAction.ScriptBlock)) { scope.LogPropertyUpdate("ScriptBlock"); existingCustomAction.ScriptBlock = parser.ParseString(customAction.ScriptBlock); isDirty = true; } if (existingCustomAction.ScriptSrc != parser.ParseString(customAction.ScriptSrc, "~site", "~sitecollection")) { scope.LogPropertyUpdate("ScriptSrc"); existingCustomAction.ScriptSrc = parser.ParseString(customAction.ScriptSrc, "~site", "~sitecollection"); isDirty = true; } if (existingCustomAction.Sequence != customAction.Sequence) { scope.LogPropertyUpdate("Sequence"); existingCustomAction.Sequence = customAction.Sequence; isDirty = true; } if (existingCustomAction.Title != parser.ParseString(customAction.Title)) { scope.LogPropertyUpdate("Title"); existingCustomAction.Title = parser.ParseString(customAction.Title); isDirty = true; } #if !ONPREMISES if (customAction.Title.ContainsResourceToken()) { if (existingCustomAction.TitleResource.SetUserResourceValue(customAction.Title, parser)) { isDirty = true; } } #endif if (existingCustomAction.Url != parser.ParseString(customAction.Url)) { scope.LogPropertyUpdate("Url"); existingCustomAction.Url = parser.ParseString(customAction.Url); isDirty = true; } if (isDirty) { existingCustomAction.Update(); existingCustomAction.Context.ExecuteQueryRetry(); } }
// Update is called once per frame void Update () { if(!assigningActions) { placedThisFrame = false; // Mouse world position assigning per frame mWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); if(grabbedObject != null) // if we have a grabbed object { if(!grabbedObject.GetComponent<ShipPart>().snapped) { grabbedObject.transform.position = new Vector3(mWorldPos.x, mWorldPos.y, grabbedObject.transform.position.z) + new Vector3(grabOffset.x, grabOffset.y,0); // if you click when an object is not snapped to a surface, leave it floating their if(Input.GetMouseButtonDown(0) && !grabbedThisFrame) { if(!grabbedObject.GetComponent<ShipPart>().startingPart) { grabbedObject.transform.parent = Camera.main.transform; floatingObjects.Add(grabbedObject); } grabbedObject = null; placedThisFrame = true; } } else // if the object has been snapped into place keep it there; { Vector3 worldPos = grabbedObject.transform.position; float dist = Vector2.Distance(((Vector2) worldPos) , (Vector2) mWorldPos); if(dist > snapRadius * 6)// if mouse gets far enough away, unsnap { grabbedObject.GetComponent<ShipPart>().snapped = false; grabbedObject.transform.eulerAngles = new Vector3(grabbedObject.transform.eulerAngles.x, grabbedObject.transform.eulerAngles.y, storedAngle); grabbedObject.transform.parent = null; //grabbedObject.GetComponent<ShipPart>().Disconnect(); } if(Input.GetMouseButtonDown(0)) { if(grabbedObject.GetComponent<ShipPart>().snapped) // if the piece is snapped and you click again, connect the points { grabbedObject.GetComponent<ShipPart>().SetOnShip(true); connectedSP1.connected = true; connectedSP2.connected = true; connectedSP2.connectedToParent = true; placedThisFrame = true; grabbedObject = null; } } } if(Input.GetMouseButtonDown(1) && !grabbedObject.GetComponent<ShipPart>().snapped) { grabbedObject.transform.eulerAngles -= new Vector3(0,0,90); } } grabbedThisFrame = false; } else { if(assigningAction != null && assigningActionNum != 0) { if(detectPressedKeyOrButton() != KeyCode.Delete) { assigningAction.AssignAction(assigningActionNum, detectPressedKeyOrButton()); assigningAction = null; assigningActionNum = 0; } } } }
private static void SetCustomActionResourceValues(TokenParser parser, CustomAction customAction, UserCustomAction uca) { if (uca != null) { bool isDirty = false; #if !ONPREMISES if (!string.IsNullOrEmpty(customAction.Title) && customAction.Title.ContainsResourceToken()) { if (uca.TitleResource.SetUserResourceValue(customAction.Title, parser)) { isDirty = true; } } if (!string.IsNullOrEmpty(customAction.Description) && customAction.Description.ContainsResourceToken()) { if (uca.DescriptionResource.SetUserResourceValue(customAction.Description, parser)) { isDirty = true; } } #endif if (isDirty) { uca.Update(); uca.Context.ExecuteQueryRetry(); } } }
private static void CreateListCustomAction(List existingList, TokenParser parser, CustomAction userCustomAction) { UserCustomAction newUserCustomAction = existingList.UserCustomActions.Add(); newUserCustomAction.Title = userCustomAction.Title; newUserCustomAction.Description = userCustomAction.Description; #if !ONPREMISES if (!string.IsNullOrEmpty(userCustomAction.Title) && userCustomAction.Title.ContainsResourceToken()) { newUserCustomAction.TitleResource.SetUserResourceValue(userCustomAction.Title, parser); } if (!string.IsNullOrEmpty(userCustomAction.Description) && userCustomAction.Description.ContainsResourceToken()) { newUserCustomAction.DescriptionResource.SetUserResourceValue(userCustomAction.Description, parser); } #endif newUserCustomAction.Name = userCustomAction.Name; newUserCustomAction.ImageUrl = userCustomAction.ImageUrl; newUserCustomAction.Rights = userCustomAction.Rights; newUserCustomAction.Sequence = userCustomAction.Sequence; newUserCustomAction.Group = userCustomAction.Group; newUserCustomAction.Location = userCustomAction.Location; //newUserCustomAction.RegistrationId = userCustomAction.RegistrationId; //newUserCustomAction.RegistrationType = userCustomAction.RegistrationType; newUserCustomAction.CommandUIExtension = userCustomAction.CommandUIExtension != null ? parser.ParseString(userCustomAction.CommandUIExtension.ToString()) : string.Empty; newUserCustomAction.ScriptBlock = userCustomAction.ScriptBlock; newUserCustomAction.ScriptSrc = userCustomAction.ScriptSrc; newUserCustomAction.Url = userCustomAction.Url; newUserCustomAction.Update(); }
private CustomAction CopyUserCustomAction(UserCustomAction userCustomAction, ProvisioningTemplateCreationInformation creationInfo, ProvisioningTemplate template) { var customAction = new CustomAction(); customAction.Description = userCustomAction.Description; customAction.Enabled = true; customAction.Group = userCustomAction.Group; customAction.ImageUrl = userCustomAction.ImageUrl; customAction.Location = userCustomAction.Location; customAction.Name = userCustomAction.Name; customAction.Rights = userCustomAction.Rights; customAction.ScriptBlock = userCustomAction.ScriptBlock; customAction.ScriptSrc = userCustomAction.ScriptSrc; customAction.Sequence = userCustomAction.Sequence; customAction.Title = userCustomAction.Title; customAction.Url = userCustomAction.Url; customAction.RegistrationId = userCustomAction.RegistrationId; customAction.RegistrationType = userCustomAction.RegistrationType; customAction.CommandUIExtension = !System.String.IsNullOrEmpty(userCustomAction.CommandUIExtension) ? XElement.Parse(userCustomAction.CommandUIExtension) : null; #if !ONPREMISES if (creationInfo.PersistMultiLanguageResources) { var resourceKey = userCustomAction.Name.Replace(" ", "_"); if (UserResourceExtensions.PersistResourceValue(userCustomAction.TitleResource, string.Format("CustomAction_{0}_Title", resourceKey), template, creationInfo)) { var customActionTitle = string.Format("{{res:CustomAction_{0}_Title}}", resourceKey); customAction.Title = customActionTitle; } if (UserResourceExtensions.PersistResourceValue(userCustomAction.DescriptionResource, string.Format("CustomAction_{0}_Description", resourceKey), template, creationInfo)) { var customActionDescription = string.Format("{{res:CustomAction_{0}_Description}}", resourceKey); customAction.Description = customActionDescription; } } #endif return customAction; }
public Delegate Create(CustomAction<int> action) { Delegate d = (Action<int>)action.Invoke; return d; }
private CustomAction CopyUserCustomAction(UserCustomAction userCustomAction) { var customAction = new CustomAction(); customAction.Description = userCustomAction.Description; customAction.Enabled = true; customAction.Group = userCustomAction.Group; customAction.ImageUrl = userCustomAction.ImageUrl; customAction.Location = userCustomAction.Location; customAction.Name = userCustomAction.Name; customAction.Rights = userCustomAction.Rights; customAction.ScriptBlock = userCustomAction.ScriptBlock; customAction.ScriptSrc = userCustomAction.ScriptSrc; customAction.Sequence = userCustomAction.Sequence; customAction.Title = userCustomAction.Title; customAction.Url = userCustomAction.Url; customAction.RegistrationId = userCustomAction.RegistrationId; customAction.RegistrationType = userCustomAction.RegistrationType; customAction.CommandUIExtension = userCustomAction.CommandUIExtension; return customAction; }