예제 #1
0
        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);
        }
예제 #2
0
        public void GetRigAnimation(RigAnimationName animation, Action <AnimationClip> foundAnimationClipCallback)
        {
            // TODO: This is a bit of a hack should probably be removed.
            if (animation == RigAnimationName.None)
            {
                Debug.LogError("animation being passed into GetRigAnimation is 'None'.");
                return;
            }
            // Check if we have the the rig animation asset already.
            if (mRigAnimationLookUpTable.ContainsKey(animation))
            {
                foundAnimationClipCallback(mRigAnimationLookUpTable[animation].AnimationClip);
                return;
            }

            // If we don't have the rig animation asset already grab the info from the lookup table and loaded it from the repo.
            // The repo calls the AddRigAnimation function in the class which puts it in the rig animation lookup table.
            if (!mEmoteToAssetInfoLookUpTable.ContainsKey(animation))
            {
                Debug.LogError("There is no asset info for the animation: " + animation.ToString());
                return;
            }
            mClientAssetRepository.GetAsset <RigAnimationAsset>(mEmoteToAssetInfoLookUpTable[animation], delegate(RigAnimationAsset asset)
            {
                foundAnimationClipCallback(asset.AnimationClip);
            });
        }
예제 #3
0
        private void SetRigAnimationAssetInfo(AssetInfo rigAnimationAssetInfo)
        {
            string           animationNameString = rigAnimationAssetInfo.AssetData.SelectSingleNode("AnimationName").InnerText;
            RigAnimationName rigAnimationName    = (RigAnimationName)Enum.Parse(typeof(RigAnimationName), animationNameString);

            SetRigAnimationAssetInfo(rigAnimationName, rigAnimationAssetInfo);
        }
예제 #4
0
        private void SetupOverlayActionButtons(string itemId, string itemType, XmlNode assetsNode)
        {
            LocalAvatarEntity localAvatarEntity = GameFacade.Instance.RetrieveMediator <AvatarMediator>().LocalAvatarEntity;

            switch (itemType)
            {
            case ItemType.TOPS:
            case ItemType.PANTS:
            case ItemType.SKIRT:
            case ItemType.BAGS:
            case ItemType.SHOES:
            case ItemType.HAIR:
            case ItemType.BODY:
            case ItemType.MAKEUP:
            case ItemType.FACE:
            case ItemType.MOOD:
                // Call method to apply clothing to body
                localAvatarEntity.ApplyTempClothingToAvatar(assetsNode);
                break;

            case ItemType.EMOTE:
                string animationNameString = assetsNode.SelectSingleNode("Asset/AssetData/AnimationName").InnerText;
                animationNameString = animationNameString.Split(' ')[0];
                RigAnimationName animationName = (RigAnimationName)Enum.Parse(typeof(RigAnimationName), animationNameString);
                GameFacade.Instance.RetrieveProxy <AnimationProxy>().SetRigAnimationAssetInfo(animationName, new ClientAssetInfo(assetsNode.SelectSingleNode("Asset")));
                GameFacade.Instance.RetrieveProxy <ClientAssetRepository>().GetAsset <RigAnimationAsset>(new ClientAssetInfo(assetsNode.SelectSingleNode("Asset")), delegate(RigAnimationAsset animationAsset)
                {
                    GameFacade.Instance.SendNotification(GameFacade.PLAY_EMOTE, animationNameString as object);
                });
                break;
            }
        }
        public override void HandleNotification(INotification notification)
        {
            switch (notification.Name)
            {
            case GameFacade.PLAY_EMOTE:
                string emoteName = notification.Body as string;
                if (emoteName == null)
                {
                    Console.LogError("Unable to parse notification.Body into emoteName");
                    return;
                }
                RigAnimationName animationName = (RigAnimationName)Enum.Parse(typeof(RigAnimationName), emoteName);
                GameFacade.Instance.RetrieveProxy <AnimationProxy>().GetRigAnimation(animationName, delegate(AnimationClip animationClip)
                {
                    AnimationSequence emoteSequence = new AnimationSequence(animationClip.name, true);
                    emoteSequence.AddListing(new AnimationSequence.Listing(animationClip, new AnimationLoopCount(1, 1)));
                    Emote emote = new Emote(animationName, emoteSequence);

                    // Send emote message so other clients see us emoting
                    GameFacade.Instance.RetrieveProxy <LocalAvatarProxy>().LocalAvatarDistributedObject.SendEmoteUpdate(emote.Name.ToString());
                    PlayEmote(emote);
                });
                break;
            }
        }
