Esempio n. 1
0
    // DrawFollowers
    void DrawFollowers()
    {
        var followers = InGameLobby.instance.displayedAccount.followersOnly;

        // Header
        using (new GUIHorizontal(groupHeaderStyle)) {
            GUILayout.Label("Followers", groupNameStyle);
            GUILayout.FlexibleSpace();
        }

        // Followers
        using (new GUIVertical("box")) {
            if (followers == null || followers.Count == 0)
            {
                GUILayout.Label("You don't have any followers yet.", friendNameStyle);
            }
            else
            {
                foreach (var followerAccountId in followers)
                {
                    var playerName = PlayerAccount.Get(followerAccountId).playerName;

                    using (new GUIHorizontal()) {
                        DrawPlayerName(playerName, new GUIContent(playerName), friendNameStyle);
                        GUILayout.FlexibleSpace();
                    }
                }
            }
        }
    }
Esempio n. 2
0
        private EmbedBuilder GetPlayerAccountEmbedBuilder(PlayerAccount playerAccount)
        {
            var followers  = MagirecoInfoSvc.FollowingInfo.FindMyFollowerAccount(playerAccount.Id).ToList();
            var followings = MagirecoInfoSvc.FollowingInfo.FindMyFollowingAccount(playerAccount.Id).ToList();

            var accountFieldBuilders = new List <EmbedFieldBuilder>
            {
                new EmbedFieldBuilder {
                    Name = "暱稱", Value = playerAccount.GameHandle ?? "--", IsInline = true
                },
                new EmbedFieldBuilder {
                    Name = "等級", Value = playerAccount.GameLevel == 0 ? "--" : playerAccount.GameLevel.ToString(), IsInline = true
                },
                //new EmbedFieldBuilder{ Name = "鏡層牌位", Value = "無", IsInline = true },
                new EmbedFieldBuilder {
                    Name = "Following", Value = followings.Count, IsInline = true
                },
                new EmbedFieldBuilder {
                    Name = "Follower", Value = followers.Count, IsInline = true
                },
                //new EmbedFieldBuilder{ Name = "上次更新", Value = "2019/10/31", IsInline = true }
            };
            var accountEB = new EmbedBuilder
            {
                ImageUrl = playerAccount.ProfileImageUrl,
                Fields   = accountFieldBuilders
            };

            return(accountEB);
        }
        // -------------------------------------------------------------------------------
        // OnTriggerEnter
        // @Client / @Server
        // -------------------------------------------------------------------------------
        public override void OnTriggerEnter(Collider co)
        {
            if (targetAnchors == null || targetAnchors.Length == 0)
            {
                DebugManager.LogWarning("You forgot to add anchors to MultiWarpPortal: " + this.name);
                return;
            }

            PlayerAccount pc = co.GetComponentInParent <PlayerAccount>();

            if (pc == null || !pc.IsLocalPlayer)
            {
                return;
            }

            if (!bypassConfirmation)
            {
                if (pc.CheckCooldown)
                {
                    UIPopupPrompt.singleton.Init(popupEnter, OnClickConfirm);
                }
                else
                {
                    UIPopupNotify.singleton.Init(String.Format(popupWait, pc.GetCooldownTimeRemaining().ToString("F0")));
                }
            }
            else
            {
                OnClickConfirm();
            }
        }
Esempio n. 4
0
    // Get
    public static PlayerAccount Get(string accountId)
    {
        PlayerAccount acc;

        // Load from cache or create new account
        if (!PlayerAccount.idToAccount.TryGetValue(accountId, out acc))
        {
            acc = new PlayerAccount {
                accountId = accountId
            };

            PlayerAccount.idToAccount[accountId] = acc;
        }

        // Set my account
        if (PlayerAccount.mine == null)
        {
            PlayerAccount.mine = acc;

            if (InGameLobby.instance != null)
            {
                InGameLobby.instance.displayedAccount = acc;
            }
        }

        return(acc);
    }
