Exemple #1
0
 internal ScoreMessage PushWorldInternal(ScoreFlashFollow3D follow3D, object message, bool enqueueMessage)
 {
     // follow3D.keepStatic is ignored in the specific case
     return PushLocal(message, null, null, null, enqueueMessage ? (int?) follow3D.GetInstanceID() : null, follow3D);
 }
Exemple #2
0
 private ScoreMessage PushWorld(ScoreFlashFollow3D follow3D, object message, Color? color, GUIStyle style, GUIStyle styleHighDensity)
 {
     if (!follow3D.keepStatic) {
         return PushLocal(message, color, style, styleHighDensity, follow3D.GetInstanceID(), follow3D);
     } else {
         Vector3 worldPosition = follow3D.GetLocation().CurrentTranslatedPosition;
         Vector2 screenOffset = follow3D.GetLocation().CurrentScreenOffset;
         ScoreMessage msg = PushWorld(worldPosition, screenOffset, message, color, style, styleHighDensity, follow3D.GetInstanceID());
         return msg;
     }
 }
Exemple #3
0
 /// <summary>
 ///     See <see cref="IScoreFlash.PushWorld(ScoreFlashFollow3D, object, GUIStyle, GUIStyle)"/>!
 /// </summary>
 /// <param name="follow3D">See <see cref="IScoreFlash.PushWorld(ScoreFlashFollow3D, object, GUIStyle, GUIStyle)"/>!</param>
 /// <param name="message">See <see cref="IScoreFlash.PushLocal(object, GUIStyle, GUIStyle, int)"/>!</param>
 /// <param name="style">See <see cref="IScoreFlash.PushLocal(object, GUIStyle, GUIStyle, int)"/>!</param>
 /// <param name="styleHighDensity">See <see cref="IScoreFlash.PushLocal(object, GUIStyle, GUIStyle, int)"/>!</param>
 /// <returns>the ScoreMessage representing the message</returns>
 public ScoreMessage PushWorld(ScoreFlashFollow3D follow3D, object message, GUIStyle style, GUIStyle styleHighDensity)
 {
     return PushWorld(follow3D, message, null, style, styleHighDensity);
 }
