Example #1
0
 public void Unselect(FashionModel model)
 {
     if (model == mSelection.Model)
     {
         mSelection.ClearModel();
     }
 }
Example #2
0
        public virtual void ModelArrived(FashionModel model)
        {
            if (mModelAtThisStation == null)
            {
                if (this.RequiresWorker)
                {
                    Worker.PlayWorkingAnimation();
                }
                PlayActivationSound();

                mModelAtThisStation = model;
                if (mWaitThenContinue != null)
                {
                    mWaitThenContinue.Exit();
                }
                mWaitThenContinue = mScheduler.StartCoroutine(WaitThenContinue(model, WaitTime));

                mWaitThenContinue.AddOnExitAction(delegate()
                {
                    model.Clickable = true;
                    model.WalkToCenter();
                    mModelAtThisStation = null;

                    this.HideProgressGui();
                });
            }
            else
            {
                model.WalkToCenter();
            }
        }
Example #3
0
 public ModelInactiveState(FashionModel model)
 {
     if (model == null)
     {
         throw new ArgumentNullException("model");
     }
     mModel = model;
 }
 public void Select(FashionModel model)
 {
     if (model != null)
     {
         ClearModel();
         mModel = model;
         mModel.Select(delegate() { mModel = null; });
     }
 }
Example #5
0
        public FashionModel GetModel(FashionLevel level, FashionModelNeeds needs, string type)
        {
            FashionModelInfo modelTypeInfo = mFashionModelTypes[type];
            FashionModel     resultModel   = mFashionModels.GetNpc();

            resultModel.SetActive(needs, level);
            resultModel.WalkSpeed = modelTypeInfo.Speed;
            resultModel.UnityGameObject.SetActiveRecursively(true);

            return(resultModel);
        }
Example #6
0
        public override void ModelArrived(FashionModel model)
        {
            base.ModelArrived(model);

            if (!mUsedHoldingStation)
            {
                mUsedHoldingStation = true;

                EventLogger.Log(LogGlobals.CATEGORY_FASHION_MINIGAME, LogGlobals.GAMEPLAY_BEHAVIOR, "FirstTime",
                                LogGlobals.HOLDING_STATION);
            }
        }
Example #7
0
        protected IEnumerator <IYieldInstruction> WaitThenContinue(FashionModel model, float pauseTime)
        {
            ShowProgressGui();

            model.Clickable = false;
            float inversePauseTime = 1.0f / pauseTime;

            for (float t = 0.0f; t < pauseTime; t += Time.deltaTime)
            {
                SetProgress(inversePauseTime * t);
                yield return(new YieldUntilNextFrame());
            }
        }
Example #8
0
        public WalkToEndGoal(FashionModel model, FashionLevel level)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            mModel = model;

            if (level == null)
            {
                throw new ArgumentNullException("level");
            }
            mLevel = level;
        }
Example #9
0
        public AtStationState(FashionModel model, ModelStation station)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            mModel = model;

            if (station == null)
            {
                throw new ArgumentNullException("station");
            }
            mStation = station;
        }
Example #10
0
        private IEnumerator <IYieldInstruction> SpawnModels(ModelWave wave)
        {
            foreach (Pair <string, FashionModelNeeds> model in wave.Models)
            {
                yield return(new YieldWhile(delegate()
                {
                    return !mModelFactory.HasInactiveModels;
                }));

                FashionModel newModel = mModelFactory.GetModel(mLevel, model.Second, model.First);

                mActiveModels.Add(newModel.UnityGameObject, newModel);
                newModel.WalkToEndTarget();

                newModel.AddOnTargetReachedAction((new ClosureBugWorkaround(newModel, this)).ExecuteClosureHack);
                wave.ModelSpawned();

                yield return(new YieldForSeconds(wave.TimeBetweenSpawns));
            }
        }
