Esempio n. 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);
        }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
        private ComplexUvAnimation ParseComplexUvAnimation(XmlNode complexUvAnimationXmlNode)
        {
            string      name = XmlUtility.GetStringAttribute(complexUvAnimationXmlNode, "name");
            XmlNodeList complexFrameNodes = complexUvAnimationXmlNode.SelectNodes("ComplexFrame");

            if (complexFrameNodes.Count == 0)
            {
                Console.LogError("ComplexUvAnimation " + name + " does not have any ComplexFrames defined in node: " + complexUvAnimationXmlNode.OuterXml);
                return(null);
            }

            ComplexFrame[] frames = new ComplexFrame[complexFrameNodes.Count];

            /* Foreach ComplexFrame */
            int complexFrameCount = 0;

            foreach (XmlNode complexFrameNode in complexFrameNodes)
            {
                int   repeatFrame       = XmlUtility.GetIntAttribute(complexFrameNode, "repeatFrame");
                float waitAfterFinished = XmlUtility.GetFloatAttribute(complexFrameNode, "waitAfterFinished");

                XmlNodeList simpleAnimationNodes = complexFrameNode.SelectNodes("SimpleAnimation");
                if (simpleAnimationNodes.Count == 0)
                {
                    Console.LogError("ComplexFrame does not have any Simple animations defined in name: " + complexFrameNode.OuterXml);
                    return(null);
                }

                /* Foreach Animation Frame */
                List <SimpleUvAnimation> simpleAnimations = new List <SimpleUvAnimation>();
                foreach (XmlNode simpleAnimation in simpleAnimationNodes)
                {
                    string      uvAnimationId = XmlUtility.GetStringAttribute(simpleAnimation, "assetId");
                    UvAnimation uvAnimation;
                    if (mUvAnimationLookUpTable.TryGetValue(uvAnimationId, out uvAnimation))
                    {
                        SimpleUvAnimation simpleUvAnimation = (SimpleUvAnimation)uvAnimation;
                        if (simpleUvAnimation == null)
                        {
                            Console.Log("Could not assign uvAnimation as SimpleAnimation from key: " + uvAnimationId);
                        }
                        else
                        {
                            simpleAnimations.Add(simpleUvAnimation);
                        }
                    }
                    else
                    {
                        Console.LogError("Unable to pull simple uv animation from dictionary using key: " + uvAnimationId);
                    }
                }
                frames[complexFrameCount] = new ComplexFrame(repeatFrame, waitAfterFinished, simpleAnimations.ToArray());
                ++complexFrameCount;
            }

            return(new ComplexUvAnimation(name, frames));
        }
Esempio n. 4
0
 private void SetupSimpleUvAnimations(XmlNode rootNode)
 {
     /* foreach ComplexUvAnimation Range */
     foreach (XmlNode uvAnimationNode in rootNode.SelectNodes("descendant::SimpleUvAnimation"))
     {
         SimpleUvAnimation newUva        = SimpleUvAnimation.Parse(uvAnimationNode);
         string            uvAnimationId = XmlUtility.GetStringAttribute(uvAnimationNode, "assetId");
         mUvAnimationLookUpTable.Add(uvAnimationId, newUva);
     }
 }
Esempio n. 5
0
 private void SetupComplexUvAnimations(XmlNode rootNode)
 {
     /* foreach ComplexUvAnimation Range */
     foreach (XmlNode complexUvAnimationNode in rootNode.SelectNodes("ComplexUvAnimations/Animation"))
     {
         ComplexUvAnimation newCuva = ParseComplexUvAnimation(complexUvAnimationNode);
         if (newCuva == null)
         {
             Console.LogError("Complex Uv Animation could not be created from node: " + complexUvAnimationNode);
         }
         else
         {
             string complexUvAnimationId = XmlUtility.GetStringAttribute(complexUvAnimationNode, "assetId");
             mUvAnimationLookUpTable.Add(complexUvAnimationId, newCuva);
         }
     }
 }