Exemple #4
0
    internal ScoreMessage PushLocal(object message,
            Color? color, GUIStyle style, GUIStyle styleHighDensity,
            int? messageQueueID, ScoreFlashFollow3D follow3D)
    {
        // Unity fails on compiling: (int)ScoreFlash.DefaultMessageQueueID.Default

        // if this instance of ScoreFlash is not enabled - there's no point in registering the message
        if (!this.enabled) {
            return new ScoreMessage(this, this, message);
        }

        #region Initializing the Message

        // note: messageQueueID null => do not put the message in the queue (used internally)
        // if we have a value here, we're never in the scene view => false
        if (messageQueueID.HasValue) {
            SetIsSceneView(false);
        }

        IHasVisualDesigner scoreFlashLayout = this;
        if (message is ScoreFlashLayout) {
            ScoreFlashLayout sender = (ScoreFlashLayout)message;
            scoreFlashLayout = sender;
            message = sender.MessageForScoreFlash;
        }

        ScoreMessage msg = new ScoreMessage(this, scoreFlashLayout, message);

        if (follow3D != null) {
            msg.SetScoreFlashFollow3D(follow3D);
            if (msg.FollowLocation != null && !allFollow3Ds.Contains(msg.FollowLocation)) {
                allFollow3Ds.Add(msg.FollowLocation);
            }
        }

        msg.isDebug = isDebugMode;
        msg.pos = NGUtil.Scale(new Vector2(fadeInOffsetX, fadeInOffsetY));
        msg.rotationSpeed = fadeOutInitialRotationSpeed;
        msg.useRealTime = timeReference == TimeReference.UseRealTime;

        if (msg.scoreFlashRenderer == null) {
            if (rendering == RenderingType.CustomRenderer && scoreFlashRenderer != null) {
                // do we still have objects in the pool? if so => take on from there ;-)
                ScoreFlashRendererBase objectFromPool = GetRendererFromPool();
                if (objectFromPool != null) {
                    msg.scoreFlashRenderer = objectFromPool;
                } else {
                    Transform parent = scoreFlashRenderer.RequiresCustomParent && customParent != null
                        ? customParent : this.transform;
                    msg.scoreFlashRenderer = scoreFlashRenderer.CreateInstance(parent);
                    msg.scoreFlashRenderer.name = string.Format("Renderer_{0:0000}", rendererIndex++);
                }
            }
        } else { // if we have a renderer "delivered" with the message, do the parent assignment now
            if (scoreFlashRenderer.RequiresCustomParent && customParent != null) {
                msg.scoreFlashRenderer.transform.SetParent(customParent);
            } else {
                msg.scoreFlashRenderer.transform.SetParent(this.transform);
            }
        }

        // if a style is passed to the method, this overwrites the font definition!
        if (style == null && rendering == RenderingType.UnityGUI_Font) {
            style = GetStyleFromPool();
            style.font = CurrentFont;
            style.normal.textColor = Color.white;
            style.alignment = (TextAnchor)NGAlignment.ConvertAlignment(msg.InnerAnchor, NGAlignment.AlignmentType.TextAnchor);
            style.wordWrap = false;
        }

        // if we are using UnityGUI, the following is relevant ...
        if (style == null) {
            if (CurrentSkin == null && msg.scoreFlashRenderer == null) {
                Debug.LogError(
                    string.Format(
                    "You have not assigned a GUISkin and called PushLocal without a style - this won't work! "
                    + "Either assign a GUISkin to ScoreFlash, or use one of the Push-methods that take a "
                    + "GUIStyle as parameter! Message '{0}' will not be shown!", message), this);
                return msg;
            }

            if (CurrentSkin != null) {
                if (CurrentSkin.FindStyle(guiStyleName) == null) {
                    if (!hasWarnedMissingCustomStyle) {
                        Debug.LogWarning(
                            string.Format("Your GUISkin does not have custom style '{0}' - please add that custom style "
                            + "and configure it with your desired font. Using label style instead!", guiStyleName),
                            CurrentSkin);
                        hasWarnedMissingCustomStyle = true;
                    }
                    style = GetStyleFromPool(CurrentSkin.label);
                } else {
                    style = GetStyleFromPool(CurrentSkin.FindStyle(guiStyleName));
                }
                // we need these two and people (including myself) forget to assign them => hardcode it!
                //style.alignment = TextAnchor.UpperCenter; // this is now overridden with innerAnchor

                // this may be overridden when the message exceeds maxWidth
                style.wordWrap = false;
            }
        }
        if (styleHighDensity == null) {
            styleHighDensity = style;
        }

        // this is just an initial reference position - it may be overwritten later!
        if (follow3D == null) {
            msg.ScreenAlign = scoreFlashLayout.ScreenAlign;
            msg.InnerAnchor = scoreFlashLayout.LockInnerAnchor ? msg.ScreenAlign : scoreFlashLayout.InnerAnchor;
            msg.OriginalPosition = NGAlignment.GetScreenBasedReferencePosition(msg.ScreenAlign, Vector2.zero, IsSceneView);
            msg.ReferencePosition = NGAlignment.GetScreenBasedReferencePosition(msg.ScreenAlign, scoreFlashLayout.Position, IsSceneView);
        }

        if (style != null) {
            AssignStyle(msg, style, styleHighDensity);
        }

        if (!color.HasValue) {
            AssignColors(msg);
        } else {
            AssignAlphaMultipliedColor(msg, color.Value);
        }

        // when passing a custom renderer, don't use the one ScoreFlash might define
        if (msg.scoreFlashRenderer != null) {
            // this is put down here because ScoreFlashRendererUnityGUI needs the style to calculate the size
            msg.scoreFlashRenderer.Initialize(msg);
            Rect pos = msg.Position;
            Vector2 size = msg.scoreFlashRenderer.GetSize(msg);
            pos.width = size.x;
            pos.height = size.y;
            msg.Position = pos;
        }

        if (messageQueueID.HasValue) {
            if (!scoreMessages.ContainsKey(messageQueueID.Value)) {
                scoreMessages[messageQueueID.Value] = new NGQueue<ScoreMessage>();
            }
            NGQueue<ScoreMessage> messageQueue = scoreMessages[messageQueueID.Value];

            messageQueue.Enqueue(msg);
            if (messageQueue.Count > maxSimultanuousMessages) {
                messageQueue.QueueOrderedList[messageQueue.Count - maxSimultanuousMessages - 1].LocalTimeScale = 8;
            }

            AnimateMessages(); // make sure everything is immediately initialized
        #if LOGGING_FACADE // if narayana games Logging Facade is available, we add some logging
        log.DebugFormat("Received score message: '{0}'", msg.Text);
        #endif
        }

        return msg;
        #endregion Initializing the Message
    }
