Esempio n. 1
0
 /**
  * <summary>Gets a Sprite based on the portrait graphic of the speaking character.
  * If lipsincing is enabled, the sprite will be based on the current phoneme.</summary>
  * <returns>The speaking character's portrait sprite</returns>
  */
 public UnityEngine.Sprite GetPortraitSprite()
 {
     if (speaker != null)
     {
         CursorIconBase portraitIcon = speaker.GetPortrait();
         if (portraitIcon != null && portraitIcon.texture != null)
         {
             if (IsAnimating())
             {
                 if (speaker.isLipSyncing)
                 {
                     return(portraitIcon.GetAnimatedSprite(speaker.GetLipSyncFrame()));
                 }
                 else
                 {
                     portraitIcon.GetAnimatedRect();
                     return(portraitIcon.GetAnimatedSprite(true));
                 }
             }
             else
             {
                 return(portraitIcon.GetSprite());
             }
         }
     }
     return(null);
 }
Esempio n. 2
0
        private void DrawPreviewMenu(Menu menu)
        {
            if (menu == null || menu.IsUnityUI())
            {
                return;
            }

            if (KickStarter.mainCamera != null)
            {
                KickStarter.mainCamera.DrawBorders();
            }

            CheckScreenSize(menu);

            if (menu.CanPause() && menu.pauseWhenEnabled && menuManager.pauseTexture)
            {
                GUI.DrawTexture(AdvGame.GUIRect(0.5f, 0.5f, 1f, 1f), menuManager.pauseTexture, ScaleMode.ScaleToFit, true, 0f);
            }

            if ((menu.positionType == AC_PositionType.FollowCursor || menu.positionType == AC_PositionType.AppearAtCursorAndFreeze || menu.positionType == AC_PositionType.OnHotspot || menu.positionType == AC_PositionType.AboveSpeakingCharacter || menu.positionType == AC_PositionType.AbovePlayer) && AdvGame.GetReferences().cursorManager&& AdvGame.GetReferences().cursorManager.pointerIcon.texture)
            {
                CursorIconBase icon = AdvGame.GetReferences().cursorManager.pointerIcon;
                GUI.DrawTexture(AdvGame.GUIBox(KickStarter.mainCamera.GetPlayableScreenArea(false).center, icon.size), icon.texture, ScaleMode.ScaleToFit, true, 0f);
            }

            menu.StartDisplay();

            foreach (MenuElement element in menu.visibleElements)
            {
                SetStyles(element);

                for (int i = 0; i < element.GetNumSlots(); i++)
                {
                    if (menuManager.GetSelectedElement() == element && element.isClickable && i == 0)
                    {
                        element.Display(highlightedStyle, i, 1f, true);
                    }

                    else
                    {
                        element.Display(normalStyle, i, 1f, false);
                    }
                }

                if (UnityEditor.EditorWindow.mouseOverWindow != null && UnityEditor.EditorWindow.mouseOverWindow.ToString() != null && UnityEditor.EditorWindow.mouseOverWindow.ToString().Contains("(UnityEditor.GameView)"))
                {
                    if (menu.IsPointerOverSlot(element, 0, Event.current.mousePosition + new Vector2(menu.GetRect().x, menu.GetRect().y)))
                    {
                        menuManager.SelectElementFromPreview(menu, element);
                    }
                }
            }

            menu.EndDisplay();

            if (menuManager.drawOutlines)
            {
                menu.DrawOutline(menuManager.GetSelectedElement());
            }
        }
Esempio n. 3
0
        /**
         * <summary>Copies the values from another CursorIconBase.</summary>
         * <param name = "_icon">The CursorIconBase to copy from</param>
         */
        public void Copy(CursorIconBase _icon)
        {
            texture                   = _icon.texture;
            isAnimated                = _icon.isAnimated;
            numFrames                 = _icon.numFrames;
            animSpeed                 = _icon.animSpeed;
            endAnimOnLastFrame        = _icon.endAnimOnLastFrame;
            skipFirstFrameWhenLooping = _icon.skipFirstFrameWhenLooping;
            clickOffset               = _icon.clickOffset;
            numRows                   = _icon.numRows;
            numCols                   = _icon.numCols;
            size          = _icon.size;
            alwaysAnimate = _icon.alwaysAnimate;

            frameSpeeds = new float[0];
            if (_icon.frameSpeeds != null)
            {
                frameSpeeds = new float[_icon.frameSpeeds.Length];
                for (int i = 0; i < frameSpeeds.Length; i++)
                {
                    frameSpeeds[i] = _icon.frameSpeeds[i];
                }
            }

            Reset();
        }
Esempio n. 4
0
 private void DrawIcon(CursorIconBase icon, bool isLook, bool canAnimate = true)
 {
     if (icon != null)
     {
         DrawIcon(new Vector2(0f, 0f), icon, isLook, canAnimate);
     }
 }
Esempio n. 5
0
        protected virtual void Awake()
        {
            GameObject newOb = new GameObject();

            newOb.name       = this.name + " (Grab point)";
            grabPoint        = newOb.transform;
            grabPoint.parent = this.transform;

            if (moveSoundClip)
            {
                GameObject newSoundOb = new GameObject();
                newSoundOb.name             = this.name + " (Move sound)";
                newSoundOb.transform.parent = this.transform;
                newSoundOb.AddComponent <Sound>();
                newSoundOb.GetComponent <AudioSource>().playOnAwake = false;
                moveSound = newSoundOb.GetComponent <Sound>();
            }

            icon = GetMainIcon();

            if (GetComponent <Sound>())
            {
                collideSound = GetComponent <Sound>();
            }

            if (GetComponent <Rigidbody>())
            {
                _rigidbody = GetComponent <Rigidbody>();
            }
            else
            {
                ACDebug.LogWarning("A Rigidbody component is required for " + this.name);
            }
        }
Esempio n. 6
0
        protected override void Awake()
        {
            base.Awake();

            GameObject newOb = new GameObject();

            newOb.name       = this.name + " (Grab point)";
            grabPoint        = newOb.transform;
            grabPoint.parent = this.transform;

            if (moveSoundClip)
            {
                GameObject newSoundOb = new GameObject();
                newSoundOb.name             = this.name + " (Move sound)";
                newSoundOb.transform.parent = this.transform;
                newSoundOb.AddComponent <Sound>();
                newSoundOb.GetComponent <AudioSource>().playOnAwake = false;
                moveSound = newSoundOb.GetComponent <Sound>();
            }

            icon = GetMainIcon();

            collideSound = GetComponent <Sound>();
            if (collideSound == null)
            {
                collideSound = gameObject.AddComponent <Sound>();
            }
        }
Esempio n. 7
0
 private void DrawIcon(CursorIconBase icon, bool isLook)
 {
     if (icon != null)
     {
         DrawIcon(new Vector2(0f, 0f), icon, isLook);
     }
 }
Esempio n. 8
0
        public void CopyGraphic(MenuGraphic _element)
        {
            uiImage = _element.uiImage;

            graphicType = _element.graphicType;
            graphic = _element.graphic;
            base.Copy (_element);
        }
Esempio n. 9
0
        public void CopyGraphic(MenuGraphic _element)
        {
            uiImage = _element.uiImage;

            graphicType = _element.graphicType;
            graphic     = _element.graphic;
            base.Copy(_element);
        }
Esempio n. 10
0
        private void CopyGraphic(MenuGraphic _element)
        {
            uiImage = _element.uiImage;

            graphicType = _element.graphicType;
            graphic     = new CursorIconBase();
            graphic.Copy(_element.graphic);
            base.Copy(_element);
        }
        private void IconBaseGUI(string fieldLabel, CursorIconBase icon, string apiPrefix, string tooltip = "", bool includeAlwaysAnimate = true)
        {
            if (fieldLabel != "" && fieldLabel.Length > 0)
            {
                EditorGUILayout.LabelField(fieldLabel, CustomStyles.subHeader);
            }

            icon.ShowGUI(true, includeAlwaysAnimate, "Texture:", cursorRendering, apiPrefix, tooltip);
            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
        }
Esempio n. 12
0
        private void IconBaseGUI(string fieldLabel, CursorIconBase icon, string apiPrefix)
        {
            if (fieldLabel != "")
            {
                EditorGUILayout.LabelField(fieldLabel, CustomStyles.subHeader);
            }

            icon.ShowGUI(true, "Texture:", cursorRendering, apiPrefix);
            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
        }
Esempio n. 13
0
		public override void Declare ()
		{
			isVisible = true;
			isClickable = false;
			graphic = new CursorIconBase ();
			numSlots = 1;
			SetSize (new Vector2 (10f, 5f));

			base.Declare ();
		}
Esempio n. 14
0
 /**
  * <summary>Copies the values from another CursorIconBase.</summary>
  * <param name = "_icon">The CursorIconBase to copy from</param>
  */
 public void Copy(CursorIconBase _icon)
 {
     texture            = _icon.texture;
     isAnimated         = _icon.isAnimated;
     numFrames          = _icon.numFrames;
     animSpeed          = _icon.animSpeed;
     endAnimOnLastFrame = _icon.endAnimOnLastFrame;
     clickOffset        = _icon.clickOffset;
     numRows            = _icon.numRows;
     numCols            = _icon.numCols;
 }
Esempio n. 15
0
        /**
         * Initialises the element when it is created within MenuManager.
         */
        public override void Declare()
        {
            uiImage = null;

            graphicType = AC_GraphicType.Normal;
            isVisible   = true;
            isClickable = false;
            graphic     = new CursorIconBase();
            numSlots    = 1;
            SetSize(new Vector2(10f, 5f));

            base.Declare();
        }
Esempio n. 16
0
        /**
         * Initialises the element when it is created within MenuManager.
         */
        public override void Declare()
        {
            uiImage = null;

            graphicType = AC_GraphicType.Normal;
            isVisible = true;
            isClickable = false;
            graphic = new CursorIconBase ();
            numSlots = 1;
            SetSize (new Vector2 (10f, 5f));

            base.Declare ();
        }
