示例#1
0
        public FaceAnimationFactory(Hangout.Shared.Action finishedLoadingFaceAnimationAssets)
        {
            // TODO: Put in a better loading handler which processes all three of these in parallel.
            ClientAssetRepository clientAssetRepository = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            if (mSimpleUvAnimationsXml != null && mComplexUvAnimationsXml != null && mMoodToXml != null)
            {
                SetupSimpleUvAnimations(mSimpleUvAnimationsXml);
                SetupComplexUvAnimations(mComplexUvAnimationsXml);
                SetupMoodNameToXmlLookUp(mMoodToXml);
            }
            else
            {
                // The simple uvs must be created first since the complex uvs rely on them to be constructed.
                clientAssetRepository.LoadAssetFromPath <XmlAsset>(SIMPLE_UV_ANIMATION_LOOKUP_PATH, delegate(XmlAsset simpleUvAnimationsXmlAsset)
                {
                    mSimpleUvAnimationsXml = simpleUvAnimationsXmlAsset.XmlDocument;
                    SetupSimpleUvAnimations(simpleUvAnimationsXmlAsset.XmlDocument);
                    clientAssetRepository.LoadAssetFromPath <XmlAsset>(COMPLEX_UV_ANIMATION_LOOKUP_PATH, delegate(XmlAsset complexUvAnimationsXmlAsset)
                    {
                        mComplexUvAnimationsXml = complexUvAnimationsXmlAsset.XmlDocument;
                        SetupComplexUvAnimations(complexUvAnimationsXmlAsset.XmlDocument);
                        clientAssetRepository.LoadAssetFromPath <XmlAsset>(AVATAR_MOOD_TO_XML_LOOKUP_PATH, delegate(XmlAsset moodToXml)
                        {
                            mMoodToXml = moodToXml.XmlDocument;
                            SetupMoodNameToXmlLookUp(moodToXml.XmlDocument);
                            finishedLoadingFaceAnimationAssets();
                        });
                    });
                });
            }
        }
示例#2
0
        public void Init()
        {
            ClientAssetRepository clientAssetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            XmlDocument mXmlSoundDocument = XmlUtility.LoadXmlDocument(SOUND_LOOKUP_TABLE_XML_PATH);

            // TODO: Remove this loading hack.
            XmlNodeList soundNodes = mXmlSoundDocument.SelectNodes("Sounds/Sound");

            mSoundsLeftToLoad = soundNodes.Count;

            foreach (XmlNode soundNode in soundNodes)
            {
                string    name      = soundNode.SelectSingleNode("Name").InnerText;
                SoundName soundName = (SoundName)Enum.Parse(typeof(SoundName), name);

                string path = soundNode.SelectSingleNode("Path").InnerText;
                //Console.WriteLine("Loading sound: " + name + ", " + path);
                clientAssetRepo.LoadAssetFromPath <SoundAsset>(path, delegate(SoundAsset asset)
                {
                    RetrieveSoundAssetFromRepoOnLoad(soundName, asset);
                });
            }

            mMainCamera = GameFacade.Instance.RetrieveMediator <CameraManagerMediator>().MainCamera;
        }
        /// <summary>
        /// Loads and sends a feed from the given path and name. Javascript will hide unity until the feed
        /// is taken care of and then when Unity is shown again, onFeedSent will be executed.
        /// </summary>
        public void PostFeed(long?targetId, string feedCopyDataPath, string feedDataName, Hangout.Shared.Action onFeedSent, string param)
        {
            if (String.IsNullOrEmpty(feedCopyDataPath))
            {
                throw new ArgumentNullException("feedCopyDataPath");
            }
            if (String.IsNullOrEmpty(feedDataName))
            {
                throw new ArgumentNullException("feedDataName");
            }
            if (onFeedSent == null)
            {
                throw new ArgumentNullException("onFeedSent");
            }

            // Log the post
            ConnectionProxy connectionProxy = GameFacade.Instance.RetrieveProxy <ConnectionProxy>();
            long            fromId          = connectionProxy.FacebookAccountId;
            string          extraProps      = String.Format("{0}|{1}", fromId, targetId);

            EventLogger.Log(LogGlobals.CATEGORY_FACEBOOK, LogGlobals.FACEBOOK_FEED_POST, feedDataName, extraProps);

            mAssetRepo.LoadAssetFromPath <XmlAsset>(feedCopyDataPath, delegate(XmlAsset asset)
            {
                mTaskCollection.Add(mScheduler.StartCoroutine(SendFeedJavascript(targetId, asset.XmlDocument, feedDataName, onFeedSent, param)));
            });
        }
示例#4
0
        public RunwaySequenceState(Hangout.Shared.Action onExitCallback)
        {
            mOnExitCallback = onExitCallback;

            mClientAssetRepository = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();
            mClientAssetRepository.LoadAssetFromPath <XmlAsset>(PATH_TO_MODELS_XML, delegate(XmlAsset asset)
            {
                mPathToRunwayWalkAnimation = asset.XmlDocument.SelectSingleNode("RunwaySequence/RunwayWalkPath").InnerText;
                mPathToRunwayEnvironment   = asset.XmlDocument.SelectSingleNode("RunwaySequence/RunwayEnvironmentPath").InnerText;
            });
        }
