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); }
/// <summary> /// Adds the asset info to the MoodAnimation. /// </summary> /// <param name="moodAnimationName"></param> /// <param name="moodAnimationAssetInfos"></param> public void SetMoodAnimationAssetInfo(MoodAnimation moodAnimationName, List <AssetInfo> moodAnimationAssetInfos) { if (!mMoodAssetInfoLookUpTable.ContainsKey(moodAnimationName)) { mMoodAssetInfoLookUpTable.Add(moodAnimationName, moodAnimationAssetInfos); } }
private void SetupMoodNameToXmlLookUp(XmlDocument moodXml) { foreach (XmlNode faceAnimationNode in moodXml.SelectNodes("MoodAnimations/FaceAnimation")) { string moodName = XmlUtility.GetStringAttribute(faceAnimationNode, "name"); MoodAnimation mood = (MoodAnimation)Enum.Parse(typeof(MoodAnimation), moodName); mMoodToFaceAnimationNode.Add(mood, faceAnimationNode); } }
public List <AssetInfo> GetMoodAssetInfos(MoodAnimation moodName) { if (mMoodAssetInfoLookUpTable.ContainsKey(moodName)) { return(mMoodAssetInfoLookUpTable[moodName]); } else { Debug.LogError("Mood named: " + moodName + " is not found in mMoodAssetInfoLookUpTable"); return(new List <AssetInfo>()); } }
public FaceAnimation GetFaceAnimation(MoodAnimation moodName) { XmlNode moodNode; if (mMoodToFaceAnimationNode.TryGetValue(moodName, out moodNode)) { return(ConstructMood(moodNode)); } else { Console.LogError("Could not create face animation for MoodAnimation: " + moodName.ToString()); return(null); } }
public void SetOwnedMood(MoodAnimation moodAnimation) { if (mPlayableMoodLookUpTable.ContainsKey(moodAnimation)) { mPlayableMoodLookUpTable[moodAnimation] = true; } else if (mMoodAssetInfoLookUpTable.ContainsKey(moodAnimation)) { mPlayableMoodLookUpTable.Add(moodAnimation, true); } else { Debug.LogError("mMoodAssetInfoLookUpTable does not contain asset info, therefore we cannot add mood animation name: " + moodAnimation + " to mPlayableEmoteLookUpTable"); } }
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; }
private void ShowMoodMenu() { mAnimationProxy = GameFacade.Instance.RetrieveProxy <AnimationProxy>(); List <IWidget> enabledMenuButtons = new List <IWidget>(); List <IWidget> disabledMenuButtons = new List <IWidget>(); foreach (KeyValuePair <MoodAnimation, bool> kvp in mAnimationProxy.PlayableMoodLookUpTable) { if (mCurrentMood == kvp.Key) { Button button = (Button)mActiveMoodButton.Clone(); button.AddOnPressedAction(delegate() { Hide(); }); enabledMenuButtons.Add(button); button.Text = kvp.Key.ToString(); } else { Button button = (Button)mActiveMenuButton.Clone(); if (kvp.Value) { button.Enable(); enabledMenuButtons.Add(button); } else { button.Disable(); disabledMenuButtons.Add(button); } button.Text = kvp.Key.ToString(); string moodNameString = kvp.Key.ToString(); button.AddOnPressedAction(delegate() { moodNameString = moodNameString.Split(' ')[0]; MoodAnimation moodName = (MoodAnimation)Enum.Parse(typeof(MoodAnimation), moodNameString); List <AssetInfo> assetInfos = GameFacade.Instance.RetrieveProxy <AnimationProxy>().GetMoodAssetInfos(moodName); GameFacade.Instance.RetrieveMediator <AvatarMediator>().LocalAvatarEntity.UpdateAssetsWithCallback(assetInfos, delegate(AvatarEntity avatarEntity) { GameFacade.Instance.RetrieveProxy <LocalAvatarProxy>().SaveDna(); }); EventLogger.Log(LogGlobals.CATEGORY_GUI, LogGlobals.EVENT_MOOD_CLICKED, "Mood", moodNameString); mCurrentMood = moodName; EventLogger.Log(LogGlobals.CATEGORY_GUI, LogGlobals.EVENT_MOOD_CLICKED, "Mood", moodNameString); Hide(); }); } } List <IWidget> menuButtons = enabledMenuButtons; menuButtons.AddRange(disabledMenuButtons); ResizeTextMenuWindow(mTextMenuWindow, mActiveMenuButton, menuButtons.Count); RepositionWindow(mTextMenuWindow, mMainMenuWindow); mTextMenuGridView.SetPositionsWithBorderPadding(menuButtons, menuButtons.Count, 1, 0, mMenuBorderPadding, mMenuBorderPadding, mMenuButtonPadding); mTextMenuWindow.Showing = true; mIconMenuWindow.Showing = false; mLastWindowShowing = mTextMenuWindow; mLastWindowShowingToUpdate = "mood"; }
public FaceAnimation GetFaceAnimation(string moodName) { MoodAnimation mood = (MoodAnimation)Enum.Parse(typeof(MoodAnimation), moodName); return(GetFaceAnimation(mood)); }