Esempio n. 5
0
 public Landlord(Rent rent, PlayerAccount acct)
 {
     _currentRent    = rent;
     _rentersAccount = acct;
     World.Subscribe(EventSubscription.Create <DayEnded>(IncreaseRent, this));
     World.Subscribe(EventSubscription.Create <RentPaid>(RentPaid, this));
 }
        // -------------------------------------------------------------------------------
        // OnTriggerEnter
        // @Client / @Server
        // -------------------------------------------------------------------------------
        public override void OnTriggerEnter(Collider co)
        {
            PlayerAccount pc = co.GetComponentInParent <PlayerAccount>();

            if (pc == null || !pc.IsLocalPlayer)
            {
                return;
            }

            // -- can we switch zones?
            if (!ZoneManager.singleton.GetCanSwitchZone)
            {
                UIPopupNotify.singleton.Init(popupClosed);
                return;
            }

            if (!bypassConfirmation)
            {
                if (pc.CheckCooldown)
                {
                    UIPopupPrompt.singleton.Init(String.Format(popupEnter, targetZone.title), OnClickConfirm);
                }
                else
                {
                    UIPopupNotify.singleton.Init(String.Format(popupWait, pc.GetCooldownTimeRemaining().ToString("F0")));
                }
            }
            else
            {
                OnClickConfirm();
            }
        }
        // -------------------------------------------------------------------------------
        // OnClickConfirm
        // @Client
        // -------------------------------------------------------------------------------
        public override void OnClickConfirm()
        {
            GameObject player = PlayerAccount.localPlayer;

            if (player == null)
            {
                return;
            }

            PlayerAccount pc = player.GetComponent <PlayerAccount>();

            int    index        = UnityEngine.Random.Range(0, targetAnchors.Length);
            string targetAnchor = targetAnchors[index];

            if (player && targetZone != null && !String.IsNullOrWhiteSpace(targetAnchor) && pc.CheckCooldown)
            {
                pc.WarpRemote(targetAnchor, targetZone.name);
            }

            base.OnClickConfirm();

            if (UIPopupNotify.singleton)
            {
                UIPopupNotify.singleton.Init(popupZoning, 10f, false);
            }
        }
Esempio n. 8
0
 public MoneyUI()
 {
     _account = CurrentGameState.State.PlayerAccount;
     _label   = new Label {
         BackgroundColor = Color.Transparent, TextColor = Color.White, Transform = new Transform2(Sizes.SmallLabel)
     };
 }
        // ============================== MAJOR ACTIONS ==================================

        // -------------------------------------------------------------------------------
        // AutoLoginPlayer
        // @Server
        // -------------------------------------------------------------------------------
        protected void AutoLoginPlayer(NetworkConnection conn, string username, string playername, int token)
        {
            GameObject player = LoginPlayer(conn, username, playername, token);

            if (player)
            {
                PlayerAccount pc = player.GetComponent <PlayerAccount>();

                // -- log the user in (again)
                LoginUser(conn, username);

                // -- update zone
                pc.zoneInfo.zonename = pc.currentZone.name;

                // -- warp to anchor location (if any)
                string anchorName = pc.zoneInfo.anchorname;

                if (pc.zoneInfo.startpos)                                                                       // -- warp to start position
                {
                    pc.WarpLocal(AnchorManager.singleton.GetArchetypeStartPositionAnchorName(player));
                    pc.zoneInfo.startpos = false;
                }
                else if (!String.IsNullOrWhiteSpace(anchorName))                                        // -- warp to anchor
                {
                    pc.WarpLocal(anchorName);
                    pc.zoneInfo.anchorname = "";
                }
            }
            else
            {
                ServerSendError(conn, systemText.unknownError, true);
            }
        }
