Example #1
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);
        }
Example #2
0
        public TextBubble(IGuiManager guiManager, Texture2D texture, Transform worldPointToFollow, Camera camera)
        {
            mTweakablesHandler = new TweakablesHandler(mTweakablesPath, this);
            IgnoreUnusedVariableWarning(mTweakablesHandler);

            if (guiManager == null)
            {
                throw new ArgumentNullException("guiManager");
            }
            mGuiManager = guiManager;
            XmlGuiFactory loadTextBubble = new XmlGuiFactory(mResourcePath, guiManager);
            IGuiStyle     bubbleStyle    = null;
            IGuiStyle     textStyle      = null;

            foreach (IGuiStyle style in loadTextBubble.ConstructAllStyles())
            {
                if (style == null)
                {
                    continue;
                }
                if (style.Name == "TextBubbleStyleWindow")
                {
                    bubbleStyle = style;
                }
                else if (style.Name == "TextBubbleStyleBase")
                {
                    textStyle = style;
                }
            }

            if (bubbleStyle == null)
            {
                throw new Exception("Unable to load TextBubbleStyleWindow from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            if (textStyle == null)
            {
                throw new Exception("Unable to load TextBubbleStyleBase from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            foreach (IGuiElement element in loadTextBubble.ConstructAllElements())
            {
                if (element is Window && element.Name == "TextBubbleWindow")
                {
                    mBubbleWindow = (Window)element;
                }
            }

            if (mBubbleWindow == null)
            {
                throw new Exception("Unable to load TextBubbleWindow from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            mFollowWorldSpaceObject = new FollowWorldSpaceObject
                                      (
                camera,
                worldPointToFollow,
                GuiAnchor.BottomLeft,
                new Vector2(0.0f, 0.0f),                        // SDN: TODO:  make these offsets configurable
                new Vector3(0.0f, 1.8f, 0.0f)
                                      );

            guiManager.SetTopLevelPosition
            (
                mBubbleWindow,
                mFollowWorldSpaceObject
            );


            mBubbleWindow.Style = bubbleStyle;

            Image bubbleImage = mBubbleWindow.SelectSingleElement <Image>("**/TextBubbleImage");

            bubbleImage.Texture = texture;

            GuiFrame mainFrame  = mBubbleWindow.SelectSingleElement <GuiFrame>("**/TextBubbleFrame");
            Textbox  bubbleText = mBubbleWindow.SelectSingleElement <Textbox>("**/TextBubbleTextbox");

            mainFrame.RemoveChildWidget(bubbleText);

            Vector2 size = new Vector2(texture.width, texture.height);

            size.x += mBubbleWindow.Style.InternalMargins.Left + mBubbleWindow.Style.InternalMargins.Right;
            size.y += mBubbleWindow.Style.InternalMargins.Top + mBubbleWindow.Style.InternalMargins.Bottom;

            mBubbleWindow.GuiSize = new FixedSize(size);
        }
Example #3
0
        public TextBubble(IGuiManager guiManager, string text, Transform worldPointToFollow, Camera camera)
        {
            mTweakablesHandler = new TweakablesHandler(mTweakablesPath, this);
            IgnoreUnusedVariableWarning(mTweakablesHandler);

            if (guiManager == null)
            {
                throw new ArgumentNullException("guiManager");
            }
            mGuiManager = guiManager;
            XmlGuiFactory loadTextBubble = new XmlGuiFactory(mResourcePath, guiManager);
            IGuiStyle     bubbleStyle    = null;
            IGuiStyle     textStyle      = null;

            foreach (IGuiStyle style in loadTextBubble.ConstructAllStyles())
            {
                if (style == null)
                {
                    continue;
                }
                if (style.Name == "TextBubbleStyleWindow")
                {
                    bubbleStyle = style;
                }
                else if (style.Name == "TextBubbleStyleBase")
                {
                    textStyle = style;
                }
            }

            if (bubbleStyle == null)
            {
                throw new Exception("Unable to load TextBubbleStyleWindow from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            if (textStyle == null)
            {
                throw new Exception("Unable to load TextBubbleStyleBase from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            foreach (IGuiElement element in loadTextBubble.ConstructAllElements())
            {
                if (element is Window && element.Name == "TextBubbleWindow")
                {
                    mBubbleWindow = (Window)element;
                }
            }

            if (mBubbleWindow == null)
            {
                throw new Exception("Unable to load TextBubbleWindow from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            mFollowWorldSpaceObject = new FollowWorldSpaceObject
                                      (
                camera,
                worldPointToFollow,
                GuiAnchor.BottomLeft,
                new Vector2(0.0f, 0),                                // SDN: TODO:  make these offsets configurable
                new Vector3(0.0f, 1.8f, 0.0f)
                                      );

            guiManager.SetTopLevelPosition
            (
                mBubbleWindow,
                mFollowWorldSpaceObject
            );

            Textbox bubbleText = mBubbleWindow.SelectSingleElement <Textbox>("**/TextBubbleTextbox");

            mBubbleWindow.Style = bubbleStyle;
            bubbleText.Text     = text;

            Image    bubbleImage = mBubbleWindow.SelectSingleElement <Image>("**/TextBubbleImage");
            GuiFrame mainFrame   = mBubbleWindow.SelectSingleElement <GuiFrame>("**/TextBubbleFrame");

            mainFrame.RemoveChildWidget(bubbleImage);

            // Set the size of the window to be the smallest that draws the entire chat message
            UnityEngine.GUIStyle unityStyle = bubbleText.Style.GenerateUnityGuiStyle();
            unityStyle.wordWrap = false;
            GUIContent textContent = new GUIContent(text);

            Vector2 size = unityStyle.CalcSize(textContent);

            if (size.x > mMaxWidth)
            {
                size.x = mMaxWidth;
                unityStyle.wordWrap = true;
                size.y = unityStyle.CalcHeight(textContent, mMaxWidth);
            }
            if (size.x < mMinWidth)
            {
                size.x = mMinWidth;
            }
            size.x += mBubbleWindow.Style.InternalMargins.Left + mBubbleWindow.Style.InternalMargins.Right;
            size.y += mBubbleWindow.Style.InternalMargins.Top + mBubbleWindow.Style.InternalMargins.Bottom;

            mBubbleWindow.GuiSize = new FixedSize(size);
        }
Example #4
0
        public FashionGameStation(Pair <Vector3> location, string name, Texture2D image, float time, Vector3 guiOffset, GameObject displayObject)
            : base(GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>(), PROGRESS_INDICATOR_GUI)
        {
            if (time < 0.0f)
            {
                throw new ArgumentOutOfRangeException("time");
            }

            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            mName = name;

            if (location == null)
            {
                throw new ArgumentNullException("location");
            }
            mLocation = location.First;

            mImage = image;

            mScheduler = GameFacade.Instance.RetrieveMediator <SchedulerMediator>().Scheduler;

            mUnityGameObject = displayObject;
            foreach (Component component in mUnityGameObject.GetComponentsInChildren(typeof(Collider)))
            {
                component.gameObject.layer = FashionMinigame.STATION_LAYER;
            }
            mUnityGameObject.transform.forward = location.Second;

            foreach (Component component in mUnityGameObject.GetComponentsInChildren(typeof(Renderer)))
            {
                Renderer renderer = (Renderer)component;
                mOriginalColors.Add(renderer, renderer.material.color);
            }

            mWaitTime = time;

            mGuiPosition = new FollowWorldSpaceObject(GameFacade.Instance.RetrieveMediator <FashionCameraMediator>().Camera, mUnityGameObject.transform, GuiAnchor.CenterCenter, Vector2.zero, guiOffset);

            foreach (ITopLevel topLevel in this.AllGuis)
            {
                GameFacade.Instance.RetrieveMediator <RuntimeGuiManager>().SetTopLevelPosition(topLevel, mGuiPosition);
                Image stationIcon = topLevel.SelectSingleElement <Image>("**/StationIcon");
                stationIcon.Texture = mImage;
                switch (topLevel.Name)
                {
                case "IdleStationWindow":
                    mIdleWindow         = (Window)topLevel;
                    mIdleWindow.Showing = true;
                    break;

                case "InProgressWindow":
                    mInProgressWindow         = (Window)topLevel;
                    mProgressIndicator        = mInProgressWindow.SelectSingleElement <ProgressIndicator>("**/Progress");
                    mInProgressWindow.Showing = false;
                    break;
                }
            }

            GameObject friendLocation = GameObjectUtility.GetNamedChildRecursive("Friend Location", displayObject);

            if (friendLocation != null)
            {
                mStationWorkerTransform = friendLocation.transform;
            }

            HideProgressGui();
        }