示例#5
0
        private void ShowIconMenu()
        {
            mAnimationProxy = GameFacade.Instance.RetrieveProxy <AnimationProxy>();
            List <IWidget> enabledMenuButtons  = new List <IWidget>();
            List <IWidget> disabledMenuButtons = new List <IWidget>();

            foreach (KeyValuePair <string, bool> kvp in mAnimationProxy.PlayableIconLookUpTable)
            {
                Button button;
                button = (Button)mIconMenuButton.Clone();
                if (kvp.Value)
                {
                    button.Enable();
                    enabledMenuButtons.Add(button);
                }
                else
                {
                    button.Disable();
                    disabledMenuButtons.Add(button);
                }
                string emoticonPath = kvp.Key;
                mClientAssetRepository.LoadAssetFromPath <ImageAsset>(emoticonPath, delegate(ImageAsset asset)
                {
                    button.Image = asset.Texture2D;
                    button.AddOnPressedAction(delegate()
                    {
                        object[] args = { emoticonPath };
                        GameFacade.Instance.SendNotification(GameFacade.SEND_EMOTICON, args);
                        EventLogger.Log(LogGlobals.CATEGORY_GUI, LogGlobals.EVENT_EMOTICON_CLICKED, "Emoticon", emoticonPath);
                        Hide();
                    });
                });
            }
            List <IWidget> menuButtons = enabledMenuButtons;

            menuButtons.AddRange(disabledMenuButtons);

            ResizeIconWindow(mIconMenuWindow, mIconMenuButton, menuButtons.Count);
            RepositionWindow(mIconMenuWindow, mMainMenuWindow);
            int rows = menuButtons.Count / mIconFrameColumns + 1;

            mIconMenuGridView.SetPositionsWithBorderPadding(menuButtons, rows, mIconFrameColumns, 0, mMenuBorderPadding, mMenuBorderPadding, mIconButtonPadding);
            mIconMenuWindow.Showing    = true;
            mTextMenuWindow.Showing    = false;
            mLastWindowShowing         = mIconMenuWindow;
            mLastWindowShowingToUpdate = "icon";
        }
示例#6
0
        public override void Execute(INotification notification)
        {
            AvatarDistributedObject avatar              = (AvatarDistributedObject)((object[])notification.Body)[0];
            String                emoticonPath          = (String)((object[])notification.Body)[1];
            IGuiManager           guiManager            = GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>();
            CameraManagerMediator cameraManager         = GameFacade.Instance.RetrieveMediator <CameraManagerMediator>();
            ClientAssetRepository clientAssetRepository = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            clientAssetRepository.LoadAssetFromPath <ImageAsset>(emoticonPath, delegate(ImageAsset imageAsset)
            {
                // Show the chat bubble above the avatars head
                avatar.ShowChat(imageAsset.Texture2D, cameraManager.GetMainCamera(), guiManager);

                // TODO: Determine whether or not we want emoticons in the chat log.  Will be a good bit of work
                // to get images as well as text in the chat log.
                // Put the message in the chat log
                //ChatMediator chatMediator = GameFacade.Instance.RetrieveMediator<ChatMediator>();
                //chatMediator.AddChatText(chatText);

                GameFacade.Instance.SendNotification(GameFacade.PLAY_SOUND_POPUP_APPEAR_B);
            });
        }
示例#7
0
        private void Loading()
        {
            mClientAssetRepository.LoadAssetFromPath <ImageAsset>(mBackgroundUrl, delegate(ImageAsset asset)
            {
                mBackgroundTexture = asset.Texture2D;
                mBackgroundLoaded  = true;
                CheckIfDoneLoading();
            });

            if (mMusicPath != null)
            {
                mClientAssetRepository.LoadAssetFromPath <SoundAsset>(mMusicPath, delegate(SoundAsset asset)
                {
                    mMusicLoaded            = true;
                    mMusicAudioClip         = asset.AudioClip;
                    mMusicGameObject        = new GameObject("music game object");
                    AudioSource audioSource = (AudioSource)mMusicGameObject.AddComponent(typeof(AudioSource));
                    audioSource.clip        = mMusicAudioClip;
                    audioSource.loop        = true;
                    audioSource.volume      = 0.9f;
                    audioSource.Play();
                    CheckIfDoneLoading();
                });
            }
            else
            {
                // If there's no music path, there ain't gonna be any music
                mMusicLoaded = true;
            }

            // If these are null then we need to load them from the repo using their paths.
            if (mRunwayEnvironmentObject == null)
            {
                mClientAssetRepository.LoadAssetFromPath <UnityEngineAsset>(mPathToRunwayEnvironment, delegate(UnityEngineAsset asset)
                {
                    mRunwayEnvironmentObject = asset.UnityObject;
                    CheckIfDoneLoading();
                });
            }

            if (mRunwayWalkClip == null)
            {
                mClientAssetRepository.LoadAssetFromPath <UnityEngineAsset>(mPathToRunwayWalkAnimation, delegate(UnityEngineAsset asset)
                {
                    UnityEngine.Object unityObject = ((UnityEngineAsset)asset).UnityObject;
                    GameObject gameObject          = (GameObject)GameObject.Instantiate(unityObject);
                    try
                    {
                        Animation animation1 = (Animation)gameObject.GetComponentInChildren(typeof(Animation));
                        if (animation1 == null)
                        {
                            throw new Exception("Error loading late bound asset file, there's no animation component on the asset (" + gameObject.name + ")");
                        }

                        AnimationClip result = animation1.GetClip(unityObject.name);
                        if (result == null)
                        {
                            throw new Exception("Cannot find clip (" + unityObject.name + ") in Animation component on " + animation1.name);
                        }
                        mRunwayWalkClip = result;
                    }
                    finally
                    {
                        GameObject.Destroy(gameObject);
                        CheckIfDoneLoading();
                    }
                });
            }
        }
示例#8
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();
            });
        }