Esempio n. 10
0
        public ShoppingItemUI(IItem item, int i, Action whenBought)
        {
            _playerAccount = CurrentGameState.State.PlayerAccount;
            Branch         = new ClickUIBranch(item.Name, (int)ClickUIPriorities.Pad);
            var x = (i % 4) * (Sizes.Item.Width + Sizes.Margin);
            var y = (i / 4) * (Sizes.Item.Height + Sizes.Margin * 2 + Sizes.Button.Height);

            _transform      = new Transform2(new Vector2((int)x, (int)y));
            _productDetails = new ImageWithDescription("Images/Items/" + item.Name.ToLower().Replace(" ", "-").Replace(".", ""), item.Description, new Transform2(Sizes.Item));
            _label          = new Label
            {
                BackgroundColor = Color.Transparent,
                TextColor       = Color.White,
                Font            = "Fonts/14",
                Transform       = new Transform2(new Vector2(0, Sizes.Item.Height + 5), new Size2(Sizes.Item.Width, 30)),
                RawText         = item.Name + " - $" + item.Cost.Amount()
            };
            _amount = item.Cost.Amount();
            _button = ImageTextButtonFactory.Create("Buy", new Vector2(0, Sizes.Item.Height + Sizes.SmallMargin + 30),
                                                    () => { if (_playerAccount.Amount() >= _amount)
                                                            {
                                                                whenBought();
                                                            }
                                                    });
            _disabledButton = new ImageLabel("Buy", "Images/UI/button-disable", new Transform2(new Vector2(0, Sizes.Item.Height + Sizes.SmallMargin + 30), Sizes.Button));
            Branch.Add(_button);
            Branch.Add(_productDetails);
        }
Esempio n. 11
0
        // -------------------------------------------------------------------------------
        // LoginPlayer
        // @Server
        // -------------------------------------------------------------------------------
        /// <summary>
        /// Method <c>LoginPlayer</c>.
        /// Run on the server.
        /// Logs in the player.
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="username"></param>
        /// <param name="playername"></param>
        protected GameObject LoginPlayer(NetworkConnection conn, string username, string playername, int token)
        {
            string prefabname = DatabaseManager.singleton.GetPlayerPrefabName(playername);

            GameObject prefab = GetPlayerPrefab(prefabname);
            GameObject player = DatabaseManager.singleton.LoadDataPlayer(prefab, playername);

            PlayerAccount pc = player.GetComponent <PlayerAccount>();

            // -- check the security token if required
            if (token == 0 || (token > 0 && pc.zoneInfo.ValidateToken(token)))
            {
                // -- log the player in
                DatabaseManager.singleton.LoginPlayer(conn, player, playername, username);

                NetworkServer.AddPlayerForConnection(conn, player);

                onlinePlayers.Add(player.name, player);

                state = NetworkState.Game;

                this.InvokeInstanceDevExtMethods(nameof(LoginPlayer), conn, player, playername, username); //HOOK
                eventListeners.OnLoginPlayer.Invoke(conn);                                                 //EVENT

                debug.LogFormat(this.name, nameof(LoginPlayer), username, playername);                     //DEBUG

                return(player);
            }

            return(null);
        }
Esempio n. 12
0
    // DrawAccountTimeStampData
    void DrawAccountTimeStampData(KeyValue <TimeStamp>[] data)
    {
        if (data == null)
        {
            return;
        }

        var now = System.DateTime.UtcNow;

        foreach (var entry in data)
        {
            var account        = PlayerAccount.Get(entry.key);
            var timeSpan       = now - entry.val.dateTime;
            var timeSpanString = TimeSpanToString(timeSpan);
            var columnWidth    = GUILayout.Width(GUIArea.width * 0.25f);

            using (new GUIHorizontal()) {
                DrawPlayerName(
                    account.playerName,
                    new GUIContent(
                        "<b>" + account.playerName + "</b> <size=10>(ID: " + account.accountId + ")</size>"
                        ),
                    GUI.skin.label,
                    columnWidth
                    );

                GUILayout.Label(timeSpanString, columnWidth);
                GUILayout.Label("<size=12>" + entry.val.readableDateTime + " UTC</size>", columnWidth);
            }
        }
    }
Esempio n. 13
0
    void ReceiveFriendsList(string accountId, string newList)
    {
        friendsList = Jboy.Json.ReadObject <FriendsList>(newList);
        PlayerAccount.Get(accountId).friends = friendsList;

        LogManager.General.Log("FriendsGUI: Received friends list: " + friendsList);
    }
