Exemplo n.º 1
0
        public void TestInsertTooManyShips()
        {
            ServerClass.TheWorld = new World();
            string path = "../../ValidStarsXmlSettings.xml";

            ServerClass.gameSettings = ServerClass.XmlSettingsReader(path);
            ServerClass.InsertStars();
            for (int i = 0; i < 100; i++)
            {
                ServerClass.InsertShip(i, "JohnDoe" + i, 0);
            }
            int      shipCount = 0;
            Vector2D vel       = new Vector2D(0, 0);

            foreach (Ship s in ServerClass.TheWorld.GetShipsAll())
            {
                if (shipCount == 0)
                {
                    Assert.AreEqual(0, s.ID);
                    Assert.AreEqual(0, s.score);
                    Assert.AreEqual("JohnDoe0", s.name);
                    Assert.AreEqual(vel, s.vel);
                }
                shipCount++;
            }
            Assert.AreEqual(100, shipCount);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Méthode exécutée à la fermeture de la fenêtre
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Partie_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Initialisation d'un nouvel objet de transfert de données en indiquant que l'on ferme la fenêtre
            dt       = new DataTransit();
            dt.Alive = false;
            this.updateOutputLog("Fermeture de la partie en cours", 0);

            // On envois les données et on ferme la connexion
            if (joueur == 1)
            {
                ClientClass.prepareSendData(dt);
                this.form.changeScanButtonActivate(true);
                ClientClass.CloseConnection();
                this.Dispose();
            }
            else
            {
                ServerClass.prepareSendData(dt);
                this.form.changeServerButtonActivate(true);
                ServerClass.CloseConnection();
                this.Dispose();
                this.form.InvokeClickServer();
            }

            // La fenêtre de configuration Bluetooth est réaffichée
            this.form.ChangeVisibily(true);
        }
Exemplo n.º 3
0
	public void ResetScene()
	{
		
		StartCoroutine(AsyncLoader());
        //SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        ServerClass.UpdateStatus();
	}
Exemplo n.º 4
0
        public void TestXmlReader()
        {
            string path = "../../ValidXmlSettings.xml";
            Dictionary <string, object> gameSettings = ServerClass.XmlSettingsReader(path);

            Assert.AreEqual(750, gameSettings["UniverseSize"]);
            Assert.AreEqual(16, gameSettings["MSPerFrame"]);
            Assert.AreEqual(6, gameSettings["FramesPerShot"]);
            Assert.AreEqual(300, gameSettings["RespawnRate"]);
            Assert.AreEqual(5, gameSettings["StartingHP"]);
            Assert.AreEqual(0.2, gameSettings["EnginePower"]);
            Assert.AreEqual(120, gameSettings["RespawnTime"]);
            List <double[]> temp    = (List <double[]>)gameSettings["stars"];
            int             counter = 0;

            foreach (double[] star in temp)
            {
                if (counter == 0)
                {
                    Assert.AreEqual((double)0, star[0]);
                    Assert.AreEqual((double)0, star[1]);
                    Assert.AreEqual(0.01, star[2]);
                }
                if (counter == 1)
                {
                    Assert.AreEqual((double)1, star[0]);
                    Assert.AreEqual((double)1, star[1]);
                    Assert.AreEqual(0.02, star[2]);
                }
                counter++;
            }
        }
Exemplo n.º 5
0
        public void TestInsertShip()
        {
            ServerClass.TheWorld = new World();
            string path = "../../ValidXmlSettings.xml";

            ServerClass.gameSettings = ServerClass.XmlSettingsReader(path);
            ServerClass.InsertShip(0, "JohnDoe", 0);
            ServerClass.InsertShip(1, "Timmy", 0);
            ServerClass.InsertStars();
            int      shipCount = 0;
            Vector2D vel       = new Vector2D(0, 0);

            foreach (Ship s in ServerClass.TheWorld.GetShipsAll())
            {
                if (shipCount == 0)
                {
                    Assert.AreEqual(0, s.ID);
                    Assert.AreEqual(0, s.score);
                    Assert.AreEqual("JohnDoe", s.name);
                    Assert.AreEqual(vel, s.vel);
                }
                shipCount++;
            }
            Assert.AreEqual(2, shipCount);
        }
