Ejemplo n.º 1
0
    // GetStarterArtifactTree
    public static ArtifactTree GetStarterArtifactTree()
    {
        var tree = new ArtifactTree();

        tree.BuildStarterArtifacts();
        return(tree);
    }
Ejemplo n.º 2
0
    // TODO: Bitstream variant
    protected void ReceiveArtifactTree(string jsonTree)
    {
        Log("Received artifact tree! " + jsonTree);

        this.artifactTree = Jboy.Json.ReadObject <ArtifactTree>(jsonTree);
        this.ApplyCharacterStats();
    }
Ejemplo n.º 3
0
    // Reader
    public static object JsonDeserializer(Jboy.JsonReader reader)
    {
        reader.ReadArrayStart();

        var tree = new ArtifactTree();

        for (int i = 0; i < tree.slots.Length; i++)
        {
            int numSlots  = Artifact.maxLevel - i;
            var slotLevel = tree.slots[i];
            reader.ReadArrayStart();

            for (int slotIndex = 0; slotIndex < numSlots; slotIndex++)
            {
                var artifactSlot = new ArtifactSlot((byte)i);
                artifactSlot.artifact = Jboy.Json.ReadObject <Artifact>(reader);

                slotLevel[slotIndex] = artifactSlot;
            }

            reader.ReadArrayEnd();
        }

        reader.ReadArrayEnd();
        return(tree);
    }
Ejemplo n.º 4
0
    void ClientArtifactTree(string jsonTree, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);
        //LogManager.General.Log(jsonTree);

        ArtifactTree tree = Jboy.Json.ReadObject <ArtifactTree>(jsonTree);

        LogManager.General.Log("Player '" + player.name + "' sent new artifact tree " + tree.ToString());
        ArtifactsDB.SetArtifactTree(player, tree);
    }
Ejemplo n.º 5
0
    // Start
    void Start()
    {
        //loginClientGUI = this.GetComponent<LoginClientGUI>();
        //inGameLobby = this.GetComponent<InGameLobby>();

        artifactTree      = null;
        artifactInventory = null;
        //statsTree.Randomize();

        // Receive lobby RPCs
        Lobby.AddListener(this);
    }
Ejemplo n.º 6
0
    // Awake
    protected override void Awake()
    {
        base.Awake();

        baseMoveSpeed = Config.instance.playerMoveSpeed;

        // Parent
        myTransform.parent = Player.playerRoot;

        // Reset customization
        customization = null;

        // Full block duration
        playerVisibility = new Dictionary <Entity, bool>();

        this.skillBuild     = null;
        this.charStats      = null;
        this.artifactTree   = null;
        this.artifactReward = null;

        // Components
        motor        = GetComponent <CharacterMotor>();
        comboCounter = GetComponent <ComboCounter>();
        voIP         = GetComponent <VoIP>();

        // Used for hovering / flying
        if (motor != null)
        {
            motorGravity         = motor.movement.gravity;
            motorAirAcceleration = motor.movement.maxAirAcceleration;
        }

        charGraphicsModel = InstantiateChild(Config.instance.femalePrefab, charGraphics);

        // Destroy
        onDestroy += () => {
            // Remove from global lists
            Player.accountIdToPlayer.Remove(this.accountId);
            Player.allPlayers.Remove(this);
            Entity.idToEntity.Remove(this.id);

            // In case we stored some old pointers, react as if he is dead.
            // Particularly useful for the Enemy threat based target finding.
            health = 0;
        };

        // Update player count
        Player.allPlayers.Add(this);
    }
Ejemplo n.º 7
0
 // Set artifact tree
 public static Coroutine SetArtifactTree(LobbyPlayer player, ArtifactTree tree)
 {
     return(GameDB.instance.StartCoroutine(GameDB.Set <ArtifactTree>(
                                               "AccountToArtifactTree",
                                               player.accountId,
                                               tree,
                                               data => {
         if (data == null)
         {
             Lobby.RPC("ArtifactTreeSaveError", player.peer);
         }
         else
         {
             player.artifactTree = data;
         }
     }
                                               )));
 }
Ejemplo n.º 8
0
    // Get artifact tree
    public static Coroutine GetArtifactTree(LobbyPlayer player)
    {
        return(GameDB.instance.StartCoroutine(GameDB.Get <ArtifactTree>(
                                                  "AccountToArtifactTree",
                                                  player.accountId,
                                                  data => {
            if (data == null)
            {
                player.artifactTree = ArtifactTree.GetStarterArtifactTree();
            }
            else
            {
                player.artifactTree = data;
            }

            Lobby.RPC("ReceiveArtifactTree", player.peer, player.accountId, Jboy.Json.WriteObject(player.artifactTree));
        }
                                                  )));
    }