Esempio n. 17
0
        /**
         * <summary>A constructor for a runtime-generated Conversation's dialogue option.</summary>
         * <param name = "_ID">An ID number unique to this instance of ButtonDialog within a Conversation</param>
         * <param name = "_label">The option's display text</param>
         * <param name = "_isOn">If True, the option will be enabled</param>
         */
        public ButtonDialog(int _ID, string _label, bool _isOn)
        {
            label      = _label;
            icon       = null;
            cursorIcon = new CursorIconBase();
            isOn       = _isOn;
            isLocked   = false;

            conversationAction = ConversationAction.Stop;

            assetFile       = null;
            newConversation = null;
            dialogueOption  = null;
            lineID          = -1;
            ID = _ID;
        }
Esempio n. 18
0
        /**
         * <summary>The default Constructor.</summary>
         * <param name = "idArray">An array of already-used ID numbers, so that a unique one can be generated</param>
         */
        public Expression(int[] idArray)
        {
            ID = 0;
            portraitIcon = new CursorIconBase ();
            label = "New expression";

            // Update id based on array
            if (idArray != null && idArray.Length > 0)
            {
                foreach (int _id in idArray)
                {
                    if (ID == _id)
                        ID ++;
                }
            }
        }
Esempio n. 19
0
        /**
         * <summary>A constructor for a scene-based Conversation's dialogue option.</summary>
         * <param name = "_ID">An ID number unique to this instance of ButtonDialog within a Conversation</param>
         * <param name = "_label">The option's display text</param>
         * <param name = "_startEnabled">If True, the option will be enabled by default</param>
         * <param name = "_dialogueOption">The DialogueOption to run when the option is chosen</param>
         * <param name = "_endsConversation">If True, the Conversation will end after the DialogueOption has finished running</param>
         */
        public ButtonDialog(int _ID, string _label, bool _startEnabled, DialogueOption _dialogueOption, bool _endsConversation)
        {
            label      = _label;
            icon       = null;
            cursorIcon = new CursorIconBase();
            isOn       = _startEnabled;
            isLocked   = false;

            conversationAction = (_endsConversation) ? ConversationAction.Stop : ConversationAction.ReturnToConversation;

            assetFile       = null;
            newConversation = null;
            dialogueOption  = _dialogueOption;
            lineID          = -1;
            ID = _ID;
        }
Esempio n. 20
0
        private void DrawIcon(Vector2 offset, CursorIconBase icon, bool isLook, bool canAnimate = true)
        {
            if (icon != null)
            {
                bool isNew = false;
                if (isLook && activeLookIcon != icon)
                {
                    activeLookIcon = icon;
                    isNew          = true;
                    icon.Reset();
                }
                else if (!isLook && activeIcon != icon)
                {
                    activeIcon = icon;
                    isNew      = true;
                    icon.Reset();
                }

                if (KickStarter.cursorManager.cursorRendering == CursorRendering.Hardware)
                {
                    if (icon.isAnimated)
                    {
                        Texture2D animTex = icon.GetAnimatedTexture(canAnimate);

                        if (icon.GetName() != lastCursorName)
                        {
                            lastCursorName = icon.GetName();
                            RecordCursorTexture(animTex);

                            SetHardwareCursor(currentCursorTexture2D, icon.clickOffset);
                        }
                    }
                    else if (isNew)
                    {
                        RecordCursorTexture(icon.texture);

                        SetHardwareCursor(currentCursorTexture2D, icon.clickOffset);
                    }
                }
                else
                {
                    Texture tex = icon.Draw(KickStarter.playerInput.GetMousePosition() + offset, canAnimate);
                    RecordCursorTexture(tex);
                }
            }
        }
        private void CopyGraphic(MenuGraphic _element, bool ignoreUnityUI)
        {
            if (ignoreUnityUI)
            {
                uiImage = null;
            }
            else
            {
                uiImage = _element.uiImage;
            }
            uiRawImage  = _element.uiRawImage;
            uiImageType = _element.uiImageType;

            graphicType = _element.graphicType;
            graphic     = new CursorIconBase();
            graphic.Copy(_element.graphic);
            base.Copy(_element);
        }
Esempio n. 22
0
        /**
         * <summary>The default Constructor.</summary>
         * <param name = "idArray">An array of already-used ID numbers, so that a unique one can be generated</param>
         */
        public Expression(int[] idArray)
        {
            ID           = 0;
            portraitIcon = new CursorIconBase();
            label        = "New expression";

            // Update id based on array
            if (idArray != null && idArray.Length > 0)
            {
                foreach (int _id in idArray)
                {
                    if (ID == _id)
                    {
                        ID++;
                    }
                }
            }
        }
Esempio n. 23
0
        private void DrawIcon(Rect _rect, Texture _tex)
        {
            if (_tex != null)
            {
                RecordCursorTexture(_tex);

                if (KickStarter.cursorManager.cursorRendering == CursorRendering.Hardware)
                {
                    lastCursorName = "";
                    activeIcon     = activeLookIcon = null;
                    Cursor.SetCursor(currentCursorTexture2D, Vector2.zero, CursorMode.Auto);
                }
                else
                {
                    GUI.DrawTexture(_rect, currentCursorTexture, ScaleMode.ScaleToFit, true, 0f);
                }
            }
        }
Esempio n. 24
0
        protected void DrawIcon(Rect _rect, Texture _tex)
        {
            if (_tex)
            {
                RecordCursorTexture(_tex);

                if (KickStarter.cursorManager.cursorRendering == CursorRendering.Hardware)
                {
                    lastCursorName = string.Empty;
                    activeIcon     = activeLookIcon = null;

                    SetHardwareCursor(currentCursorTexture2D, Vector2.zero);
                }
                else
                {
                    GUI.DrawTexture(_rect, currentCursorTexture, ScaleMode.ScaleToFit, true, 0f);
                }
            }
        }
Esempio n. 25
0
        private void DrawIcon(Vector2 offset, CursorIconBase icon, bool isLook)
        {
            if (icon != null)
            {
                bool isNew = false;
                if (isLook && activeLookIcon != icon)
                {
                    activeLookIcon = icon;
                    icon.Reset();
                }
                else if (!isLook && activeIcon != icon)
                {
                    activeIcon = icon;
                    isNew      = true;
                    icon.Reset();
                }

                if (KickStarter.cursorManager.cursorRendering == CursorRendering.Hardware)
                {
                    if (icon.isAnimated)
                    {
                        Texture2D animTex = icon.GetAnimatedTexture();
                        if (icon.GetName() != lastCursorName)
                        {
                            lastCursorName = icon.GetName();
                            Cursor.SetCursor(animTex, icon.clickOffset, CursorMode.Auto);
                        }
                    }
                    else if (isNew)
                    {
                        Cursor.SetCursor(icon.texture, icon.clickOffset, CursorMode.Auto);
                    }
                }
                else
                {
                    icon.Draw(KickStarter.playerInput.GetMousePosition() + offset);
                }
            }
        }
Esempio n. 26
0
		protected virtual void Awake ()
		{
			GameObject newOb = new GameObject ();
			newOb.name = this.name + " (Grab point)";
			grabPoint = newOb.transform;
			grabPoint.parent = this.transform;

			if (moveSoundClip)
			{
				GameObject newSoundOb = new GameObject ();
				newSoundOb.name = this.name + " (Move sound)";
				newSoundOb.transform.parent = this.transform;
				newSoundOb.AddComponent <Sound>();
				newSoundOb.GetComponent<AudioSource>().playOnAwake = false;
				moveSound = newSoundOb.GetComponent <Sound>();
			}

			icon = GetMainIcon ();

			if (Camera.main)
			{
				cameraTransform = Camera.main.transform;
			}

			if (GetComponent <Sound>())
			{
				collideSound = GetComponent <Sound>();
			}

			if (GetComponent <Rigidbody>())
			{
				_rigidbody = GetComponent <Rigidbody>();
			}
			else
			{
				Debug.LogWarning ("A Rigidbody component is required for " + this.name);
			}
		}
Esempio n. 27
0
        /**
         * <summary>The default Constructor.</summary>
         * <param name = "idArray">An array of existing ID numbers, so that a unique ID number can be assigned</param>
         */
        public ButtonDialog(int[] idArray)
        {
            label              = "";
            icon               = null;
            cursorIcon         = new CursorIconBase();
            isOn               = true;
            isLocked           = false;
            conversationAction = ConversationAction.ReturnToConversation;
            assetFile          = null;
            newConversation    = null;
            dialogueOption     = null;
            lineID             = -1;
            ID = 1;

            // Update id based on array
            foreach (int _id in idArray)
            {
                if (ID == _id)
                {
                    ID++;
                }
            }
        }