Exemplo n.º 6
0
    public void setText()
    {
        ServerClass bs  = MyServer;
        Label       lbl = bs.Controls["label1"] as Label;

        lbl.Text = "New Text";
    }
Exemplo n.º 7
0
 // assume props array is deep-copied
 private Entity(ServerClass serverClass, EntityProperty?[] props, uint serial, bool inPvs)
 {
     ServerClass = serverClass;
     Props       = props;
     Serial      = serial;
     InPvs       = inPvs;
 }
Exemplo n.º 8
0
    public static void Main()
    {
        ServerClass serverObject = new ServerClass();

        // Create the thread object, passing in the
        // serverObject.InstanceMethod method using a
        // ThreadStart delegate.
        Thread InstanceCaller = new Thread(
            new ThreadStart(serverObject.InstanceMethod));

        // Start the thread.
        InstanceCaller.Start();

        Console.WriteLine("The Main() thread calls this after "
                          + "starting the new InstanceCaller thread.");

        // Create the thread object, passing in the
        // serverObject.StaticMethod method using a
        // ThreadStart delegate.
        Thread StaticCaller = new Thread(
            new ThreadStart(ServerClass.StaticMethod));

        // Start the thread.
        StaticCaller.Start();

        Console.WriteLine("The Main() thread calls this after "
                          + "starting the new StaticCaller thread.");
    }
