Пример #1
0
        /// <summary>
        /// 更新状态
        /// </summary>
        public override void Update()
        {
            Vector2 pos       = Input.MousePositionInConsole;
            Vector2 cursorPos = new Vector2(pos.X / (int)manager.Graphics.CharWidth, pos.Y);

            bool enter = positions.Contains(cursorPos) && Input.MouseInConsole;

            if (enter)
            {
                OnEnter?.Invoke();
                if (Touch)
                {
                    if (Input.GetMouseButton(MouseButton.Left))
                    {
                        OnClick?.Invoke();
                    }
                }
                else
                {
                    if (Input.GetMouseButtonUp(MouseButton.Left))
                    {
                        OnClick?.Invoke();
                    }
                }
            }
            else
            {
                OnLeave?.Invoke();
            }
        }
Пример #2
0
        private void Late()
        {
            foreach (var other in Check)
            {
                if (other?.Associate == default)
                {
                    continue;
                }

                if (!Active.Contains(other))
                {
                    OnLeave.Invoke(other.Associate as PhysicsComponent);
                }
            }

            Check.Clear();

            foreach (var active in Active)
            {
                if (active?.Associate == default)
                {
                    continue;
                }

                Check.Add(active);
            }
        }
Пример #3
0
        internal void Leave(bool doReturn = true, bool checkLeave = true)
        {
            if (checkLeave)
            {
                var allowLeave = GetRoom()?.OnLeave(User);
                if (allowLeave == false)
                {
                    return;
                }
            }

            if (Rooms.Count != 0)
            {
                CurrentRoom = Rooms.Pop();
                User.MessageManager.ShownStats = CurrentRoom?.ShownStats ?? ShownStats.Default;
            }
            else
            {
                CurrentRoom = null;
            }

            OnLeave?.Invoke(User);

            if (doReturn)
            {
                GetRoom()?.OnReturn(User);
            }
        }
Пример #4
0
        public void SetConnection(Connection connection)
        {
            Connection = connection;

            Connection.OnClose   += (code) => OnLeave?.Invoke(code);
            Connection.OnError   += (message) => OnError?.Invoke(message);
            Connection.OnMessage += (bytes) => ParseMessage(bytes);
        }
Пример #5
0
 //Show message in chat room
 public void ServeClient()
 {
     while (true)
     {
         var message = new Message(TcpClient.GetStream());
         OnMessage?.Invoke(message);
         if (message.IsClosing())
         {
             OnLeave?.Invoke(this);
         }
     }
 }
        public void SetConnection(Connection connection)
        {
            Connection = connection;

            Connection.OnClose += (code) => OnLeave?.Invoke(code);

            // TODO: expose WebSocket error code!
            // Connection.OnError += (code, message) => OnError?.Invoke(code, message);

            Connection.OnError   += (message) => OnError?.Invoke(0, message);
            Connection.OnMessage += (bytes) => ParseMessage(bytes);
        }
        /// <summary>
        ///     Called by the <see cref="ColyseusClient" /> upon connection to a room
        /// </summary>
        /// <param name="colyseusConnection">The connection created by the client</param>
        public void SetConnection(ColyseusConnection colyseusConnection)
        {
            this.colyseusConnection = colyseusConnection;

            this.colyseusConnection.OnClose += code => OnLeave?.Invoke(code);

            // TODO: expose WebSocket error code!
            // Connection.OnError += (code, message) => OnError?.Invoke(code, message);

            this.colyseusConnection.OnError   += message => OnError?.Invoke(0, message);
            this.colyseusConnection.OnMessage += bytes => ParseMessage(bytes);
        }
        public void Remove(Person p)
        {
            IConsole      link = p;
            StringBuilder sb   = new StringBuilder();

            sb.AppendFormat("\n[{0} ушел домой]", p.Name);
            link.WriteLine(sb);

            office.Remove(p);
            OnLeave -= p.Goodbye;
            OnLeave?.Invoke(this, new OfficeEventArgs(p));
            OnCame -= p.Greet;
        }