Esempio n. 28
0
        /**
         * Draws the cursor. This is called from StateHandler's OnGUI() function.
         */
        public void DrawCursor()
        {
            if (!showCursor)
            {
                if (!isDrawingHiddenCursor)
                {
                    activeIcon = activeLookIcon = null;

                    SetHardwareCursor(null, Vector2.zero);
                    isDrawingHiddenCursor = true;
                }
                return;
            }
            isDrawingHiddenCursor = false;

            if (KickStarter.playerInput.IsCursorLocked() && KickStarter.settingsManager.hideLockedCursor)
            {
                canShowHardwareCursor = false;
                return;
            }

            GUI.depth             = -1;
            canShowHardwareCursor = true;

            if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.CustomScript)
            {
                ShowCycleCursor(manualCursorID);
                return;
            }

            if (InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance))
            {
                // Cursor becomes selected inventory
                SelectedCursor        = -2;
                canShowHardwareCursor = false;
            }
            else if (KickStarter.settingsManager.interactionMethod != AC_InteractionMethod.ChooseInteractionThenHotspot)
            {
                if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive && KickStarter.cursorManager.allowInteractionCursorForInventory && InvInstance.IsValid(KickStarter.runtimeInventory.HoverInstance))
                {
                    ShowContextIcons(KickStarter.runtimeInventory.HoverInstance.InvItem);
                    return;
                }
                else if (KickStarter.playerInteraction.GetActiveHotspot() && KickStarter.stateHandler.IsInGameplay() && (KickStarter.playerInteraction.GetActiveHotspot().HasContextUse() || KickStarter.playerInteraction.GetActiveHotspot().HasContextLook()))
                {
                    SelectedCursor = 0;

                    if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
                    {
                        Button useButton = KickStarter.playerInteraction.GetActiveHotspot().GetFirstUseButton();
                        if (useButton != null)
                        {
                            SelectedCursor = useButton.iconID;
                        }

                        if (KickStarter.cursorManager.allowInteractionCursor)
                        {
                            canShowHardwareCursor = false;
                            ShowContextIcons();
                        }
                        else if (KickStarter.cursorManager.mouseOverIcon.texture)
                        {
                            DrawIcon(KickStarter.cursorManager.mouseOverIcon, false);
                        }
                        else
                        {
                            DrawMainCursor();
                        }
                    }
                }
                else
                {
                    SelectedCursor = -1;
                }
            }
            else if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
            {
                if (KickStarter.stateHandler.gameState == GameState.DialogOptions)
                {
                    SelectedCursor = -1;
                }
                else if (KickStarter.stateHandler.gameState == GameState.Paused)
                {
                    if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot && KickStarter.cursorManager.cycleCursors && KickStarter.settingsManager.inventoryInteractions == InventoryInteractions.Multiple)
                    {
                    }
                    else
                    {
                        SelectedCursor = -1;
                    }
                }
                else if (KickStarter.playerInteraction.GetActiveHotspot() && !KickStarter.playerInteraction.GetActiveHotspot().IsSingleInteraction() && (selectedCursor == -1 || !KickStarter.cursorManager.allowInteractionCursor) && KickStarter.cursorManager.mouseOverIcon.texture)
                {
                    DrawIcon(KickStarter.cursorManager.mouseOverIcon, false);
                    return;
                }
            }

            if (KickStarter.stateHandler.gameState == GameState.Cutscene && KickStarter.cursorManager.waitIcon.texture)
            {
                // Wait
                int elementOverCursorID = KickStarter.playerMenus.GetElementOverCursorID();
                if (elementOverCursorID >= 0)
                {
                    DrawIcon(KickStarter.cursorManager.GetCursorIconFromID(elementOverCursorID), false);
                    return;
                }

                DrawIcon(KickStarter.cursorManager.waitIcon, false);
            }
            else if (selectedCursor == -2 && InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance))
            {
                // Inventory
                canShowHardwareCursor = false;

                if (KickStarter.settingsManager.SelectInteractionMethod() == SelectInteractions.CyclingCursorAndClickingHotspot && KickStarter.settingsManager.cycleInventoryCursors)
                {
                    if (KickStarter.playerInteraction.GetActiveHotspot() == null && !InvInstance.IsValid(KickStarter.runtimeInventory.HoverInstance))
                    {
                        if (KickStarter.playerInteraction.InteractionIndex >= 0)
                        {
                            // Item was selected due to cycling icons
                            KickStarter.playerInteraction.ResetInteractionIndex();
                            KickStarter.runtimeInventory.SetNull();
                            return;
                        }
                    }
                }
                if (KickStarter.settingsManager.InventoryDragDrop && KickStarter.playerInput.GetDragState() != DragState.Inventory)
                {
                    DrawMainCursor();
                }
                else if (KickStarter.settingsManager.inventoryActiveEffect != InventoryActiveEffect.None && KickStarter.runtimeInventory.SelectedInstance.InvItem.CanBeAnimated() && !string.IsNullOrEmpty(KickStarter.playerMenus.GetHotspotLabel()) &&
                         (KickStarter.settingsManager.activeWhenUnhandled ||
                          KickStarter.playerInteraction.DoesHotspotHaveInventoryInteraction() ||
                          (InvInstance.IsValid(KickStarter.runtimeInventory.HoverInstance) && KickStarter.runtimeInventory.HoverInstance.InvItem.DoesHaveInventoryInteraction(KickStarter.runtimeInventory.SelectedInstance.InvItem))))
                {
                    if (KickStarter.cursorManager.inventoryHandling == InventoryHandling.ChangeHotspotLabel)
                    {
                        DrawMainCursor();
                    }
                    else
                    {
                        DrawActiveInventoryCursor();
                    }
                }
                else
                {
                    if (KickStarter.cursorManager.inventoryHandling != InventoryHandling.ChangeHotspotLabel && KickStarter.runtimeInventory.SelectedInstance.InvItem.HasCursorIcon())
                    {
                        DrawInventoryCursor();
                    }
                    else
                    {
                        if (KickStarter.cursorManager.inventoryHandling != InventoryHandling.ChangeHotspotLabel && !KickStarter.runtimeInventory.SelectedInstance.InvItem.HasCursorIcon())
                        {
                            ACDebug.LogWarning("Cannot change cursor to display the selected Inventory item because the item '" + KickStarter.runtimeInventory.SelectedInstance.InvItem.label + "' has no associated graphic.");
                        }

                        if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
                        {
                            if (KickStarter.playerInteraction.GetActiveHotspot() == null)
                            {
                                DrawMainCursor();
                            }
                            else if (KickStarter.cursorManager.allowInteractionCursor)
                            {
                                canShowHardwareCursor = false;
                                ShowContextIcons();
                            }
                            else if (KickStarter.cursorManager.mouseOverIcon.texture)
                            {
                                DrawIcon(KickStarter.cursorManager.mouseOverIcon, false);
                            }
                            else
                            {
                                DrawMainCursor();
                            }
                        }
                        else if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                        {
                            if (KickStarter.stateHandler.gameState == GameState.DialogOptions || KickStarter.stateHandler.gameState == GameState.Paused)
                            {
                            }
                            else if (KickStarter.playerInteraction.GetActiveHotspot() && !KickStarter.playerInteraction.GetActiveHotspot().IsSingleInteraction() && !KickStarter.cursorManager.allowInteractionCursor && KickStarter.cursorManager.mouseOverIcon.texture)
                            {
                                DrawIcon(KickStarter.cursorManager.mouseOverIcon, false);
                            }
                            else
                            {
                                DrawMainCursor();
                            }
                        }
                        else if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction)
                        {
                            if (KickStarter.settingsManager.CanSelectItems(false) && KickStarter.stateHandler.gameState == GameState.Normal)
                            {
                                DrawMainCursor();
                            }
                        }
                    }
                }

                KickStarter.runtimeInventory.DrawSelectedInventoryCount();
            }
            else if (KickStarter.settingsManager.SelectInteractionMethod() == SelectInteractions.CyclingCursorAndClickingHotspot)
            {
                ShowCycleCursor(KickStarter.playerInteraction.GetActiveUseButtonIconID());
            }
            else if (KickStarter.cursorManager.allowMainCursor || KickStarter.settingsManager.inputMethod == InputMethod.KeyboardOrController)
            {
                // Pointer
                pulseDirection = 0;

                if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction)
                {
                    if (!InvInstance.IsValid(KickStarter.runtimeInventory.HoverInstance) && KickStarter.playerInteraction.GetActiveHotspot() && (!KickStarter.playerMenus.IsInteractionMenuOn() || KickStarter.settingsManager.SelectInteractionMethod() == SelectInteractions.CyclingMenuAndClickingHotspot))
                    {
                        if (KickStarter.playerInteraction.GetActiveHotspot().IsSingleInteraction())
                        {
                            ShowContextIcons();
                        }
                        else if (KickStarter.cursorManager.mouseOverIcon.texture)
                        {
                            DrawIcon(KickStarter.cursorManager.mouseOverIcon, false);
                        }
                        else
                        {
                            DrawMainCursor();
                        }
                    }
                    else
                    {
                        DrawMainCursor();
                    }
                }
                else if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
                {
                    if (selectedCursor == -1)
                    {
                        DrawMainCursor();
                    }
                    else if (selectedCursor == -2 && !InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance))
                    {
                        SelectedCursor = -1;
                    }
                }
                else if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                {
                    if (KickStarter.playerInteraction.GetActiveHotspot() && KickStarter.playerInteraction.GetActiveHotspot().IsSingleInteraction())
                    {
                        //SelectedCursor = -1;

                        if (KickStarter.cursorManager.allowInteractionCursor)
                        {
                            ShowContextIcons();
                        }
                        else if (KickStarter.cursorManager.mouseOverIcon.texture)
                        {
                            DrawIcon(KickStarter.cursorManager.mouseOverIcon, false);
                        }
                        else
                        {
                            DrawMainCursor();
                        }
                    }
                    else if (selectedCursor >= 0)
                    {
                        if (KickStarter.cursorManager.allowInteractionCursor)
                        {
                            //	Custom icon
                            pulseDirection        = 0;
                            canShowHardwareCursor = false;

                            bool canAnimate = false;
                            if (!KickStarter.cursorManager.onlyAnimateOverHotspots ||
                                KickStarter.playerInteraction.GetActiveHotspot() != null ||
                                (KickStarter.settingsManager.InventoryInteractions == InventoryInteractions.Multiple && InvInstance.IsValid(KickStarter.runtimeInventory.HoverInstance)))
                            {
                                canAnimate = true;
                            }

                            DrawIcon(KickStarter.cursorManager.cursorIcons [selectedCursor], false, canAnimate);
                        }
                        else
                        {
                            DrawMainCursor();
                        }
                    }
                    else if (selectedCursor == -1)
                    {
                        DrawMainCursor();
                    }
                    else if (selectedCursor == -2 && !InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance))
                    {
                        SelectedCursor = -1;
                    }
                }
            }
        }
Esempio n. 29
0
 private void DrawIcon(CursorIconBase icon, bool isLook, bool canAnimate = true)
 {
     if (icon != null)
     {
         DrawIcon (new Vector2 (0f, 0f), icon, isLook, canAnimate);
     }
 }