Exemplo n.º 9
0
        /// <summary>
        /// Méthode permettant de reset la fenêtre en cours et ses variables
        /// </summary>
        private void Reset()
        {
            Victoire.Visible     = false;
            Instructions.Visible = false;

            temps.Text     = "100";
            temps.Location = new Point(this.ClientSize.Width / 2 - temps.Width / 2, temps.Location.Y);

            raquette.Location = new Point(raquette.Location.X, this.Height / 2 - raquette.Height / 2);

            scoreClient = 0;
            scoreServer = 0;
            score.Text  = scoreServer + "-" + scoreClient;

            if (joueur == 0)
            {
                ball.Visible  = true;
                ball.Location = new Point(this.ClientSize.Width / 2 - ball.Width / 2, this.ClientSize.Height / 2 - ball.Height / 2);
                b             = new Balle(ball.Location.X, ball.Location.Y);
                b.EnDehors    = false;

                // Envois de l'information de reset à l'adversaire
                dt       = new DataTransit();
                dt.Reset = true;
                ServerClass.prepareSendData(dt);
            }
            else
            {
                ball.Visible = false;
                b.Vitesse    = 0;
            }

            timerMvmt.Enabled   = true;
            timerChrono.Enabled = false;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates, configures and runs a new thread of type ServerClass, which will be resposible
        /// of managing incoming request of transmission.
        /// </summary>
        private void InitReceiverThread()
        {
            // Start the thread responsible of receiving request of transferring files
            receiver = new ServerClass();
            receiver.RequestReceived += (ToAccept request) => {
                AutoResetEvent goOn = new AutoResetEvent(false);    // To wait for the closing of the window
                // On the gui thread
                Application.Current.Dispatcher.Invoke((Action) delegate {
                    //mostra la finestra e prende in uscita path e response
                    ReceiveWindow rw = new ReceiveWindow(request);
                    openedWindow.Add(rw);
                    rw.Closed += (object target, EventArgs args) => {
                        goOn.Set();
                    };
                    rw.Show();
                    rw.Activate();
                });
                // wait until window is closed
                goOn.WaitOne();
                return(request);
            };

            /* Some callback must be registered to the receiver thread to instruct it about
             * what to do in case of errors during the tranfer. */
            receiver.ConnectionError += (Job j) => {
                if (j == null || j.Status == Job.JobStatus.ConnectionError)
                {
                    bf.NotifyError(BackgroundForm.ErrorNotificationType.Receiving, BackgroundForm.ErrorDirection.Receiving);
                }
            };
            receiver.PathError += manageIOException;
            // Run the receiver thread
            receiver.run();
        }
Exemplo n.º 11
0
        public void TestSetLeft()
        {
            ServerClass.TheWorld = new World();
            string path = "../../ValidXmlSettings.xml";

            ServerClass.gameSettings      = ServerClass.XmlSettingsReader(path);
            ServerClass.ClientConnections = new Dictionary <int, Client>();
            for (int i = 0; i < 4; i++)
            {
                Socket s = null;
                Networking.SocketState ss = new Networking.SocketState(s, socketstate => { }, i);
                Client c = new Client(i, "JonDoe" + i, ss);
                ServerClass.ClientConnections.Add(c.ID, c);
                ServerClass.InsertShip(i, "JonDoe" + 1, 0);
            }

            ServerClass.ClientConnections[0].left = true;
            Vector2D prevDir2 = ServerClass.TheWorld.GetShipAtId(0).dir;

            ServerClass.ProcessCommands();
            Assert.IsFalse(ServerClass.ClientConnections[0].right);
            Vector2D newDir2 = ServerClass.TheWorld.GetShipAtId(0).dir;

            Assert.AreNotEqual(prevDir2, newDir2);
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            ServerClass serverClass = new ServerClass();

            serverClass.launchServer();
            Console.ReadLine();
        }
        private static Entity ReadEnterPVS(IBitStream reader, int id, DemoParser parser)
        {
            int serverClassID = (int)reader.ReadInt(parser.SendTableParser.ClassBits);

            ServerClass entityClass = parser.SendTableParser.ServerClasses[serverClassID];

            reader.ReadInt(10); //Entity serial.

            Entity newEntity = new Entity(id, entityClass);

            newEntity.ServerClass.AnnounceNewEntity(newEntity);

            object[] fastBaseline;
            if (parser.PreprocessedBaselines.TryGetValue(serverClassID, out fastBaseline))
            {
                PropertyEntry.Emit(newEntity, fastBaseline);
            }
            else
            {
                var preprocessedBaseline = new List <object>();
                if (parser.instanceBaseline.ContainsKey(serverClassID))
                {
                    using (var collector = new PropertyCollector(newEntity, preprocessedBaseline))
                        using (var bitStream = BitStreamUtil.Create(parser.instanceBaseline[serverClassID]))
                            newEntity.ApplyUpdate(bitStream);
                }

                parser.PreprocessedBaselines.Add(serverClassID, preprocessedBaseline.ToArray());
            }

            return(newEntity);
        }
Exemplo n.º 14
0
 private static void Initialize()
 {
     if (_instance == null)
     {
         _instance = new GameObject("ServerClass").AddComponent <ServerClass>();
         DontDestroyOnLoad(_instance.gameObject);
     }
 }
        private void OutBoundDeleteButton_Click(object sender, RoutedEventArgs e)
        {
            ServerClass   a = new ServerClass();
            List <string> OutBoundIDList = new List <string>();

            OutBoundIDList.Add(OutBoundID.Content.ToString());
            a.outBoundDeleteDB(OutBoundIDList);
        }
Exemplo n.º 16
0
        public void TestProcessCommands()
        {
            ServerClass.TheWorld = new World();
            string path = "../../ValidXmlSettings.xml";

            ServerClass.gameSettings      = ServerClass.XmlSettingsReader(path);
            ServerClass.ClientConnections = new Dictionary <int, Client>();
            for (int i = 0; i < 4; i++)
            {
                Socket s = null;
                Networking.SocketState ss = new Networking.SocketState(s, socketstate => { }, i);
                Client c = new Client(i, "JonDoe" + i, ss);
                ServerClass.ClientConnections.Add(c.ID, c);
                ServerClass.InsertShip(i, "JonDoe" + 1, 0);
            }


            ServerClass.ClientConnections[0].right = true;
            Vector2D prevDir1 = ServerClass.TheWorld.GetShipAtId(0).dir;

            ServerClass.ProcessCommands();
            Assert.IsFalse(ServerClass.ClientConnections[0].right);
            Vector2D newDir1 = ServerClass.TheWorld.GetShipAtId(0).dir;

            Assert.AreNotEqual(prevDir1, newDir1);

            ServerClass.ClientConnections[0].left = true;
            Vector2D prevDir2 = ServerClass.TheWorld.GetShipAtId(0).dir;

            ServerClass.ProcessCommands();
            Assert.IsFalse(ServerClass.ClientConnections[0].right);
            Vector2D newDir2 = ServerClass.TheWorld.GetShipAtId(0).dir;

            Assert.AreNotEqual(prevDir2, newDir2);

            ServerClass.ClientConnections[0].thrust = true;
            ServerClass.ProcessCommands();
            Ship ship = ServerClass.TheWorld.GetShipAtId(0);

            Assert.IsTrue(ship.thrust);
            Assert.IsFalse(ServerClass.ClientConnections[0].right);


            ServerClass.ClientConnections[0].fire = true;
            ServerClass.ProcessCommands();
            int projectileCount = 0;

            foreach (Projectile p in ServerClass.TheWorld.GetProjectiles())
            {
                Assert.AreEqual(ship.dir, p.dir);
                projectileCount++;
            }
            Assert.AreEqual(1, projectileCount);
            Assert.AreEqual(-1, ship.fireRateCounter);
            ServerClass.ProcessShips();
        }
Exemplo n.º 17
0
        public void TestProcessShips()
        {
            ServerClass.TheWorld = new World();
            string path = "../../ValidXmlSettings.xml";

            ServerClass.gameSettings      = ServerClass.XmlSettingsReader(path);
            ServerClass.ClientConnections = new Dictionary <int, Client>();
            ServerClass.InsertStars();
            List <Vector2D> locations = new List <Vector2D>();

            for (int i = 0; i < 20; i++)
            {
                ServerClass.InsertShip(i, "john" + 1, 0);
                if (i == 5)
                {
                    ServerClass.TheWorld.GetShipAtId(i).SetLoc(new Vector2D(0, 0));
                }
                if (i == 6)
                {
                    ServerClass.TheWorld.GetShipAtId(i).SetDir(new Vector2D(0, -1));
                    ServerClass.TheWorld.GetShipAtId(i).SetThrust(true);
                }
                if (i == 7)
                {
                    ServerClass.TheWorld.GetShipAtId(i).SetDir(new Vector2D(-1, 0));
                    ServerClass.TheWorld.GetShipAtId(i).SetThrust(true);
                }
                if (i == 8)
                {
                    ServerClass.TheWorld.GetShipAtId(i).SetDir(new Vector2D(1, 0));
                    ServerClass.TheWorld.GetShipAtId(i).SetThrust(true);
                }
                if (i == 9)
                {
                    ServerClass.TheWorld.GetShipAtId(i).SetThrust(true);
                }
                locations.Add(ServerClass.TheWorld.GetShipAtId(i).loc);
                ServerClass.ProcessShips();
            }
            ServerClass.ProcessShips();
            int idCounter = 0;

            foreach (Vector2D loc in locations)
            {
                Assert.AreNotEqual(ServerClass.TheWorld.GetShipAtId(idCounter).loc, loc);
            }

            int gameCounter = 0;

            ServerClass.TheWorld.GetShipAtId(6).SetFireRateCounter(3);
            while (gameCounter < 1000)
            {
                ServerClass.UpdateWorld();
                gameCounter++;
            }
        }
Exemplo n.º 18
0
        public void TestFancyGame()
        {
            ServerClass.TheWorld = new World();
            string path = "../../ValidFancyGameXmlSettings.xml";

            ServerClass.gameSettings      = ServerClass.XmlSettingsReader(path);
            ServerClass.ClientConnections = new Dictionary <int, Client>();
            ServerClass.InsertStars();
            ServerClass.ProcessStars();
        }
        private void WorkerInsertButton_Click(object sender, RoutedEventArgs e)
        {
            ServerClass a      = new ServerClass();
            bool        result = a.workerInsertDB(WorkerNameTextBox.Text, WorkerPhoneTextBox.Text, WorkerMailTextBox.Text, WorkerUserNameTextBox.Text, WorkerPasswordTextBox.Text, WorkerLevelComboBox.Text, WorkerRemarkTextBox.Text);

            if (result)
            {
                this.Close();
            }
        }
Exemplo n.º 20
0
    public void InitializeLocalValues()
    {
        //Navigation Values

        Canal     = 0;
        Nivel     = 0;
        EmpresaID = -1;
        GranjaID  = -1;
        NucleoID  = -1;
        GalponID  = -1;
        SiloID    = -1;

        //Get Scripts

        ServerScript     = gameObject.GetComponent <ServerClass>();
        GridScript       = gameObject.GetComponent <GridClass>();
        ThemeScript      = gameObject.GetComponent <ThemeClass>();
        WinManagerScript = gameObject.GetComponent <WindowManager>();

        //Initialize Grids

        GridName     = "Grid";
        GridLocation = GameObject.Find("Grid");
        GridCanales  = GameObject.Find("GridCanales");
        GridLocation.SetActive(false);

        //Channels Buttons

        GameObject.Find("Temas").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("temas"));
        GameObject.Find("Indicadores").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("indicadores"));
        GameObject.Find("Resumen").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("resumen"));
        GameObject.Find("Temperatura").transform.Find("Fondo").GetComponent <Button>().onClick.AddListener(() => GoToChannel("temperatura"));

        //Debugging and navigation

        backBtn = GameObject.Find("back-btn").GetComponent <Button>();
        backBtn.onClick.AddListener(() => JumpToComponent("menu"));
        empresaBtn       = GameObject.Find("empresas-btn").GetComponent <Button>();
        granjaBtn        = GameObject.Find("granjas-btn").GetComponent <Button>();
        nucleoBtn        = GameObject.Find("nucleos-btn").GetComponent <Button>();
        galponBtn        = GameObject.Find("galpones-btn").GetComponent <Button>();
        empresaImg       = GameObject.Find("empresas-btn").GetComponent <Image>();
        granjaImg        = GameObject.Find("granjas-btn").GetComponent <Image>();
        nucleoImg        = GameObject.Find("nucleos-btn").GetComponent <Image>();
        galponImg        = GameObject.Find("galpones-btn").GetComponent <Image>();
        enabledColor     = AuxFunctions.ConvertColorRGBA(107.0f, 171.0f, 129.0f, 1.0f);
        disabledColor    = AuxFunctions.ConvertColorRGBA(143.0f, 168.0f, 185.0f, 1.0f);
        empresaImg.color = disabledColor;
        granjaImg.color  = disabledColor;
        nucleoImg.color  = disabledColor;
        galponImg.color  = disabledColor;
        empresaBtn.onClick.AddListener(() => JumpToComponent("empresa"));
        granjaBtn.onClick.AddListener(() => JumpToComponent("granja"));
        nucleoBtn.onClick.AddListener(() => JumpToComponent("nucleo"));
    }