Esempio n. 6
0
        private FaceAnimation ConstructMood(XmlNode moodRootNode)
        {
            string             moodName         = XmlUtility.GetStringAttribute(moodRootNode, "name");
            List <UvAnimation> moodUvAnimations = new List <UvAnimation>();

            foreach (XmlNode uvAnimationNode in moodRootNode.SelectNodes("Animation"))
            {
                string      animationName = XmlUtility.GetStringAttribute(uvAnimationNode, "assetId");
                UvAnimation uvAnimation;
                if (mUvAnimationLookUpTable.TryGetValue(animationName, out uvAnimation))
                {
                    moodUvAnimations.Add(uvAnimation);
                }
                else
                {
                    Console.LogError("UvAnimation named: " + animationName + " could not be found in UvAnimation Lookup table.");
                }
            }
            return(new FaceAnimation(moodName, moodUvAnimations[0], moodUvAnimations));
        }
Esempio n. 7
0
        /*
         *      Create a SimpleUvAnimation from XML
         */
        public static SimpleUvAnimation Parse(XmlNode uvAnimationXmlNode)
        {
            string      name = XmlUtility.GetStringAttribute(uvAnimationXmlNode, "name");
            XmlNodeList frameSequenceNodes = uvAnimationXmlNode.SelectNodes("descendant::FrameSequence");

            if (frameSequenceNodes.Count == 0)
            {
                Console.LogError("SimpleUvAnimation " + name + " does not have any FrameSequences defined");
                return(null);
            }

            int[][]  frameSequences      = new int[frameSequenceNodes.Count][];
            string[] frameSequenceTarget = new string[frameSequenceNodes.Count];

            /* Foreach FrameSequence */
            int sequenceCount = 0;

            foreach (XmlNode frameSequenceNode in frameSequenceNodes)
            {
                string sequenceTarget = XmlUtility.GetStringAttribute(frameSequenceNode, "target");
                frameSequenceTarget[sequenceCount] = sequenceTarget;

                XmlNodeList frameNodes = frameSequenceNode.SelectNodes("descendant::Frame");
                if (frameNodes.Count == 0)
                {
                    Console.LogError("FrameSequence for target " + sequenceTarget + " does not have any Frames defined");
                    return(null);
                }

                /* Foreach Animation Frame */
                frameSequences[sequenceCount] = new int[frameNodes.Count];
                int frameCount = 0;
                foreach (XmlNode frameNode in frameNodes)
                {
                    frameSequences[sequenceCount][frameCount] = XmlUtility.GetIntAttribute(frameNode, "value");
                    ++frameCount;
                }
                ++sequenceCount;
            }
            return(new SimpleUvAnimation(name, frameSequenceTarget, frameSequences));
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        public FaceMeshAsset(AssetSubType type, Mesh mesh, string displayName, string path, string key, XmlNode meshInfo)
            : base(type, mesh, displayName, path, key)
        {
            if (mesh == null)
            {
                throw new ArgumentNullException("mesh");
            }

            XmlNode faceMeshInfoNode = meshInfo;

            XmlNodeList uvShellNodes = faceMeshInfoNode.SelectNodes("descendant::UvShell");

            mUvShellCount = uvShellNodes.Count;
            if (mUvShellCount == 0)
            {
                Console.LogError("FaceMeshAsset(): FaceMesh " + DisplayName + " does not have any UvShell info");
                return;
            }
            mUvShellNames     = new string[mUvShellCount];
            mUvGridDimensions = new Vector2[mUvShellCount];
            mTextureZoneNames = new string[mUvShellCount];

            /* foreach UvShell get its data */
            int count = 0;

            foreach (XmlNode uvShellNode in uvShellNodes)
            {
                int subMeshIndex = XmlUtility.GetIntAttribute(uvShellNode, "subMeshIndex");
                mUvShellNames[subMeshIndex]     = XmlUtility.GetStringAttribute(uvShellNode, "name");
                mTextureZoneNames[subMeshIndex] = XmlUtility.GetStringAttribute(uvShellNode, "textureZone");

                int gridWidth  = XmlUtility.GetIntAttribute(uvShellNode, "gridWidth");
                int gridHeight = XmlUtility.GetIntAttribute(uvShellNode, "gridHeight");

                mUvGridDimensions[subMeshIndex] = new Vector2(gridWidth, gridHeight);
                ++count;
            }
        }
Esempio n. 10
0
        public override void HandleSearchResults(XmlDocument xmlResponse)
        {
            //Debug.Log("HandleSearchResults " + xmlResponse.OuterXml);
            XmlElement responseNode = (XmlElement)xmlResponse.SelectSingleNode("Response");
            string     responseVerb = responseNode.GetAttribute("verb");

            foreach (XmlNode itemNode in xmlResponse.SelectNodes("item"))
            {
                string itemTypeName = XmlUtility.GetStringAttribute(itemNode, "itemTypeName");
                if (!mCurrentItemType.Contains(itemTypeName))
                {
                    return;
                }
            }
            if (responseVerb == "GetStoreInventory")
            {
                // Save returned results
                mCurrentSearchResultsXml = xmlResponse;

                // Update the gui
                UpdatePageNumbers();
                UpdateStoreButtons();
            }
        }
Esempio n. 11
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;
        }