Esempio n. 30
0
        private void DrawIcon(Vector2 offset, CursorIconBase icon, bool isLook, bool canAnimate = true)
        {
            if (icon != null)
            {
                bool isNew = false;
                if (isLook && activeLookIcon != icon)
                {
                    activeLookIcon = icon;
                    isNew = true;
                    icon.Reset ();
                }
                else if (!isLook && activeIcon != icon)
                {
                    activeIcon = icon;
                    isNew = true;
                    icon.Reset ();
                }

                if (KickStarter.cursorManager.cursorRendering == CursorRendering.Hardware)
                {
                    if (icon.isAnimated && canAnimate)
                    {
                        Texture2D animTex = icon.GetAnimatedTexture ();
                        if (icon.GetName () != lastCursorName)
                        {
                            lastCursorName = icon.GetName ();
                            Cursor.SetCursor (animTex, icon.clickOffset, CursorMode.Auto);
                        }
                    }
                    else if (isNew)
                    {
                        Cursor.SetCursor (icon.texture, icon.clickOffset, CursorMode.Auto);
                    }
                }
                else
                {
                    icon.Draw (KickStarter.playerInput.GetMousePosition () + offset, canAnimate);
                }
            }
        }
        private void CopyGraphic(MenuGraphic _element)
        {
            uiImage = _element.uiImage;

            graphicType = _element.graphicType;
            graphic = new CursorIconBase ();
            graphic.Copy (_element.graphic);
            base.Copy (_element);
        }
        private void Finish()
        {
            if (!references)
            {
                GetReferences();
            }

            if (!references)
            {
                return;
            }

            string managerPath = gameName + "/Managers";

            try
            {
                System.IO.Directory.CreateDirectory(Application.dataPath + "/" + managerPath);
            }
            catch (System.Exception e)
            {
                ACDebug.LogError("Wizard aborted - Could not create directory: " + Application.dataPath + "/" + managerPath + ". Please make sure the Assets direcrory is writeable, and that the intended game name contains no special characters.");
                Debug.LogException(e, this);
                pageNumber--;
                return;
            }

            try
            {
                ScriptableObject t = CustomAssetUtility.CreateAsset <SceneManager> ("SceneManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SceneManager.asset", gameName + "_SceneManager");
                references.sceneManager = (SceneManager)t;

                t = CustomAssetUtility.CreateAsset <SettingsManager> ("SettingsManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SettingsManager.asset", gameName + "_SettingsManager");
                references.settingsManager = (SettingsManager)t;

                references.settingsManager.saveFileName      = gameName;
                references.settingsManager.cameraPerspective = cameraPerspective;
                references.settingsManager.movingTurning     = movingTurning;
                references.settingsManager.movementMethod    = movementMethod;
                references.settingsManager.inputMethod       = inputMethod;
                references.settingsManager.interactionMethod = interactionMethod;
                references.settingsManager.hotspotDetection  = hotspotDetection;
                if (cameraPerspective == CameraPerspective.TwoPointFiveD)
                {
                    references.settingsManager.forceAspectRatio = true;
                }

                t = CustomAssetUtility.CreateAsset <ActionsManager> ("ActionsManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/ActionsManager.asset", gameName + "_ActionsManager");
                references.actionsManager = (ActionsManager)t;
                AdventureCreator.RefreshActions();
                ActionsManager defaultActionsManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_ActionsManager.asset", typeof(ActionsManager)) as ActionsManager;
                if (defaultActionsManager != null)
                {
                    references.actionsManager.defaultClass     = defaultActionsManager.defaultClass;
                    references.actionsManager.defaultClassName = defaultActionsManager.defaultClassName;
                }

                t = CustomAssetUtility.CreateAsset <VariablesManager> ("VariablesManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/VariablesManager.asset", gameName + "_VariablesManager");
                references.variablesManager = (VariablesManager)t;

                t = CustomAssetUtility.CreateAsset <InventoryManager> ("InventoryManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/InventoryManager.asset", gameName + "_InventoryManager");
                references.inventoryManager = (InventoryManager)t;

                t = CustomAssetUtility.CreateAsset <SpeechManager> ("SpeechManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SpeechManager.asset", gameName + "_SpeechManager");
                references.speechManager = (SpeechManager)t;

                references.speechManager.ClearLanguages();

                t = CustomAssetUtility.CreateAsset <CursorManager> ("CursorManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/CursorManager.asset", gameName + "_CursorManager");
                references.cursorManager = (CursorManager)t;

                t = CustomAssetUtility.CreateAsset <MenuManager> ("MenuManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/MenuManager.asset", gameName + "_MenuManager");
                references.menuManager = (MenuManager)t;

                CursorManager defaultCursorManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_CursorManager.asset", typeof(CursorManager)) as CursorManager;
                if (wizardMenu == WizardMenu.Blank)
                {
                    if (defaultCursorManager != null)
                    {
                        CursorIcon useIcon = new CursorIcon();
                        useIcon.Copy(defaultCursorManager.cursorIcons[0]);
                        references.cursorManager.cursorIcons.Add(useIcon);
                        EditorUtility.SetDirty(references.cursorManager);
                    }
                }
                else
                {
                    if (defaultCursorManager != null)
                    {
                        foreach (CursorIcon defaultIcon in defaultCursorManager.cursorIcons)
                        {
                            CursorIcon newIcon = new CursorIcon();
                            newIcon.Copy(defaultIcon);
                            references.cursorManager.cursorIcons.Add(newIcon);
                        }

                        CursorIconBase pointerIcon = new CursorIconBase();
                        pointerIcon.Copy(defaultCursorManager.pointerIcon);
                        references.cursorManager.pointerIcon = pointerIcon;
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot find Default_CursorManager asset to copy from!");
                    }
                    references.cursorManager.allowMainCursor = true;
                    EditorUtility.SetDirty(references.cursorManager);

                    MenuManager defaultMenuManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_MenuManager.asset", typeof(MenuManager)) as MenuManager;
                    if (defaultMenuManager != null)
                    {
                                                #if UNITY_EDITOR
                        references.menuManager.drawOutlines = defaultMenuManager.drawOutlines;
                        references.menuManager.drawInEditor = defaultMenuManager.drawInEditor;
                                                #endif
                        references.menuManager.pauseTexture = defaultMenuManager.pauseTexture;

                        if (wizardMenu != WizardMenu.Blank)
                        {
                            System.IO.Directory.CreateDirectory(Application.dataPath + "/" + gameName + "/UI");
                        }
                        foreach (Menu defaultMenu in defaultMenuManager.menus)
                        {
                            Menu newMenu = ScriptableObject.CreateInstance <Menu>();
                            newMenu.Copy(defaultMenu, true, true);
                            newMenu.Recalculate();

                            if (wizardMenu == WizardMenu.DefaultAC)
                            {
                                newMenu.menuSource = MenuSource.AdventureCreator;
                            }
                            else if (wizardMenu == WizardMenu.DefaultUnityUI)
                            {
                                newMenu.menuSource = MenuSource.UnityUiPrefab;
                            }

                            if (defaultMenu.canvas)
                            {
                                string newCanvasPath = "Assets/" + gameName + "/UI/" + defaultMenu.canvas.name + ".prefab";

                                GameObject canvasObInScene = (GameObject)PrefabUtility.InstantiatePrefab(defaultMenu.canvas.gameObject);
                                PrefabUtility.DisconnectPrefabInstance(canvasObInScene);
                                GameObject canvasObNewPrefab = PrefabUtility.CreatePrefab(newCanvasPath, canvasObInScene);

                                newMenu.canvas = canvasObNewPrefab.GetComponent <Canvas>();
                                DestroyImmediate(canvasObInScene);

                                newMenu.rectTransform = null;
                            }

                            foreach (MenuElement newElement in newMenu.elements)
                            {
                                AssetDatabase.AddObjectToAsset(newElement, references.menuManager);
                                newElement.hideFlags = HideFlags.HideInHierarchy;
                            }
                            AssetDatabase.AddObjectToAsset(newMenu, references.menuManager);
                            newMenu.hideFlags = HideFlags.HideInHierarchy;

                            references.menuManager.menus.Add(newMenu);
                        }

                        EditorUtility.SetDirty(references.menuManager);
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot find Default_MenuManager asset to copy from!");
                    }
                }

                CreateManagerPackage(gameName);

                AssetDatabase.SaveAssets();
                if (GameObject.FindObjectOfType <KickStarter>() == null)
                {
                    bool initScene = EditorUtility.DisplayDialog("Setup scene?", "Process complete.  Would you like to organise the scene objects to begin working?  This can be done at any time within the Scene Manager.", "Yes", "No");
                    if (initScene)
                    {
                        references.sceneManager.InitialiseObjects();
                    }
                }
            }
            catch (System.Exception e)
            {
                ACDebug.LogWarning("Could not create Manager. Does the subdirectory " + managerPath + " exist?");
                Debug.LogException(e, this);
                pageNumber--;
            }
        }
