Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        private FashionModelNeeds BuildNeedsFromInfo(FashionModelInfo info, IEnumerable <ModelStation> modelStations)
        {
            FashionModelNeeds result = new FashionModelNeeds();
            int clothingNeeds        = mRand.Next(info.ClothingNeeds.Low, info.ClothingNeeds.High + 1);
            int stationNeeds         = mRand.Next(info.StationNeeds.Low, info.StationNeeds.High + 1);

            ClothingMediator    clothingMediator = GameFacade.Instance.RetrieveMediator <ClothingMediator>();
            List <ModelStation> stations         = new List <ModelStation>();

            foreach (ModelStation station in modelStations)
            {
                if (!(station is HoldingStation))
                {
                    stations.Add(station);
                }
            }

            List <string> clothingTypes = new List <string>(clothingMediator.ClothingItemTypes);

            // Setup Clothing Needs
            for (int i = 0; i < clothingNeeds; ++i)
            {
                string clothingType = clothingTypes[mRand.Next(0, clothingTypes.Count)];
                clothingTypes.Remove(clothingType);

                foreach (Pair <string> synonym in mSynonyms)
                {
                    if (synonym.First == clothingType)
                    {
                        clothingTypes.Remove(synonym.Second);
                    }
                    else if (synonym.Second == clothingType)
                    {
                        clothingTypes.Remove(synonym.First);
                    }
                }

                List <ClothingItem> clothesForThisType = new List <ClothingItem>(clothingMediator.ClothingForType(clothingType));
                if (clothesForThisType.Count == 0)
                {
                    continue;
                }

                ItemId clothing = clothesForThisType[mRand.Next(0, clothesForThisType.Count)].ItemId;
                result.Add(clothing);

                if (clothingTypes.Count == 0)
                {
                    break;
                }
            }

            // Setup Station Needs
            if (stations.Count != 0)
            {
                for (int i = 0; i < stationNeeds; ++i)
                {
                    ModelStation station = stations[mRand.Next(0, stations.Count)];

                    string stationName = station.Name;
                    stations.RemoveAll(delegate(ModelStation stationInList)
                    {
                        return(stationInList.Name == stationName);
                    });

                    result.Add(station);

                    if (stations.Count == 0)
                    {
                        break;
                    }
                }
            }

            result.NeedFixinChance = info.NeedFixinChance;

            return(result);
        }
Exemplo n.º 3
0
 public void ClearNeeds()
 {
     mNeeds = null;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Starts a walk down the runway
        /// </summary>
        public void SetActive(FashionModelNeeds needs, FashionLevel level)
        {
            if (needs == null)
            {
                throw new ArgumentNullException("needs");
            }
            mNeeds = needs;

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

            mNametag.MainGui.Showing = true;

            mDesiredClothing.Clear();
            if (mDesiredClothingFrame != null)
            {
                mDesiredClothingFrame.ClearChildWidgets();
            }
            mDesiredStations.Clear();

            mStateMachine = new FashionModelStateMachine(this, mLevel);

            UnityGameObject.transform.position = mLevel.Start.First;

            mActiveWalkCycle      = mCatWalk;
            mActiveWalkCycleSpeed = mCatWalkSpeed;

            mCompletionBonusTime = 5.0f;
            mReady = false;

            mHandleBonusTask = mScheduler.StartCoroutine(HandleBonus());

            IGuiManager manager = GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>();

            mDesiredClothingFrame = new GuiFrame("MainFrame", new MainFrameSizePosition());

            IGuiStyle windowStyle = new GuiStyle(manager.GetDefaultStyle(typeof(Window)), "ModelNeedsWindow");

            windowStyle.Normal.Background = null;
            windowStyle.Hover.Background  = null;

            // TODO: Hard coded values
            float windowHeight = 192.0f;

            mDesiredClothingWindow = new Window
                                     (
                "ModelClothingPanel",
                new FixedSize(128.0f, windowHeight),
                manager,
                mDesiredClothingFrame,
                windowStyle
                                     );

            // TODO: Hard coded values
            mFollowWorldSpaceObject = new FollowWorldSpaceObject
                                      (
                GameFacade.Instance.RetrieveMediator <FashionCameraMediator>().Camera,
                this.DisplayObject.transform,
                GuiAnchor.CenterLeft,
                new Vector2(0.0f, windowHeight * 0.4f),
                new Vector3(0.125f, APPROX_AVATAR_HEIGHT * 1.3f, 0.25f)
                                      );

            manager.SetTopLevelPosition
            (
                mDesiredClothingWindow,
                mFollowWorldSpaceObject
            );

            ClothingMediator clothingMediator = GameFacade.Instance.RetrieveMediator <ClothingMediator>();

            // Setup Clothes GUI
            foreach (ItemId clothing in mNeeds.Clothing)
            {
                Image desiredClothingImage = new Image("DesiredClothingLabel", clothingMediator.GetThumbStyle(clothing), clothingMediator.GetThumbnail(clothing));
                mDesiredClothing.Add(clothing, desiredClothingImage);
                mDesiredClothingFrame.AddChildWidget(desiredClothingImage, new HorizontalAutoLayout());
            }

            // Setup Station GUI
            foreach (ModelStation station in mNeeds.Stations)
            {
                Image desiredStationImage = new Image("DesiredStationImage", station.Image);

                mDesiredStations.Add(station, desiredStationImage);
                mDesiredClothingFrame.AddChildWidget(desiredStationImage, new HorizontalAutoLayout());

                mCompletionBonusTime += station.WaitTime + mWalkToStationTimeBonus;
            }

            this.DisplayObject.SetActiveRecursively(true);

            Shader fashionModelShader = Shader.Find("Avatar/Fashion Model");

            if (fashionModelShader == null)
            {
                throw new Exception("Cannot find 'Avatar/Fashion Model' shader");
            }

            mModelMaterials.Clear();
            foreach (Component component in UnityGameObject.GetComponentsInChildren(typeof(Renderer)))
            {
                Renderer renderer = (Renderer)component;
                foreach (Material mat in renderer.materials)
                {
                    mat.shader = fashionModelShader;
                    mModelMaterials.Add(mat);
                }
            }

            mNeeds.AddOnCompleteAction(ModelComplete);
        }