Beispiel #1
0
        private void SelectFrame(IGuiFrame friendListing)
        {
            GuiPath selectEverything = new GuiPath("**/*");

            foreach (Button button in selectEverything.SelectElements <Button>((IGuiContainer)friendListing.Parent))
            {
                button.Disable();
            }

            IGuiStyle buttonStyle = new GuiStyle(mGuiManager.GetDefaultStyle(typeof(Button)), "ButtonStyle");
            IGuiStyle frameStyle  = new GuiStyle(friendListing.Style, "FrameStyle");

            foreach (IGuiStyle style in mFirstTimeLevelGui.AllStyles)
            {
                if (style.Name == "SecondaryButtonStyle")
                {
                    buttonStyle = new GuiStyle(style, "ButtonStyle");
                }
                else if (style.Name == "SelectedFrameStyle")
                {
                    frameStyle = new GuiStyle(style, "FrameStyle");
                }
            }

            foreach (Button button in selectEverything.SelectElements <Button>(friendListing))
            {
                button.Style = buttonStyle;
                button.Enable();
            }
            friendListing.Style = frameStyle;
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public RuntimeConsole(IGuiManager guiManager)
            : base(guiManager, mGuiPath)
        {
            if (guiManager == null)
            {
                throw new ArgumentNullException("guiManager");
            }

            mManager               = guiManager;
            mConsoleWindow         = this.MainGui;
            mConsoleWindow.Showing = false;

            IInputManager inputManager = GameFacade.Instance.RetrieveMediator <InputManagerMediator>();

            if (inputManager == null)
            {
                throw new Exception("Cannot construct a RuntimeConsole without having an InputManagerMediator registered in the GameFacade");
            }

            inputManager.RegisterForButtonUp(KeyCode.BackQuote, delegate()
            {
                mConsoleWindow.Showing = !mConsoleWindow.Showing;
            });

            mLogFrame       = mConsoleWindow.SelectSingleElement <IGuiFrame>("MainFrame/DebugLogFrame");
            mMainFrameWidth = mLogFrame.Size.x;
            Button closeButton = mConsoleWindow.SelectSingleElement <Button>("HeaderFrame/CloseButton");

            if (closeButton == null)
            {
                throw new Exception("Cannot find the button expected to be at 'HeaderFrame/CloseButton'");
            }

            closeButton.AddOnPressedAction(delegate()
            {
                mConsoleWindow.Showing = false;
            });

            IGuiStyle defaultLabelStyle = new GuiStyle(mManager.GetDefaultStyle(typeof(Label)), "ConsoleLabel");

            defaultLabelStyle.WordWrap = true;
            //defaultLabelStyle.DefaultFont = (Font)Resources.Load("Fonts/CourierBold");

            IGuiStyle errorStyle = new GuiStyle(defaultLabelStyle, "ConsoleErrorLabel");

            defaultLabelStyle.Normal.TextColor = Color.white;
            errorStyle.Normal.TextColor        = Color.Lerp(Color.black, Color.red, 0.35f);

            mLogLevelStyles.Add(LogLevel.Error, errorStyle);
            mLogLevelStyles.Add(LogLevel.Info, defaultLabelStyle);

            mCommandEntryBox = mConsoleWindow.SelectSingleElement <Textbox>("**/CommandEntryBox");

            inputManager.RegisterForButtonDown(KeyCode.Return, delegate()
            {
                if (this.MainGui.Showing)
                {
                    List <string> lineParsed = new List <string>(mCommandEntryBox.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
                    Action <ICollection <string> > command;
                    if (lineParsed.Count > 0 && mCommands.TryGetValue(lineParsed[0], out command))
                    {
                        lineParsed.RemoveAt(0);
                        command(lineParsed);
                    }
                }
            });
        }