Esempio n. 33
0
        private void Finish()
        {
            if (!references)
            {
                GetReferences();
            }

            if (!references)
            {
                return;
            }

            string managerPath = gameName + "/Managers";

            try
            {
                System.IO.Directory.CreateDirectory(Application.dataPath + "/" + managerPath);
            }
            catch
            {
                Debug.LogWarning("Could not create directory: " + Application.dataPath + "/" + managerPath);
                pageNumber--;
                return;
            }

            try
            {
                ScriptableObject t = CustomAssetUtility.CreateAsset <SceneManager> ("SceneManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SceneManager.asset", gameName + "_SceneManager");
                references.sceneManager = (SceneManager)t;

                t = CustomAssetUtility.CreateAsset <SettingsManager> ("SettingsManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SettingsManager.asset", gameName + "_SettingsManager");
                references.settingsManager = (SettingsManager)t;

                references.settingsManager.saveFileName      = gameName;
                references.settingsManager.cameraPerspective = cameraPerspective;
                references.settingsManager.movementMethod    = movementMethod;
                references.settingsManager.inputMethod       = inputMethod;
                references.settingsManager.interactionMethod = interactionMethod;
                references.settingsManager.hotspotDetection  = hotspotDetection;
                references.settingsManager.movingTurning     = movingTurning;
                if (cameraPerspective == CameraPerspective.TwoPointFiveD)
                {
                    references.settingsManager.forceAspectRatio = true;
                }

                t = CustomAssetUtility.CreateAsset <ActionsManager> ("ActionsManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/ActionsManager.asset", gameName + "_ActionsManager");
                references.actionsManager = (ActionsManager)t;
                AdventureCreator.RefreshActions();
                ActionsManager demoActionsManager = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/Managers/Demo_ActionsManager.asset", typeof(ActionsManager)) as ActionsManager;
                if (demoActionsManager != null)
                {
                    references.actionsManager.defaultClass = demoActionsManager.defaultClass;
                }

                t = CustomAssetUtility.CreateAsset <VariablesManager> ("VariablesManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/VariablesManager.asset", gameName + "_VariablesManager");
                references.variablesManager = (VariablesManager)t;

                t = CustomAssetUtility.CreateAsset <InventoryManager> ("InventoryManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/InventoryManager.asset", gameName + "_InventoryManager");
                references.inventoryManager = (InventoryManager)t;

                t = CustomAssetUtility.CreateAsset <SpeechManager> ("SpeechManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SpeechManager.asset", gameName + "_SpeechManager");
                references.speechManager = (SpeechManager)t;

                references.speechManager.ClearLanguages();

                t = CustomAssetUtility.CreateAsset <CursorManager> ("CursorManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/CursorManager.asset", gameName + "_CursorManager");
                references.cursorManager = (CursorManager)t;

                t = CustomAssetUtility.CreateAsset <MenuManager> ("MenuManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/MenuManager.asset", gameName + "_MenuManager");
                references.menuManager = (MenuManager)t;

                if (wizardMenu != WizardMenu.Blank)
                {
                    CursorManager demoCursorManager = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/Managers/Demo_CursorManager.asset", typeof(CursorManager)) as CursorManager;
                    if (demoCursorManager != null)
                    {
                        foreach (CursorIcon demoIcon in demoCursorManager.cursorIcons)
                        {
                            CursorIcon newIcon = new CursorIcon();
                            newIcon.Copy(demoIcon);
                            references.cursorManager.cursorIcons.Add(newIcon);
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Cannot find Demo_CursorManager asset to copy from!");
                    }
                    references.cursorManager.allowMainCursor = true;

                    CursorIconBase pointerIcon = new CursorIconBase();
                    pointerIcon.Copy(demoCursorManager.pointerIcon);
                    references.cursorManager.pointerIcon = pointerIcon;
                    EditorUtility.SetDirty(references.cursorManager);

                    MenuManager demoMenuManager = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/Managers/Demo_MenuManager.asset", typeof(MenuManager)) as MenuManager;
                    if (demoMenuManager != null)
                    {
                        references.menuManager.drawOutlines = demoMenuManager.drawOutlines;
                        references.menuManager.drawInEditor = demoMenuManager.drawInEditor;
                        references.menuManager.pauseTexture = demoMenuManager.pauseTexture;

                        if (wizardMenu == WizardMenu.DefaultUnityUI)
                        {
                            System.IO.Directory.CreateDirectory(Application.dataPath + "/" + gameName + "/UI");
                        }

                        foreach (Menu demoMenu in demoMenuManager.menus)
                        {
                            Menu newMenu = ScriptableObject.CreateInstance <Menu>();
                            newMenu.Copy(demoMenu);

                            if (wizardMenu == WizardMenu.DefaultAC)
                            {
                                newMenu.menuSource = MenuSource.AdventureCreator;
                            }
                            else if (wizardMenu == WizardMenu.DefaultUnityUI)
                            {
                                newMenu.menuSource = MenuSource.UnityUiPrefab;

                                if (demoMenu.canvas)
                                {
                                    string oldCanvasPath = AssetDatabase.GetAssetPath(demoMenu.canvas);
                                    string newCanvasPath = "Assets/" + gameName + "/UI/" + demoMenu.canvas.name + ".prefab";
                                    if (AssetDatabase.CopyAsset(oldCanvasPath, newCanvasPath))
                                    {
                                        AssetDatabase.ImportAsset(newCanvasPath);
                                        newMenu.canvas = (Canvas)AssetDatabase.LoadAssetAtPath(newCanvasPath, typeof(Canvas));
                                    }
                                }
                            }

                            newMenu.hideFlags = HideFlags.HideInHierarchy;
                            references.menuManager.menus.Add(newMenu);
                            EditorUtility.SetDirty(references.menuManager);
                            foreach (MenuElement newElement in newMenu.elements)
                            {
                                newElement.hideFlags = HideFlags.HideInHierarchy;
                                AssetDatabase.AddObjectToAsset(newElement, references.menuManager);
                            }
                            AssetDatabase.AddObjectToAsset(newMenu, references.menuManager);
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Cannot find Demo_MenuManager asset to copy from!");
                    }
                }

                CreateManagerPackage(gameName);

                AssetDatabase.SaveAssets();
                references.sceneManager.InitialiseObjects();
                pageNumber = 0;
            }
            catch
            {
                Debug.LogWarning("Could not create Manager. Does the subdirectory " + Resource.managersDirectory + " exist?");
                pageNumber--;
            }
        }
Esempio n. 34
0
        public void DrawHotspotIcon()
        {
            if (IsOn())
            {
                Vector3 direction = (transform.position - Camera.main.transform.position);
                if (Vector3.Angle(direction, Camera.main.transform.forward) > 90f)
                {
                    iconAlpha = 0f;
                    return;
                }

                if (KickStarter.settingsManager.cameraPerspective != CameraPerspective.TwoD && KickStarter.settingsManager.occludeIcons)
                {
                    // Is icon occluded?
                    Ray        ray = new Ray(Camera.main.transform.position, GetIconPosition() - Camera.main.transform.position);
                    RaycastHit hit;
                    if (Physics.Raycast(ray, out hit, KickStarter.settingsManager.hotspotRaycastLength, 1 << LayerMask.NameToLayer(KickStarter.settingsManager.hotspotLayer)))
                    {
                        if (hit.collider.gameObject != this.gameObject)
                        {
                            iconAlpha = 0f;
                            return;
                        }
                    }
                }

                if (KickStarter.playerInput.interactionMenuIsOn && KickStarter.settingsManager.hideIconUnderInteractionMenu)
                {
                    iconAlpha = Mathf.Lerp(iconAlpha, 0f, Time.deltaTime * 5f);
                }
                else if (KickStarter.settingsManager.hotspotIconDisplay == HotspotIconDisplay.OnlyWhenHighlighting ||
                         KickStarter.settingsManager.hotspotIconDisplay == HotspotIconDisplay.OnlyWhenFlashing)
                {
                    if (highlight)
                    {
                        if (KickStarter.settingsManager.hotspotIconDisplay == HotspotIconDisplay.OnlyWhenHighlighting)
                        {
                            iconAlpha = highlight.GetHighlightAlpha();
                        }
                        else
                        {
                            iconAlpha = highlight.GetFlashAlpha(iconAlpha);
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Cannot display correct Hotspot Icon alpha on " + name + " because it has no associated Highlight object.");
                    }
                }
                else if (KickStarter.settingsManager.hotspotIconDisplay == HotspotIconDisplay.Always)
                {
                    iconAlpha = 1f;
                }
                else
                {
                    iconAlpha = 0f;
                }
            }
            else
            {
                iconAlpha = 0f;
                return;
            }

            if (!KickStarter.mainCamera.IsPointInCamera(GetIconScreenPosition()))
            {
                return;
            }

            if (iconAlpha > 0f)
            {
                Color c         = GUI.color;
                Color tempColor = c;
                c.a       = iconAlpha;
                GUI.color = c;

                if (KickStarter.settingsManager.hotspotIcon == HotspotIcon.UseIcon)
                {
                    CursorIconBase icon = GetMainIcon();
                    if (icon != null)
                    {
                        icon.Draw(GetIconScreenPosition());
                    }
                }
                else if (KickStarter.settingsManager.hotspotIconTexture != null)
                {
                    GUI.DrawTexture(AdvGame.GUIBox(GetIconScreenPosition(), KickStarter.settingsManager.hotspotIconSize), KickStarter.settingsManager.hotspotIconTexture, ScaleMode.ScaleToFit, true, 0f);
                }

                GUI.color = tempColor;
            }
        }
Esempio n. 35
0
 /**
  * <summary>Copies the values from another CursorIconBase.</summary>
  * <param name = "_icon">The CursorIconBase to copy from</param>
  */
 public void Copy(CursorIconBase _icon)
 {
     texture = _icon.texture;
     isAnimated = _icon.isAnimated;
     numFrames = _icon.numFrames;
     animSpeed = _icon.animSpeed;
     endAnimOnLastFrame = _icon.endAnimOnLastFrame;
     clickOffset = _icon.clickOffset;
     numRows = _icon.numRows;
     numCols = _icon.numCols;
 }
Esempio n. 36
0
        /**
         * <summary>Recalculates the element's size.
         * This should be called whenever a Menu's shape is changed.</summary>
         * <param name = "source">How the parent Menu is displayed (AdventureCreator, UnityUiPrefab, UnityUiInScene)</param>
         */
        public override void RecalculateSize(MenuSource source)
        {
            if (Application.isPlaying)
            {
                if (linkedConversation != null)
                {
                    numOptions = linkedConversation.GetCount();

                    if (fixedOption)
                    {
                        if (numOptions < optionToShow)
                        {
                            numSlots = 0;
                        }
                        else
                        {
                            numSlots  = 1;
                            labels    = new string[numSlots];
                            labels[0] = linkedConversation.GetOptionName(optionToShow - 1);
                            labels[0] = AddIndexNumber(labels[0], optionToShow);

                            icons    = new CursorIconBase[numSlots];
                            icons[0] = new CursorIconBase();
                            icons[0].Copy(linkedConversation.GetOptionIcon(optionToShow - 1));

                            chosens    = new bool[numSlots];
                            chosens[0] = linkedConversation.OptionHasBeenChosen(optionToShow - 1);
                        }
                    }
                    else
                    {
                        numSlots = numOptions;
                        if (numSlots > maxSlots)
                        {
                            numSlots = maxSlots;
                        }

                        labels  = new string[numSlots];
                        icons   = new CursorIconBase[numSlots];
                        chosens = new bool[numSlots];
                        for (int i = 0; i < numSlots; i++)
                        {
                            labels[i] = linkedConversation.GetOptionName(i + offset);
                            labels[i] = AddIndexNumber(labels[i], i + offset + 1);
                            icons[i]  = new CursorIconBase();
                            icons[i].Copy(linkedConversation.GetOptionIcon(i + offset));
                            chosens[i] = linkedConversation.OptionHasBeenChosen(i + offset);
                        }

                        if (markAlreadyChosen && source != MenuSource.AdventureCreator)
                        {
                            for (int i = 0; i < chosens.Length; i++)
                            {
                                bool chosen = chosens[i];

                                if (uiSlots.Length > i)
                                {
                                    if (chosen)
                                    {
                                        uiSlots[i].SetColour(alreadyChosenFontColour);
                                    }
                                    else
                                    {
                                        uiSlots[i].RestoreColour();
                                    }
                                }
                            }
                        }

                        LimitOffset(numOptions);
                    }
                }
                else
                {
                    numSlots = 0;
                }
            }
            else if (fixedOption)
            {
                numSlots = 1;
                offset   = 0;
                labels   = new string[numSlots];
                icons    = new CursorIconBase[numSlots];
                chosens  = new bool[numSlots];
            }

            if (Application.isPlaying && uiSlots != null)
            {
                ClearSpriteCache(uiSlots);
            }

            if (!isVisible)
            {
                LimitUISlotVisibility(uiSlots, 0, uiHideStyle);
            }

            base.RecalculateSize(source);
        }
		private void Finish ()
		{
			if (!references)
			{
				GetReferences ();
			}
			
			if (!references)
			{
				return;
			}

			string managerPath = gameName + "/Managers";
			try
			{
				System.IO.Directory.CreateDirectory (Application.dataPath + "/" + managerPath);
			}
			catch
			{
				Debug.LogWarning ("Could not create directory: " + Application.dataPath + "/" + managerPath);
				pageNumber --;
				return;
			}

			try
			{
				ScriptableObject t = CustomAssetUtility.CreateAsset<SceneManager> ("SceneManager", managerPath);
				AssetDatabase.RenameAsset ("Assets/" + managerPath + "/SceneManager.asset", gameName + "_SceneManager");
				references.sceneManager = (SceneManager) t;

				t = CustomAssetUtility.CreateAsset<SettingsManager> ("SettingsManager", managerPath);
				AssetDatabase.RenameAsset ("Assets/" + managerPath + "/SettingsManager.asset", gameName + "_SettingsManager");
				references.settingsManager = (SettingsManager) t;

				references.settingsManager.saveFileName = gameName;
				references.settingsManager.cameraPerspective = cameraPerspective;
				references.settingsManager.movementMethod = movementMethod;
				references.settingsManager.inputMethod = inputMethod;
				references.settingsManager.interactionMethod = interactionMethod;
				references.settingsManager.hotspotDetection = hotspotDetection;
				references.settingsManager.movingTurning = movingTurning;

				t = CustomAssetUtility.CreateAsset<ActionsManager> ("ActionsManager", managerPath);
				AssetDatabase.RenameAsset ("Assets/" + managerPath + "/ActionsManager.asset", gameName + "_ActionsManager");
				references.actionsManager = (ActionsManager) t;
				references.actionsManager.RefreshList ();
				references.actionsManager.SetEnabled ();

				t = CustomAssetUtility.CreateAsset<VariablesManager> ("VariablesManager", managerPath);
				AssetDatabase.RenameAsset ("Assets/" + managerPath + "/VariablesManager.asset", gameName + "_VariablesManager");
				references.variablesManager = (VariablesManager) t;

				t = CustomAssetUtility.CreateAsset<InventoryManager> ("InventoryManager", managerPath);
				AssetDatabase.RenameAsset ("Assets/" + managerPath + "/InventoryManager.asset", gameName + "_InventoryManager");
				references.inventoryManager = (InventoryManager) t;

				t = CustomAssetUtility.CreateAsset<SpeechManager> ("SpeechManager", managerPath);
				AssetDatabase.RenameAsset ("Assets/" + managerPath + "/SpeechManager.asset", gameName + "_SpeechManager");
				references.speechManager = (SpeechManager) t;

				t = CustomAssetUtility.CreateAsset<CursorManager> ("CursorManager", managerPath);
				AssetDatabase.RenameAsset ("Assets/" + managerPath + "/CursorManager.asset", gameName + "_CursorManager");
				references.cursorManager = (CursorManager) t;

				t = CustomAssetUtility.CreateAsset<MenuManager> ("MenuManager", managerPath);
				AssetDatabase.RenameAsset ("Assets/" + managerPath + "/MenuManager.asset", gameName + "_MenuManager");
				references.menuManager = (MenuManager) t;

				if (!createNewMenu)
				{
					CursorManager demoCursorManager = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/Managers/Demo_CursorManager.asset", typeof(CursorManager)) as CursorManager;
					foreach (CursorIcon demoIcon in demoCursorManager.cursorIcons)
					{
						CursorIcon newIcon = new CursorIcon ();
						newIcon.Copy (demoIcon);
						references.cursorManager.cursorIcons.Add (newIcon);
					}

					references.cursorManager.allowMainCursor = true;

					CursorIconBase pointerIcon = new CursorIconBase ();
					pointerIcon.Copy (demoCursorManager.pointerIcon);
					references.cursorManager.pointerIcon = pointerIcon;
					EditorUtility.SetDirty (references.cursorManager);

					MenuManager demoMenuManager = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/Managers/Demo_MenuManager.asset", typeof(MenuManager)) as MenuManager;
					references.menuManager.drawOutlines = demoMenuManager.drawOutlines;
					references.menuManager.drawInEditor = demoMenuManager.drawInEditor;
					references.menuManager.pauseTexture = demoMenuManager.pauseTexture;
					foreach (Menu demoMenu in demoMenuManager.menus)
					{
						Menu newMenu = ScriptableObject.CreateInstance <Menu>();
						newMenu.Copy (demoMenu);
						newMenu.hideFlags = HideFlags.HideInHierarchy;
						references.menuManager.menus.Add (newMenu);
						EditorUtility.SetDirty (references.menuManager);
						foreach (MenuElement newElement in newMenu.elements)
						{
							newElement.hideFlags = HideFlags.HideInHierarchy;
							AssetDatabase.AddObjectToAsset (newElement, references.menuManager);
						}
						AssetDatabase.AddObjectToAsset (newMenu, references.menuManager);
					}
				}

				CreateManagerPackage (gameName);

				AssetDatabase.SaveAssets ();
				references.sceneManager.InitialiseObjects ();
			}
			catch
			{
				Debug.LogWarning ("Could not create Manager. Does the subdirectory " + Resource.managersDirectory + " exist?");
				pageNumber --;
			}
		}
Esempio n. 38
0
        private void OnGUI()
        {
            if (!Application.isPlaying)
            {
                if (AdvGame.GetReferences())
                {
                    menuManager = AdvGame.GetReferences().menuManager;

                    if (menuManager && menuManager.drawInEditor && AdvGame.GetReferences().viewingMenuManager)
                    {
                        if (menuManager.GetSelectedMenu() != null)
                        {
                            AC.Menu menu = menuManager.GetSelectedMenu();

                            if (menu.IsUnityUI())
                            {
                                return;
                            }

                            CheckScreenSize(menu);

                            if ((menu.appearType == AppearType.Manual || menu.appearType == AppearType.OnInputKey) && menu.pauseWhenEnabled && menuManager.pauseTexture)
                            {
                                GUI.DrawTexture(AdvGame.GUIRect(0.5f, 0.5f, 1f, 1f), menuManager.pauseTexture, ScaleMode.ScaleToFit, true, 0f);
                            }

                            if ((menu.positionType == AC_PositionType.FollowCursor || menu.positionType == AC_PositionType.AppearAtCursorAndFreeze || menu.positionType == AC_PositionType.OnHotspot || menu.positionType == AC_PositionType.AboveSpeakingCharacter || menu.positionType == AC_PositionType.AbovePlayer) && AdvGame.GetReferences().cursorManager&& AdvGame.GetReferences().cursorManager.pointerIcon.texture)
                            {
                                CursorIconBase icon = AdvGame.GetReferences().cursorManager.pointerIcon;
                                GUI.DrawTexture(AdvGame.GUIBox(new Vector2(AdvGame.GetMainGameViewSize().x / 2f, AdvGame.GetMainGameViewSize().y / 2f), icon.size), icon.texture, ScaleMode.ScaleToFit, true, 0f);
                            }

                            menu.StartDisplay();

                            foreach (MenuElement element in menu.visibleElements)
                            {
                                SetStyles(element);

                                for (int i = 0; i < element.GetNumSlots(); i++)
                                {
                                    if (menuManager.GetSelectedElement() == element && element.isClickable && i == 0)
                                    {
                                        //	element.PreDisplay (i, true, 0);
                                        element.Display(highlightedStyle, i, 1f, true);
                                    }

                                    else
                                    {
                                        //	element.PreDisplay (i, true, 0);
                                        element.Display(normalStyle, i, 1f, false);
                                    }
                                }

                                if (UnityEditor.EditorWindow.mouseOverWindow != null && UnityEditor.EditorWindow.mouseOverWindow.ToString().Contains("(UnityEditor.GameView)"))
                                {
                                    if (menu.IsPointerOverSlot(element, 0, Event.current.mousePosition + new Vector2(menu.GetRect().x, menu.GetRect().y)))
                                    {
                                        menuManager.SelectElementFromPreview(menu, element);
                                    }
                                }
                            }

                            menu.EndDisplay();

                            if (menuManager.drawOutlines)
                            {
                                menu.DrawOutline(menuManager.GetSelectedElement());
                            }
                        }
                    }
                }
            }
        }
Esempio n. 39
0
		public void CopyGraphic (MenuGraphic _element)
		{
			graphic = _element.graphic;
			base.Copy (_element);
		}
Esempio n. 40
0
        private void Finish()
        {
            if (!references)
            {
                GetReferences();
            }

            if (!references)
            {
                return;
            }

            string managerPath = gameName + "/Managers";

            try
            {
                System.IO.Directory.CreateDirectory(Application.dataPath + "/" + managerPath);
            }
            catch (System.Exception e)
            {
                ACDebug.LogError("Wizard aborted - Could not create directory: " + Application.dataPath + "/" + managerPath + ". Please make sure the Assets direcrory is writeable, and that the intended game name contains no special characters.");
                Debug.LogException(e, this);
                pageNumber--;
                return;
            }

            try
            {
                ShowProgress(0f);

                ScriptableObject t = CustomAssetUtility.CreateAsset <SceneManager> ("SceneManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SceneManager.asset", gameName + "_SceneManager");
                references.sceneManager = (SceneManager)t;

                ShowProgress(0.1f);

                t = CustomAssetUtility.CreateAsset <SettingsManager> ("SettingsManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SettingsManager.asset", gameName + "_SettingsManager");
                references.settingsManager = (SettingsManager)t;

                references.settingsManager.saveFileName      = gameName;
                references.settingsManager.cameraPerspective = cameraPerspective;
                references.settingsManager.movingTurning     = movingTurning;
                references.settingsManager.movementMethod    = movementMethod;
                references.settingsManager.inputMethod       = inputMethod;
                references.settingsManager.interactionMethod = interactionMethod;
                references.settingsManager.hotspotDetection  = hotspotDetection;
                if (cameraPerspective == CameraPerspective.TwoPointFiveD)
                {
                    references.settingsManager.forceAspectRatio = true;
                }

                ShowProgress(0.2f);

                t = CustomAssetUtility.CreateAsset <ActionsManager> ("ActionsManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/ActionsManager.asset", gameName + "_ActionsManager");
                references.actionsManager = (ActionsManager)t;
                AdventureCreator.RefreshActions();
                ActionsManager defaultActionsManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_ActionsManager.asset", typeof(ActionsManager)) as ActionsManager;
                if (defaultActionsManager != null)
                {
                    references.actionsManager.defaultClass     = defaultActionsManager.defaultClass;
                    references.actionsManager.defaultClassName = defaultActionsManager.defaultClassName;
                }

                ShowProgress(0.3f);

                t = CustomAssetUtility.CreateAsset <VariablesManager> ("VariablesManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/VariablesManager.asset", gameName + "_VariablesManager");
                references.variablesManager = (VariablesManager)t;

                ShowProgress(0.4f);

                t = CustomAssetUtility.CreateAsset <InventoryManager> ("InventoryManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/InventoryManager.asset", gameName + "_InventoryManager");
                references.inventoryManager = (InventoryManager)t;

                ShowProgress(0.5f);

                t = CustomAssetUtility.CreateAsset <SpeechManager> ("SpeechManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/SpeechManager.asset", gameName + "_SpeechManager");
                references.speechManager = (SpeechManager)t;
                references.speechManager.ClearLanguages();

                ShowProgress(0.6f);

                t = CustomAssetUtility.CreateAsset <CursorManager> ("CursorManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/CursorManager.asset", gameName + "_CursorManager");
                references.cursorManager = (CursorManager)t;

                ShowProgress(0.7f);

                t = CustomAssetUtility.CreateAsset <MenuManager> ("MenuManager", managerPath);
                AssetDatabase.RenameAsset("Assets/" + managerPath + "/MenuManager.asset", gameName + "_MenuManager");
                references.menuManager = (MenuManager)t;

                CursorManager defaultCursorManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_CursorManager.asset", typeof(CursorManager)) as CursorManager;
                if (wizardMenu == WizardMenu.Blank)
                {
                    if (defaultCursorManager != null)
                    {
                        CursorIcon useIcon = new CursorIcon();
                        useIcon.Copy(defaultCursorManager.cursorIcons[0], false);
                        references.cursorManager.cursorIcons.Add(useIcon);
                        EditorUtility.SetDirty(references.cursorManager);
                    }
                }
                else
                {
                    if (defaultCursorManager != null)
                    {
                        foreach (CursorIcon defaultIcon in defaultCursorManager.cursorIcons)
                        {
                            CursorIcon newIcon = new CursorIcon();
                            newIcon.Copy(defaultIcon, false);
                            references.cursorManager.cursorIcons.Add(newIcon);
                        }

                        CursorIconBase pointerIcon = new CursorIconBase();
                        pointerIcon.Copy(defaultCursorManager.pointerIcon);
                        references.cursorManager.pointerIcon = pointerIcon;
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot find Default_CursorManager asset to copy from!");
                    }

                    references.cursorManager.allowMainCursor = true;
                    EditorUtility.SetDirty(references.cursorManager);

                    MenuManager defaultMenuManager = AssetDatabase.LoadAssetAtPath(Resource.MainFolderPath + "/Default/Default_MenuManager.asset", typeof(MenuManager)) as MenuManager;
                    if (defaultMenuManager != null)
                    {
                                                #if UNITY_EDITOR
                        references.menuManager.drawOutlines = defaultMenuManager.drawOutlines;
                        references.menuManager.drawInEditor = defaultMenuManager.drawInEditor;
                                                #endif
                        references.menuManager.pauseTexture = defaultMenuManager.pauseTexture;

                        if (wizardMenu != WizardMenu.Blank)
                        {
                            System.IO.Directory.CreateDirectory(Application.dataPath + "/" + gameName + "/UI");
                        }

                        foreach (Menu defaultMenu in defaultMenuManager.menus)
                        {
                            float progress = (float)defaultMenuManager.menus.IndexOf(defaultMenu) / (float)defaultMenuManager.menus.Count;
                            ShowProgress((progress * 0.3f) + 0.7f);

                            Menu newMenu = ScriptableObject.CreateInstance <Menu>();
                            newMenu.Copy(defaultMenu, true, true);
                            newMenu.Recalculate();

                            if (wizardMenu == WizardMenu.DefaultAC)
                            {
                                newMenu.menuSource = MenuSource.AdventureCreator;
                            }
                            else if (wizardMenu == WizardMenu.DefaultUnityUI)
                            {
                                newMenu.menuSource = MenuSource.UnityUiPrefab;
                            }

                            if (defaultMenu.canvas)
                            {
                                string oldPath = AssetDatabase.GetAssetPath(defaultMenu.canvas.gameObject);
                                string newPath = "Assets/" + gameName + "/UI/" + defaultMenu.canvas.name + ".prefab";

                                if (AssetDatabase.CopyAsset(oldPath, newPath))
                                {
                                    AssetDatabase.ImportAsset(newPath);
                                    GameObject canvasObNewPrefab = (GameObject)AssetDatabase.LoadAssetAtPath(newPath, typeof(GameObject));
                                    newMenu.canvas = canvasObNewPrefab.GetComponent <Canvas>();
                                }
                                else
                                {
                                    newMenu.canvas = null;
                                    ACDebug.LogWarning("Could not copy asset " + oldPath + " to " + newPath, defaultMenu.canvas.gameObject);
                                }
                                newMenu.rectTransform = null;
                            }

                            foreach (MenuElement newElement in newMenu.elements)
                            {
                                if (newElement != null)
                                {
                                    AssetDatabase.AddObjectToAsset(newElement, references.menuManager);
                                    newElement.hideFlags = HideFlags.HideInHierarchy;
                                }
                                else
                                {
                                    ACDebug.LogWarning("Null element found in " + newMenu.title + " - the interface may not be set up correctly.");
                                }
                            }

                            if (newMenu != null)
                            {
                                AssetDatabase.AddObjectToAsset(newMenu, references.menuManager);
                                newMenu.hideFlags = HideFlags.HideInHierarchy;

                                references.menuManager.menus.Add(newMenu);
                            }
                            else
                            {
                                ACDebug.LogWarning("Unable to create new Menu from original '" + defaultMenu.title + "'");
                            }
                        }

                        EditorUtility.SetDirty(references.menuManager);

                                                #if CAN_USE_TIMELINE
                        if (references.speechManager != null)
                        {
                            references.speechManager.previewMenuName = "Subtitles";
                            EditorUtility.SetDirty(references.speechManager);
                        }
                                                #endif
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot find Default_MenuManager asset to copy from!");
                    }
                }

                EditorUtility.ClearProgressBar();
                ManagerPackage newManagerPackage = CreateManagerPackage(gameName);

                AssetDatabase.SaveAssets();

                if (newManagerPackage == null || !newManagerPackage.IsFullyAssigned())
                {
                    EditorUtility.DisplayDialog("Wizard failed", "The New Game Wizard failed to generate a new 'Manager Package' file with all eight Managers assigned. Pleae verify that your Assets directory is writable and try again.", "OK");
                }
                else if (GameObject.FindObjectOfType <KickStarter>() == null)
                {
                    bool initScene = EditorUtility.DisplayDialog("Organise scene?", "Process complete.  Would you like to organise the scene objects to begin working?  This can be done at any time within the Scene Manager.", "Yes", "No");
                    if (initScene)
                    {
                        references.sceneManager.InitialiseObjects();
                    }
                }
            }
            catch (System.Exception e)
            {
                ACDebug.LogWarning("Could not create Manager. Does the subdirectory " + managerPath + " exist?");
                Debug.LogException(e, this);
                pageNumber--;
            }
        }
Esempio n. 41
0
        /**
         * <summary>Draws an icon at the Hotspot's centre.</summary>
         * <param name = "inWorldSpace">If True, the icon shall be drawn as a sprite in world space, as opposed to an OnGUI graphic in screen space.</param>
         */
        public void DrawHotspotIcon(bool inWorldSpace = false)
        {
            if (iconAlpha > 0f)
            {
                if (!KickStarter.mainCamera.IsPointInCamera(GetIconScreenPosition()))
                {
                    return;
                }

                if (inWorldSpace)
                {
                    if (iconRenderer == null)
                    {
                        GameObject iconOb = new GameObject(this.name + " - icon");
                        iconRenderer = iconOb.AddComponent <SpriteRenderer>();
                        iconOb.transform.localScale = Vector3.one * (25f * KickStarter.settingsManager.hotspotIconSize);

                        if (GameObject.Find("_Hotspots") && GameObject.Find("_Hotspots").transform.eulerAngles == Vector3.zero)
                        {
                            iconOb.transform.parent = GameObject.Find("_Hotspots").transform;
                        }
                    }

                    if (KickStarter.settingsManager.hotspotIcon == HotspotIcon.UseIcon)
                    {
                        CursorIconBase icon = GetMainIcon();
                        if (icon != null)
                        {
                            iconRenderer.sprite = icon.GetSprite();
                        }
                    }
                    else
                    {
                        if (iconSprite == null && KickStarter.settingsManager.hotspotIconTexture != null)
                        {
                            iconSprite = UnityEngine.Sprite.Create(KickStarter.settingsManager.hotspotIconTexture, new Rect(0f, 0f, KickStarter.settingsManager.hotspotIconTexture.width, KickStarter.settingsManager.hotspotIconTexture.height), new Vector2(0.5f, 0.5f));
                        }
                        if (iconSprite != iconRenderer.sprite)
                        {
                            iconRenderer.sprite = iconSprite;
                        }
                    }
                    iconRenderer.transform.position = GetIconPosition();
                    iconRenderer.transform.LookAt(iconRenderer.transform.position + KickStarter.mainCamera.transform.rotation * Vector3.forward, KickStarter.mainCamera.transform.rotation * Vector3.up);
                }
                else
                {
                    if (iconRenderer != null)
                    {
                        GameObject.Destroy(iconRenderer.gameObject);
                        iconRenderer = null;
                    }

                    Color c         = GUI.color;
                    Color tempColor = c;
                    c.a       = iconAlpha;
                    GUI.color = c;

                    if (KickStarter.settingsManager.hotspotIcon == HotspotIcon.UseIcon)
                    {
                        CursorIconBase icon = GetMainIcon();
                        if (icon != null)
                        {
                            icon.Draw(GetIconScreenPosition());
                        }
                    }
                    else if (KickStarter.settingsManager.hotspotIconTexture != null)
                    {
                        GUI.DrawTexture(AdvGame.GUIBox(GetIconScreenPosition(), KickStarter.settingsManager.hotspotIconSize), KickStarter.settingsManager.hotspotIconTexture, ScaleMode.ScaleToFit, true, 0f);
                    }

                    GUI.color = tempColor;
                }
            }

            if (inWorldSpace && iconRenderer != null)
            {
                Color tempColor = iconRenderer.color;
                tempColor.a        = iconAlpha;
                iconRenderer.color = tempColor;
            }
        }
        private void Finish()
        {
            if (!references)
            {
                GetReferences ();
            }

            if (!references)
            {
                return;
            }

            string managerPath = gameName + "/Managers";
            try
            {
                System.IO.Directory.CreateDirectory (Application.dataPath + "/" + managerPath);
            }
            catch
            {
                ACDebug.LogWarning ("Could not create directory: " + Application.dataPath + "/" + managerPath);
                pageNumber --;
                return;
            }

            try
            {
                ScriptableObject t = CustomAssetUtility.CreateAsset<SceneManager> ("SceneManager", managerPath);
                AssetDatabase.RenameAsset ("Assets/" + managerPath + "/SceneManager.asset", gameName + "_SceneManager");
                references.sceneManager = (SceneManager) t;

                t = CustomAssetUtility.CreateAsset<SettingsManager> ("SettingsManager", managerPath);
                AssetDatabase.RenameAsset ("Assets/" + managerPath + "/SettingsManager.asset", gameName + "_SettingsManager");
                references.settingsManager = (SettingsManager) t;

                references.settingsManager.saveFileName = gameName;
                references.settingsManager.cameraPerspective = cameraPerspective;
                references.settingsManager.movementMethod = movementMethod;
                references.settingsManager.inputMethod = inputMethod;
                references.settingsManager.interactionMethod = interactionMethod;
                references.settingsManager.hotspotDetection = hotspotDetection;
                references.settingsManager.movingTurning = movingTurning;
                if (cameraPerspective == CameraPerspective.TwoPointFiveD)
                {
                    references.settingsManager.forceAspectRatio = true;
                }

                t = CustomAssetUtility.CreateAsset<ActionsManager> ("ActionsManager", managerPath);
                AssetDatabase.RenameAsset ("Assets/" + managerPath + "/ActionsManager.asset", gameName + "_ActionsManager");
                references.actionsManager = (ActionsManager) t;
                AdventureCreator.RefreshActions ();
                ActionsManager demoActionsManager = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/Managers/Demo_ActionsManager.asset", typeof(ActionsManager)) as ActionsManager;
                if (demoActionsManager != null)
                {
                    references.actionsManager.defaultClass = demoActionsManager.defaultClass;
                }

                t = CustomAssetUtility.CreateAsset<VariablesManager> ("VariablesManager", managerPath);
                AssetDatabase.RenameAsset ("Assets/" + managerPath + "/VariablesManager.asset", gameName + "_VariablesManager");
                references.variablesManager = (VariablesManager) t;

                t = CustomAssetUtility.CreateAsset<InventoryManager> ("InventoryManager", managerPath);
                AssetDatabase.RenameAsset ("Assets/" + managerPath + "/InventoryManager.asset", gameName + "_InventoryManager");
                references.inventoryManager = (InventoryManager) t;

                t = CustomAssetUtility.CreateAsset<SpeechManager> ("SpeechManager", managerPath);
                AssetDatabase.RenameAsset ("Assets/" + managerPath + "/SpeechManager.asset", gameName + "_SpeechManager");
                references.speechManager = (SpeechManager) t;

                references.speechManager.ClearLanguages ();

                t = CustomAssetUtility.CreateAsset<CursorManager> ("CursorManager", managerPath);
                AssetDatabase.RenameAsset ("Assets/" + managerPath + "/CursorManager.asset", gameName + "_CursorManager");
                references.cursorManager = (CursorManager) t;

                t = CustomAssetUtility.CreateAsset<MenuManager> ("MenuManager", managerPath);
                AssetDatabase.RenameAsset ("Assets/" + managerPath + "/MenuManager.asset", gameName + "_MenuManager");
                references.menuManager = (MenuManager) t;

                CursorManager demoCursorManager = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/Managers/Demo_CursorManager.asset", typeof(CursorManager)) as CursorManager;
                if (wizardMenu == WizardMenu.Blank)
                {
                    if (demoCursorManager != null)
                    {
                        CursorIcon useIcon = new CursorIcon ();
                        useIcon.Copy (demoCursorManager.cursorIcons[0]);
                        references.cursorManager.cursorIcons.Add (useIcon);
                        EditorUtility.SetDirty (references.cursorManager);
                    }
                }
                else
                {
                    if (demoCursorManager != null)
                    {
                        foreach (CursorIcon demoIcon in demoCursorManager.cursorIcons)
                        {
                            CursorIcon newIcon = new CursorIcon ();
                            newIcon.Copy (demoIcon);
                            references.cursorManager.cursorIcons.Add (newIcon);
                        }

                        CursorIconBase pointerIcon = new CursorIconBase ();
                        pointerIcon.Copy (demoCursorManager.pointerIcon);
                        references.cursorManager.pointerIcon = pointerIcon;
                    }
                    else
                    {
                        ACDebug.LogWarning ("Cannot find Demo_CursorManager asset to copy from!");
                    }

                    references.cursorManager.allowMainCursor = true;
                    EditorUtility.SetDirty (references.cursorManager);

                    MenuManager demoMenuManager = AssetDatabase.LoadAssetAtPath("Assets/AdventureCreator/Demo/Managers/Demo_MenuManager.asset", typeof(MenuManager)) as MenuManager;
                    if (demoMenuManager != null)
                    {
                        #if UNITY_EDITOR
                        references.menuManager.drawOutlines = demoMenuManager.drawOutlines;
                        references.menuManager.drawInEditor = demoMenuManager.drawInEditor;
                        #endif
                        references.menuManager.pauseTexture = demoMenuManager.pauseTexture;

                        if (wizardMenu == WizardMenu.DefaultUnityUI)
                        {
                            System.IO.Directory.CreateDirectory (Application.dataPath + "/" + gameName + "/UI");
                        }

                        foreach (Menu demoMenu in demoMenuManager.menus)
                        {
                            Menu newMenu = ScriptableObject.CreateInstance <Menu>();
                            newMenu.Copy (demoMenu);

                            if (wizardMenu == WizardMenu.DefaultAC)
                            {
                                newMenu.menuSource = MenuSource.AdventureCreator;
                            }
                            else if (wizardMenu == WizardMenu.DefaultUnityUI)
                            {
                                newMenu.menuSource = MenuSource.UnityUiPrefab;

                                if (demoMenu.canvas)
                                {
                                    string oldCanvasPath = AssetDatabase.GetAssetPath (demoMenu.canvas);
                                    string newCanvasPath = "Assets/" + gameName + "/UI/" + demoMenu.canvas.name + ".prefab";
                                    if (AssetDatabase.CopyAsset (oldCanvasPath, newCanvasPath))
                                    {
                                        AssetDatabase.ImportAsset (newCanvasPath);
                                        newMenu.canvas = (Canvas) AssetDatabase.LoadAssetAtPath (newCanvasPath, typeof (Canvas));
                                    }
                                }
                            }

                            newMenu.hideFlags = HideFlags.HideInHierarchy;
                            references.menuManager.menus.Add (newMenu);
                            EditorUtility.SetDirty (references.menuManager);
                            foreach (MenuElement newElement in newMenu.elements)
                            {
                                newElement.hideFlags = HideFlags.HideInHierarchy;
                                AssetDatabase.AddObjectToAsset (newElement, references.menuManager);
                            }
                            AssetDatabase.AddObjectToAsset (newMenu, references.menuManager);
                        }
                    }
                    else
                    {
                        ACDebug.LogWarning ("Cannot find Demo_MenuManager asset to copy from!");
                    }
                }

                CreateManagerPackage (gameName);

                AssetDatabase.SaveAssets ();
                references.sceneManager.InitialiseObjects ();
                pageNumber = 0;
            }
            catch
            {
                ACDebug.LogWarning ("Could not create Manager. Does the subdirectory " + Resource.managersDirectory + " exist?");
                pageNumber --;
            }
        }
Esempio n. 43
0
		private void IconBaseGUI (string fieldLabel, CursorIconBase icon)
		{
			EditorGUILayout.LabelField (fieldLabel, EditorStyles.boldLabel);
			icon.ShowGUI (true, cursorRendering);
			GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
		}
Esempio n. 44
0
 private void DrawIcon(CursorIconBase icon, bool isLook)
 {
     if (icon != null)
     {
         DrawIcon (new Vector2 (0f, 0f), icon, isLook);
     }
 }