Beispiel #1
0
        /// <summary>
        /// Creates a new player
        /// </summary>
        /// <param name="client">The Fluid client</param>
        /// <param name="username">The username</param>
        internal Player(FluidClient client, string username)
        {
            Username      = username;
            this.m_Client = client;

            Type = m_Client.GetConnectionType(ConnectionId);
        }
Beispiel #2
0
        /// <summary>
        /// Log in through armorgames
        /// </summary>
        /// <param name="config">The config</param>
        /// <returns>The established client if valid; otherwise null</returns>
        public Client LogIn(Config config)
        {
            string loginCookie = GetArmorgamesLoginCookie();

            if (loginCookie == null)
            {
                return(null);
            }

            ArmorgamesFlashvars flashVars = GetFlashvars(loginCookie);

            if (flashVars == null)
            {
                return(null);
            }

            FluidClient guestClient = new FluidClient(new GuestAuth());

            if (!guestClient.LogIn())
            {
                return(null);
            }

            SecureConnection secureConnection = guestClient.GetSecureConnection();

            if (secureConnection == null)
            {
                return(null);
            }

            secureConnection.SendAuth(flashVars.UserId, flashVars.AuthToken);
            AuthEvent armorGamesAuth = secureConnection.WaitForServerEvent <AuthEvent>();

            if (armorGamesAuth.IsAuthenitcated())
            {
                return(PlayerIO.Connect(config.GameID, "secure", armorGamesAuth.UserID, armorGamesAuth.AuthToken, "armorgames"));
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Creates a new world reference
 /// </summary>
 /// <param name="client">The Fluid client</param>
 /// <param name="worldId">The world id</param>
 public WorldReference(FluidClient client, string worldId)
 {
     this.m_Client = client;
     WorldID       = worldId;
 }
Beispiel #4
0
        /// <summary>
        /// Processes the message
        /// </summary>
        /// <param name="connectionBase">The connection base</param>
        /// <param name="message">The playerio message</param>
        /// <param name="handled">Whether the message was already handled</param>
        public void Process(ConnectionBase connectionBase, Message message, bool handled)
        {
            WorldConnection worldCon = (WorldConnection)connectionBase;

            World world = new World(connectionBase.Client, message);

            string username = message.GetString(9);
            int    userId   = message.GetInt(6);

            WorldPlayer connected = new WorldPlayer(worldCon, username, userId);

            FluidClient client = connectionBase.Client;

            if (client.GetConnectionType(client.ConnectionUserId) != PlayerType.Guest)
            {
                PlayerObject playerObject = connectionBase.Client.LoadMyPlayerObject();

                connected.Face             = playerObject.Smiley;
                connected.HasBuildersClub  = playerObject.IsInBuildersClub;
                connected.HasChat          = playerObject.CanChat;
                connected.IsFriendsWithYou = false;
                connected.IsGuardian       = playerObject.IsGuardian;
                connected.IsModerator      = playerObject.IsModerator;
            }
            else
            {
                connected.Face             = FaceID.Smile;
                connected.HasBuildersClub  = false;
                connected.HasChat          = false;
                connected.IsFriendsWithYou = false;
                connected.IsGuardian       = false;
                connected.IsModerator      = false;
            }

            connected.X = message.GetInt(7);
            connected.Y = message.GetInt(8);

            bool decodingPotions = true;

            for (uint i = message.Count - 1; i >= 0; i--)
            {
                if (message[i] is string)
                {
                    if (string.Compare(message.GetString(i), "pe", false) == 0)
                    {
                        decodingPotions = true;
                        continue;
                    }
                    else if (string.Compare(message.GetString(i), "ps", false) == 0)
                    {
                        break;
                    }
                }

                if (decodingPotions)
                {
                    int potionCount = message.GetInt(i);
                    int potionType  = message.GetInt(i--);
                    worldCon.Potions.SetPotionCount((Potion)potionType, potionCount);
                }
            }

            if (!handled)
            {
                worldCon.World = world;
                worldCon.Players.Add(connected);
                worldCon.Me = connected;
            }

            InitEvent initEvent = new InitEvent();

            initEvent.Raw             = message;
            initEvent.World           = world;
            initEvent.ConnectedPlayer = connected;

            connectionBase.RaiseServerEvent <InitEvent>(initEvent);
        }