Ejemplo n.º 1
0
 /// <summary>
 /// If useDefaultGUI is <c>true</c> and a usable object has been targeted, this method
 /// draws a selection message and targeting reticle.
 /// </summary>
 public virtual void OnGUI()
 {
     if (!useDefaultGUI)
     {
         return;
     }
     if (guiStyle == null && (Event.current.type == EventType.Repaint || usable != null))
     {
         SetGuiStyle();
     }
     if (usable != null)
     {
         bool inUseRange = (distance <= usable.maxUseDistance);
         guiStyle.normal.textColor = inUseRange ? inRangeColor : outOfRangeColor;
         if (string.IsNullOrEmpty(heading))
         {
             heading    = usable.GetName();
             useMessage = DialogueManager.GetLocalizedText(string.IsNullOrEmpty(usable.overrideUseMessage) ? defaultUseMessage : usable.overrideUseMessage);
         }
         UnityGUITools.DrawText(new Rect(0, 0, Screen.width, Screen.height), heading, guiStyle, textStyle, textStyleColor);
         UnityGUITools.DrawText(new Rect(0, guiStyleLineHeight, Screen.width, Screen.height), useMessage, guiStyle, textStyle, textStyleColor);
         Texture2D reticleTexture = inUseRange ? reticle.inRange : reticle.outOfRange;
         if (reticleTexture != null)
         {
             GUI.Label(new Rect(0.5f * (Screen.width - reticle.width), 0.5f * (Screen.height - reticle.height), reticle.width, reticle.height), reticleTexture);
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// If useDefaultGUI is <c>true</c> and a usable object has been targeted, this method
 /// draws a selection message and targeting reticle.
 /// </summary>
 public virtual void OnGUI()
 {
     if (useDefaultGUI)
     {
         SetGuiStyle();
         Rect screenRect = new Rect(0, 0, Screen.width, Screen.height);
         if (usable != null)
         {
             bool inUseRange = (distance <= usable.maxUseDistance);
             guiStyle.normal.textColor = inUseRange ? inRangeColor : outOfRangeColor;
             if (string.IsNullOrEmpty(heading))
             {
                 heading    = usable.GetName();
                 useMessage = string.IsNullOrEmpty(usable.overrideUseMessage) ? defaultUseMessage : usable.overrideUseMessage;
                 /////pene
             }
             UnityGUITools.DrawText(screenRect, heading, guiStyle, textStyle, textStyleColor);
             UnityGUITools.DrawText(new Rect(0, guiStyle.CalcSize(new GUIContent("Ay")).y, Screen.width, Screen.height), useMessage, guiStyle, textStyle, textStyleColor);
             Texture2D reticleTexture = inUseRange ? reticle.inRange : reticle.outOfRange;
             if (reticleTexture != null)
             {
                 GUI.Label(new Rect(0.5f * (Screen.width - reticle.width), 0.5f * (Screen.height - reticle.height), reticle.width, reticle.height), reticleTexture);
             }
         }
     }
 }
Ejemplo n.º 3
0
	void OnSelectedUsable(Usable usable) {
		NGUITools.SetActive(mainControl.gameObject, true);
		if(usable!=null) {
			string actionText = usable.defaultActionText;
		//	iTween.FadeTo(mainControl.gameObject,1.0f,0.25f);
			_trigger = usable.GetComponent<ConversationTrigger>();
				#if UNITY_IPHONE || UNITY_ANDROID
				string output = "Press chat icon "+actionText+" "+usable.GetName();
				label.text = output.ToUpper();
			#else
				string output = "Press Space "+actionText +" "+ usable.GetName();
				label.text = output.ToUpper();
			#endif 
		}
		
	}
Ejemplo n.º 4
0
        protected void DrawOnSelection(Usable usable, float distance, Selector.Reticle reticle, GUIStyle guiStyle, string defaultUseMessage,
                                       Color inRangeColor, Color outOfRangeColor, TextStyle textStyle, Color textStyleColor)
        {
            if (usable == null)
            {
                return;
            }
            if ((usable != lastUsable) || string.IsNullOrEmpty(heading))
            {
                lastUsable = usable;
                heading    = usable.GetName();
                useMessage = string.IsNullOrEmpty(usable.overrideUseMessage) ? defaultUseMessage : usable.overrideUseMessage;
            }
            GameObject selection = usable.gameObject;

            if (selection != lastSelectionDrawn)
            {
                selectionHeight         = Tools.GetGameObjectHeight(selection);
                selectionHeadingSize    = guiStyle.CalcSize(new GUIContent(heading));
                selectionUseMessageSize = guiStyle.CalcSize(new GUIContent(useMessage));
            }

            // Set text color based on distance:
            bool inUseRange = (distance <= usable.maxUseDistance);

            guiStyle.normal.textColor = inUseRange ? inRangeColor : outOfRangeColor;

            // Draw heading:
            Vector3 screenPos = UnityEngine.Camera.main.WorldToScreenPoint(selection.transform.position + (Vector3.up * selectionHeight));

            screenPos += offset;
            screenPos  = new Vector3(screenPos.x, screenPos.y + selectionUseMessageSize.y + selectionHeadingSize.y, screenPos.z);
            if (screenPos.z < 0)
            {
                return;
            }
            Rect rect = new Rect(screenPos.x - (selectionHeadingSize.x / 2), (Screen.height - screenPos.y) - (selectionHeadingSize.y / 2), selectionHeadingSize.x, selectionHeadingSize.y);

            UnityGUITools.DrawText(rect, heading, guiStyle, textStyle, textStyleColor);

            // Draw use message:
            screenPos  = UnityEngine.Camera.main.WorldToScreenPoint(selection.transform.position + (Vector3.up * (selectionHeight)));
            screenPos += offset;
            screenPos  = new Vector3(screenPos.x, screenPos.y + selectionUseMessageSize.y, screenPos.z);
            rect       = new Rect(screenPos.x - (selectionUseMessageSize.x / 2), (Screen.height - screenPos.y) - (selectionUseMessageSize.y / 2), selectionUseMessageSize.x, selectionUseMessageSize.y);
            UnityGUITools.DrawText(rect, useMessage, guiStyle, textStyle, textStyleColor);

            // Draw reticle:
            if (reticle != null)
            {
                Texture2D reticleTexture = inUseRange ? reticle.inRange : reticle.outOfRange;
                if (reticleTexture != null)
                {
                    screenPos = UnityEngine.Camera.main.WorldToScreenPoint(selection.transform.position + (Vector3.up * 0.5f * selectionHeight));
                    rect      = new Rect(screenPos.x - (reticle.width / 2), (Screen.height - screenPos.y) - (reticle.height / 2), reticle.width, reticle.height);
                    GUI.Label(rect, reticleTexture);
                }
            }
        }
Ejemplo n.º 5
0
        public void Start()
        {
            Usable usable = Tools.GetComponentAnywhere <Usable>(gameObject);

            if ((usable != null) && (nameText != null))
            {
                nameText.text = usable.GetName();
            }
            if (canvas != null)
            {
                canvas.enabled = false;
            }
        }
Ejemplo n.º 6
0
 protected virtual void SetCurrentUsable(Usable usable)
 {
     currentUsable = usable;
     if (usable != null)
     {
         currentHeading    = currentUsable.GetName();
         currentUseMessage = DialogueManager.GetLocalizedText(string.IsNullOrEmpty(currentUsable.overrideUseMessage) ? defaultUseMessage : currentUsable.overrideUseMessage);
     }
     else
     {
         currentHeading    = string.Empty;
         currentUseMessage = string.Empty;
     }
 }
Ejemplo n.º 7
0
 private void SetCurrentUsable(Usable usable)
 {
     currentUsable = usable;
     if (usable != null)
     {
         currentHeading    = currentUsable.GetName();
         currentUseMessage = string.IsNullOrEmpty(currentUsable.overrideUseMessage) ? defaultUseMessage : currentUsable.overrideUseMessage;
     }
     else
     {
         currentHeading    = string.Empty;
         currentUseMessage = string.Empty;
     }
 }
 private void ShowControls()
 {
     if (usable == null || elements == null)
     {
         return;
     }
     Tools.SetGameObjectActive(elements.mainGraphic, true);
     elements.nameText.SetActive(true);
     elements.useMessageText.SetActive(true);
     elements.nameText.text       = usable.GetName();
     elements.useMessageText.text = GetUseMessage();
     if (CanTriggerAnimations() && !string.IsNullOrEmpty(elements.animationTransitions.showTrigger))
     {
         elements.animator.SetTrigger(elements.animationTransitions.showTrigger);
     }
 }
		protected void DrawOnSelection(Usable usable, float distance, Selector.Reticle reticle, GUIStyle guiStyle, string defaultUseMessage,
		                               Color inRangeColor, Color outOfRangeColor, TextStyle textStyle, Color textStyleColor) {
			if (usable == null) return;
			if ((usable != lastUsable) || string.IsNullOrEmpty(heading)) {
				lastUsable = usable;
				heading = usable.GetName();
				useMessage = string.IsNullOrEmpty(usable.overrideUseMessage) ? defaultUseMessage : usable.overrideUseMessage;
			}
			GameObject selection = usable.gameObject;
			if (selection != lastSelectionDrawn) {
				selectionHeight = Tools.GetGameObjectHeight(selection);
				selectionHeadingSize = guiStyle.CalcSize(new GUIContent(heading));
				selectionUseMessageSize = guiStyle.CalcSize(new GUIContent(useMessage));
			}

			// Set text color based on distance:
			bool inUseRange = (distance <= usable.maxUseDistance);
			guiStyle.normal.textColor = inUseRange ? inRangeColor : outOfRangeColor;

			// Draw heading:
			Vector3 screenPos = Camera.main.WorldToScreenPoint(selection.transform.position + (Vector3.up * selectionHeight));
			screenPos += offset;
			screenPos = new Vector3(screenPos.x, screenPos.y + selectionUseMessageSize.y + selectionHeadingSize.y, screenPos.z);
			if (screenPos.z < 0) return;
			Rect rect = new Rect(screenPos.x - (selectionHeadingSize.x / 2), (Screen.height - screenPos.y) - (selectionHeadingSize.y / 2), selectionHeadingSize.x, selectionHeadingSize.y);
			UnityGUITools.DrawText(rect, heading, guiStyle, textStyle, textStyleColor);
			
			// Draw use message:
			screenPos = Camera.main.WorldToScreenPoint(selection.transform.position + (Vector3.up * (selectionHeight)));
			screenPos += offset;
			screenPos = new Vector3(screenPos.x, screenPos.y + selectionUseMessageSize.y, screenPos.z);
			rect = new Rect(screenPos.x - (selectionUseMessageSize.x / 2), (Screen.height - screenPos.y) - (selectionUseMessageSize.y / 2), selectionUseMessageSize.x, selectionUseMessageSize.y);
			UnityGUITools.DrawText(rect, useMessage, guiStyle, textStyle, textStyleColor);
			
			// Draw reticle:
			if (reticle != null) {
				Texture2D reticleTexture = inUseRange ? reticle.inRange : reticle.outOfRange;
				if (reticleTexture != null) {
					screenPos = Camera.main.WorldToScreenPoint(selection.transform.position + (Vector3.up * 0.5f * selectionHeight));
					rect = new Rect(screenPos.x - (reticle.width / 2), (Screen.height - screenPos.y) - (reticle.height / 2), reticle.width, reticle.height);
					GUI.Label(rect, reticleTexture);
				}
			}
		}
 private void ShowControls()
 {
     if (usable == null)
     {
         return;
     }
     Tools.SetGameObjectActive(mainGraphic, true);
     Tools.SetGameObjectActive(nameText, true);
     Tools.SetGameObjectActive(useMessageText, true);
     if (nameText != null)
     {
         nameText.text = usable.GetName();
     }
     if (useMessageText != null)
     {
         useMessageText.text = GetUseMessage();
     }
     if (CanTriggerAnimations() && !string.IsNullOrEmpty(animationTransitions.showTrigger))
     {
         animator.SetTrigger(animationTransitions.showTrigger);
     }
 }
Ejemplo n.º 11
0
		private void SetCurrentUsable(Usable usable) {
			currentUsable = usable;
			if (usable != null) {
				currentHeading = currentUsable.GetName();
				currentUseMessage = string.IsNullOrEmpty(currentUsable.overrideUseMessage) ? defaultUseMessage : currentUsable.overrideUseMessage;
			} else {
				currentHeading = string.Empty;
				currentUseMessage = string.Empty;
			}
		}
Ejemplo n.º 12
0
		private void OnSelectedUsable(Usable usable) {
			this.usable = usable;
			if (mainControl != null) NGUITools.SetActive(mainControl.gameObject, true);
			if (nameLabel != null) {
				NGUITools.SetActive(nameLabel.gameObject, true);
				nameLabel.text = usable.GetName();
			}
			if (useMessageLabel != null) {
				NGUITools.SetActive(useMessageLabel.gameObject, true);
				useMessageLabel.text = string.IsNullOrEmpty(usable.overrideUseMessage) ? defaultUseMessage : usable.overrideUseMessage;
			}
			UpdateReticle();
		}