Ejemplo n.º 1
0
        private void ContinueStateMachineSetup()
        {
            mZoneManager                = new ZoneIdManager();
            mSessionManager             = new SessionManager();
            mUsersManager               = new UsersManager(this);
            mServerObjectRepository     = new ServerObjectRepository(this);
            mDistributedObjectIdManager = new DistributedObjectIdManager();
            mServerEngine               = new ServerEngine(mSessionManager, mServerObjectRepository, SendMessageToReflector);
            mConnectionHandler          = new ConnectionHandler(this);

            // Extensions
            mRoomManager           = new RoomManager(this);
            mFashionMinigameServer = new FashionMinigameServer(this);
            mFriendsManager        = new FriendsManager(this);
            mFriendsManager.mFacebookFriendsReceivedEvent += mFashionMinigameServer.FacebookFriendsReady;
            mAvatarManager       = new AvatarManager(this);
            mPaymentItemsManager = new PaymentItemsManager(this);
            mEscrowManager       = new EscrowManager(this);
            mServerProcessingLoop.AddServerLoopWorker(RemoteCallToService.CallToServiceCallbackManager);
            mAdminManager = new AdminManager(this);

            // This needs to be called to instantiate the instance of TextFilter
            TextFilter tf = TextFilter.Instance;

            //this should be the last thing we create in our startup sequence!!  the server message processor kicks off a loop to process incoming messages
            mServerMessageProcessor = new ServerMessageProcessor(this);
            mServerProcessingLoop.AddServerLoopWorker(mServerMessageProcessor.ServerReflector);
        }
Ejemplo n.º 2
0
        private void SetLevelComplete(Message message, Guid sessionId)
        {
            mLogger.Debug("SetLevelComplete: " + message.ToString());

            if (message.Data.Count < 4)

            {
                mLogger.Error("Dropping Message (" + message + "), expected Data to be Count == 3, actual was " + message.Data.Count);
                return;
            }

            int  totalXP             = CheckType.TryAssignType <int>(message.Data[1]);
            int  XPEarnedOnThisLevel = CheckType.TryAssignType <int>(message.Data[2]);
            bool leveledUp           = CheckType.TryAssignType <bool>(message.Data[3]);

            ServerAccount serverAccount = mServerStateMachine.SessionManager.GetServerAccountFromSessionId(sessionId);

            // Save experience to the database
            FashionMinigameServiceAPI.SetGameData(serverAccount, GameDataKeys.PLAYER_EXPERIENCE_KEY, totalXP.ToString(), VerifySuccess);

            // Reward coins for experience
            int coinsEarned          = Rewards.GetCoinsFromExperience(XPEarnedOnThisLevel);
            NameValueCollection args = new NameValueCollection();

            args.Add("userId", mServerStateMachine.PaymentItemsManager.GetPaymentItemsUserId(sessionId));
            args.Add("amount", coinsEarned.ToString());
            args.Add("ipAddress", mServerStateMachine.ServerMessageProcessor.ServerReflector.GetClientIPAddress(sessionId));

            PaymentItemsProcessClientMessage clientMessage = new PaymentItemsProcessClientMessage();
            PaymentCommand cmd = clientMessage.AddVirtualCoinForUser(args);

            mServerStateMachine.PaymentItemsManager.ProcessPaymentCommand(cmd, delegate(string response)
            {
                XmlDocument xmlResponse = new XmlDocument();
                xmlResponse.LoadXml(response);
                mLogger.Debug("SetLevelComplete success: " + response);
                XmlElement vcoinNode = (XmlElement)xmlResponse.SelectSingleNode("//accounts/account[@currencyName='VCOIN']");

                // Convert to double, cast to int and then back to string to strip off decimal points
                string totalCoins = String.Empty;
                if (vcoinNode != null)
                {
                    totalCoins = ((int)Double.Parse(vcoinNode.GetAttribute("balance"))).ToString();
                }

                Hangout.Shared.Action resultMessage = delegate()
                {
                    // Return a message to the user with the results of SetLevelComplete
                    List <object> data = new List <object>();
                    data.Add(message.Data[0]);                     // callback id
                    data.Add(coinsEarned.ToString());
                    data.Add(totalCoins);
                    Message responseMessage = new Message(MessageType.FashionMinigame, data);
                    SendMessageToClient(responseMessage, sessionId);
                };
            });

            // Award friends a fraction of earned coins for working in this show
            int friendEscrowCoins = Rewards.GetFriendCoins(XPEarnedOnThisLevel, serverAccount.EntourageSize);

            if (friendEscrowCoins > 0)
            {
                EscrowManager.GiveFashionMinigameHiredFriendsCoins(serverAccount, friendEscrowCoins);
            }

            if (leveledUp)
            {
                mEnergyManager.UserLeveledUp(serverAccount);
            }
        }