public ModelWave(XmlNode waveNode, FashionNpcMediator factory, IEnumerable <ModelStation> modelStations) { if (waveNode == null) { throw new ArgumentNullException("waveNode"); } if (factory == null) { throw new ArgumentNullException("factory"); } XmlAttribute timeAttrib = waveNode.Attributes["timeBetweenSpawns"]; if (timeAttrib == null) { throw new Exception("Unable to find 'timeBetweenSpawns' attribute in XmlNode (" + waveNode.Name + ")"); } if (!float.TryParse(timeAttrib.InnerText, out mTimeBetweenSpawns)) { throw new Exception("Unable to parse the number (" + timeAttrib.InnerText + ") in the 'timeBetweenSpawns' attribute in XmlNode (" + waveNode.Name + ")"); } foreach (XmlNode modelNode in waveNode.SelectNodes("Model")) { XmlAttribute typeAttrib = modelNode.Attributes["type"]; if (typeAttrib == null) { throw new Exception("Unable to find 'type' attribute in XmlNode (" + modelNode.Name + ")"); } string type = typeAttrib.InnerText; mModels.Add(new Pair <string, FashionModelNeeds>(type, factory.BuildNeedsForType(type, modelStations))); } }
public LevelGameplay(XmlDocument levelXml, FashionLevel level, FashionNpcMediator modelFactory) { if (levelXml == null) { throw new ArgumentNullException("levelXml"); } mLevelXml = levelXml; if (level == null) { throw new ArgumentNullException("level"); } mLevel = level; mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler; XmlNode timeBetweenWaves = mLevelXml.SelectSingleNode("Level/Waves/@timeBetweenWaves"); if (timeBetweenWaves == null) { throw new Exception("Unable to load level (" + mLevel.Name + "), no Level/Waves/@timeBetweenWaves node found."); } mTimeBetweenWaves = float.Parse(timeBetweenWaves.InnerText); XmlNode perfectLevelBonusNode = mLevelXml.SelectSingleNode("Level/PerfectLevelBonus/@value"); if (perfectLevelBonusNode != null) { mPerfectLevelBonus = uint.Parse(perfectLevelBonusNode.InnerText); } else { mPerfectLevelBonus = 0; } XmlNode closeSaveDistanceNode = mLevelXml.SelectSingleNode("Level/CloseSaveDistance/@value"); if (closeSaveDistanceNode == null) { throw new Exception("Cannot load level (" + mLevel.Name + "), no Level/@path attribute found."); } mCloseSaveDistance = float.Parse(closeSaveDistanceNode.InnerText); if (modelFactory == null) { throw new ArgumentNullException("modelFactory"); } mModelFactory = modelFactory; mLevel.Gui.BuildTopGui(delegate() { if (Time.time - mNextWaveTime > mAvoidDuplicateWavesThreshold) { mNextWaveButtonPressed = true; EventLogger.Log(LogGlobals.CATEGORY_FASHION_MINIGAME, LogGlobals.GAMEPLAY_BEHAVIOR, "NextWaveButtonPress", mLevel.Name); } }); }
public void ExecuteClosure() { if (!mThisRef.mFriendHired) { mThisRef.mFriendHired = true; // Cleanup the hire GUI to up framerate through the rest of this function IGuiFrame hireParent = (IGuiFrame)mThisRef.mHireFrame.Parent; ((IGuiFrame)hireParent.Parent).RemoveChildWidget(hireParent); hireParent = null; mThisRef.mHireFrame = null; mThisRef.mHireFeedbackLabel.Showing = true; mThisRef.mHireFeedbackLabel.Text = "Hiring " + mFriendInfo.FirstName + " " + mFriendInfo.LastName + ". Please wait..."; FashionNpcMediator npcFactory = GameFacade.Instance.RetrieveMediator <FashionNpcMediator>(); FashionGameCommands.HireFriend(mFriendInfo.FbAccountId, mJob, delegate(Message message) { npcFactory.HiredFriend(message, mThisRef.mLevel); }); string feedType = ""; switch (mJob) { case Jobs.Model: feedType = HIRED_FRIEND_MODEL_FEED_COPY; break; case Jobs.Hair: feedType = HIRED_FRIEND_HAIR_FEED_COPY; break; case Jobs.Makeup: feedType = HIRED_FRIEND_MAKEUP_FEED_COPY; break; case Jobs.Seamstress: feedType = HIRED_FRIEND_SEAMSTRESS_FEED_COPY; break; } GameFacade.Instance.RetrieveMediator <FacebookFeedMediator>().PostFeed ( mFriendInfo.FbAccountId, FashionMinigame.FACEBOOK_FEED_COPY_PATH, feedType, delegate(){}, mFriendInfo.FirstName + " " + mFriendInfo.LastName ); // Add mixpanel funnel metrics FunnelGlobals.Instance.LogFunnel(FunnelGlobals.FUNNEL_FRIEND_HIRE, FunnelGlobals.CLICKED_HIRE, "{\"level\":\"" + mThisRef.mLevel.Name + "\"}"); } }
private IEnumerator <IYieldInstruction> PlayLevel() { FashionNpcMediator npcFactory = GameFacade.Instance.RetrieveMediator <FashionNpcMediator>(); mLevel.StartLevel(!npcFactory.HasModelsForLevel(mLevel)); yield return(new YieldWhile(delegate() { return !mLevel.IsComplete; })); mOnLevelComplete(); }
private IEnumerator <IYieldInstruction> BuildLevel ( XmlDocument levelXml, LevelInfo levelInfo, bool firstTimePlayed, Action <FashionLevel> fashionLevelResult ) { //Console.WriteLine(Time.realtimeSinceStartup.ToString("f2") + "> Building Level"); // Start loading the clothing assets ClothingMediator clothingMediator = GameFacade.Instance.RetrieveMediator <ClothingMediator>(); clothingMediator.LoadClothing ( Functionals.Map <ItemId> ( delegate(object xmlNode) { return(new ItemId(XmlUtility.GetUintAttribute((XmlNode)xmlNode, "id"))); }, levelXml.SelectNodes("Level/Clothing/ClothingItem") ), levelInfo.LevelDataPath ); yield return(new YieldWhile(delegate() { return !clothingMediator.ClothingLoaded; })); FashionNpcMediator fashionModelFactory = GameFacade.Instance.RetrieveMediator <FashionNpcMediator>(); // Clear this value mLeveledThisLevel = false; // Make the first level that this player qualifies for FashionLevel result = new FashionLevel(levelInfo.LevelDataPath, fashionModelFactory, firstTimePlayed, levelInfo.Energy); fashionLevelResult(result); //Console.WriteLine(Time.realtimeSinceStartup.ToString("f2") + "> Build Level Completed"); }
private IEnumerator <IYieldInstruction> SetupLevel(FashionLevel level) { // Wait for the async parts of the level to complete yield return(new YieldWhile(delegate() { return !level.IsLoaded; })); // Load the models for this level FashionNpcMediator npcFactory = GameFacade.Instance.RetrieveMediator <FashionNpcMediator>(); npcFactory.BuildNpcsForLevel(level); // Yield if there are any new models to download yield return(new YieldWhile(delegate() { return npcFactory.Downloading; })); mOnLevelLoaded(level); }
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; }
private IEnumerator <IYieldInstruction> ProcessLoadingInfo(Message loadingInfoMessage) { if (loadingInfoMessage.Data.Count < 7) { throw new Exception("Loading Info Message does not contain all the expected data"); } FashionGameInput input = new FashionGameInput(); GameFacade.Instance.RegisterMediator(input); FashionGameGui gui = new FashionGameGui(); gui.SetEnergy ( (float)loadingInfoMessage.Data[2], (float)loadingInfoMessage.Data[3], DateTime.Parse((string)loadingInfoMessage.Data[4]) ); gui.SetWave(1, 1); gui.SetLevel("Loading..."); gui.EnableNextWave(false); GameFacade.Instance.RegisterMediator(gui); PlayerProgression progression = new PlayerProgression((uint)loadingInfoMessage.Data[5], (uint)loadingInfoMessage.Data[6]); progression.UpdateProgressGUI(false); GameFacade.Instance.RegisterMediator(progression); XmlDocument modelClothesXml = new XmlDocument(); modelClothesXml.LoadXml((string)loadingInfoMessage.Data[0]); XmlDocument stationWorkerClothesXml = new XmlDocument(); stationWorkerClothesXml.LoadXml((string)loadingInfoMessage.Data[1]); FashionNpcMediator npcFactory = new FashionNpcMediator(); GameFacade.Instance.RegisterMediator(npcFactory); IEnumerable <Asset> modelClothes = null; ClientAssetRepository clientAssetRepo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>(); clientAssetRepo.GetAssets <Asset> ( ClientAssetInfo.Parse(modelClothesXml), delegate(IEnumerable <Asset> downloadedAssets) { modelClothes = downloadedAssets; } ); IEnumerable <Asset> stationWorkerClothes = null; clientAssetRepo.GetAssets <Asset> ( ClientAssetInfo.Parse(stationWorkerClothesXml), delegate(IEnumerable <Asset> downloadedAssets) { stationWorkerClothes = downloadedAssets; } ); yield return(new YieldWhile(delegate() { return modelClothes == null || stationWorkerClothes == null; })); npcFactory.SetModelDefaultClothes(modelClothes); npcFactory.SetStationWorkerDefaultClothes(stationWorkerClothes); GameFacade.Instance.RegisterMediator(new ClothingMediator()); input.StartListeningForInput(); mOnInitialInfoLoaded(); }