public void BuildStation(string type, Pair <Vector3> location, string name, Action <FashionGameStation> onResult) { if (onResult == null) { throw new ArgumentNullException("onResult"); } FashionGameStation resultStation = null; if (!mStationInfos.ContainsKey(type)) { throw new Exception("Unexpected station type (" + type + "). Stations can only be of types defined in " + STATION_DESCRIPTION_PATH); } StationInfo info = mStationInfos[type]; Texture2D stationIcon = null; if (info.ImagePath != null) { stationIcon = (Texture2D)Resources.Load(info.ImagePath); } switch (type) { case "Holding": resultStation = new HoldingStation(location, name, info.Time, info.GuiOffset, info.InstantiateAssets()); break; case "Sewing": resultStation = new TailorStation(location, name, stationIcon, info.Time, info.GuiOffset, info.InstantiateAssets()); break; case "Hair": if (stationIcon == null) { throw new Exception("Unable to load the texture at " + info.ImagePath); } resultStation = new HairStation(location, name, stationIcon, info.Time, info.GuiOffset, info.InstantiateAssets()); break; case "Makeup": if (stationIcon == null) { throw new Exception("Unable to load the texture at " + info.ImagePath); } resultStation = new MakeupStation(location, name, stationIcon, info.Time, info.GuiOffset, info.InstantiateAssets()); break; } // If this station requires late bound animations or sounds, load them, otherwise just return the station if (info.SoundPaths.Count > 0 || info.WorkingAnimationPath != null || info.IdleAnimationPath != null) { GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler.StartCoroutine(LoadExternalAssetsForStation(info, resultStation, onResult)); } else { onResult(resultStation); } }
private void MouseDown() { RaycastHit rh; Ray mouseThruScreenRay = GameFacade.Instance.RetrieveMediator <FashionCameraMediator>().Camera.ScreenPointToRay(mMousePosition); GameFacade.Instance.RetrieveMediator <FashionGameGui>().MouseDown(); if (!GameFacade.Instance.HasMediator <FashionLevel>()) { return; } bool clickHadEffect = false; FashionLevel level = GameFacade.Instance.RetrieveMediator <FashionLevel>(); if (!GameFacade.Instance.RetrieveMediator <FashionGameGui>().OccludesScreenPoint(mMousePosition)) { if (Physics.Raycast(mouseThruScreenRay, out rh, Mathf.Infinity, 1 << FashionMinigame.STATION_LAYER)) { FashionGameStation station = level.GetStationFromGameObject(rh.collider.gameObject); if (station is TailorStation) { TailorStation tailorStation = (TailorStation)station; if (tailorStation.HasReadyClothing) { mSelection.Select(tailorStation.RetrieveFixedClothing()); clickHadEffect = true; } } } if (Physics.Raycast(mouseThruScreenRay, out rh, Mathf.Infinity, 1 << FashionMinigame.CLOTHING_LAYER)) { Transform billboardHit = rh.collider.transform; foreach (TailorStation tailorStation in level.TailorStations) { if (tailorStation != null && tailorStation.CurrentClothing != null && tailorStation.CurrentClothing.UnityGameObject.transform == billboardHit) { mSelection.Select(tailorStation.RetrieveFixedClothing()); clickHadEffect = true; break; } } } if (mSelection.TopClothing == null) { if (Physics.Raycast(mouseThruScreenRay, out rh, Mathf.Infinity, 1 << FashionMinigame.STATION_LAYER)) { FashionGameStation station = level.GetStationFromGameObject(rh.collider.gameObject); if (station is ModelStation) { clickHadEffect = mSelection.Select((ModelStation)station); } } if (Physics.Raycast(mouseThruScreenRay, out rh, Mathf.Infinity, 1 << FashionMinigame.MODEL_LAYER)) { mSelection.ClearModel(); mSelection.Select(level.GetModelFromGameObject(rh.collider.gameObject)); FashionModel thisModel = mSelection.Model; mSelection.Model.AddOnTargetReachedAction(delegate() { // If the selection is still this model, unselect it if (mSelection.Model == thisModel) { mSelection.ClearModel(); } }); clickHadEffect = true; } } } else { clickHadEffect = DropClothing(mouseThruScreenRay); } if (!clickHadEffect && !MouseIsOverGui(level)) { EventLogger.LogNoMixPanel ( LogGlobals.CATEGORY_FASHION_MINIGAME, LogGlobals.GAMEPLAY_BEHAVIOR, LogGlobals.USELESS_CLICK, level.Name + " (" + mMousePosition.x.ToString("f0") + " " + mMousePosition.y.ToString("f0") + ")" ); } }