Example #11
0
        public WalkToStationState(FashionModel model, ModelStation station, FashionLevel level)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            mModel = model;

            if (station == null)
            {
                throw new ArgumentNullException("station");
            }
            mStation = station;

            if (level == null)
            {
                throw new ArgumentNullException("level");
            }
            mLevel = level;
        }
Example #12
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);
        }
Example #13
0
        private IEnumerator <IYieldInstruction> BuildNpcs
        (
            Jobs job,
            FashionLevel level,
            IEnumerable <XmlNode> modelsXml,
            Hangout.Shared.Action onBuildingNpcsComplete
        )
        {
            // Key = FBID, Value = name, assets for model
            Dictionary <long, Pair <string, IEnumerable <Asset> > > modelInfos = new Dictionary <long, Pair <string, IEnumerable <Asset> > >();
            uint gettingAssets         = 0;
            ClientAssetRepository repo = GameFacade.Instance.RetrieveProxy <ClientAssetRepository>();

            foreach (XmlNode modelXml in modelsXml)
            {
                string  name;
                XmlNode fbidNode = modelXml.SelectSingleNode(".//@FBID");
                if (fbidNode == null)
                {
                    throw new Exception("modelXml doesn't have an FBID attribute: " + modelXml.OuterXml);
                }

                long uniqueId = long.Parse(fbidNode.InnerText);
                name = modelXml.Attributes["FirstName"].InnerText;                // +" " + modelXml.Attributes["LastName"].InnerText;

                // Only grab the avatars we don't already have loaded
                if (!JobHasNpc(job, uniqueId) && !modelInfos.ContainsKey(uniqueId))
                {
                    gettingAssets++;
                    List <AssetInfo> assetInfos = new List <AssetInfo>();
                    foreach (AssetInfo assetInfo in ClientAssetInfo.Parse(modelXml))
                    {
                        if (!mIgnoredAssets.Contains(assetInfo.AssetSubType))
                        {
                            assetInfos.Add(assetInfo);
                        }
                    }

                    repo.GetAssets <Asset>(assetInfos, delegate(IEnumerable <Asset> modelAssets)
                    {
                        gettingAssets--;
                        if (!modelInfos.ContainsKey(uniqueId))
                        {
                            modelInfos.Add(uniqueId, new Pair <string, IEnumerable <Asset> >(name, modelAssets));
                        }
                        else
                        {
                            Console.WriteLine("Attempted to download model info for " + uniqueId + " twice at the same time.");
                        }
                    });
                }
            }

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

            int spreadFrames = 25;
            List <Pair <long, INpc> > newNpcs = new List <Pair <long, INpc> >();

            foreach (KeyValuePair <long, Pair <string, IEnumerable <Asset> > > assets in modelInfos)
            {
                // This object will be cleaned up by the fashion model
                GameObject displayObject = (GameObject)GameObject.Instantiate(mRigPrototype);
                displayObject.SetActiveRecursively(false);

                HeadController headController = new HeadController(GameObjectUtility.GetNamedChildRecursive("Head", displayObject));
                BodyController bodyController = new BodyController(displayObject);

                bodyController.SetAssets(assets.Value.Second);
                headController.SetAssets(assets.Value.Second);

                bodyController.UpdateAssetsOverFrames(spreadFrames);
                headController.UpdateAssetsOverFrames(spreadFrames);

                INpc newNpc;
                if (job == Jobs.Model)
                {
                    newNpc = new FashionModel(assets.Value.First, level, displayObject, headController, bodyController);
                }
                else
                {
                    newNpc = new StationWorker(assets.Value.First, displayObject, headController, bodyController);
                }

                CharacterMediator.AddAnimationClipToRig(newNpc.DisplayObject, "Avatar/F_walk_normal_loop");
                CharacterMediator.AddAnimationClipToRig(newNpc.DisplayObject, "Avatar/F_idle_normal_loop");

                newNpcs.Add(new Pair <long, INpc>(assets.Key, newNpc));
            }

            yield return(new YieldWhile(delegate()
            {
                return spreadFrames-- != 0 || !mModelAnimationsDownloaded;
            }));

            foreach (Pair <long, INpc> npc in newNpcs)
            {
                switch (job)
                {
                case Jobs.Hair:
                    mHairStationWorkers.AddNpc(npc.First, npc.Second);
                    break;

                case Jobs.Makeup:
                    mMakeupStationWorkers.AddNpc(npc.First, npc.Second);
                    break;

                case Jobs.Model:
                    FashionModel newModel = (FashionModel)npc.Second;

                    newModel.SetImpatientSitIdle(mImpatientSitIdle);
                    newModel.SetSittingIdle(mSittingIdle);
                    newModel.SetMediumHurried(mMediumHurried, mMediumHurriedSpeed);
                    newModel.SetCatWalk(mCatWalk, mCatWalkSpeed);

                    mFashionModels.AddNpc(npc.First, npc.Second);
                    break;

                case Jobs.Seamstress:
                    mSewingStationWorkers.AddNpc(npc.First, npc.Second);
                    break;
                }
            }

            if (onBuildingNpcsComplete != null)
            {
                onBuildingNpcsComplete();
            }
        }
