Ejemplo n.º 1
0
        private void initialiseNaviClient(Client peer, Navi_Name_ID NaviID, ulong NAVIEXEID)
        {
            NetNavi_Type navi = Navi_resources.Get_Data(NaviID, NAVIEXEID);

            navi.Initialised  = true;
            navi.Program_Step = NaviData.Host_Navi.Program_Step;
            NaviData.Client_Navi[peer.Name] = navi;
        }
Ejemplo n.º 2
0
        private void handle_Approved(Client peer)
        {
            networkName    = peer.ReadString();                  // read our network name
            networkCaptain = peer.ReadString();                  // read captains name

            Navi_Name_ID name  = (Navi_Name_ID)peer.ReadInt32(); // read name
            ulong        EXEID = peer.ReadUInt64();              // read EXEID

            NaviData.Host_Navi.Program_Step = peer.ReadUInt64(); // read the current program step
            pending_peers = peer.ReadInt32();                    // read number of soon-to-be incoming connections
            initialiseNaviClient(peer, name, EXEID);

            Console.WriteLine("Connected to host " + peer.IPAddress);
            peer.Authenticated = true;
            changePeerName(peer.Name, networkCaptain);
            //Send first update to captain
            packet_NaviUpdate(peer, NaviData.Host_Navi);
        }