Esempio n. 12
0
        /// <summary>
        /// Update store buttons from xml data returned by server
        /// </summary>
        private void UpdateStoreButtons()
        {
            if (mCurrentSearchResultsXml != null)
            {
                XmlNodeList itemOfferList = mCurrentSearchResultsXml.SelectNodes("/Response/store/itemOffers/itemOffer");
                int         i             = 0;
                foreach (XmlElement itemOfferNode in itemOfferList)
                {
                    //string description = itemOfferNode.GetAttribute("description");

                    XmlElement itemNode     = (XmlElement)itemOfferNode.SelectSingleNode("item");
                    string     thumbnailUrl = ConvertPaymentItemsUrl(itemNode.GetAttribute("smallImageUrl"));

                    // Fill in details of button
                    XmlElement itemOfferElement = itemOfferNode;
                    Button     currentButton    = (Button)mGridItemButtons[i].Value;
                    //currentButton.Text = itemName;
                    GuiFrame buttonFrame = mGridItemButtons[i].Key;
                    Image    thumbnail   = buttonFrame.SelectSingleElement <Image>("Thumbnail");
                    buttonFrame.Showing = true;
                    Label   price     = buttonFrame.SelectSingleElement <Label>("PriceLabel");
                    XmlNode moneyNode = itemOfferNode.SelectSingleNode("price/money");
                    price.Text = FormatPrice(XmlUtility.GetStringAttribute(moneyNode, "amount"));

                    Image priceIcon = buttonFrame.SelectSingleElement <Image>("PriceIcon");
                    if (XmlUtility.GetStringAttribute(moneyNode, "currencyName") == "VCOIN")
                    {
                        priceIcon.Texture = mGameCurrencyIcon;
                    }
                    else
                    {
                        priceIcon.Texture = mRealMoneyIcon;
                    }

                    currentButton.ClearOnPressedActions();
                    currentButton.Text    = "Loading...";
                    currentButton.Enabled = false;
                    currentButton.AddOnPressedAction(delegate()
                    {
                        GridItemSelected(buttonFrame, itemOfferElement, itemNode);
                    });

                    // If no thumbnail, don't load anything.
                    // TODO: should we load a default image?
                    if (thumbnailUrl != "")
                    {
                        ApplyImageToButton(thumbnailUrl, currentButton, thumbnail);
                    }
                    else
                    {
                        currentButton.Text = "No Image.";
                    }

                    i++;
                }

                for (int j = i; j < mBlockSize; ++j)
                {
                    ClearButton(mGridItemButtons[j].Value);
                }
            }
            else
            {
                Console.LogError("no items found in store response");
            }
        }