Esempio n. 14
0
        private void RegisterPlayer(Player player)
        {
            var registerDialog = new InputDialog("Register", "Insert your password", true, "Submit", "Cancel");

            registerDialog.Show(player);
            registerDialog.Response += async(senderPlayer, ev) =>
            {
                if (ev.DialogButton == DialogButton.Left)
                {
                    var hash = PasswordHashingService.GetPasswordHash(ev.InputText);

                    var newAccount = new PlayerAccount {
                        Name = player.Name, Password = hash
                    };

                    await AccountRepository.AddAsync(newAccount);

                    LoginPlayer(player);
                }
                else
                {
                    player.Kick();
                }
            };
        }
Esempio n. 15
0
    void ReceiveArtifactInventory(string accountId, string jsonTree)
    {
        var acc = PlayerAccount.Get(accountId);

        acc.artifactInventory = Jboy.Json.ReadObject <ArtifactInventory>(jsonTree);

        LogManager.General.Log("ArtifactsGUI: Received artifact inventory!");
    }
Esempio n. 16
0
 public object GetSaveData()
 {
     return(new
     {
         Clock = Clock.Time,
         PlayerAccount = PlayerAccount.Amount()
     });
 }
Esempio n. 17
0
    void ReceiveItemInventory(string accountId, string jsonInventory)
    {
        var inv = Jboy.Json.ReadObject <ItemInventory>(jsonInventory);

        LogManager.General.Log("ItemInventoryGUI: Received item inventory " + jsonInventory + "!");

        PlayerAccount.Get(accountId).itemInventory = inv;
    }
Esempio n. 18
0
    void ReceiveAccessLevel(string accountId, byte newAccessLevel)
    {
        var accLevel = (AccessLevel)newAccessLevel;

        LogManager.General.Log("Lobby: Received access level: " + accLevel.ToString() + "!");

        PlayerAccount.Get(accountId).accessLevel = accLevel;
    }
Esempio n. 19
0
    public static PlayerAccount createPlayerData(string filepath)
    {
        PlayerAccount instance = ScriptableObject.CreateInstance <PlayerAccount>();

        initializeDefaults(instance);
        instance.path = filepath;
        return(instance);
    }
Esempio n. 20
0
    void ReceiveExperience(string accountId, uint exp)
    {
        LogManager.General.Log("Lobby: Received experience. Account ID: " + accountId + ", Exp: " + exp);

        var acc = PlayerAccount.Get(accountId);

        acc.experience = exp;
    }
Esempio n. 21
0
    void ReceivePlayerEmail(string accountId, string playerEmail)
    {
        LogManager.General.Log("Lobby: Received player info. Account ID: " + accountId + ", Email: " + playerEmail);

        var acc = PlayerAccount.Get(accountId);

        acc.email = playerEmail;
    }
Esempio n. 22
0
    void CustomizeCharacter(string accountId)
    {
        LogManager.General.Log("Character customization not available yet!");

        PlayerAccount.Get(accountId).custom = new CharacterCustomization();
        this.accountSetupPageStatus[(int)AccountSetupPage.CharacterCustomization] = RequestStatus.DoesntExist;
        UpdateAccountInfo();
    }
Esempio n. 23
0
    void ReceiveCrystalBalance(string accountId, int newCrystalBalance)
    {
        PlayerAccount.Get(accountId).crystals = newCrystalBalance;

        if (pendingCrystalBalanceRequests > 0)
        {
            pendingCrystalBalanceRequests -= 1;
        }
    }
Esempio n. 24
0
    public static PlayerAccount createPlayerData(PlayerData info, string filepath)
    {
        PlayerAccount instance = ScriptableObject.CreateInstance <PlayerAccount>();

        instance.path        = filepath;
        instance.accountInfo = info;
        instance.throwables  = playerDataToGameObjects(info);
        return(instance);
    }
Esempio n. 25
0
    // ResetAccountInfo
    public void ResetAccountInfo()
    {
        PlayerAccount.mine = null;
        displayedAccount   = null;

        for (int i = 0; i < accountSetupPageStatus.Length; i++)
        {
            accountSetupPageStatus[i] = RequestStatus.Unknown;
        }
    }
