// Draw public override void Draw() { using (new GUIHorizontal()) { var acc = InGameLobby.instance.displayedAccount; artifactInventory = acc.artifactInventory; ItemInventoryGUI.DrawInventory(artifactInventory, ref inventoryScrollPosition, acc.isMine, true); DrawArtifactSlots(); } }
// Start void Start() { //loginClientGUI = this.GetComponent<LoginClientGUI>(); //inGameLobby = this.GetComponent<InGameLobby>(); artifactTree = null; artifactInventory = null; //statsTree.Randomize(); // Receive lobby RPCs Lobby.AddListener(this); }
// Set artifact tree public static Coroutine SetArtifactInventory(LobbyPlayer player, ArtifactInventory inv) { return GameDB.instance.StartCoroutine(GameDB.Set<ArtifactInventory>( "AccountToArtifactInventory", player.accountId, inv, data => { if(data == null) Lobby.RPC("ArtifactInventorySaveError", player.peer); else player.artifactInventory = data; } )); }
// SendArtifactRewards public static IEnumerator SendArtifactRewards(Player player) { string accountId = player.accountId; // Retrieve inventory var bucket = new Bucket("AccountToArtifactInventory"); var getRequest = bucket.Get(accountId); yield return(getRequest.WaitUntilDone()); ArtifactInventory artifactInventory; if (getRequest.isSuccessful) { artifactInventory = getRequest.GetValue <ArtifactInventory>(); LogManager.DB.Log("Queried artifact inventory of account '" + accountId + "' successfully"); } else { artifactInventory = new ArtifactInventory(); LogManager.DB.Log("Account " + accountId + " doesn't have any artifact inventory yet"); } // TODO: Skill dependant var arti = new Artifact((byte)Random.Range(0, 3)); artifactInventory.AddArtifact(arti); // Let the player know about his reward player.networkView.RPC("ReceiveArtifactReward", uLink.RPCMode.Owner, arti.id); // Write new stats var setRequest = bucket.Set(accountId, artifactInventory, Encoding.Json); yield return(setRequest.WaitUntilDone()); if (setRequest.isSuccessful) { LogManager.DB.Log("Wrote artifact inventory of '" + accountId + "' successfully"); } else { LogManager.DB.LogError("Could not write artifact inventory for '" + accountId + "'"); } }
// Set artifact tree public static Coroutine SetArtifactInventory(LobbyPlayer player, ArtifactInventory inv) { return(GameDB.instance.StartCoroutine(GameDB.Set <ArtifactInventory>( "AccountToArtifactInventory", player.accountId, inv, data => { if (data == null) { Lobby.RPC("ArtifactInventorySaveError", player.peer); } else { player.artifactInventory = data; } } ))); }
protected override void GrabInventories() { base.GrabInventories(); if (PowerNodeInventory == null) { { GameObject powerNodeInventoryTmp = GameObject.Find(PowerNodeInventoryName); if (powerNodeInventoryTmp != null) { PowerNodeInventory = powerNodeInventoryTmp.GetComponent <Inventory>(); } } } if (SuitInventory == null) { { GameObject suitInventoryTmp = GameObject.Find(SuitInventoryName); if (suitInventoryTmp != null) { SuitInventory = suitInventoryTmp.GetComponent <Inventory>(); } } } if (SuitUpgradeInventory == null) { { GameObject suitUpgradeInventoryTmp = GameObject.Find(SuitUpgradeInventoryName); if (suitUpgradeInventoryTmp != null) { SuitUpgradeInventory = suitUpgradeInventoryTmp.GetComponent <Inventory>(); } } } if (BlasterUpgradeInventory == null) { { GameObject blasterUpgradeInventoryTmp = GameObject.Find(BlasterUpgradeInventoryName); if (blasterUpgradeInventoryTmp != null) { BlasterUpgradeInventory = blasterUpgradeInventoryTmp.GetComponent <Inventory>(); } } } if (ArtifactInventory == null) { { GameObject artifactInventoryTmp = GameObject.Find(ArtifactInventoryName); if (artifactInventoryTmp != null) { ArtifactInventory = artifactInventoryTmp.GetComponent <Inventory>(); } } } if (MeleeInventory == null) { { GameObject meleeInventoryTmp = GameObject.Find(MeleeInventoryName); if (meleeInventoryTmp != null) { MeleeInventory = meleeInventoryTmp.GetComponent <Inventory>(); } } } if (LoreInventory == null) { { GameObject loreInventoryTmp = GameObject.Find(LoreInventoryName); if (loreInventoryTmp != null) { LoreInventory = loreInventoryTmp.GetComponent <Inventory>(); } } } if (PowerNodeInventory != null) { PowerNodeInventory.SetOwner(this.gameObject); PowerNodeInventory.TargetTransform = this.transform; } if (SuitInventory != null) { SuitInventory.SetOwner(this.gameObject); SuitInventory.TargetTransform = this.transform; } if (SuitUpgradeInventory != null) { SuitUpgradeInventory.SetOwner(this.gameObject); SuitUpgradeInventory.TargetTransform = this.transform; } if (BlasterUpgradeInventory != null) { BlasterUpgradeInventory.SetOwner(this.gameObject); BlasterUpgradeInventory.TargetTransform = this.transform; } if (ArtifactInventory != null) { ArtifactInventory.SetOwner(this.gameObject); ArtifactInventory.TargetTransform = this.transform; } if (MeleeInventory != null) { MeleeInventory.SetOwner(this.gameObject); MeleeInventory.TargetTransform = this.transform; } if (LoreInventory != null) { LoreInventory.SetOwner(this.gameObject); LoreInventory.TargetTransform = this.transform; } }
// 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); }