Beispiel #1
0
        public LevelGui(XmlDocument levelXml, FashionLevel level)
        {
            if (levelXml == null)
            {
                throw new ArgumentNullException("levelXml");
            }
            mLevelXml = levelXml;

            if (level == null)
            {
                throw new ArgumentNullException("level");
            }
            mLevel = level;

            ClientAssetRepository assetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            assetRepo.LoadAssetFromPath <SoundAsset>(LEVEL_COMPLETE_SFX_PATH, delegate(SoundAsset asset)
            {
                mLevelCompleteSfx = asset.AudioClip;
            });

            assetRepo.LoadAssetFromPath <SoundAsset>(LEVEL_UP_SFX_PATH, delegate(SoundAsset asset)
            {
                mLevelUpSfx = asset.AudioClip;
            });
        }
Beispiel #2
0
        public PlayerProgression(uint initialPlayerExperience, uint entourageSize)
        {
            mXP            = initialPlayerExperience;
            mEntourageSize = entourageSize;

            XmlDocument progressionSettingsXml = XmlUtility.LoadXmlDocument(PROGRESSION_SETTINGS_PATH);

            foreach (XmlNode levelNode in progressionSettingsXml.SelectNodes("//PlayerLevel"))
            {
                mExperienceToLevel.Add
                (
                    uint.Parse(levelNode.Attributes["xp"].InnerText),
                    new LevelInfo
                    (
                        levelNode.Attributes["level"].InnerText,
                        float.Parse(levelNode.Attributes["energy"].InnerText)
                    )
                );
            }

            ClientAssetRepository assetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            assetRepo.LoadAssetFromPath <SoundAsset>(LEVEL_UP_SFX_PATH, delegate(SoundAsset asset)
            {
                mLevelUpSfx = asset.AudioClip;
            });

            ParseExperienceRewards();
        }
Beispiel #3
0
        /// <summary>
        /// List<Pair<string, string>>, the first string is the facebook friend name, the second string is the facebook friend image url
        /// </summary>
        /// <param name="receivedFriends"></param>
        public void ListEntourage(List <Pair <string, string> > receivedFriends)
        {
            mEntourageListScrollFrame.ClearChildWidgets();
            ClientAssetRepository clientAssetRepository = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            // Show the bonus
            int percentBonus = (int)(Rewards.GetEntourageExperienceBonusPercent(receivedFriends.Count) * 100);

            mMemberCountLabel.Text = String.Format(Translation.ENTOURAGE_MEMBER_COUNT, percentBonus);

            //sort by facebook friend name
            Comparison <Pair <string, string> > sortAlphabetically = new Comparison <Pair <string, string> >(SortNamesAlphabetically);

            receivedFriends.Sort(sortAlphabetically);


            foreach (Pair <string, string> friendNameAndImageUrl in receivedFriends)
            {
                IGuiFrame friendListing = (IGuiFrame)mEntourageListingPrototypeFrame.Clone();

                string facebookFriendPictureUrl = friendNameAndImageUrl.Second;
                clientAssetRepository.LoadAssetFromPath <ImageAsset>(facebookFriendPictureUrl,
                                                                     delegate(ImageAsset friendImageTexture)
                {
                    Image friendImage   = friendListing.SelectSingleElement <Image>("FriendImage");
                    friendImage.Texture = friendImageTexture.Texture2D;
                });

                Label friendNameLabel = friendListing.SelectSingleElement <Label>("FriendName");
                friendNameLabel.Text = friendNameAndImageUrl.First;

                mEntourageListScrollFrame.AddChildWidget(friendListing, new HorizontalAutoLayout());
            }
        }
Beispiel #4
0
        public void StartLevel(bool firstTimePlayed, bool needsToHire, Hangout.Shared.Action onStartLevel)
        {
            if (needsToHire || firstTimePlayed)
            {
                BuildFirstTimeHireGui(onStartLevel);
            }
            else
            {
                BuildReplayLevelGui(onStartLevel);
            }

            Label energyRequirementLabel = mFirstTimeLevelGui.MainGui.SelectSingleElement <Label>("**/EnergyRequirement");

            energyRequirementLabel.Text = String.Format(energyRequirementLabel.Text, mLevel.RequiredEnergy);

            string musicPath = mLevelXml.SelectSingleNode("Level/Music/@path").InnerText;
            ClientAssetRepository assetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            assetRepo.LoadAssetFromPath <SoundAsset>(musicPath, delegate(SoundAsset asset)
            {
                mMusicClip              = asset.AudioClip;
                mMusicGameObject        = new GameObject("music game object");
                AudioSource audioSource = (AudioSource)mMusicGameObject.AddComponent(typeof(AudioSource));
                audioSource.clip        = mMusicClip;
                audioSource.loop        = true;
                audioSource.volume      = 0.9f;
                audioSource.Play();
            });
        }
