//When the character interact with this selectable, check all the actions and see if any should be triggered. public void Use(PlayerCharacter character) { if (enabled) { ItemSlot islot = InventoryBar.Get().GetSelectedSlot(); ItemSlot eslot = EquipBar.Get().GetSelectedSlot(); ItemSlot slot = eslot != null ? eslot : islot; MAction maction = slot != null && slot.GetItem() != null?slot.GetItem().FindMergeAction(this) : null; AAction aaction = FindAutoAction(); if (maction != null && maction.CanDoAction(character, this)) { maction.DoAction(character, slot, this); TheUI.Get().CancelSelection(); } else if (aaction != null && aaction.CanDoAction(character, this)) { aaction.DoAction(character, this); } else if (actions.Length > 0) { ActionSelector.Get().Show(character, this); } if (onUse != null) { onUse.Invoke(character); } } }
private bool ReadUI() { Regex reg = new Regex(@"^\d*$"); if (!reg.IsMatch(this.textBox2.Text.Trim())) { MessageBox.Show("操作前等待需要输入正整数"); return(false); } if (!reg.IsMatch(this.textBox4.Text.Trim())) { MessageBox.Show("操作后等待需要输入正整数"); return(false); } if (this.Entity == null) { this.Entity = new AAction(); this.Entity.Id = Guid.NewGuid().ToString(); } this.Entity.BreakOnFail = this.comboBox2.SelectedIndex == 0; this.Entity.WaitResponse = this.comboBox1.SelectedIndex == 0; this.Entity.Predelay = Convert.ToInt32(this.textBox2.Text.Trim()); this.Entity.Postdelay = Convert.ToInt32(this.textBox4.Text.Trim()); this.Entity.Name = this.textBox1.Text.Trim(); this.Entity.Command = this.textBox3.Text.Trim(); return(true); }
private async Task SendActionToConnection(AAction action, string connectionId) { var json = LambdaSerializer.Serialize <object>(action); if (DebugLoggingEnabled) { LogDebug($"Post to connection: {connectionId}\n{{0}}", json); } else { LogInfo($"Post to connection: {connectionId}"); } // attempt to send serialized message to connection var messageBytes = Encoding.UTF8.GetBytes(json); try { await _amaClient.PostToConnectionAsync(new PostToConnectionRequest { ConnectionId = connectionId, Data = new MemoryStream(messageBytes) }); } catch (AmazonServiceException e) when(e.StatusCode == System.Net.HttpStatusCode.Gone) { // HTTP Gone status code indicates the connection has been closed; nothing to do } catch (Exception e) { LogErrorAsWarning(e, "PostToConnectionAsync() failed on connection {0}", connectionId); } }
public virtual void Awake() { gameObject.tag = "Animal"; gameObject.layer = LayerMask.NameToLayer("Animal"); nextPOS = RoundToIntVector3XZ(transform.position); DIR.z = 1; targetPOS = nextPOS + DIR + Vector3.up; if (GetComponent<Rigidbody>()) { } else { gameObject.AddComponent<Rigidbody>(); } GetComponent<Rigidbody>().useGravity = false; GetComponent<Rigidbody>().isKinematic = true; if (GetComponent<BoxCollider>()) { } else { gameObject.AddComponent<BoxCollider>(); } GetComponent<BoxCollider>().center = Vector3.up * ObjectScale.y / 2; GetComponent<BoxCollider>().size = ObjectScale; Inventory = transform.FindChild("Inventory"); ItemBag = Inventory.FindChild("ItemBag"); WeaponBag = Inventory.FindChild("WeaponBag"); RingBag = Inventory.FindChild("RingBag"); MindBag = Inventory.FindChild("MindBag"); Equipment = transform.FindChild("Equipment"); Weapon = Equipment.FindChild("Weapon"); Ring = Equipment.FindChild("Ring"); Mind = Equipment.FindChild("Mind"); Buffs = transform.FindChild("Buffs"); visionManager = transform.FindChild("Vision").GetComponent<VisionManager>(); visionManager.SetMindSlots(MindSlots); actionShortcuts = new AAction[9]; setMainComponentPool(); }
public WinAction(BComponent unit) : base(unit) { actionUnit = unit as AAction; imgOptions = Resources.Load <Texture>("opcje"); imgDelete = Resources.Load <Texture>("usun"); if (unit is ActionBool) { txtType = "Bool"; imgActionType = Resources.Load <Texture>("ActionBollean"); } else if (unit is ActionEnumerator) { txtType = "Enumerator"; imgActionType = Resources.Load <Texture>("ActionEnumerator"); } else if (unit is ActionProperty) { txtType = "Property"; imgActionType = Resources.Load <Texture>("ActionProperty"); } else if (unit is ActionVoid) { txtType = "Void"; imgActionType = Resources.Load <Texture>("ActionVoid"); } }
public Node(WorldState currentWP, AAction action, int accCost) { this.currentWorldState = currentWP; this.action = action; this.accCost = accCost; heuristicCost = 0; }
public void StartAction <T>() { AAction newAction = null; foreach (AAction item in list) { if (item is T) { newAction = item; break; } } if (newAction == Action || newAction == null) { return; } if (Action == null) { Action = newAction; Action.Start(); } else if (list.IndexOf(newAction) > list.IndexOf(Action)) { Action.Stop(); Action = newAction; Action.Start(); } }
// Use this for initialization void Start() { m_state = State.Standing; //m_mode = new ControlMode(); forward = new Forward(); back = new Back(); right = new Right(); left = new Left(); plane = new Plane(forceSaut, this.GetComponents <Rigidbody>()[0]); }
public bool isActionAlreadyClosed(AAction action) { for (int j = 0; j < closedNodes.Count; j++) { if (closedNodes[j].action != null && closedNodes[j].action.Equals(action)) { return(true); } } return(false); }
public AAction FindAutoAction() { foreach (SAction action in actions) { if (action is AAction) { AAction aaction = (AAction)action; return(aaction); } } return(null); }
public async Task DoAction (AAction action) { if ( action.Execute( out ActionContext context, out string failureMessage ) ) { await Commit( context ); await Clients.Group( context.SessionId ) .SendAsync( "HandleSessionUpdate", new SessionUpdate { SessionId = context.SessionId, Game = context.Game, Board = context.Board } ); } else { Console.WriteLine( failureMessage ); await Clients.Caller.SendAsync( "LogMessage", failureMessage ); } }
private void ClickDelete(object sender, EventArgs arg) { AAction entity = this.myGridView1.FindFirstSelect <AAction>(); if (entity != null) { if (MessageBox.Show("是否删除数据?", "确认", MessageBoxButtons.OKCancel) == DialogResult.OK) { xmlBll.ActionList.Remove(entity); xmlBll.SaveActions(); xmlBll.Load(); this.myGridView1.LoadData(this.xmlBll.ActionList, base.ignoreFields); } } }
public async Task UndoAction (AAction action, string actionId) { if ( action.UnExecute( out ActionContext context, actionId, out string failureMessage ) ) { context.Game!.RemoveGameAction( actionId ); await Commit( context ); Console.WriteLine($"SessionId: {context.SessionId}"); await Clients.Group( context.SessionId ) .SendAsync( "HandleSessionUpdate", new SessionUpdate { SessionId = context.SessionId, Game = context.Game, Board = context.Board } ); } else { Console.WriteLine( failureMessage ); await Clients.Caller.SendAsync( "LogMessage", failureMessage ); } }
/** * Main function to deal with interaction * */ public void ProximityInteraction() { // First we select the closest target in the proximityTargets list GameObject target = GetClosestTarget(); if (target == null) { return; } // Then we try to find a suitable action for this target AAction suitableAction = GetSuitableAction(target); if (suitableAction == null) { return; } // If there is indeed a suitable action, we act suitableAction.Act(target); }
private void LoadActions() { this.ActionList = new List <AAction>(); ActionList = new List <AAction>(); XElement xe = XElement.Load(actionXml); foreach (var inst in xe.Descendants("action")) { AAction Action = new AAction(); Action.Id = inst.Attribute("id").Value; Action.Name = GetAttributeValue(inst.Attribute("name")); string waitResponseString = GetAttributeValue(inst.Attribute("waitresponse")); if (!string.IsNullOrEmpty(waitResponseString)) { Action.WaitResponse = bool.Parse(waitResponseString); } string breakOnFailString = GetAttributeValue(inst.Attribute("breakOnFail")); if (!string.IsNullOrEmpty(breakOnFailString)) { Action.BreakOnFail = bool.Parse(breakOnFailString); } string predelayString = GetElementValue(inst.Element("predelay")); if (!string.IsNullOrEmpty(predelayString)) { Action.Predelay = int.Parse(predelayString); } string postdelayString = GetElementValue(inst.Element("postdelay")); if (!string.IsNullOrEmpty(postdelayString)) { Action.Postdelay = int.Parse(postdelayString); } Action.Command = GetElementValue(inst.Element("command")); ActionList.Add(Action); } }
public override void Execute(Player player, AAction action) { Move(player.gameObject.transform); }
public abstract void Execute(Player player, AAction action);
APlugin(AAction action) { Action = action; }
public void AddAction(AAction AnyAction) { isInput = true; if (Interrupting) { } else { if (actionStack[0] == null) { actionStack[0] = AnyAction; actionStack[1] = mainComponentPool.GetComponent<Idle>(); actionStack[2] = null; } else { actionStack[1] = AnyAction; actionStack[2] = mainComponentPool.GetComponent<Idle>(); } } }
/// <summary> /// kowai /// </summary> /// <param name="colliderInfo"></param> protected void OnTriggerEnter(Collider colliderInfo) { if (colliderInfo.gameObject.layer == LayerMask.NameToLayer("Item")) { mainComponentPool.GetComponent<PickUp>().TargetItem = colliderInfo.gameObject.GetComponent<AItem>(); SubmitAction = mainComponentPool.GetComponent<PickUp>(); } else if (colliderInfo.gameObject.layer == LayerMask.NameToLayer("DamageField")) { focusedAnimal = colliderInfo.gameObject.GetComponent<ADamageField>().Creator; } }
protected void OnTriggerExit(Collider colliderInfo) { if (colliderInfo.gameObject.layer == LayerMask.NameToLayer("Item")) { SubmitAction = null; } }