Beispiel #1
0
 // Set skill build
 public static void SetSkillBuild(string accountId, SkillBuild skillBuild, GameDB.ActionOnResult <SkillBuild> func = null)
 {
     GameDB.instance.StartCoroutine(GameDB.Set <SkillBuild>(
                                        "AccountToSkillBuild",
                                        accountId,
                                        skillBuild,
                                        func
                                        ));
 }
Beispiel #2
0
    void SkillBuildUpdate(SkillBuild nSkillBuild, uLink.NetworkMessageInfo info)
    {
        if (info.sender != networkView.owner)
        {
            return;
        }

        networkView.RPC("ReceiveSkillBuild", uLink.RPCMode.All, nSkillBuild);
    }
Beispiel #3
0
    // Awake
    protected override void Awake()
    {
        base.Awake();

        // Parent
        myTransform.parent = Enemy.enemiesRoot;

        charStats  = new CharacterStats();
        skillBuild = SkillBuild.GetStarterBuild();

        runes             = new List <Rune>();
        weapons           = Magic.instance.GetWeapons(runes, skillBuild);
        moveSpeedModifier = 1.0f;

        charGraphicsModel = InstantiateChild(prefab, charGraphics);

        // Set name
        name = gameObject.name.ToCleanGameObjectName();

        // Visibility
        isVisible = false;

        // Layer
        layer      = gameObject.layer;
        skillLayer = layer;

        // Death
        onDeath += () => {
            if (animator != null)
            {
                animator.SetBool(deadHash, true);
            }

            Invoke("DisableCollider", Config.instance.deathColliderDisableTime);
        };

        // Destroy
        onDestroy += () => {
            // Remove from global lists
            Enemy.allEnemies.Remove(this);
            Entity.idToEntity.Remove(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;
        };

        // Add to global list
        Enemy.allEnemies.Add(this);
    }
Beispiel #4
0
    // Get a copy of the weapons
    public List <Weapon> GetWeapons(List <Rune> runes, SkillBuild build)
    {
        // Create runes for each skill
        foreach (var skill in runeDetonators.skills)
        {
            runes.Add(new Rune(skill));
        }

        // Weapon list
        var weapons = new List <Weapon>();

        foreach (var weaponBuild in build.weapons)
        {
            LogManager.Spam.Log("Trying to find weapon ID " + weaponBuild.weaponId);
            var originalWeapon = Weapon.idToWeapon[weaponBuild.weaponId];
            var weapon         = new Weapon(originalWeapon);

            LogManager.Spam.Log("Registered weapon " + weapon.name);
            weapons.Add(weapon);

            // Add attunements from attunement IDs
            foreach (var attunementBuild in weaponBuild.attunements)
            {
                var originalAttunement = Attunement.idToAttunement[attunementBuild.attunementId];
                var attunement         = new Attunement(
                    originalAttunement.name,
                    originalAttunement.id,
                    null
                    );

                // Add skills from skill IDs
                foreach (var skillId in attunementBuild.skills)
                {
                    try {
                        var skill = Skill.idToSkill[skillId];
                        attunement.AddSkill(Skill.Copy(skill));
                    } catch (KeyNotFoundException) {
                        LogManager.General.LogError("Could not find skill with ID: " + skillId);
                    }
                }

                weapon.AddAttunement(attunement);
            }
        }

        return(weapons);
    }
Beispiel #5
0
    void ClientSkillBuild(SkillBuild build, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // TODO: Check the build for hacks

        SkillBuildsDB.SetSkillBuild(
            player.accountId,
            build,
            data => {
            if (data == null)
            {
                Lobby.RPC("SkillBuildSaveError", info.sender);
            }
        }
            );
    }
Beispiel #6
0
    // Draw
    public override void Draw()
    {
        build       = gameLobby.displayedAccount.skillBuild;
        GUI.enabled = gameLobby.displayedAccount.isMine;

        if (build == null)
        {
            return;
        }

        using (new GUIHorizontal()) {
            // Draw the current build
            using (new GUIVertical("box")) {
                DrawCurrentBuild();
            }

            GUILayout.Space(8);

            // Attunement / Skill selection
            using (new GUIVertical("box")) {
                DrawSelectableChanges();
            }

            GUILayout.Space(8);
            GUI.enabled = true;

            // Skill description
            using (new GUIVertical("box", GUILayout.Width(GUIArea.width / 3))) {
                GUILayout.Label("Description", titleStyle);

                GUILayout.Space(8);

                if (showSkill != null && showSkill.stages.Count > 0)
                {
                    using (new GUIVertical()) {
                        showSkill.DrawDescription(descriptionStyle);
                    }
                }
                else
                {
                    GUILayout.FlexibleSpace();
                }
            }
        }
    }
Beispiel #7
0
    protected void ReceiveSkillBuild(SkillBuild newBuild)
    {
        Log("Received skill build with X weapons: " + newBuild.weapons.Length);

        skillBuild = newBuild;

        ApplyCharacterStats();

        // Enable skill bar
        if (GameManager.isClient)
        {
            var skillBar = this.GetComponent <SkillBar>();
            if (skillBar != null)
            {
                skillBar.enabled = true;
            }
        }
    }
Beispiel #8
0
 void ReceiveSkillBuild(string accountId, SkillBuild build)
 {
     PlayerAccount.Get(accountId).skillBuild = build;
     LogManager.General.Log("SkillsGUI: Received skill build!");
 }
Beispiel #9
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);
    }
Beispiel #10
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);
    }