Пример #9
0
        private void OnLeftSubNode(Node node)
        {
            OnLeave?.Invoke(node);
            if (lastSubNode == node)
            {
                lastSubNode = null;
            }

            if (isActivatingNewLink && activatingSubNode == null)
            {
                node.ActivatingLinkEnd();
                Element.VisualElement.AddToClassList(ActivatingLinkClass);
            }
        }
Пример #10
0
        private void FinishLeaving()
        {
            if (state == State.Fleeing)
            {
                // Drop any excess coins
                while (Coins > 0)
                {
                    DropCoin();
                }
            }

            state = State.None;
            OnLeave?.Invoke(this);
            Destroy(gameObject);
            SpawnPoofCloud();
        }
Пример #11
0
 /// <summary>
 /// gibt zurück ob der mauscursor über der komponente ist
 /// </summary>
 /// <param name="location"></param>
 /// <returns></returns>
 public virtual bool OnHover(Vector location)
 {
     if (location.X > this.location.X && location.X < this.location.X + size.X && this.location.Y < location.Y && this.location.Y + size.Y > location.Y)
     {
         if (hovering == false)
         {
             OnEnter?.Invoke(this, location);
         }
         return(hovering = true);
     }
     if (hovering == true)
     {
         OnLeave?.Invoke(this, location);
     }
     return(hovering = false);
 }
Пример #12
0
        private void Leaving(ActionPoint sender, Load load)
        {
            load.OnDisposed -= CurrentLoadDisposed;
            ClearCurrentLoadRemovedEvent(load.Route);

            OnLeave?.Invoke(this, load);

            if (previousload != null && previousload.Equals(load))
            {
                previousload = null;
            }

            if (currentload != null && currentload.Equals(load))
            {
                currentload = null;
            }
        }
 /// <summary>
 ///     Leave the room
 /// </summary>
 /// <param name="consented">If the user agreed to this disconnection</param>
 /// <returns>Connection closure depending on user consent</returns>
 public async Task Leave(bool consented = true)
 {
     if (Id != null)
     {
         if (consented)
         {
             await colyseusConnection.Send(new[] { ColyseusProtocol.LEAVE_ROOM });
         }
         else
         {
             await colyseusConnection.Close();
         }
     }
     else
     {
         OnLeave?.Invoke(WebSocketCloseCode.Normal);
     }
 }
Пример #14
0
 /// <summary>
 /// Leave the room.
 /// </summary>
 public async Task Leave(bool consented = true)
 {
     if (Id != null)
     {
         if (consented)
         {
             await Connection.Send(new object[] { Protocol.LEAVE_ROOM });
         }
         else
         {
             await Connection.Close();
         }
     }
     else if (OnLeave != null)
     {
         OnLeave?.Invoke(NativeWebSocket.WebSocketCloseCode.Normal);
     }
 }
Пример #15
0
 /// <summary>
 /// Leave the room.
 /// </summary>
 public void Leave(bool consented = true)
 {
     if (Id != null)
     {
         if (consented)
         {
             Connection.Send(new object[] { Protocol.LEAVE_ROOM });
         }
         else
         {
             Connection.Close();
         }
     }
     else if (OnLeave != null)
     {
         OnLeave.Invoke(this, new EventArgs());
     }
 }