Exemplo n.º 21
0
        public Entity(WorldState ws, ServerClass sClass, SendTable table, uint index, uint serialNumber)
        {
            m_World        = ws;
            m_Class        = sClass;
            m_NetworkTable = table;
            m_Index        = index;
            m_SerialNumber = serialNumber;

            Team  = new EntityPropertyMonitor <Team?>("DT_BaseEntity.m_iTeamNum", this, o => (Team)(int)o);
            Owner = new EntityPropertyMonitor <EHandle>("DT_BaseEntity.m_hOwnerEntity", this, o => new EHandle(ws, (uint)o));
        }
Exemplo n.º 22
0
        public void TestProcessProjectiles()
        {
            ServerClass.TheWorld = new World();
            string path = "../../ValidXmlSettings.xml";

            ServerClass.gameSettings      = ServerClass.XmlSettingsReader(path);
            ServerClass.ClientConnections = new Dictionary <int, Client>();
            Dictionary <int, Vector2D> projectileCompare = new Dictionary <int, Vector2D>();
            int clientCounter = 0;

            for (int i = 0; i < 4; i++)
            {
                Socket s = null;
                Networking.SocketState ss = new Networking.SocketState(s, socketstate => { }, i);
                Client c = new Client(i, "JonDoe" + i, ss);
                ServerClass.ClientConnections.Add(c.ID, c);
                ServerClass.InsertShip(i, "JonDoe" + 1, 0);
            }


            foreach (KeyValuePair <int, Client> c in ServerClass.ClientConnections)
            {
                Client client = c.Value;
                ServerClass.ClientConnections[clientCounter].fire = true;
                ServerClass.ProcessCommands();
                clientCounter++;
            }
            foreach (Projectile proj in ServerClass.TheWorld.GetProjectiles())
            {
                projectileCompare.Add(proj.ID, proj.loc);
            }

            ServerClass.ProcessProjectiles();

            foreach (Projectile proj in ServerClass.TheWorld.GetProjectiles())
            {
                Assert.AreEqual(15, (proj.loc - projectileCompare[proj.ID]).Length());
            }


            foreach (Projectile proj in ServerClass.TheWorld.GetProjectiles())
            {
                projectileCompare[proj.ID] = proj.dir;
            }

            ServerClass.ProcessProjectiles();

            foreach (Projectile proj in ServerClass.TheWorld.GetProjectiles())
            {
                Assert.AreEqual(proj.dir, projectileCompare[proj.ID]);
            }
            ServerClass.ProcessShips();
        }
