Exemplo n.º 1
0
 private void P_OnObserve(int obj)
 {
     if (GameObjectsManager.GetObject(obj, out GameObject go))
     {
         PacketsSender.SpawnGameObject(this, go);
     }
 }
Exemplo n.º 2
0
        public override void Update()
        {
            base.Update();

            if (TargetId != -1)
            {
                if (stats[Stat.HEALTH] > 0 && Time.time > lastAttackTime + 1)
                {
                    if (GameObjectsManager.GetObject(TargetId, out Character target))
                    {
                        target.DealDamage(this, stats[Stat.DAMAGE]);
                        lastAttackTime = Time.time;
                    }
                }
            }
        }
Exemplo n.º 3
0
        protected override void OnClose(CloseEventArgs e)
        {
            Console.WriteLine("Player Disconnected " + e.Reason);
            GameObjectsManager.GetObject <Player>(ObjectRefId, out Player p);

            MongoCRUD c = new MongoCRUD("bridge-mmo");

            c.UpdateCharacter(Player);

            p.OnObserve     -= P_OnObserve;
            p.OnUnobserve   -= P_OnUnobserve;
            p.OnStatChanged -= P_OnStatChanged;

            GameObject.Destroy(p);

            UsersManager.RemoveUser(ObjectRefId);
        }
Exemplo n.º 4
0
        private void ReadMessage(int msgId, dynamic obj)
        {
            switch (msgId)
            {
            case 0:
                int x = (int)obj.x;
                int y = (int)obj.y;

                JObject pck = new JObject();
                pck["msgId"] = 2;
                pck["id"]    = ObjectRefId;
                pck["x"]     = x;
                pck["y"]     = y;

                var p = Player;
                p.posX = x;
                p.posY = y;

                foreach (var item in UsersManager.GetUsers(Player.Observed))
                {
                    item.Value.Send(pck.ToString());
                }

                Send(pck.ToString());
                break;

            case 1:
                if (GameObjectsManager.GetObject((int)obj.id, out GameObject go))
                {
                    go.Click(this);
                }
                break;

            case 2:
                if (ObjectRefId == -1)
                {
                    EnterGame((string)obj.hash);
                }
                break;
            }
        }