Exemplo n.º 1
0
        public void InitClient(string key)
        {
            var fighter = new StarFighter(Color.Red, new SizeF(10f, 10f), new Vector2F(200, 200), 0);

            fighter.Init();
            gameObjects.Add(key, fighter);
            Console.WriteLine("sending " + key + " objects");
            try
            {
                foreach (var obj in gameObjects)
                {
                    string typeName = obj.Value.GetType().Name.ToString();
                    Console.WriteLine("sending to " + key + " " + " of type" + typeName + " " + obj.ToString());
                    var item = ((IGame2DProperties)obj.Value);
                    var dat  = key + "," + item.Location.X + "," + item.Location.Y;
                    var type = (GameAction)Enum.Parse(typeof(GameAction), typeName);
                    ServerSide.SendData(type, dat, PlayingClients[key].Ns);
                }
                ServerSide.SendCommand(GameAction.Done, PlayingClients[key].Ns);
            }
            catch
            {
            }

            PlayingClients[key].status = "loaded";
            foreach (var obj in gameObjects)
            {
                obj.Value.Init();
            }
        }