Ejemplo n.º 1
0
    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));
    }
Ejemplo n.º 2
0
    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);
        }
    }
Ejemplo n.º 3
0
    //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);
     }
 }
Ejemplo n.º 5
0
    public void SendMsg(object sender, EventMsg e)
    {
        var msg = e as EventSingleArgs <NetDataWriter>;

        _netManger.SendToAll(msg.value, SendOptions.ReliableOrdered);
        _netManger.Flush();
    }
Ejemplo n.º 6
0
        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);
            }
        }
Ejemplo n.º 7
0
    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;
        }
    }
Ejemplo n.º 8
0
    private void OnSceneObjectRemoveComponent(object sender, EventMsg msg)
    {
        var so = sender as SceneObject;
        var e  = msg as EventSingleArgs <SceneObjectBaseComponent>;

        RemoveComponent(e.value);
    }
Ejemplo n.º 9
0
 public void MsgAll(EventMsg msg)
 {
     foreach (ActorModel am in ModelManager.GetActors())
     {
         am.TakeMsg(msg);
     }
 }
Ejemplo n.º 10
0
 public virtual void OnMiddlewareWorking(EventMsg msg)
 {
     if (MiddlewareWorking != null)
     {
         MiddlewareWorking(this, msg);
     }
 }
Ejemplo n.º 11
0
        private void OnSceneObjectAddComponent(object sender, EventMsg msg)
        {
            var so = sender as SceneObject;
            var e  = msg as EventSingleArgs <SceneObjectBaseComponent>;

            AddComponent(e.value.GetType(), so);
        }
Ejemplo n.º 12
0
    public override string ToString()
    {
        EventMsg nam = new EventMsg(EventType.GetName, null);

        nam.Text = "WT: ";
        TakeMsg(nam);
        return(nam.Text);
    }
Ejemplo n.º 13
0
    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);
    }
Ejemplo n.º 14
0
    private void OnRemoveSceneObject(object sender, EventMsg e)
    {
        EventSingleArgs <int> msg = e as EventSingleArgs <int>;
        U3DSceneObject        uso = GetObject(msg.value);

        uso.Destroy();
        RemoveObject(msg.value);
    }
Ejemplo n.º 15
0
        private void OnJoystickEnd(object sender, EventMsg e)
        {
            IsPressing = false;
            var cmd = Pool.SP.Get <StopCommand>();

            cmd.Sender = SceneObject.Id;
            LogicCore.SP.LockFrameMgr.SendCommand(cmd);
        }
Ejemplo n.º 16
0
        private void OnJoystickStart(object sender, EventMsg e)
        {
            IsPressing = true;
            var cmd = Pool.SP.Get <MoveCommand>();

            cmd.Sender = SceneObject.Id;
            LogicCore.SP.LockFrameMgr.SendCommand(cmd);
        }
Ejemplo n.º 17
0
 public void ShowMsg(object sender, EventMsg msg)
 {
     msg.PurchaserType = PurchaserType.Qunar;
     if (OnWoking != null)
     {
         OnWoking(sender, msg);
     }
 }
Ejemplo n.º 18
0
            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);
            }
Ejemplo n.º 19
0
        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);
            }
        }
Ejemplo n.º 20
0
        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));
        }
Ejemplo n.º 21
0
    public static void TriggerEvent(string eventName, System.Object arg = null)
    {
        EventMsg thisEvent = null;

        if (Instance._eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(arg);
        }
    }
Ejemplo n.º 22
0
    private void OnTargetPosiChanged(object sender, EventMsg e)
    {
        var curPosi = target.Position;

        if (Vector3d.SqrDistance(curPosi, previousPosi) > 1)
        {
            CacualtePath();
        }
    }
Ejemplo n.º 23
0
    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);
    }
Ejemplo n.º 24
0
        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();
            }
        }
Ejemplo n.º 25
0
    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;
        }
    }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
 public void TakeMsg(EventMsg msg)
 {
     if (!Listeners.ContainsKey(msg.Type))
     {
         return;
     }
     foreach (Trait t in Listeners[msg.Type])
     {
         t.TakeMsg(this, msg);
     }
 }
Ejemplo n.º 28
0
        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));
        }
Ejemplo n.º 29
0
    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);
    }
Ejemplo n.º 30
0
 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);
     }
 }