private void DisplaySuccessDialog(XmlDocument xmlResponse) { XmlNode purchasedOfferNode = xmlResponse.SelectSingleNode("Response/purchaseResults/purchaseResult/offer"); XmlNode purchasedItemNode = purchasedOfferNode.SelectSingleNode("item"); string itemType = XmlUtility.GetStringAttribute(purchasedItemNode, "itemTypeName"); AnimationProxy animationProxy = GameFacade.Instance.RetrieveProxy <AnimationProxy>(); switch (itemType) { case "Emote": XmlNode assetInfoNode = purchasedItemNode.SelectSingleNode("Assets/Asset"); AssetInfo assetInfo = new ClientAssetInfo(assetInfoNode); string animationName = purchasedItemNode.SelectSingleNode("Assets/Asset/AssetData/AnimationName").InnerText; RigAnimationName rigAnimationName = (RigAnimationName)Enum.Parse(typeof(RigAnimationName), animationName); animationProxy.SetRigAnimationAssetInfo(rigAnimationName, assetInfo); animationProxy.SetOwnedEmote(rigAnimationName); break; case "Mood": List <AssetInfo> moodInfos = new List <AssetInfo>(); foreach (XmlNode moodInfoNode in purchasedItemNode.SelectNodes("Assets/Asset")) { AssetInfo moodInfo = new ClientAssetInfo(moodInfoNode); moodInfos.Add(moodInfo); } string moodName = XmlUtility.GetStringAttribute(purchasedItemNode, "buttonName"); moodName = moodName.Split(' ')[0]; MoodAnimation moodAnimationName = (MoodAnimation)Enum.Parse(typeof(MoodAnimation), moodName); animationProxy.SetMoodAnimationAssetInfo(moodAnimationName, moodInfos); animationProxy.SetOwnedMood(moodAnimationName); break; case "Emoticon": XmlNode emoticonInfoNode = purchasedItemNode.SelectSingleNode("Assets/Asset"); if (emoticonInfoNode == null) { Debug.LogError("EmoticonInfoNode was null: " + purchasedItemNode.OuterXml); break; } AssetInfo emoticonInfo = new ClientAssetInfo(emoticonInfoNode); animationProxy.SetEmoticonAssetInfo(emoticonInfo); animationProxy.SetOwnedEmoticon(emoticonInfo.Path); break; default: Console.Log("Successful purchase of item type: " + itemType + ". No action taken."); break; } // Parse out the price of the item and add it to the log XmlElement priceNode = (XmlElement)purchasedOfferNode.SelectSingleNode("price/money"); string currency = priceNode.GetAttribute("currencyName"); string price = priceNode.GetAttribute("amount"); string itemName = ((XmlElement)purchasedOfferNode).GetAttribute("name"); LogPurchaseSuccess(itemName, price, currency); }
public void RemoveClothingFromAvatar(XmlNode assetsNode) { List <AssetInfo> assetInfos = new List <AssetInfo>(); foreach (XmlNode assetNode in assetsNode.SelectNodes("Asset")) { AssetInfo assetInfo = new ClientAssetInfo(assetNode); assetInfos.Add(assetInfo); } RemoveAssets(assetInfos); }
/// <summary> /// Puts clothes on the avatar permanently and updates the dna. /// </summary> /// <param name="assetsNode"></param> public void ApplyAssetsToAvatar(XmlNode assetsNode) { List <AssetInfo> assetInfos = new List <AssetInfo>(); foreach (XmlNode assetNode in assetsNode.SelectNodes("Asset")) { AssetInfo assetInfo = new ClientAssetInfo(assetNode); assetInfos.Add(assetInfo); } UpdateAssets(assetInfos); }
/// <summary> /// Puts clothes on temporarily (updates the tempDna only) /// </summary> /// <param name="assetsNode"></param> public void ApplyTempClothingToAvatar(XmlNode assetsNode) { List <AssetInfo> assetInfos = new List <AssetInfo>(); foreach (XmlNode assetNode in assetsNode.SelectNodes("Asset")) { AssetInfo assetInfo = new ClientAssetInfo(assetNode); assetInfos.Add(assetInfo); } ApplyTempAssetInfos(assetInfos); }
private void RecvDnaUpdate(Message message) { XmlDocument assetsToSetDoc = new XmlDocument(); assetsToSetDoc.LoadXml(message.Data[0].ToString()); List <AssetInfo> assetInfos = new List <AssetInfo>(); foreach (XmlNode assetInfoNode in assetsToSetDoc.SelectNodes("Items/Item/Assets/Asset")) { AssetInfo assetInfo = new ClientAssetInfo(assetInfoNode); assetInfos.Add(assetInfo); } GameFacade.Instance.RetrieveProxy <ClientAssetRepository>().GetAssets <Asset>(assetInfos, RetrieveAssetsFromClientAssetRepo); }
private void ReceiveEmote(Message message) { // Parse out the emote info to load from the repo to make sure the emote is loaded before we try to play it. XmlDocument emoteDoc = new XmlDocument(); emoteDoc.LoadXml((string)message.Data[0]); XmlNode emoteNode = emoteDoc.SelectSingleNode("Asset"); ClientAssetInfo emoteInfo = new ClientAssetInfo(emoteNode); GameFacade.Instance.RetrieveProxy <ClientAssetRepository>().GetAsset <RigAnimationAsset>(emoteInfo, delegate(RigAnimationAsset rigAnimationAsset) { if (this.StateMachine.CurrentState is DefaultForeignAvatarState) { DefaultForeignAvatarState state = (DefaultForeignAvatarState)this.StateMachine.CurrentState; state.PlayEmote(rigAnimationAsset.AnimationName.ToString()); } }); }
private void SetupAssetsFromItemsXml(string roomItemsXmlString) { XmlDocument roomDna = new XmlDocument(); roomDna.LoadXml(roomItemsXmlString); ClientAssetRepository clientAssetRepository = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>(); XmlNodeList itemXmlNodes = roomDna.SelectNodes("Items/Item"); foreach (XmlNode itemXmlNode in itemXmlNodes) { XmlNodeList assetXmlNodes = itemXmlNode.SelectNodes("Assets/Asset"); foreach (XmlNode assetXmlNode in assetXmlNodes) { AssetInfo assetInfo = new ClientAssetInfo(assetXmlNode); clientAssetRepository.GetAsset <Asset>(assetInfo, ApplyAssetToType); } } }
public LocalAvatarEntity(GameObject avatarBodyGameObject, GameObject headGameObject) : base(avatarBodyGameObject, headGameObject) { mAvatarDna = new Dna(); mChangesToDna = new Dna(); List <AssetInfo> assetInfos = new List <AssetInfo>(); XmlDocument defaultsDoc = XmlUtility.LoadXmlDocument("resources://Avatar/DefaultAssetList"); foreach (XmlNode defaultAssetNode in defaultsDoc.SelectNodes("DefaultAssets/Asset")) { string stringSubType = XmlUtility.GetStringAttribute(defaultAssetNode, "AssetSubType"); if (stringSubType == null) { throw new XmlException("Could not retrieve asset sub type string from node: " + defaultAssetNode); } AssetInfo assetInfo = new ClientAssetInfo(defaultAssetNode); assetInfos.Add(assetInfo); } mDefaultDna.SetDna(assetInfos); }
public void Init() { mClientAssetRepository.LoadAssetFromPath <XmlAsset>(PATH_TO_EMOTE_LIST_XML, delegate(XmlAsset emoteListXmlAsset) { // Parse out all the emotes and set them as false. Make call to server to get list of owned Emotes. foreach (XmlNode emoteNode in emoteListXmlAsset.XmlDocument.SelectNodes("EmoteList/Emote")) { RigAnimationName emoteName = (RigAnimationName)Enum.Parse(typeof(RigAnimationName), emoteNode.InnerText); if (!mPlayableEmoteLookUpTable.ContainsKey(emoteName)) { mPlayableEmoteLookUpTable.Add(emoteName, false); } } mEmotesParsed = true; CheckIfAllPossibleEmotesIconsMoodsHaveBeenParsed(); }); mClientAssetRepository.LoadAssetFromPath <XmlAsset>(PATH_TO_MOOD_LIST_XML, delegate(XmlAsset emoteListXmlAsset) { // Parse out all the emotes and set them as false. Make call to server to get list of owned Emotes. foreach (XmlNode moodNode in emoteListXmlAsset.XmlDocument.SelectNodes("MoodList/Mood")) { MoodAnimation moodAnimationName = (MoodAnimation)Enum.Parse(typeof(MoodAnimation), moodNode.InnerText); if (!mPlayableMoodLookUpTable.ContainsKey(moodAnimationName)) { if (moodAnimationName.ToString() == "Happy") { XmlNodeList assetNodes = moodNode.SelectNodes("//Assets/Asset"); ClientAssetInfo faceAnimation = new ClientAssetInfo(assetNodes[0]); ClientAssetInfo idle = new ClientAssetInfo(assetNodes[1]); ClientAssetInfo walk = new ClientAssetInfo(assetNodes[2]); List <AssetInfo> assets = new List <AssetInfo>(); assets.Add(faceAnimation); assets.Add(idle); assets.Add(walk); mMoodAssetInfoLookUpTable.Add(moodAnimationName, assets); mPlayableMoodLookUpTable.Add(moodAnimationName, true); } else { mPlayableMoodLookUpTable.Add(moodAnimationName, false); } } } mMoodsParsed = true; CheckIfAllPossibleEmotesIconsMoodsHaveBeenParsed(); }); mClientAssetRepository.LoadAssetFromPath <XmlAsset>(PATH_TO_ICON_LIST_XML, delegate(XmlAsset iconListXmlAsset) { // Parse out all the emotes and set them as false. foreach (XmlNode iconNode in iconListXmlAsset.XmlDocument.SelectNodes("IconList/Icon")) { if (!mPlayableIconLookUpTable.ContainsKey(iconNode.InnerText)) { mPlayableIconLookUpTable.Add(iconNode.InnerText, false); } } mIconsParsed = true; CheckIfAllPossibleEmotesIconsMoodsHaveBeenParsed(); }); }
public void SetOwnedEmotesAndMoodsXml(XmlDocument emoteXml) { foreach (XmlNode itemNode in emoteXml.SelectNodes("Response/itemInstances/itemInstance/item")) { string itemType = XmlUtility.GetStringAttribute(itemNode, "itemTypeName"); switch (itemType) { case "Emote": XmlNode assetInfoNode = itemNode.SelectSingleNode("Assets/Asset"); AssetInfo assetInfo = new ClientAssetInfo(assetInfoNode); string animationNameString = assetInfoNode.SelectSingleNode("AssetData/AnimationName").InnerText; RigAnimationName rigAnimationName = (RigAnimationName)Enum.Parse(typeof(RigAnimationName), animationNameString); // Add asset info. if (!mEmoteToAssetInfoLookUpTable.ContainsKey(rigAnimationName)) { mEmoteToAssetInfoLookUpTable.Add(rigAnimationName, assetInfo); } // Add to owned lookup table. // TODO: Get a true or false with the response to actually set it. if (!mPlayableEmoteLookUpTable.ContainsKey(rigAnimationName)) { mPlayableEmoteLookUpTable.Add(rigAnimationName, true); } else { mPlayableEmoteLookUpTable[rigAnimationName] = true; } break; case "Mood": List <AssetInfo> moodAssetInfos = new List <AssetInfo>(); string moodNameString = XmlUtility.GetStringAttribute(itemNode, "buttonName"); moodNameString = moodNameString.Split(' ')[0]; MoodAnimation moodName = (MoodAnimation)Enum.Parse(typeof(MoodAnimation), moodNameString); foreach (XmlNode assetNode in itemNode.SelectNodes("Assets/Asset")) { AssetInfo moodAssetInfo = new ClientAssetInfo(assetNode); // If the client Asset repo has the walk animation cached these walk and idle animations (happens when /// game states are changed), the animations wouldn't have been added to this proxy. if (moodAssetInfo.AssetSubType == AssetSubType.RigAnimation || moodAssetInfo.AssetSubType == AssetSubType.RigWalkAnimation || moodAssetInfo.AssetSubType == AssetSubType.RigIdleAnimation) { SetRigAnimationAssetInfo(moodAssetInfo); } moodAssetInfos.Add(moodAssetInfo); } if (!mMoodAssetInfoLookUpTable.ContainsKey(moodName)) { mMoodAssetInfoLookUpTable.Add(moodName, moodAssetInfos); } // Add to owned lookup table. // TODO: Get a true or false with the response to actually set it. if (!mPlayableMoodLookUpTable.ContainsKey(moodName)) { mPlayableMoodLookUpTable.Add(moodName, true); } else { mPlayableMoodLookUpTable[moodName] = true; } break; case "Emoticon": XmlNode emoticonInfoNode = itemNode.SelectSingleNode("Assets/Asset"); if (emoticonInfoNode == null) { Debug.LogError("emoticonInfoNode is null in Xml: " + itemNode.OuterXml); break; } AssetInfo emoticonInfo = new ClientAssetInfo(emoticonInfoNode); if (!mEmoticonToAssetInfoLookUpTable.ContainsKey(emoticonInfo.Path)) { mEmoticonToAssetInfoLookUpTable.Add(emoticonInfo.Path, emoticonInfo); } if (!mPlayableIconLookUpTable.ContainsKey(emoticonInfo.Path)) { mPlayableIconLookUpTable.Add(emoticonInfo.Path, true); } else { mPlayableIconLookUpTable[emoticonInfo.Path] = true; } break; default: Debug.LogError("Do not yet know how to parse type of: " + itemType); break; } } // Parse the xml into Asset Infos and store list with AnimationName enum. // Fill this out mEmoteToAssetInfoLookUpTable here. GameFacade.Instance.SendNotification(GameFacade.ANIMATION_PROXY_LOADED); mOnFinishedLoading(); mLoaded = true; }
/// <summary> /// Show the item detail popup /// </summary> /// <param name="button"></param> /// <param name="index">Index of the item on the current page that this button corresponds to</param> private void GridItemSelected(IWidget widget, XmlElement itemOfferNode, XmlElement itemNode) { XmlElement priceNode = (XmlElement)itemOfferNode.SelectSingleNode("price/money"); string description = itemOfferNode.GetAttribute("description"); string itemName = itemOfferNode.GetAttribute("title"); string thumbnailUrl = ConvertPaymentItemsUrl(itemNode.GetAttribute("smallImageUrl")); string uniqueId = itemNode.GetAttribute("name"); string itemExpiration = itemOfferNode.GetAttribute("endDate"); string itemQuantity = itemOfferNode.GetAttribute("numAvailable"); string currency = priceNode.GetAttribute("currencyName"); string price = priceNode.GetAttribute("amount"); string itemType = itemNode.GetAttribute("itemTypeName"); XmlNode assetsNode = itemNode.SelectSingleNode("Assets"); mCurrentSelectedItemOffer = itemOfferNode; ShowItemInfoOverlay(widget, thumbnailUrl, price, currency); ShowItemInfoFrame(itemName, description, itemExpiration, itemQuantity); SetupOverlayActionButtons(uniqueId, itemType, assetsNode); // Log for metrics if (currency == "HOUTS") { EventLogger.Log(LogGlobals.CATEGORY_SHOPPING, LogGlobals.CLICKED_ON_CASH_ITEM, itemName, price); mItemOverlayActionButton.ClearOnPressedActions(); mItemOverlayActionButton.AddOnPressedAction(delegate() { mOverlayWindow.Showing = false; }); // Disable the Buy button if you don't have enough currency to purchase. if (GameFacade.Instance.RetrieveProxy <InventoryProxy>().Houts < Double.Parse(price)) { mItemOverlayActionButton.AddOnPressedAction(delegate() { BuyCoinUtility.GoToBuyCashPage ( Translation.NEED_CASH_TITLE, Translation.NOT_ENOUGH_COIN, delegate(string s) { Console.WriteLine("Opening cash store: " + s); }, delegate() { GameFacade.Instance.SendNotification(GameFacade.GET_CASH_GUI_CLOSED); } ); }); } else { mItemOverlayActionButton.AddOnPressedAction(delegate() { Purchase(); }); } } else { EventLogger.Log(LogGlobals.CATEGORY_SHOPPING, LogGlobals.CLICKED_ON_COIN_ITEM, itemName, price); // Disable the Buy button if you don't have enough currency to purchase. if (GameFacade.Instance.RetrieveProxy <InventoryProxy>().VCoin < Double.Parse(price)) { mItemOverlayActionButton.AddOnPressedAction(delegate() { BuyCoinUtility.GoToBuyCashPage ( Translation.NEED_CASH_TITLE, Translation.NOT_ENOUGH_CASH, delegate(string s) { Console.WriteLine("Opening cash store: " + s); }, delegate() { GameFacade.Instance.SendNotification(GameFacade.GET_CASH_GUI_CLOSED); } ); }); } else { mItemOverlayActionButton.AddOnPressedAction(delegate() { Purchase(); }); } } mRemoveButton.ClearOnPressedActions(); mRemoveButton.AddOnPressedAction(delegate() { List <AssetInfo> assetInfos = new List <AssetInfo>(); foreach (XmlNode assetNode in assetsNode.SelectNodes("Asset")) { AssetInfo assetInfo = new ClientAssetInfo(assetNode); assetInfos.Add(assetInfo); } GameFacade.Instance.RetrieveMediator <AvatarMediator>().LocalAvatarEntity.RemoveTempAssetInfos(assetInfos); mOverlayWindow.Showing = false; }); }