Ejemplo n.º 3
0
        //Captain should only call this
        private string getUniqueNaviName(Navi_Name_ID name, ulong EXEID)
        {
            string peerName = name.ToString() + EXEID.ToString();
            string hostName = NaviData.Host_Navi.ToString() + NaviData.Host_Navi.NAVIEXEID.ToString();

            for (int x = 0; x < 500; x++)
            {
                if (!peers.ContainsKey(peerName + "-" + x.ToString()))
                {
                    if (networkName != (peerName + "-" + x.ToString()))
                    {
                        return(peerName + "-" + x.ToString());
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 4
0
 public void CopyToNavi(NetNavi_Network_Type b)
 {
     Program_Step      = b.Program_Step;
     NAVIEXEID         = b.NAVIEXEID;
     NaviID            = b.NaviID;
     Location          = b.Location;
     Speed             = b.Speed;
     Scale             = b.Scale;
     Sprite            = b.Sprite;
     Health            = b.Health;
     Energy            = b.Energy;
     Activated_Ability = b.Activated_Ability;
     OnGround          = b.OnGround;
     FaceLeft          = b.FaceLeft;
     Running           = b.Running;
     Jumping           = b.Jumping;
     HasJumped         = b.HasJumped;
     Shooting          = b.Shooting;
     WallGrabing       = b.WallGrabing;
     Dashing           = b.Dashing;
     HasDashed         = b.HasDashed;
 }
Ejemplo n.º 5
0
        private void handle_RequestJoin(Client peer)
        {
            if (networkCaptain != null) // we are not the captain
            {
                if (!packet_RedirectToCaptian(peer))
                {
                    disconnectPeer(peer); return;
                }
            }

            if (peerCount == MAX_PEERS) // full
            {
                if (!packet_DeniedFull(peer))
                {
                    disconnectPeer(peer); return;
                }
            }

            int          port  = peer.ReadInt32();               // read port
            Navi_Name_ID name  = (Navi_Name_ID)peer.ReadInt32(); // read name
            ulong        EXEID = peer.ReadUInt64();              // read EXEID

            string peerName = getUniqueNaviName(name, EXEID);

            if (peerName == null)
            {
                disconnectPeer(peer); return;
            }

            if (!packet_ApproveClient(peer, peerName, port))
            {
                return;                                              // Approve and send them their name
            }
            changePeerName(peer.Name, peerName);
            initialiseNaviClient(peer, name, EXEID);
            Console.WriteLine("Client " + peerName + " at " + peer.IPAddress + " Authenticated");
            peer.Authenticated = true;
        }
Ejemplo n.º 6
0
        public static NetNavi_Type Get_Data(Navi_Name_ID Navi_Name, ulong NAVIEXEID)
        {
            NetNavi_Type N = new NetNavi_Type();

            switch (Navi_Name)
            {
            case
                Navi_Name_ID.Junker:
                N.Navi_Display_Name = "Junker";
                N.HitBox            = new Rectangle(0, 0, 35, 27);
                N.SpriteSheet       = Net_Navis.Resource1.Junker;
                N.GLSpriteSheetName = GLNaviSpriteName.Junker;
                N.Icon        = Net_Navis.Resource1.Rebel_Icon;
                N.SpriteSize  = new Point(35, 27);
                N.HealthMax   = 10;
                N.EnergyMax   = 10;
                N.Weight      = 10;
                N.GroundSpeed = 0f;
                N.AirSpeed    = 0f;
                N.DashSpeed   = 0;
                N.Acrobatics  = 0;
                break;

            case
                Navi_Name_ID.Raven:
                N.Navi_Display_Name = "Raven";
                N.HitBox            = new Rectangle(10, 22, 26, 26);
                N.SpriteSheet       = Net_Navis.Resource1.Raven;
                N.GLSpriteSheetName = GLNaviSpriteName.Raven;
                N.Icon        = Net_Navis.Resource1.Raven_Icon;
                N.SpriteSize  = new Point(48, 48);
                N.HealthMax   = 100;
                N.EnergyMax   = 100;
                N.Weight      = 50;
                N.GroundSpeed = 0.5f;
                N.AirSpeed    = 0.15f;
                N.DashSpeed   = 1;
                N.Acrobatics  = 15;
                N.ShootPoint  = new Point(40, 33);
                break;

            case
                Navi_Name_ID.Vex:
                N.Navi_Display_Name = "Vex";
                N.HitBox            = new Rectangle(11, 18, 29, 30);
                N.SpriteSheet       = Net_Navis.Resource1.Vex;
                N.GLSpriteSheetName = GLNaviSpriteName.Vex;
                N.Icon        = Net_Navis.Resource1.Vex_Icon;
                N.SpriteSize  = new Point(48, 48);
                N.HealthMax   = 100;
                N.EnergyMax   = 100;
                N.Weight      = 25;
                N.GroundSpeed = 0.5f;
                N.AirSpeed    = 0.1f;
                N.DashSpeed   = 2;
                N.Acrobatics  = 10;
                N.ShootPoint  = new Point(37, 34);
                break;

            case
                Navi_Name_ID.Barnabus:
                N.Navi_Display_Name = "Barnabus";
                N.HitBox            = new Rectangle(3, 5, 27, 27);
                N.SpriteSheet       = Net_Navis.Resource1.Barnabus;
                N.GLSpriteSheetName = GLNaviSpriteName.Barabus;
                N.Icon        = Net_Navis.Resource1.Barnabus_Icon;
                N.SpriteSize  = new Point(32, 32);
                N.HealthMax   = 100;
                N.EnergyMax   = 100;
                N.Weight      = 50;
                N.GroundSpeed = 0.5f;
                N.AirSpeed    = 0.1f;
                N.DashSpeed   = 1;
                N.Acrobatics  = 10;

                break;

            case
                Navi_Name_ID.Rebel:
                N.Navi_Display_Name = "Rebel";
                N.HitBox            = new Rectangle(13, 22, 22, 26);
                N.SpriteSheet       = Net_Navis.Resource1.Rebelpullsheet;
                N.GLSpriteSheetName = GLNaviSpriteName.Rebel;
                N.Icon        = Net_Navis.Resource1.Rebel_Icon;
                N.SpriteSize  = new Point(48, 48);
                N.HealthMax   = 100;
                N.EnergyMax   = 100;
                N.Weight      = 30;
                N.GroundSpeed = 0.5f;
                N.AirSpeed    = 0.1f;
                N.DashSpeed   = 1;
                N.Acrobatics  = 10;
                break;

            case
                Navi_Name_ID.Zen:
                N.Navi_Display_Name = "Zen";
                N.HitBox            = new Rectangle(15, 21, 19, 27);
                N.SpriteSheet       = Net_Navis.Resource1.Zen;
                N.GLSpriteSheetName = GLNaviSpriteName.Zen;
                N.Icon        = Net_Navis.Resource1.Zen_Icon;
                N.SpriteSize  = new Point(48, 48);
                N.HealthMax   = 100;
                N.EnergyMax   = 100;
                N.Weight      = 15;
                N.GroundSpeed = 0.8f;
                N.AirSpeed    = 0.1f;
                N.DashSpeed   = 2;
                N.Acrobatics  = 10;
                N.ShootPoint  = new Point(35, 37);
                break;

            case
                Navi_Name_ID.DC24:
                N.Navi_Display_Name = "DC24";
                N.HitBox            = new Rectangle(18, 9, 34, 49);
                N.SpriteSheet       = Net_Navis.Resource1.DC24;
                N.GLSpriteSheetName = GLNaviSpriteName.DC24;
                N.Icon        = Net_Navis.Resource1.DC24_Icon;
                N.SpriteSize  = new Point(64, 64);
                N.HealthMax   = 100;
                N.EnergyMax   = 100;
                N.Weight      = 15;
                N.GroundSpeed = 0.2f;
                N.AirSpeed    = 0.1f;
                N.DashSpeed   = 0.3f;
                N.Acrobatics  = 10;
                N.ShootPoint  = new Point(51, 29);
                break;
            }
            N.NaviID    = Navi_Name;
            N.NAVIEXEID = NAVIEXEID;
            N.Location  = new PointF(0, 0);
            N.Sprite    = new Point(0, 0);
            return(N);
        }