Beispiel #5
0
        private void LayoutFriends()
        {
            string filter = "";

            if (mUserNameFilterBox != null)
            {
                filter = mUserNameFilterBox.Text;
            }

            ClientAssetRepository clientAssetRepository = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();
            Vector2 nextGuiPosition = mFriendListingStartPosition;

            mHireFrame.ClearChildWidgets();

            List <Regex> searchFilters = new List <Regex>();

            foreach (string filterSplit in filter.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
            {
                searchFilters.Add(new Regex(filterSplit, RegexOptions.IgnoreCase | RegexOptions.Compiled));
            }

            foreach (FacebookFriendInfo facebookFriend in mPossibleHires.Values)
            {
                bool matches = true;
                foreach (Regex rx in searchFilters)
                {
                    if (!rx.IsMatch(facebookFriend.FirstName) && !rx.IsMatch(facebookFriend.LastName))
                    {
                        matches = false;
                        break;
                    }
                }

                if (matches)
                {
                    IGuiFrame friendListing = (IGuiFrame)mHireFriendPrototypeFrame.Clone();
                    (friendListing.SelectSingleElement <ITextGuiElement>("FriendNameLabel")).Text = facebookFriend.FirstName + " " + facebookFriend.LastName;

                    Button hireFriendButton   = friendListing.SelectSingleElement <Button>("HireFriendButton");
                    Image  friendListingImage = friendListing.SelectSingleElement <Image>("FriendImage");
                    if (facebookFriend.ImageUrl != "")
                    {
                        clientAssetRepository.LoadAssetFromPath <ImageAsset>
                        (
                            facebookFriend.ImageUrl,
                            delegate(ImageAsset image)
                        {
                            friendListingImage.Texture = image.Texture2D;
                        }
                        );
                    }
                    hireFriendButton.AddOnPressedAction(new HireFriendClosure(this, friendListing, mJobToHireFor, facebookFriend).ExecuteClosure);

                    mHireFrame.AddChildWidget(friendListing, new FixedPosition(nextGuiPosition));
                    nextGuiPosition.y += friendListing.ExternalSize.y + mFriendListingStartPosition.y;
                }
            }
        }
Beispiel #6
0
        public FashionGameInput()
        {
            mSelection = new FashionGameSelection();

            // Uncomment this to see the raycasts used from this class
            //GameFacade.Instance.RetrieveMediator<SchedulerMediator>().Scheduler.StartCoroutine(Debug());

            ClientAssetRepository assetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            assetRepo.LoadAssetFromPath <SoundAsset>(APPLY_CLOTHING_SFX, delegate(SoundAsset asset)
            {
                mApplyClothingSfx = asset.AudioClip;
            });
            assetRepo.LoadAssetFromPath <SoundAsset>(ERROR_SFX_PATH, delegate(SoundAsset asset)
            {
                mErrorSfx = asset.AudioClip;
            });
        }
Beispiel #7
0
        private IEnumerator <IYieldInstruction> LoadAnimations(XmlDocument modelsXmlDoc)
        {
            uint downloadingAssets          = 0;
            ClientAssetRepository assetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            foreach (XmlNode animationNode in modelsXmlDoc.SelectSingleNode("Models/Animations").ChildNodes)
            {
                downloadingAssets++;
                string nodeName = animationNode.Name;

                XmlNode speedNode = animationNode.SelectSingleNode("@speed");
                assetRepo.LoadAssetFromPath <RigAnimationAsset>
                (
                    animationNode.Attributes["path"].InnerText,
                    delegate(RigAnimationAsset loadedAsset)
                {
                    downloadingAssets--;

                    AnimationClip clip = GetClipFromAsset(loadedAsset);
                    switch (nodeName)
                    {
                    case "ImpatientSitIdle":
                        mImpatientSitIdle = clip;
                        break;

                    case "SittingIdle":
                        mSittingIdle = clip;
                        break;

                    case "MediumHurried":
                        mMediumHurriedSpeed = float.Parse(speedNode.InnerText);
                        mMediumHurried      = clip;
                        break;

                    case "CatWalk":
                        mCatWalkSpeed = float.Parse(speedNode.InnerText);
                        mCatWalk      = clip;
                        break;

                    default:
                        throw new Exception("Unable to load the Animation (" + nodeName + ") from " + MODEL_TYPES_PATH);
                    }
                }
                );
            }

            yield return(new YieldWhile(delegate()
            {
                return downloadingAssets != 0;
            }));

            mModelAnimationsDownloaded = true;
        }
Beispiel #8
0
        private void SetupWorkerAnimation(string animationPath, StationInfo stationInfo, FashionGameStation station, Action <AnimationClip> applyAnimation)
        {
            if (!station.RequiresWorker)
            {
                throw new Exception("Station (" + stationInfo.Type + ") has an animation node, but it isn't a type of station that has a worker.");
            }

            ClientAssetRepository assetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            assetRepo.LoadAssetFromPath <RigAnimationAsset>(animationPath, delegate(RigAnimationAsset asset)
            {
                applyAnimation(asset.AnimationClip);
            });
        }
Beispiel #9
0
        /// <summary>
        /// Creates a new FashionModel Entity
        /// </summary>
        /// <param name="start">Pair of Vector3s, first = Position, second = Direction</param>
        /// <param name="walkSpeed">Constant speed that the fashion models walk at</param>
        public FashionModel(string name, FashionLevel level, GameObject displayObject, HeadController headController, BodyController bodyController)
            : base(name, displayObject, headController, bodyController)
        {
            if (level == null)
            {
                throw new ArgumentNullException("level");
            }
            mLevel = level;

            mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler;

            ClientAssetRepository assetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            assetRepo.LoadAssetFromPath <SoundAsset>(APPLY_CLOTHING_SFX, delegate(SoundAsset asset)
            {
                mApplyClothingSfx = asset.AudioClip;
            });
            assetRepo.LoadAssetFromPath <SoundAsset>(ERROR_SFX_PATH, delegate(SoundAsset asset)
            {
                mErrorSfx = asset.AudioClip;
            });

            mNametag = SetupNametag(name, displayObject);
        }
Beispiel #10
0
        private IEnumerator <IYieldInstruction> LoadExternalAssetsForStation(StationInfo stationInfo, FashionGameStation station, Action <FashionGameStation> onResult)
        {
            ClientAssetRepository assetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();
            int loadingSounds = 0;

            foreach (string soundPath in stationInfo.SoundPaths)
            {
                loadingSounds++;
                assetRepo.LoadAssetFromPath <SoundAsset>(soundPath, delegate(SoundAsset asset)
                {
                    loadingSounds--;
                    station.AddActivationSound(asset.AudioClip);
                });
            }

            int loadingAnimation = 0;

            if (stationInfo.WorkingAnimationPath != null)
            {
                loadingAnimation++;
                SetupWorkerAnimation(stationInfo.WorkingAnimationPath, stationInfo, station, delegate(AnimationClip clip)
                {
                    loadingAnimation--;
                    station.SetWorkingAnimation(clip);
                });
            }

            if (stationInfo.IdleAnimationPath != null)
            {
                loadingAnimation++;
                SetupWorkerAnimation(stationInfo.IdleAnimationPath, stationInfo, station, delegate(AnimationClip clip)
                {
                    loadingAnimation--;
                    station.SetIdleAnimation(clip);
                });
            }

            yield return(new YieldWhile(delegate()
            {
                return loadingSounds != 0 || loadingAnimation != 0;
            }));

            onResult(station);
        }
Beispiel #11
0
        public FashionLevel(string levelDataPath, FashionNpcMediator fashionNpcMediator, bool firstTimePlayed, float requiredEnergy)
        {
            mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler;

            mLevelXmlPath = levelDataPath;
            mLevelXml     = XmlUtility.LoadXmlDocument(mLevelXmlPath);

            XmlNode backgroundNode = mLevelXml.SelectSingleNode("Level/RunwayBackground");

            if (backgroundNode != null)
            {
                mRunwayBackgroundPath = backgroundNode.InnerText;
            }
            else
            {
                Debug.LogError("No background url node in level xml.");
            }

            XmlNode locationNode = mLevelXml.SelectSingleNode("Level/LocationName");

            if (backgroundNode != null)
            {
                mLocationName = locationNode.InnerText;
            }
            else
            {
                Debug.LogError("No location node in level xml.");
            }

            XmlNode runwayMusicNode = mLevelXml.SelectSingleNode("Level/RunwayMusic");

            if (runwayMusicNode != null)
            {
                mRunwayMusicPath = runwayMusicNode.InnerText;
            }
            else
            {
                Debug.LogError("No runway music node in level xml.");
            }

            XmlNode levelAssetsPath = mLevelXml.SelectSingleNode("Level/@path");

            if (levelAssetsPath == null)
            {
                throw new Exception("Cannot load level from " + levelDataPath + ", no Level/@path attribute found.");
            }

            ClientAssetRepository clientAssetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            clientAssetRepo.LoadAssetFromPath <UnityEngineAsset>(levelAssetsPath.InnerText, BuildLevelAssets);

            XmlNode startNode = mLevelXml.SelectSingleNode("Level/ModelSpawn");

            mStartWidth     = float.Parse(startNode.Attributes["width"].InnerText);
            mEnd            = XmlUtility.ParsePositionDirection(mLevelXml.SelectSingleNode("Level/ModelDrain"));
            mEndWidth       = float.Parse(startNode.Attributes["width"].InnerText);
            mName           = mLevelXml.SelectSingleNode("Level/@name").InnerText;
            mStart          = XmlUtility.ParsePositionDirection(startNode);
            mModelsRequired = int.Parse(mLevelXml.SelectSingleNode("Level/Waves/@requiredModels").InnerText);

            mLevelGui = new LevelGui(mLevelXml, this);
            if (fashionNpcMediator == null)
            {
                throw new ArgumentNullException("fashionModelMediator");
            }
            mFashionNpcMediator = fashionNpcMediator;
            mLevelGameplay      = new LevelGameplay(mLevelXml, this, mFashionNpcMediator);
            mFirstTimePlayed    = firstTimePlayed;

            mRequiredEnergy = requiredEnergy;
        }