Ejemplo n.º 1
0
        public StationWorker GetStationWorker(FashionGameStation station)
        {
            StationWorker result = null;

            if (station is HoldingStation)
            {
                throw new ArgumentException("HoldingStations don't have workers", "station");
            }
            else if (station is HairStation)
            {
                result = mHairStationWorkers.GetNpc();
            }
            else if (station is MakeupStation)
            {
                result = mMakeupStationWorkers.GetNpc();
            }
            else if (station is TailorStation)
            {
                result = mSewingStationWorkers.GetNpc();
            }
            else
            {
                throw new ArgumentException("Unexpected ModelStation (" + station.GetType().Name + ")");
            }

            return(result);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        private IEnumerator <IYieldInstruction> AssignNpcWhenAvailable(FashionGameStation station)
        {
            yield return(new YieldWhile(delegate()
            {
                return !mFashionNpcMediator.HasActiveWorkerForStation(station);
            }));

            station.AssignWorker(mFashionNpcMediator.GetStationWorker(station));
        }
Ejemplo n.º 4
0
        public void PutAtStation(FashionGameStation station)
        {
            mNametag.MainGui.Showing = true;
            mAtStation = station;
            this.UnityGameObject.SetActiveRecursively(true);

            if (mPlayIdle != null)
            {
                mPlayIdle.Exit();
            }

            mPlayIdle = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler.StartCoroutine(PlayIdle());
        }
Ejemplo n.º 5
0
        private void MousePosition(Vector3 position)
        {
            mMousePosition = position;
            FashionCameraMediator fashionCam = GameFacade.Instance.RetrieveMediator <FashionCameraMediator>();
            Ray mouseThruScreenRay           = fashionCam.Camera.ScreenPointToRay(position);

            // Update the clothing icon's world position
            mSelection.UpdateClothingPosition(mouseThruScreenRay.GetPoint(fashionCam.Camera.nearClipPlane * 1.1f));

            // Do Mouseovers
            RaycastHit rh;

            if (GameFacade.Instance.HasMediator <FashionLevel>() && Physics.Raycast(mouseThruScreenRay, out rh, Mathf.Infinity, 1 << FashionMinigame.STATION_LAYER))
            {
                FashionGameStation station = GameFacade.Instance.RetrieveMediator <FashionLevel>().GetStationFromGameObject(rh.collider.gameObject);
                if (station != null)
                {
                    station.MouseIsOver();
                }
            }
        }
Ejemplo n.º 6
0
        private INpcPool GetPoolForStation(FashionGameStation station)
        {
            NpcPool <StationWorker> pool;

            if (station is HairStation)
            {
                pool = mHairStationWorkers;
            }
            else if (station is MakeupStation)
            {
                pool = mMakeupStationWorkers;
            }
            else if (station is TailorStation)
            {
                pool = mSewingStationWorkers;
            }
            else
            {
                throw new ArgumentException("Unexpected station type (" + station.GetType().Name + ")");
            }

            return(pool);
        }
Ejemplo n.º 7
0
 public bool HasWorkerForStation(FashionGameStation station)
 {
     return(GetPoolForStation(station).Count > 0);
 }
Ejemplo n.º 8
0
 public bool HasActiveWorkerForStation(FashionGameStation station)
 {
     return(GetPoolForStation(station).HasInactiveNpcs);
 }
Ejemplo n.º 9
0
        private bool DropClothing(Ray mouseThruScreenRay)
        {
            bool clickHadEffect = false;

            if (mSelection.NeedsFixin)
            {
                List <RaycastHit> stationHits = new List <RaycastHit>();
                CastRaysThruClothing(delegate(Ray castRay)
                {
                    stationHits.AddRange(Physics.RaycastAll(castRay, Mathf.Infinity, 1 << FashionMinigame.STATION_LAYER));
                });

                foreach (RaycastHit hit in stationHits)
                {
                    FashionGameStation station = GameFacade.Instance.RetrieveMediator <FashionLevel>().GetStationFromGameObject(hit.collider.gameObject);
                    if (station is TailorStation)
                    {
                        foreach (ClothingItem item in mSelection.Clothes)
                        {
                            if (item.NeedsFixin)
                            {
                                ((TailorStation)station).AddClothing(item);
                                mSelection.RemoveClothing(item);
                                clickHadEffect = true;
                                break;
                            }
                        }
                    }
                }
            }

            int layerMask          = (1 << FashionMinigame.MODEL_LAYER) | (1 << FashionMinigame.UNSELECTABLE_MODEL_LAYER);
            List <RaycastHit> hits = new List <RaycastHit>();

            CastRaysThruClothing(delegate(Ray castRay)
            {
                hits.AddRange(Physics.RaycastAll(castRay, Mathf.Infinity, layerMask));
            });

            FashionModel modelToSelect = null;
            int          removed       = 0;

            foreach (RaycastHit hit in hits)
            {
                FashionModel model = GameFacade.Instance.RetrieveMediator <FashionLevel>().GetModelFromGameObject(hit.collider.gameObject);
                if (model == null)
                {
                    continue;
                }

                List <ClothingItem> toRemove = new List <ClothingItem>();
                foreach (ClothingItem item in mSelection.Clothes)
                {
                    if (model.ApplyClothing(item))
                    {
                        if (model.RequiredStations.Count != 0)
                        {
                            modelToSelect = model;
                        }
                        toRemove.Add(item);
                    }
                }

                removed += toRemove.Count;

                foreach (ClothingItem item in toRemove)
                {
                    mSelection.RemoveClothing(item);
                }
            }

            // Bonus score for multiple clothing applications
            if (removed > 1)
            {
                GameFacade.Instance.SendNotification
                (
                    FashionMinigame.EARNED_EXPERIENCE_NOTIFICATION,
                    new ExperienceInfo
                    (
                        ExperienceType.MultipleClothingPlacement,
                        mouseThruScreenRay.GetPoint(1.0f),
                        (uint)removed
                    )
                );
            }

            // Sound effects
            if (removed >= 1)
            {
                // Play an apply clothing sfx if anybody got clothing from this drop
                if (mApplyClothingSfx != null)
                {
                    GameObject mainCamera = GameFacade.Instance.RetrieveMediator <CameraManagerMediator>().MainCamera;
                    AudioSource.PlayClipAtPoint(mApplyClothingSfx, mainCamera.transform.position, 0.5f);
                }
            }
            else if (hits.Count != 0)
            {
                // Only play the error sound if we hit something and no model needed any clothing.
                if (mErrorSfx != null)
                {
                    GameObject mainCamera = GameFacade.Instance.RetrieveMediator <CameraManagerMediator>().MainCamera;
                    AudioSource.PlayClipAtPoint(mErrorSfx, mainCamera.transform.position, 0.2f);
                }
            }

            if (hits.Count > 0)
            {
                mSelection.ClearSelection();
                if (modelToSelect != null && !modelToSelect.Ready)
                {
                    mSelection.Select(modelToSelect);
                }
            }

            if (removed > 0)
            {
                clickHadEffect = true;
            }
            return(clickHadEffect);
        }
Ejemplo n.º 10
0
        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") + ")"
                );
            }
        }
Ejemplo n.º 11
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);
            });
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
 public void EndOfLevel()
 {
     mAtStation = null;
     mNametag.MainGui.Showing = false;
     this.UnityGameObject.SetActiveRecursively(false);
 }