Exemplo n.º 23
0
    public static void CreateThreads()
    {
        ServerClass serverObject = new ServerClass();

        Thread InstanceCaller = new Thread(new ThreadStart(serverObject.InstanceMethod));

        // Start the thread.
        InstanceCaller.Start();

        Console.WriteLine("The Main() thread calls this after "
                          + "starting the new InstanceCaller thread.");
    }
Exemplo n.º 24
0
        public DemoDataTablesCommand(Stream input) : base(input)
        {
            Type = DemoCommandType.dem_datatables;

            BitStream stream;

            using (BinaryReader reader = new BinaryReader(input, Encoding.ASCII, true))
            {
                int length = reader.ReadInt32();
                stream = new BitStream(reader.ReadBytes(length));
            }

            while (stream.ReadBool())
            {
                SendTables.Add(ParseSendTable(stream));
            }

            // Link referenced datatables
            foreach (SendTable table in SendTables)
            {
                foreach (SendPropDefinition dtProp in table.Properties)
                {
                    if (dtProp.Type == SendPropType.Datatable)
                    {
                        dtProp.Table       = SendTables.Single(t => t.NetTableName == dtProp.ExcludeName);
                        dtProp.ExcludeName = null;
                    }
                }
            }

            short serverClasses = stream.ReadShort();

            Debug.Assert(serverClasses > 0);

            ServerClasses = new List <ServerClass>(serverClasses);

            for (int i = 0; i < serverClasses; i++)
            {
                short classID = stream.ReadShort();
                if (classID >= serverClasses)
                {
                    throw new DemoParseException("Invalid server class ID");
                }

                ServerClass sc = new ServerClass();
                sc.Classname     = stream.ReadCString();
                sc.DatatableName = stream.ReadCString();
                ServerClasses.Add(sc);
            }

            Debug.Assert((stream.Length - stream.Cursor) < 8);
        }
