示例#1
0
        public static List <CommNode> createSingleNodeList(Core.CommunicationNode node, Core.User user)
        {
            List <CommNode> commNodes = new List <CommNode>();

            //create known nodes
            if (Core.Core.Instance.commNodes.ContainsKey(node.id))
            {
                CommNode xmlNode = CommNode.createCommNode(
                    node,
                    user);
                commNodes.Add(xmlNode);
            }
            return(commNodes);
        }
示例#2
0
        public static CommNode createCommNode(SpacegameServer.Core.CommunicationNode node, SpacegameServer.Core.User user)
        {
            CommNode xmlNode = new CommNode();

            xmlNode.node = node;
            SpacegameServer.Core.CommNodeUser commNodeUser = node.commNodeUsers.ContainsKey(user.id) ?
                                                             node.commNodeUsers[user.id] :
                                                             new SpacegameServer.Core.CommNodeUser(user.id, node.id);

            xmlNode.commNodeUser = commNodeUser;

            xmlNode.visited            = node.commNodeUsers.ContainsKey(user.id);
            xmlNode.messageUnReadCount = xmlNode.visited ? node.commNodeMessages.Count(e => e.Key > commNodeUser.lastReadMessage) : 0;

            return(xmlNode);
        }
示例#3
0
        public static CommNode createAllianceCommNode(SpacegameServer.Core.User user)
        {
            CommNode xmlNode = new CommNode();

            Core.CommunicationNode node = Core.CommunicationNode.GetAllianceNode(user);

            xmlNode.node = node;

            if (node.commNodeUsers.ContainsKey(user.id))
            {
                xmlNode.commNodeUser = node.commNodeUsers[user.id];
            }

            xmlNode.visited            = true;
            xmlNode.messageUnReadCount = xmlNode.visited ? node.commNodeMessages.Count(e => e.Key > node.commNodeUsers[user.id].lastReadMessage) : 0;

            return(xmlNode);
        }
示例#4
0
        public static List <CommNode> createKnownAndNearNodesList(Core.User user)
        {
            List <CommNode> commNodes = new List <CommNode>();

            //create known nodes
            foreach (var node in user.commNodeRights)
            {
                if (Core.Core.Instance.commNodes.ContainsKey(node.Key))
                {
                    CommNode xmlNode = CommNode.createCommNode(
                        Core.Core.Instance.commNodes[node.Key],
                        user);
                    commNodes.Add(xmlNode);
                }
            }

            //fetch nearby nodes
            SpacegameServer.Core.NodeQuadTree.BoundarySouthWest boundarySouthWest    = new SpacegameServer.Core.NodeQuadTree.BoundarySouthWest(user.homeCoordX - 80, user.homeCoordY - 80);
            SpacegameServer.Core.NodeQuadTree.Bounding          NodeQuadTreeBounding = new SpacegameServer.Core.NodeQuadTree.Bounding(boundarySouthWest, 160);

            List <int> nearby = Core.Core.Instance.nodeQuadTree.queryRange(NodeQuadTreeBounding);

            foreach (var id in nearby)
            {
                if (Core.Core.Instance.commNodes.ContainsKey(id))
                {
                    var node = Core.Core.Instance.commNodes[id];

                    if (node.commNodeUsers.ContainsKey(user.id))
                    {
                        continue;
                    }

                    CommNode xmlNode = CommNode.createCommNode(
                        node,
                        user);

                    commNodes.Add(xmlNode);
                }
            }

            return(commNodes);
        }