Ejemplo n.º 9
0
    // DrawArtifactSlots
    public void DrawArtifactSlots()
    {
        var acc = InGameLobby.instance.displayedAccount;

        artifactTree          = acc.artifactTree;
        artifactTreeStatsInfo = acc.charStats.GetMultiLineStringCombined(artifactTree.charStats);

        if (artifactTree == null)
        {
            return;
        }

        using (new GUIVertical("box")) {
            using (new GUIScrollView(ref scrollPosition)) {
                GUI.Label(new Rect(5, 0, 200, 300), artifactTreeStatsInfo);

                for (int i = Artifact.maxLevel - 1; i >= 0; i--)
                {
                    var slotLevel = artifactTree.slots[i];

                    using (new GUIHorizontalCenter()) {
                        for (int slotIndex = 0; slotIndex < slotLevel.Length; slotIndex++)
                        {
                            var slot = slotLevel[slotIndex];

                            if (slot.artifact != null)
                            {
                                if (GUIHelper.Button(new GUIContent("", slot.artifact.icon, slot.artifact.tooltip), artifactStyle) && acc.isMine)                                  // && !saving
                                {
                                    Lobby.RPC("ClientArtifactUnequip", Lobby.lobby, (byte)i, (byte)slotIndex);
                                }
                            }
                            else
                            {
                                GUIHelper.Button(_("L{0}", slot.requiredLevel + 1), artifactSlotStyle);
                            }
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 10
0
    // Reader
    public static object JsonDeserializer(Jboy.JsonReader reader)
    {
        reader.ReadArrayStart();

        var tree = new ArtifactTree();
        for(int i = 0; i < tree.slots.Length; i++) {
            int numSlots = Artifact.maxLevel - i;
            var slotLevel = tree.slots[i];
            reader.ReadArrayStart();

            for(int slotIndex = 0; slotIndex < numSlots; slotIndex++) {
                var artifactSlot = new ArtifactSlot((byte)i);
                artifactSlot.artifact = Jboy.Json.ReadObject<Artifact>(reader);

                slotLevel[slotIndex] = artifactSlot;
            }

            reader.ReadArrayEnd();
        }

        reader.ReadArrayEnd();
        return tree;
    }
Ejemplo n.º 11
0
 // GetStarterArtifactTree
 public static ArtifactTree GetStarterArtifactTree()
 {
     var tree = new ArtifactTree();
     tree.BuildStarterArtifacts();
     return tree;
 }
Ejemplo n.º 12
0
 // Set artifact tree
 public static Coroutine SetArtifactTree(LobbyPlayer player, ArtifactTree tree)
 {
     return GameDB.instance.StartCoroutine(GameDB.Set<ArtifactTree>(
         "AccountToArtifactTree",
         player.accountId,
         tree,
         data => {
             if(data == null)
                 Lobby.RPC("ArtifactTreeSaveError", player.peer);
             else
                 player.artifactTree = data;
         }
     ));
 }
Ejemplo n.º 13
0
    // InstantiatePlayer
    void InstantiatePlayer(uLink.NetworkPlayer networkPlayer, string accountId, string playerName, Vector3 respawnPosition, float cameraYRotation, int partyId)
    {
        LogManager.General.Log(string.Format("Instantiating player prefabs for '{0}' with account ID '{1}'", playerName, accountId));

        var party = GameServerParty.partyList[partyId];

        // Instantiates an avatar for the player connecting to the server
        // The player will be the "owner" of this object. Read the manual chapter 7 for more
        // info about object roles: Creator, Owner and Proxy.
        GameObject obj = uLink.Network.Instantiate(
            networkPlayer,                                      // Owner
            proxyPrefab,
            ownerPrefab,
            creatorPrefab,
            respawnPosition,
            Cache.quaternionIdentity,
            0,                                                          // Network group
            accountId                                                   // Initial data
            );

        // Player component
        Player player = obj.GetComponent <Player>();

        player.accountId        = accountId;
        networkPlayer.localData = player;

        // Send name
        player.networkView.RPC("ReceivePlayerName", uLink.RPCMode.All, playerName);

        // Async: DB requests
        if (isTestServer)
        {
            // This section is for quick client tests on the test server

            // Send other players and myself information about stats
            player.skillBuild    = SkillBuild.GetStarterBuild();
            player.customization = new CharacterCustomization();

            player.networkView.RPC("ReceiveSkillBuild", uLink.RPCMode.All, player.skillBuild);
            player.networkView.RPC("ReceiveCharacterCustomization", uLink.RPCMode.All, player.customization);
            player.networkView.RPC("ReceiveCharacterStats", uLink.RPCMode.All, new CharacterStats());
            player.networkView.RPC("ReceiveArtifactTree", uLink.RPCMode.All, Jboy.Json.WriteObject(ArtifactTree.GetStarterArtifactTree()));

            // After the skill build has been sent, switch the attunement
            player.networkView.RPC("SwitchWeapon", uLink.RPCMode.All, (byte)0);
            player.networkView.RPC("SwitchAttunement", uLink.RPCMode.All, (byte)0);
        }
        else
        {
            // Experience / Level
            ExperienceDB.GetExperience(
                accountId,
                data => {
                uint exp = 0;

                if (data != null)
                {
                    exp = data.experience;
                }

                player.networkView.RPC("SetExperience", uLink.RPCMode.All, exp);
            }
                );

            // TODO: We need to wait until this is finished in ApplyCharacterStats
            // Skill build
            SkillBuildsDB.GetSkillBuild(
                accountId,
                data => {
                if (data == null)
                {
                    player.skillBuild = SkillBuild.GetStarterBuild();
                }
                else
                {
                    player.skillBuild = data;
                }

                // Send build
                player.networkView.RPC("ReceiveSkillBuild", uLink.RPCMode.All, player.skillBuild);

                // After the build has been sent, switch the attunement
                player.networkView.RPC("SwitchWeapon", uLink.RPCMode.All, (byte)0);
                player.networkView.RPC("SwitchAttunement", uLink.RPCMode.All, (byte)0);
            }
                );

            // Character customization
            CharacterCustomizationDB.GetCharacterCustomization(
                accountId,
                data => {
                if (data == null)
                {
                    player.customization = new CharacterCustomization();
                }
                else
                {
                    player.customization = data;
                }

                // Send customization
                player.networkView.RPC("ReceiveCharacterCustomization", uLink.RPCMode.All, player.customization);
            }
                );

            // Character stats
            StartCoroutine(ServerGameDB.GetCharacterStats(player));

            // Guild
            GuildsDB.GetGuildList(accountId, data => {
                if (data != null)
                {
                    GuildsDB.GetGuild(data.mainGuildId, guild => {
                        if (guild != null)
                        {
                            player.networkView.RPC("ReceiveMainGuildInfo", uLink.RPCMode.All, guild.name, guild.tag);
                        }
                    });
                }
            });

            // Artifacts
            ArtifactsDB.GetArtifactTree(
                accountId,
                data => {
                if (data == null)
                {
                    player.artifactTree = ArtifactTree.GetStarterArtifactTree();
                }
                else
                {
                    player.artifactTree = data;
                }

                player.networkView.RPC("ReceiveArtifactTree", uLink.RPCMode.All, Jboy.Json.WriteObject(player.artifactTree));
            }
                );

            // Retrieve arena stats
            var statsBucket = new Bucket("AccountToStats");
            statsBucket.Get(
                accountId,
                Constants.Replication.Default,
                (request) => {
                var statsInDB = request.GetValue <PlayerStats>();

                LogManager.General.Log("Queried stats of account '" + accountId + "' successfully (Ranking: " + statsInDB.bestRanking + ")");

                // Send ranking
                player.networkView.RPC("ReceiveBestRanking", uLink.RPCMode.All, statsInDB.bestRanking);
            }, (request) => {
                var statsInDB = new PlayerStats();

                LogManager.General.Log("Account '" + accountId + "' aka player '" + playerName + "' doesn't have any player stats yet");

                // Send ranking
                player.networkView.RPC("ReceiveBestRanking", uLink.RPCMode.All, statsInDB.bestRanking);
            }
                );
        }

        if (GameManager.isArena)
        {
            player.networkView.RPC("GameMaxScore", uLink.RPCMode.Owner, gameMode.scoreNeededToWin);
        }

        // Layer
        if (GameManager.isPvP)
        {
            player.networkView.RPC("ChangeParty", uLink.RPCMode.All, partyId);
            player.networkView.RPC("ChangeLayer", uLink.RPCMode.All, party.layer);
        }
        else
        {
            player.networkView.RPC("ChangeLayer", uLink.RPCMode.All, Config.instance.openWorldPvPLayer);
        }

        // Respawn
        player.networkView.RPC("Respawn", uLink.RPCMode.All, respawnPosition);
        player.networkView.RPC("SetCameraYRotation", uLink.RPCMode.Owner, cameraYRotation);

        // On non account restricted servers we start the game instantly
        if (!GameManager.isArena || isTestServer)
        {
            player.networkView.RPC("StartGame", uLink.RPCMode.Owner);
            GameManager.gameStarted = true;
        }

        // Disable encryption in non-ranked games
        //if(!GameManager.isRankedGame)
        //	uLink.Network.UninitializeSecurity(networkPlayer);
    }
Ejemplo n.º 14
0
    // Sends data about the account to any player
    public static void SendPublicAccountInfo(string accountId, LobbyPlayer toPlayer)
    {
        var player = GetLobbyPlayer(accountId);

        // Name
        LobbyGameDB.GetPlayerName(accountId, data => {
            if (data == null)
            {
                if (player == toPlayer)
                {
                    Lobby.RPC("AskPlayerName", toPlayer.peer);
                }
            }
            else
            {
                Lobby.RPC("ReceivePlayerName", toPlayer.peer, accountId, data);

                if (player == toPlayer)
                {
                    if (string.IsNullOrEmpty(player.name))
                    {
                        player.name = data;
                        LobbyServer.OnReceivePlayerName(player);
                    }
                }
            }
        });

        // Character customization
        CharacterCustomizationDB.GetCharacterCustomization(accountId, data => {
            if (data == null)
            {
                if (player == toPlayer)
                {
                    Lobby.RPC("CustomizeCharacter", toPlayer.peer, accountId);
                }
            }
            else
            {
                if (player != null)
                {
                    player.custom = data;
                }
                Lobby.RPC("ReceiveCharacterCustomization", toPlayer.peer, accountId, data);
            }
        });

        // Skill build
        SkillBuildsDB.GetSkillBuild(accountId, data => {
            if (data == null)
            {
                Lobby.RPC("ReceiveSkillBuild", toPlayer.peer, accountId, SkillBuild.GetStarterBuild());
            }
            else
            {
                Lobby.RPC("ReceiveSkillBuild", toPlayer.peer, accountId, data);
            }
        });

        // Stats
        LobbyGameDB.GetPlayerStats(accountId, data => {
            if (data == null)
            {
                data = new PlayerStats();
            }

            // Assign stats
            if (player != null)
            {
                player.stats = data;
            }

            // Send the stats to the player
            Lobby.RPC("ReceivePlayerStats", toPlayer.peer,
                      accountId,
                      Jboy.Json.WriteObject(data)
                      );
        });

        // FFA Stats
        LobbyGameDB.GetPlayerFFAStats(accountId, data => {
            if (data == null)
            {
                data = new PlayerStats();
            }

            // Assign stats
            if (player != null)
            {
                player.ffaStats = data;
            }

            // Send the stats to the player
            Lobby.RPC("ReceivePlayerFFAStats", toPlayer.peer,
                      accountId,
                      Jboy.Json.WriteObject(data)
                      );
        });

        // Character stats
        TraitsDB.GetCharacterStats(accountId, data => {
            if (data == null)
            {
                data = new CharacterStats();
            }

            if (player != null)
            {
                player.charStats = data;
            }

            Lobby.RPC("ReceiveCharacterStats", toPlayer.peer, accountId, data);
        });

        // Artifact inventory
        ArtifactsDB.GetArtifactInventory(accountId, data => {
            if (data == null)
            {
                data = new ArtifactInventory();
            }

            if (player != null)
            {
                player.artifactInventory = data;
            }

            Lobby.RPC("ReceiveArtifactInventory", toPlayer.peer, accountId, Jboy.Json.WriteObject(data));
        });

        // Artifact tree
        ArtifactsDB.GetArtifactTree(accountId, data => {
            if (data == null)
            {
                data = ArtifactTree.GetStarterArtifactTree();
            }

            if (player != null)
            {
                player.artifactTree = data;
            }

            Lobby.RPC("ReceiveArtifactTree", toPlayer.peer, accountId, Jboy.Json.WriteObject(data));
        });

        // Experience
        ExperienceDB.GetExperience(accountId, data => {
            uint exp = 0;

            if (data != null)
            {
                exp = data.experience;
            }

            Lobby.RPC("ReceiveExperience", toPlayer.peer, accountId, exp);
        });

        // Item inventory
        ItemInventoryDB.GetItemInventory(accountId, data => {
            if (data == null)
            {
                data = new ItemInventory();
            }

            if (player != null)
            {
                player.itemInventory = data;
            }

            Lobby.RPC("ReceiveItemInventory", toPlayer.peer, accountId, Jboy.Json.WriteObject(data));
        });

        // View profile
        Lobby.RPC("ViewProfile", toPlayer.peer, accountId);
    }