Exemple #5
0
 /// <summary>
 ///     See <see cref="IScoreFlash.PushWorld(ScoreFlashFollow3D, object, GUIStyle, GUIStyle)"/>!
 /// </summary>
 /// <param name="follow3D">See <see cref="IScoreFlash.PushWorld(ScoreFlashFollow3D, object, GUIStyle, GUIStyle)"/>!</param>
 /// <param name="message">See <see cref="IScoreFlash.PushLocal(object, GUIStyle, GUIStyle, int)"/>!</param>
 /// <param name="style">See <see cref="IScoreFlash.PushLocal(object, GUIStyle, GUIStyle, int)"/>!</param>
 /// <returns>the ScoreMessage representing the message</returns>
 public ScoreMessage PushWorld(ScoreFlashFollow3D follow3D, object message, GUIStyle style)
 {
     return PushWorld(follow3D, message, style, style);
 }
Exemple #6
0
 /// <summary>
 ///     See <see cref="IScoreFlash.PushWorld(ScoreFlashFollow3D, object, Color)"/>!
 /// </summary>
 /// <param name="follow3D">See <see cref="IScoreFlash.PushWorld(ScoreFlashFollow3D, object, Color)"/>!</param>
 /// <param name="message">See <see cref="IScoreFlash.PushWorld(ScoreFlashFollow3D, object, Color)"/>!</param>
 /// <param name="color">See <see cref="IScoreFlash.PushLocal(object, Color, int)"/>!</param>
 /// <returns>the ScoreMessage representing the message</returns>
 public ScoreMessage PushWorld(ScoreFlashFollow3D follow3D, object message, Color color)
 {
     return PushWorld(follow3D, message, color, null, null);
 }
Exemple #7
0
 /// <summary>
 ///     See <see cref="IScoreFlash.PushWorld(ScoreFlashFollow3D, object, GUIStyle, GUIStyle)"/>!
 /// </summary>
 /// <param name="follow3D">See <see cref="IScoreFlash.PushWorld(ScoreFlashFollow3D, object, GUIStyle, GUIStyle)"/>!</param>
 /// <param name="message">See <see cref="IScoreFlash.PushLocal(object, GUIStyle, GUIStyle, int)"/>!</param>
 /// <returns>the ScoreMessage representing the message</returns>
 public ScoreMessage PushWorld(ScoreFlashFollow3D follow3D, object message)
 {
     return PushWorld(follow3D, message, null);
 }
Exemple #8
0
 /// <summary>
 ///     Used to follow a 3D object. Set by ScoreFlash when a message is
 ///     pushed.
 /// </summary>
 /// <param name="follow3D">a helper object used to follow a game object</param>
 internal void SetScoreFlashFollow3D(ScoreFlashFollow3D follow3D)
 {
     innerAnchor = follow3D.innerAnchor;
     followLocation = follow3D.GetLocation();
 }
 internal ScoreFlashFollow3DLocation(ScoreFlashFollow3D target)
 {
     this.target = target;
     Init();
 }