コード例 #1
0
    IEnumerator ClientArtifactEquip(int itemId, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Wait for all actions to execute
        while (player.artifactsEditingFlag)
        {
            yield return(null);
        }

        try {
            var arti = new Artifact(itemId);

            player.artifactsEditingFlag = true;
            if (player.artifactTree.AddArtifact(itemId))
            {
                player.artifactInventory.RemoveArtifact(arti);
                Lobby.RPC("ArtifactEquip", player.peer, itemId);

                // Save changes
                yield return(ArtifactsDB.SetArtifactTree(
                                 player,
                                 player.artifactTree
                                 ));

                yield return(ArtifactsDB.SetArtifactInventory(
                                 player,
                                 player.artifactInventory
                                 ));
            }
        } finally {
            player.artifactsEditingFlag = false;
        }
    }
コード例 #2
0
    IEnumerator ClientArtifactDiscard(byte level, byte slotId, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Wait for all actions to execute
        while (player.artifactsEditingFlag)
        {
            yield return(null);
        }

        try {
            player.artifactsEditingFlag = true;
            player.artifactInventory.bags[level].RemoveItemSlot(slotId);
            Lobby.RPC("ArtifactDiscard", player.peer, level, slotId);

            // Save changes
            yield return(ArtifactsDB.SetArtifactTree(
                             player,
                             player.artifactTree
                             ));

            yield return(ArtifactsDB.SetArtifactInventory(
                             player,
                             player.artifactInventory
                             ));
        } finally {
            player.artifactsEditingFlag = false;
        }
    }
コード例 #3
0
    IEnumerator ClientArtifactUnequip(byte level, byte slotIndex, LobbyMessageInfo info)
    {
        LobbyPlayer player = LobbyServer.GetLobbyPlayer(info);

        // Wait for all actions to execute
        while (player.artifactsEditingFlag)
        {
            yield return(null);
        }

        var slot = player.artifactTree.slots[level][slotIndex];

        if (slot.artifact == null)
        {
            yield break;
        }

        try {
            player.artifactsEditingFlag = true;
            player.artifactInventory.AddArtifact(slot.artifact);
            slot.artifact = null;
            Lobby.RPC("ArtifactUnequip", player.peer, level, slotIndex);

            // Save changes
            yield return(ArtifactsDB.SetArtifactTree(
                             player,
                             player.artifactTree
                             ));

            yield return(ArtifactsDB.SetArtifactInventory(
                             player,
                             player.artifactInventory
                             ));
        } finally {
            player.artifactsEditingFlag = false;
        }
    }