Esempio n. 26
0
 public RentApp()
 {
     _gameState         = CurrentGameState.State;
     _playerAccount     = _gameState.PlayerAccount;
     _landlord          = _gameState.Landlord;
     Branch             = new ClickUIBranch("Rent App", (int)ClickUIPriorities.Pad);
     _amountDue         = new ImageLabel("", "Images/UI/label", new Transform2(new Vector2(-(Sizes.Label.Width / 2), 0), Sizes.Label));
     _paymentDueBy      = new ImageLabel("", "Images/UI/label", new Transform2(new Vector2(-(Sizes.Label.Width / 2), Sizes.Label.Height + Sizes.Margin), Sizes.Label));
     _payButton         = ImageTextButtonFactory.Create("PAY", new Vector2(-(Sizes.Button.Width / 2), (Sizes.Label.Height + Sizes.Margin) * 2), () => World.Publish(new RentPaid()));
     _disabledPayButton = new ImageLabel("PAY", "Images/UI/button-disable", new Transform2(new Vector2(-(Sizes.Button.Width / 2), (Sizes.Label.Height + Sizes.Margin) * 2), Sizes.Button));
 }
Esempio n. 27
0
    // Account statistics
    public override void Draw()
    {
        account = InGameLobby.instance.displayedAccount;
        stats   = account.stats;

        if (stats == null)
        {
            return;
        }

        using (new GUIScrollView(ref scrollPosition)) {
            using (new GUIVertical()) {
                using (new GUIHorizontal()) {
                    using (new GUIVertical()) {
                        using (new GUIHorizontalCenter()) {
                            var nextProfileType = GUIHelper.Toolbar(profileType, profileMenuContents, null, GUILayout.Width(110));

                            ExecuteLater(() => {
                                profileType = nextProfileType;
                            });
                        }

                        using (new GUIVertical("box")) {
                            switch (profileType)
                            {
                            case 0: DrawOverview(); break;

                            case 1: DrawStats(); break;

                            case 2: DrawInfo(); break;
                            }

                            GUILayout.FlexibleSpace();
                        }
                    }

                    using (new GUIVertical(GUILayout.Width(GUIArea.width / 2))) {
                        using (new GUIHorizontalCenter()) {
                            var nextQueue = GUIHelper.Toolbar(currentQueue, queueContents, null, GUILayout.Width(72));

                            ExecuteLater(() => {
                                currentQueue = nextQueue;
                            });
                        }

                        using (new GUIVertical("box")) {
                            DrawQueueStats(stats.queue[currentQueue]);
                            GUILayout.FlexibleSpace();
                        }
                    }
                }
            }
        }
    }
Esempio n. 28
0
        // -------------------------------------------------------------------------------
        // OnTriggerExit
        // @Client / @Server
        // -------------------------------------------------------------------------------
        public virtual void OnTriggerExit(Collider co)
        {
            PlayerAccount pc = co.GetComponentInParent <PlayerAccount>();

            if (pc == null || !pc.IsLocalPlayer)
            {
                return;
            }

            UIPopupPrompt.singleton.Hide();
        }
Esempio n. 29
0
    void ReceiveCharacterStats(string accountId, CharacterStats charStats)
    {
        LogManager.General.Log("TraitsGUI: Received character stats!");

        var acc = PlayerAccount.Get(accountId);

        acc.charStats = charStats;

        if (acc.isMine)
        {
            lastCharacterStatsSent = new CharacterStats(charStats);
        }
    }
Esempio n. 30
0
 public static PlayerAccount loadPlayerData(string fileLoc)
 {
     if (File.Exists(fileLoc))
     {
         FileStream      file          = File.Open(fileLoc, FileMode.Open);
         BinaryFormatter bf            = new BinaryFormatter();
         PlayerData      player        = (PlayerData)bf.Deserialize(file);
         PlayerAccount   loadedAccount = PlayerAccount.createPlayerData(player, fileLoc);
         file.Close();
         return(loadedAccount);
     }
     return(null);
 }