Example #14
0
 public void ModelInactive(FashionModel model)
 {
     mLevelGameplay.ModelInactive(model);
 }
Example #15
0
 public ClosureBugWorkaround(FashionModel model, LevelGameplay level)
 {
     mModel         = model;
     mLevelGameplay = level;
 }
Example #16
0
 public void ModelInactive(FashionModel inactiveModel)
 {
     mActiveModels.Remove(inactiveModel.UnityGameObject);
 }
Example #17
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") + ")"
                );
            }
        }
        /// <summary>
        /// Constructs a FashionModelStateMachine for the given model. Model must have needs before creating the state machine (so that the proper states for each station can be created)
        /// </summary>
        public FashionModelStateMachine(FashionModel model, FashionLevel level)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            mModel = model;

            mInactiveState = new ModelInactiveState(model);

            mWalkToEndGoalState = new WalkToEndGoal(model, level);
            mInactiveState.AddTransition(mWalkToEndGoalState);

            mWalkToEndGoalState.AddTransition(mInactiveState);

            mWalkToCenterState = new WalkToCenterState(model, level);
            mWalkToCenterState.AddTransition(mInactiveState);

            List <ModelStation> possibleStations = new List <ModelStation>(model.RequiredStations);

            foreach (HoldingStation station in level.HoldingStations)
            {
                possibleStations.Add(station);
            }
            foreach (ModelStation station in possibleStations)
            {
                WalkToStationState walkToStation = new WalkToStationState(model, station, level);

                AtStationState atStation = new AtStationState(model, station);
                atStation.AddTransition(mWalkToCenterState);
                atStation.AddTransition(mInactiveState);

                // All the WalkToStation states can enter the corresponding AtStation state
                walkToStation.AddTransition(atStation);
                walkToStation.AddTransition(mInactiveState);

                mAtStationStates.Add(station, atStation);

                // If the model doesn't need to stay at this station, it could go back to walk to center
                walkToStation.AddTransition(mWalkToCenterState);

                mWalkToEndGoalState.AddTransition(walkToStation);

                // An avatar walking to center can be redirected to a station
                mWalkToCenterState.AddTransition(walkToStation);

                mWalkToStationStates.Add(station, walkToStation);
            }

            // Make it so that avatars can be interrupted from walking to
            // one station by sending them to another station they need
            foreach (WalkToStationState stateA in mWalkToStationStates.Values)
            {
                foreach (WalkToStationState stateB in mWalkToStationStates.Values)
                {
                    stateA.AddTransition(stateB);
                }
            }

            mWalkToCenterState.AddTransition(mWalkToEndGoalState);

            mModel.Clickable = mInactiveState.Clickable;
            this.EnterInitialState(mInactiveState);
        }