Пример #16
0
        public void SetConnection(Connection connection)
        {
            Connection = connection;

            Connection.OnClose += (object sender, EventArgs e) => {
                if (OnLeave != null)
                {
                    OnLeave.Invoke(this, e);
                }
            };

            Connection.OnError += (object sender, ErrorEventArgs e) => {
                if (OnError != null)
                {
                    OnError.Invoke(this, e);
                }
            };

            OnReadyToConnect.Invoke(this, new EventArgs());
        }
        internal override void DidReceive(object queryObj, Event objEvent, ParseObject objState)
        {
            ParseQuery <T> query = (ParseQuery <T>)queryObj;
            //T obj = ParseClient.Instance.ServicesFromState<T>(objState, query.GetClassName());

            // Copyed from internal code
            //T obj = (T)ObjectServiceExtensions.CreateObjectWithoutData(ParseClient.Instance.Services, query.GetClassName(), objState.ObjectId);
            T obj = (T)objState;

            // Fire those events!
            switch (objEvent)
            {
            case Event.Create:
                OnCreate?.Invoke(query, obj);
                break;

            case Event.Enter:
                OnEnter?.Invoke(query, obj);
                break;

            case Event.Update:
                OnUpdate?.Invoke(query, obj);
                break;

            case Event.Leave:
                OnLeave?.Invoke(query, obj);
                break;

            case Event.Delete:
                OnDelete?.Invoke(query, obj);
                break;

            default:
                throw new NotImplementedException("The following event type has not been handeled " + objEvent);
            }

            foreach (EventsCallback <T> eventsCallback in _eventsCallbacks)
            {
                eventsCallback(query, objEvent, obj);
            }
        }
Пример #18
0
 public override void Update(double deltaTime)
 {
     base.Update(deltaTime);
     if (Input.onHover(ActRectangle))
     {
         OnHover?.Invoke(this, new UiEventArgs(Input.getPosition()));
     }
     if (Input.onLeave(ActRectangle))
     {
         OnLeave?.Invoke(this, new UiEventArgs(Input.getPosition()));
     }
     if (Input.OnMouseDown(Input.LeftButton) && Input.IsHover(ActRectangle))
     {
         OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.LeftButton));
     }
     if (Input.OnMouseDown(Input.MiddleButton) && Input.IsHover(ActRectangle))
     {
         OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.MiddleButton));
     }
     if (Input.OnMouseDown(Input.RightButton) && Input.IsHover(ActRectangle))
     {
         OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.RightButton));
     }
     if (Input.OnMouseUp(Input.LeftButton) && Input.IsHover(ActRectangle))
     {
         OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.LeftButton));
     }
     if (Input.OnMouseUp(Input.MiddleButton) && Input.IsHover(ActRectangle))
     {
         OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.MiddleButton));
     }
     if (Input.OnMouseUp(Input.RightButton) && Input.IsHover(ActRectangle))
     {
         OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.RightButton));
     }
 }
Пример #19
0
 void Room_OnLeave(object sender, EventArgs e)
 {
     Debug.Log("Left room!");
     OnLeave?.Invoke(sender, e);
 }
 public void GoHome()
 {
     OnLeave?.Invoke(this);
 }
Пример #21
0
 public static void Leave()
 {
     SetSimulationSpeed(SimulationSpeed.Normal);
     OnLeave?.Invoke();
     SceneManager.LoadSceneAsync("Overworld");
 }
Пример #22
0
 public void Leave()
 {
     OnLeave?.Invoke(this);
 }
Пример #23
0
 public void DispatchLeave(string id)
 {
     Utilities.Logger.Info($"Client {id} left {Uri}");
     OnLeave?.Invoke(id, _manager.Clients.ToArray());
 }
Пример #24
0
 public void RLeave() => OnLeave?.Invoke(null, null);
Пример #25
0
 protected override void OnMouseLeave(UIMouseEventParameter p)
 {
     base.OnMouseLeave(p);
     OnLeave?.Invoke(this, p);
 }