예제 #6
0
        public Emote(RigAnimationName name, AnimationSequence sequence)
        {
            mName = name;

            if (sequence == null)
            {
                throw new ArgumentNullException("sequence");
            }
            mSequence = sequence;
        }
예제 #7
0
 /// <summary>
 /// Adds the asset info to the RigAnimationName.
 /// </summary>
 /// <param name="rigAnimationName"></param>
 /// <param name="rigAnimationAssetInfo"></param>
 public void SetRigAnimationAssetInfo(RigAnimationName rigAnimationName, AssetInfo rigAnimationAssetInfo)
 {
     if (!mEmoteToAssetInfoLookUpTable.ContainsKey(rigAnimationName))
     {
         mEmoteToAssetInfoLookUpTable.Add(rigAnimationName, rigAnimationAssetInfo);
     }
     else
     {
         mEmoteToAssetInfoLookUpTable[rigAnimationName] = rigAnimationAssetInfo;
     }
 }
예제 #8
0
        public RigAnimationAsset(AssetSubType type, AnimationClip rigAnimationClip, string displayName, string path, string key, RigAnimationName animationName)
            : base(type, displayName, path, key)
        {
            if (rigAnimationClip == null)
            {
                throw new ArgumentNullException("rigAnimationClip");
            }
            mAnimationClip = rigAnimationClip;

            mAnimationName = animationName;
        }
        public void PlayEmote(string emoteName)
        {
            RigAnimationName animationName = (RigAnimationName)Enum.Parse(typeof(RigAnimationName), emoteName);

            GameFacade.Instance.RetrieveProxy <AnimationProxy>().GetRigAnimation(animationName, delegate(AnimationClip animationClip)
            {
                AnimationSequence emoteSequence = new AnimationSequence(animationClip.name, true);
                emoteSequence.AddListing(new AnimationSequence.Listing(animationClip, new AnimationLoopCount(1, 1)));
                Emote emote = new Emote(animationName, emoteSequence);
                this.PlayEmote(emote);
            });
        }
예제 #10
0
        public void SendEmoteUpdate(string emoteName)
        {
            Message emoteUpdateMessage = new Message();

            List <object>    data = new List <object>();
            RigAnimationName emoteRigAnimationName = (RigAnimationName)Enum.Parse(typeof(RigAnimationName), emoteName);
            string           emoteAssetInfoNode    = GameFacade.Instance.RetrieveProxy <AnimationProxy>().EmoteToAssetInfoLookUpTable[emoteRigAnimationName].AssetNode.OuterXml;

            data.Add(emoteAssetInfoNode);

            emoteUpdateMessage.UpdateObjectMessage(true, false, mDistributedObjectId, (int)MessageSubType.Emote, data);
            this.SendMessage(emoteUpdateMessage);
        }
예제 #11
0
 public void SetOwnedEmote(RigAnimationName rigAnimationName)
 {
     if (mPlayableEmoteLookUpTable.ContainsKey(rigAnimationName))
     {
         mPlayableEmoteLookUpTable[rigAnimationName] = true;
     }
     else if (mEmoteToAssetInfoLookUpTable.ContainsKey(rigAnimationName))
     {
         mPlayableEmoteLookUpTable.Add(rigAnimationName, true);
     }
     else
     {
         Debug.LogError("mEmoteToAssetInfoLookUpTable does not contain asset info, therefore we cannot add rig animation name: " + rigAnimationName + " to mPlayableEmoteLookUpTable");
     }
 }
예제 #12
0
        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();
            });
        }
예제 #13
0
        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;
        }