private void HideUI(object sender, EventMsg e) { var v = e as EventSingleArgs <View>; v.value.OnHide(); FireEvent((int)UIEventList.OnHideUI, this, EventGroup.NewArg <EventSingleArgs <View>, View>(v.value)); }
private void ShowUI(object sender, EventMsg e) { var msg = e as EventThreeArgs <string, Type, object>; string uiName = msg.value1; Type t = msg.value2; object para = msg.value3; bool isLoading = false; for (int i = 0; i < _waitingForLoadView.Count; i++) { if (_waitingForLoadView[i].UiName.Equals(uiName)) { isLoading = true; break; } } if (!isLoading) { _waitingForLoadView.Add(new PendingViewInfo() { UiName = uiName, UiType = t, Param = para }); AssetResources.LoadAsset(uiName, OnLoadUI); } }
//If I try to move to a tile, run the bump code on any object in the area and if none stop me move there public void Move(TileModel target) { if (target == null) { return; } if (target.GetContents() != null) { //if (Type == ThingTypes.Player) { // Debug.Log(HasKey + "THIS MAN KEY PROTOCOL"); //} EventMsg bumpMsg = new EventMsg(EventType.GetBumped, this); target.GetContents().TakeMsg(bumpMsg); //if (!target.GetContents().View.transform.Find("SpecialWall")) { // EventMsg bumpMsg = new EventMsg(EventType.GetBumped, this); // target.GetContents().TakeMsg(bumpMsg); //} //else { // SetLocation(target); //} } else { SetLocation(target); } }
public void OnWork(EventMsg e) { if (OnWorking != null) { OnWorking(this, e); } }
public void SendMsg(object sender, EventMsg e) { var msg = e as EventSingleArgs <NetDataWriter>; _netManger.SendToAll(msg.value, SendOptions.ReliableOrdered); _netManger.Flush(); }
public void ShowUploadPolicyLog(EventMsg e) { if (this.InvokeRequired) { ShowUploadPolicy setpos = new ShowUploadPolicy(ShowUploadPolicyLog); this.Invoke(setpos, new object[] { e }); } else { LogContext log = new LogContext(); //showMsg = new Action<EventMsg>((txt) => // { string dis = string.IsNullOrEmpty(e.Msg) ? "" : ",描述:" + e.Msg; string exption = e.Exception == null ? "" : ",异常:" + e.Exception; if (this.lstBoxLog.Items.Count >= 34) { this.lstBoxLog.Items.Remove(this.lstBoxLog.Items[0]); } this.lstBoxLog.Items.Add(DateTime.Now + ":上传平台:" + e.PurchaserType.ToString() + "状态:" + e.Status.ToString() + dis + exption); string path = System.IO.Directory.GetCurrentDirectory(); DateTime CurrTime = DateTime.Now; string strPath = path + "\\HandDataLog\\" + CurrTime.Year + "-" + CurrTime.Month + "\\" + CurrTime.Day + ".txt"; log.AddLogInfo(strPath, DateTime.Now + ":" + JsonConvert.SerializeObject(e).ToString(), true); } }
public override void TakeMsg(ActorModel who, EventMsg msg) { switch (msg.Type) { case EventType.TakeDmg: int amount = msg.Amount; God.C.AddAction(new TakeDamageAction(who, amount)); ModelManager.TakeDamage(amount); return; case EventType.PlayerInput: if (msg.Dir == Inputs.Left) { who.Move(-1, 0); } else if (msg.Dir == Inputs.Right) { who.Move(1, 0); } else if (msg.Dir == Inputs.Up) { who.Move(0, 1); } else if (msg.Dir == Inputs.Down) { who.Move(0, -1); } return; case EventType.GetName: msg.Text += " PLAYER"; return; } }
private void OnSceneObjectRemoveComponent(object sender, EventMsg msg) { var so = sender as SceneObject; var e = msg as EventSingleArgs <SceneObjectBaseComponent>; RemoveComponent(e.value); }
public void MsgAll(EventMsg msg) { foreach (ActorModel am in ModelManager.GetActors()) { am.TakeMsg(msg); } }
public virtual void OnMiddlewareWorking(EventMsg msg) { if (MiddlewareWorking != null) { MiddlewareWorking(this, msg); } }
private void OnSceneObjectAddComponent(object sender, EventMsg msg) { var so = sender as SceneObject; var e = msg as EventSingleArgs <SceneObjectBaseComponent>; AddComponent(e.value.GetType(), so); }
public override string ToString() { EventMsg nam = new EventMsg(EventType.GetName, null); nam.Text = "WT: "; TakeMsg(nam); return(nam.Text); }
private void OnAddSceneObject(object sender, EventMsg e) { EventSingleArgs <SceneObject> msg = e as EventSingleArgs <SceneObject>; U3DSceneObject uso = new U3DSceneObject(); uso.Init(msg.value); AddObject(msg.value.Id, uso); }
private void OnRemoveSceneObject(object sender, EventMsg e) { EventSingleArgs <int> msg = e as EventSingleArgs <int>; U3DSceneObject uso = GetObject(msg.value); uso.Destroy(); RemoveObject(msg.value); }
private void OnJoystickEnd(object sender, EventMsg e) { IsPressing = false; var cmd = Pool.SP.Get <StopCommand>(); cmd.Sender = SceneObject.Id; LogicCore.SP.LockFrameMgr.SendCommand(cmd); }
private void OnJoystickStart(object sender, EventMsg e) { IsPressing = true; var cmd = Pool.SP.Get <MoveCommand>(); cmd.Sender = SceneObject.Id; LogicCore.SP.LockFrameMgr.SendCommand(cmd); }
public void ShowMsg(object sender, EventMsg msg) { msg.PurchaserType = PurchaserType.Qunar; if (OnWoking != null) { OnWoking(sender, msg); } }
public override bool Equals(object obj) { EventMsg m = obj as EventMsg; return(m != null && this.Type == m.Type && this.Id == m.Id && this.Field == m.Field); }
private void OnSceneObjRemove(object sender, EventMsg e) { var msg = e as EventSingleArgs <SceneObject>; if (msg != null && msg.value != null && msg.value.Team == _commander.Team && msg.value is IAlignmentAgent) { _npcs.Remove(msg.value as IAlignmentAgent); } }
private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam) { if (nCode == 0) { EventMsg msg = (EventMsg)Marshal.PtrToStructure(lParam, typeof(EventMsg)); if (wParam == 0x100) //WM_KEYDOWN=0x100 { barCode.VirtKey = msg.message & 0xff; //虚拟吗 barCode.ScanCode = msg.paramL & 0xff; //扫描码 StringBuilder strKeyName = new StringBuilder(225); if (GetKeyNameText(barCode.ScanCode * 65536, strKeyName, 255) > 0) { barCode.KeyName = strKeyName.ToString().Trim(new char[] { ' ', '\0' }); } else { barCode.KeyName = ""; } byte[] kbArray = new byte[256]; uint uKey = 0; GetKeyboardState(kbArray); if (ToAscii(barCode.VirtKey, barCode.ScanCode, kbArray, ref uKey, 0)) { barCode.Ascll = uKey; barCode.Chr = Convert.ToChar(uKey); } TimeSpan ts = DateTime.Now.Subtract(barCode.Time); if (ts.TotalMilliseconds > 50) { strBarCode = barCode.Chr.ToString(); } else { if ((msg.message & 0xff) == 13 && strBarCode.Length > 3) { barCode.BarCode = strBarCode; barCode.IsValid = true; } strBarCode += barCode.Chr.ToString(); } barCode.Time = DateTime.Now; if (BarCodeEvent != null) { BarCodeEvent(barCode); //触发事件 } barCode.IsValid = false; } } return(CallNextHookEx(hKeyboardHook, nCode, wParam, lParam)); }
public static void TriggerEvent(string eventName, System.Object arg = null) { EventMsg thisEvent = null; if (Instance._eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(arg); } }
private void OnTargetPosiChanged(object sender, EventMsg e) { var curPosi = target.Position; if (Vector3d.SqrDistance(curPosi, previousPosi) > 1) { CacualtePath(); } }
private void PlayDisplayAction(object sender, EventMsg e) { var msg = e as EventSingleArgs <DisplayAction>; Type t = U3DDisplayAction.LogicDisplayActions[msg.value.GetType()]; var u3dAction = Pool.SP.Get(t) as U3DDisplayAction; u3dAction.Action = msg.value; _displayActions.Add(u3dAction); u3dAction.Execute(this, null, null); }
private void OnSceneObjCreate(object sender, EventMsg e) { var msg = e as EventSingleArgs <SceneObject>; if (msg != null && msg.value != null && msg.value.Team == _commander.Team && msg.value is IAlignmentAgent) { _npcs.Add(msg.value as IAlignmentAgent); CaculateLastAlignment(); } }
public override void TakeMsg(ActorModel who, EventMsg msg) { switch (msg.Type) { case EventType.GetBumped: God.C.AddAction(new BumpAction(msg.Source, who.Location.x, who.Location.y)); who.View.GetComponentInChildren <SpriteRenderer>().color = new Color32(255, 255, 255, 255); who.View.transform.GetComponentInParent <TileView>().GetComponentInChildren <SpriteRenderer>().color = new Color32(255, 255, 255, 255); msg.Source.TakeMsg(new EventMsg(EventType.TakeDmg, who, 2)); return; case EventType.GetName: msg.Text += " " + "FakeKey"; return; case EventType.KeyMove: //Debug.Log("Move"); //who.Move() if (who.View.movement < God.GSM.monsterRound) { //God.GSM.monsterMovement++; } else if (who.View.movement == God.GSM.monsterRound) { int rand = Random.Range(0, 2); Debug.Log(rand); if (rand == 1) { if (who.Location.x > GameSettings.playerX) { who.Move(-1, 0); } else if (who.Location.x < GameSettings.playerX) { who.Move(1, 0); } } else if (rand == 0) { if (who.Location.y > GameSettings.playerY) { who.Move(0, -1); } else if (who.Location.y < GameSettings.playerY) { who.Move(0, 1); } } //God.GSM.AS.PlayOneShot(God.GSM.StompClip); who.View.movement = 0; } return; } }
public static IntPtr JournalPlaybackProc(int nCode, IntPtr wParam, IntPtr lParam) { //throw new Exception("checking"); switch ((NCode)nCode) { case NCode.HC_GETNEXT: //currentValue is a class level variable I use //which gets it's value from the HC_SKIP section. //this way no matter how many times HC_GETNEXT is called //we can give the same value EventMsg msg = currentValue; //lastTime is a class level variable I use //to save the time of the last EventMsg so //we can calculate delta. int delta = msg.time - lastTime; Marshal.StructureToPtr(msg, lParam, true); lastTime = msg.time; return(new IntPtr(delta > 0 ? delta : 0)); case NCode.HC_SKIP: string data = null; try { data = sr.ReadLine(); } catch (Exception) { sr.Close(); } //if our script is done we can stop. if (data == null) { currentValue = null; User32.UnhookWindowsHookEx(journalHook); return(IntPtr.Zero); } //get your message and put it in currentMessage currentValue = EventMsg.ParseFromJson(data); break; default: return(User32.CallNextHookEx(journalHook, nCode, wParam, lParam)); } return(IntPtr.Zero); }
public void TakeMsg(EventMsg msg) { if (!Listeners.ContainsKey(msg.Type)) { return; } foreach (Trait t in Listeners[msg.Type]) { t.TakeMsg(this, msg); } }
private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam) { EventMsg msg = (EventMsg)Marshal.PtrToStructure(lParam, typeof(EventMsg)); codes.Add(msg); if (ScanerEvent != null && msg.message == 13 && msg.paramH > 0 && !string.IsNullOrEmpty(codes.Result)) { ScanerEvent(codes); } return(CallNextHookEx(hKeyboardHook, nCode, wParam, lParam)); }
public static void Return(EventMsg e) { Type t = e.GetType(); if (!dic.ContainsKey(t)) { dic.Add(t, new Queue <EventMsg>()); } e.Clear(); dic[t].Enqueue(e); }
public void FireEvent(int e_id, object sender, EventMsg e) { if (_events.ContainsKey(e_id) && _events[e_id] != null) { _events[e_id].Invoke(sender, e); } if (e != null) { Return(e); } }