Exemplo n.º 25
0
        public static void Main()
        {
            ServerClass serverObject = new ServerClass();

            // Create the thread object, passing in the
            // serverObject.InstanceMethod method using a
            // ThreadStart delegate.
            Thread instanceCaller = new Thread(
                new ThreadStart(serverObject.InstanceMethod));

            // Start the thread.
            instanceCaller.Start();

            Debug.WriteLine(
                "The Main() thread calls this after "
                + "starting the new InstanceCaller thread.");

            // Create the thread object, passing in the
            // serverObject.StaticMethod method using a
            // ThreadStart delegate.
            Thread staticCaller = new Thread(
                new ThreadStart(ServerClass.StaticMethod));

            // Start the thread.
            staticCaller.Start();

            Debug.WriteLine(
                "The Main() thread calls this after "
                + "starting the new StaticCaller thread.");

            // Create another thread object, using a lambda expression.
            // Without retaining any reference to it and starting it immidiatly

            new Thread(() =>
            {
                Debug.WriteLine(
                    ">>>>>> This inline code is running on another thread.");

                // Pause for a moment to provide a delay to make
                // threads more apparent.
                Thread.Sleep(6000);

                Debug.WriteLine(
                    ">>>>>> The inline code by the worker thread has ended.");
            }).Start();

            Debug.WriteLine(
                "The Main() thread calls this after "
                + "starting the new inline thread with the lambda expression.");

            Thread.Sleep(Timeout.Infinite);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Méthode déclenchée lorsqu'une touche du clavier est enfoncée
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Partie_KeyDown(object sender, KeyEventArgs e)
        {
            // Si la partie est en cours
            if (timerMvmt.Enabled == true)
            {
                // Si la balle est de notre côté qu'elle est fixe et que l'on a appuyé sur espace
                if (e.KeyCode == Keys.Space && b.Vitesse == 0 && ball.Visible == true)
                {
                    // Lancement de la balle
                    b.Lance();

                    // Lancement du chronomètre
                    timerChrono.Enabled = true;

                    // Création d'un objet de transfert de données avec l'information que le chronomètre est relancé
                    dt       = new DataTransit();
                    dt.Timer = true;

                    // Si nous sommes côté serveur
                    if (joueur == 0)
                    {
                        // Stockage du nom du joueur serveur dans l'objet de transfert de données et envois
                        dt.NameJoueur = nameServer;
                        ServerClass.prepareSendData(dt);
                    }
                    else
                    {
                        // Stockage du nom du joueur client dans l'objet de transfert de données et envois
                        dt.NameJoueur = nameClient;
                        ClientClass.prepareSendData(dt);
                    }
                }
            }
            else
            {
                // Si nous sommes côté serveur
                if (joueur == 0)
                {
                    // Selon la touche enfoncée
                    if (e.KeyCode == Keys.Space)
                    {
                        // Réinitialisation de la form et de ses variables
                        this.Reset();
                    }
                    else if (e.KeyCode == Keys.Escape)
                    {
                        // Fermeture de la partie
                        this.Partie_FormClosing(null, null);
                    }
                }
            }
        }
Exemplo n.º 27
0
        public Entity(int id, ServerClass serverClass)
        {
            this.ID          = id;
            this.ServerClass = serverClass;

            var flattenedProps = ServerClass.FlattenedProps;

            Props = new PropertyEntry[flattenedProps.Count];
            for (int i = 0; i < flattenedProps.Count; i++)
            {
                Props[i] = new PropertyEntry(flattenedProps[i], i);
            }
        }
Exemplo n.º 28
0
        public void TestInsertShipDeathCounter()
        {
            ServerClass.TheWorld = new World();
            string path = "../../ValidXmlSettings.xml";

            ServerClass.gameSettings = ServerClass.XmlSettingsReader(path);
            ServerClass.InsertShip(0, "JohnDoe", 0);
            ServerClass.InsertShip(1, "Timmy", 0);
            ServerClass.InsertShip(2, "Jim", 0);

            Assert.AreEqual(0, ServerClass.TheWorld.GetShipAtId(0).deathCounter);
            Assert.AreEqual(0, ServerClass.TheWorld.GetShipAtId(1).deathCounter);
            Assert.AreEqual(0, ServerClass.TheWorld.GetShipAtId(2).deathCounter);
        }
Exemplo n.º 29
0
 public void ConnectClick()
 {
     if (!isConnected)
     {
         //Console.WriteLine("Creating server*****************************************");
         // create a server
         server = ServerClass.Instance;
         server.Start();
         sender = CommandSender.Instance;
         // connect as a client
         sender.connectToServer();
         isConnected = true;
     }
     //server.Stop();
 }
Exemplo n.º 30
0
        public void TestInsertStar()
        {
            ServerClass.TheWorld = new World();
            string path = "../../ValidXmlSettings.xml";

            ServerClass.gameSettings = ServerClass.XmlSettingsReader(path);
            ServerClass.InsertStars();
            int starCount = 0;

            foreach (Star s in ServerClass.TheWorld.GetStars())
            {
                starCount++;
            }
            Assert.AreEqual(2, starCount);
        }
Exemplo n.º 31
0
        public User(String username, int id, decimal funds, List<InvestmentData> investments, byte[] keyFile, byte[] iv, ServerClass server)
        {
            Contract.Requires(!ReferenceEquals(server, null));
            Contract.Requires(iv.Length * 8 == 128); // Aes block size is always 128.
            Contract.Ensures(iv.Equals(IV));

            this.username = username;
            this.id = id;
            this.funds = funds;
            this.investments = investments;
            this.keyFile = keyFile;
            this.iv = iv;
            this.server = server;

            expires = DateTime.Now.AddHours(1);
        }
Exemplo n.º 32
0
        public ThreadDebug()
        {
            ServerClass serverObject = new ServerClass();

            Thread InstanceCaller = new Thread(new ThreadStart(serverObject.InstanceMethod));

            InstanceCaller.Start(); // Start the thread.

            Console.WriteLine("The Main() thread calls this after starting the new InstanceCaller thread.");

            Thread StaticCaller = new Thread(new ThreadStart(ServerClass.StaticMethod));

            StaticCaller.Start();   // Start the thread.

            Console.WriteLine("The Main() thread calls this after starting the new StaticCaller thread.");
        }
Exemplo n.º 33
0
 void Start()
 {
     Debug.Log ("Starting server");
     ServerClass server = new ServerClass ();
     //server.StartServer();
 }
Exemplo n.º 34
0
        /// <summary>
        /// Set Class Data (and compile+exec)
        /// </summary>
        public int SetClass(String ClassName, String ClassScript, bool SendToGS)
        {
            // Set Weapon Data
            int Status = 0;
            ServerClass Class = null;
            if (ClassList.TryGetValue (ClassName, out Class))
            {
                Console.WriteLine("Class " + ClassName + " found. Script: " + ClassScript);
                Class.UpdateClass (ClassName, ClassScript);
                Status = 1;
            }
            else
            {
                Console.WriteLine("Class " + ClassName + " not found. Script: " + ClassScript);
                Class = new ServerClass (ClassName, ClassScript);
                ClassList [ClassName] = Class;
                SendPacket (new CString () + (byte)NCConnection.PacketOut.NC_CLASSADD + ClassName, null);
            }

            // Valid Weapon?
            if (Class != null) {
                // Send to GServer
                //if (SendToGS)
                //	this.SendGSPacket(new CString() + (byte)GServerConnection.PacketOut.NCQUERY + (byte)GServerConnection.NCREQ. + (byte)ClassName.Length + ClassName + ClassScript);

                Compiler.CompileAdd(Class);
            }

            // Added or Updated?
            return Status;
        }