Пример #26
0
        public static void TimerElapsed()
        {
            var eventTime = Trim(DateTime.UtcNow);

            try
            {
                List <Downloader.MemberData> membercache;
                if (File.Exists($"{BASE_DIR}/membercache.csv"))
                {
                    membercache = Downloader.ParseMemberData(File.ReadAllText($"{BASE_DIR}/membercache.csv")).ToList();
                }
                else
                {
                    membercache = new List <Downloader.MemberData>();
                }
                string result = Client.GetStringAsync($"http://services.runescape.com/m=clan-hiscores/members_lite.ws?clanName={Downloader.CLAN_NAME}").GetAwaiter().GetResult();
                if (result != null && !result.StartsWith("Clanmate"))
                {
                    return;
                }
                if (result != null && result.Length > 0)
                {
                    File.WriteAllText($"{BASE_DIR}/membercache.csv", result);
                }
                var current = Downloader.ParseMemberData(result).ToList();
                if (membercache.Count > 0 && current.Count > 0)
                {
                    var leave = Downloader.MemberData.Diff(membercache, current);
                    var join  = Downloader.MemberData.Diff(current, membercache);
                    if (leave.Count > 0 && join.Count == 0)
                    {
                        foreach (var leaver in leave)
                        {
                            OnLeave?.Invoke(leaver.Name);
                        }
                    }
                    else if (leave.Count == 0 && join.Count > 0)
                    {
                        foreach (var joiner in join)
                        {
                            OnJoin?.Invoke(joiner.Name);
                        }
                    }
                    else
                    {
                        for (int i = join.Count - 1; i >= 0; i--)
                        {
                            for (int j = leave.Count - 1; j >= 0; j--)
                            {
                                var joiner = join[i];
                                var leaver = leave[j];

                                if (joiner.Rank == leaver.Rank && joiner.ClanXP == leaver.ClanXP && joiner.ClanKills == leaver.ClanKills)
                                {
                                    join.RemoveAt(i);
                                    leave.RemoveAt(j);
                                    OnNamechange?.Invoke(leaver.Name, joiner.Name);
                                    break;
                                }
                            }
                        }

                        if (join.Count > 0)
                        {
                            join.ForEach((item) => OnJoin?.Invoke(item.Name));
                        }
                        if (leave.Count > 0)
                        {
                            leave.ForEach((item) => OnLeave?.Invoke(item.Name));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            if (!Paused && !Updating && (Force || eventTime.Minute % 10 == 0))
            {
                Force    = false;
                Updating = true;
                try
                {
                    var profiles = Downloader.GetProfiles(Client, Downloader.GetClanList(Client));

                    string[] cappers = Downloader.GetCappersList(profiles);

                    var message = new StringBuilder();

                    foreach (var capper in cappers)
                    {
                        if (!CappedList.Contains(capper))
                        {
                            CappedList.Add(capper);
                            if (CappedMessages.Count > 0)
                            {
                                message.Append(string.Format(CappedMessages[Random.Next(0, CappedMessages.Count)], capper) + "\n");
                            }
                        }
                    }

                    if (message.Length > 0 && UpdateChannel != 0)
                    {
                        PostMessageAsync(UpdateChannel, message.ToString()).GetAwaiter().GetResult();
                    }
                    new Thread(() =>
                    {
                        string[] items = Downloader.GetItems(Client, profiles);
                        if (ItemChannel > 0)
                        {
                            try
                            {
                                var builder = new StringBuilder();
                                foreach (var item in items)
                                {
                                    if (builder.Length + item.Length + 1 >= 2000)
                                    {
                                        PostMessageAsync(ItemChannel, builder.ToString()).GetAwaiter().GetResult();
                                        builder.Clear();
                                    }
                                    builder.Append(item);
                                }
                                if (builder.Length > 0)
                                {
                                    PostMessageAsync(ItemChannel, builder.ToString()).GetAwaiter().GetResult();
                                }
                            }
                            catch { }
                        }
                        string[] achievements = Downloader.GetAchievements(Client, profiles);
                        if (AchievementWebhook != null && !Cache)
                        {
                            try
                            {
                                var builder = new StringBuilder();
                                foreach (var achievement in achievements)
                                {
                                    if (builder.Length + achievement.Length + 1 >= 2000)
                                    {
                                        AchievementWebhook.SendMessageAsync(builder.ToString());
                                        builder.Clear();
                                    }
                                    builder.Append(achievement);
                                }
                                if (builder.Length > 0)
                                {
                                    AchievementWebhook.SendMessageAsync(builder.ToString());
                                }
                            }
                            catch { }
                        }
                        Cache = false;
                    }).Start();
                }
                catch (Exception e) { Console.WriteLine(e.Message); }
                CappedList.Sort();
                WriteCookies();
                Updating = false;
                Console.WriteLine(new LogMessage(LogSeverity.Info, "Timer", $"Update finished in {(DateTime.UtcNow - eventTime).TotalMilliseconds}ms."));
            }
            if (eventTime == CurrentResetDate)
            {
                if (ResetChannel != 0)
                {
                    PostMessageAsync(ResetChannel, ResetMessage).GetAwaiter().GetResult();
                }
                if (ListChannel != 0)
                {
                    var      message = new StringBuilder();
                    string[] cappers = CappedList.ToArray();

                    message.Append($"**__Capped citizens for the week of {CurrentResetDate.ToShortDateString()}__**\n");

                    foreach (var capper in cappers)
                    {
                        message.Append($"{capper}\n");
                    }
                    PostMessageAsync(ListChannel, message.ToString()).GetAwaiter().GetResult();
                }
                WriteCookies();
                ProgressDate();
                CappedList.Clear();
            }
        }
Пример #27
0
 public void Component_OnLeave(Vector location) => OnLeave?.Invoke(this, location);
Пример #28
0
 public void Leave()
 {
     //Log.Information($"Fsm: {Fsm} State {StateEnum};Leave");
     OnLeave?.Invoke(this, null);
 }
Пример #29
0
 public void GoHome()
 {
     // logic
     OnLeave?.Invoke(this);
 }
Пример #30
0
        public void Bind(Host host)
        {
            _host = host;
            _host.AddHandler((short)LobbyMessages.RoomCreated, (m, c) => {
                if (RoomCreated != null)
                {
                    var ds        = DataStorage.CreateForRead(m.Body);
                    var roomToken = new Token();
                    roomToken.ReadFromDs(ds);

                    RoomCreated.Invoke(roomToken);
                }
            });
            _host.AddHandler((short)LobbyMessages.PlayerLeaved, (m, c) => {
                if (OnPlayerLeaved != null)
                {
                    var ds          = DataStorage.CreateForRead(m.Body);
                    var playerToken = new Token();
                    playerToken.ReadFromDs(ds);
                    OnPlayerLeaved.Invoke(playerToken);
                }
            });
            _host.AddHandler((short)LobbyMessages.SuccesfullyLeaved, (m, c) => {
                if (OnLeave != null)
                {
                    OnLeave.Invoke();
                }
            });
            _host.AddHandler((short)LobbyMessages.PlayerJoined, (m, c) => {
                if (OnPlayerJoined != null)
                {
                    var ds          = DataStorage.CreateForRead(m.Body);
                    var playerToken = new Token();
                    playerToken.ReadFromDs(ds);
                    OnPlayerJoined.Invoke(playerToken);
                }
            });
            _host.AddHandler((short)LobbyMessages.SuccesfullyJoined, (m, c) => {
                if (OnJoin != null)
                {
                    OnJoin.Invoke();
                }
            });
            _host.AddHandler((short)LobbyMessages.GameStarted, (m, c) => {
                if (OnGameStarted != null)
                {
                    var ds     = DataStorage.CreateForRead(m.Body);
                    _roomToken = new Token();
                    _roomToken.ReadFromDs(ds);
                    OnGameStarted.Invoke();
                }
            });
            _host.AddHandler((short)LobbyMessages.GetRoomsResponse, (m, c) => {
                if (OnRoomInfoRecieved != null)
                {
                    var roomTokens = new List <Token>();
                    roomTokens.FillDeserialize(m.Body);
                    OnRoomInfoRecieved.Invoke(roomTokens);
                }
            });
        }