示例#1
0
        private void HitNote(NoteIcon icon, int index)
        {
            icon.OnHit();

            if (!longNote)
            {
                DestroyIcon(index);
            }

            // TODO: Mostrar más claramente que acertamos con la nota
        }
示例#2
0
                public override void RemoveFromView(object obj)
                {
                    Anchor.RemoveAsSubview(obj);
                    TextView.RemoveAsSubview(obj);
                    NoteIcon.RemoveAsSubview(obj);
                    UtilityLayer.RemoveAsSubview(obj);
                    DeleteButton.RemoveAsSubview(obj);
                    CloseButton.RemoveAsSubview(obj);

                    TryRemoveDebugLayer(obj);
                }
示例#3
0
                public override void AddToView(object obj)
                {
                    Anchor.AddAsSubview(obj);
                    TextView.AddAsSubview(obj);
                    NoteIcon.AddAsSubview(obj);
                    UtilityLayer.AddAsSubview(obj);
                    DeleteButton.AddAsSubview(obj);
                    CloseButton.AddAsSubview(obj);

                    TryAddDebugLayer(obj);
                }
示例#4
0
        private void DestroyIcon(int number)
        {
            NoteIcon icon = noteIcons[number];

            if (icon)
            {
                // Destruimos el objeto y asignamos la referencia en el array a null
                Destroy(icon.gameObject);
                noteIcons[number] = null;

                // Si todos los íconos de este grupo se borran
                // simplemente borramos este grupo
                noteCount--;
                if (noteCount <= 0)
                {
                    Remove();
                }
            }
        }
示例#5
0
        private void OnIconEvent(NoteEventType eventType, int note)
        {
            //Debug.Log("Event = " + eventType + ":" + note);
            // Busca una instancia de ícono que tenga el mismo índice que se le pasó
            NoteIcon icon = noteIcons[note];

            // Revisa si encontró una nota con el mismo índice para continuar con el método
            if (icon == null)
            {
                return;
            }

            // En función del parámetro eventType, actualiza el ícono
            switch (eventType)
            {
            case NoteEventType.Hit:
                HitNote(icon, note);
                break;

            case NoteEventType.Miss:
                icon.OnMiss(owner.missColor);
                // TODO: Mostrar más claramente que fallamos esa nota
                break;

            case NoteEventType.Release:
                icon.OnRelease();
                icon.OnMiss(owner.missColor);
                break;

            case NoteEventType.NextNote:
                icon.OnNextNote();
                break;
            }

            owner.noteIndicators[note].OnIconEvent(eventType);
        }
示例#6
0
                void AnimateNoteIcon(bool open)
                {
                    SizeF startSize = NoteIcon.Bounds.Size;
                    SizeF endSize;

                    PointF startPos = NoteIcon.Position;
                    PointF endPos   = GetNoteIconPos(open);

                    float startTypeSize;
                    float endTypeSize;

                    float animTime = .2f;

                    // the text must always be smaller than the bounding box,
                    // so we'll scale the typeSize anim time to be FASTER when opening
                    // and SLOWER when closing.
                    float sizeAnimTimeScalar;

                    // setup the target values based on whether we're opening or closing
                    if (open == true)
                    {
                        endSize = NoteIconOpenSize;

                        startTypeSize = PrivateNoteConfig.UserNote_IconClosedSize;
                        endTypeSize   = PrivateNoteConfig.UserNote_IconOpenSize;

                        sizeAnimTimeScalar = .95f;
                    }
                    else
                    {
                        endSize = NoteIconClosedSize;

                        startTypeSize = PrivateNoteConfig.UserNote_IconOpenSize;
                        endTypeSize   = PrivateNoteConfig.UserNote_IconClosedSize;

                        sizeAnimTimeScalar = 1.05f;
                    }

                    // size...
                    SimpleAnimator_SizeF sizeAnimator = new SimpleAnimator_SizeF(startSize, endSize, animTime,
                                                                                 delegate(float percent, object value)
                    {
                        SizeF currSize  = (SizeF)value;
                        NoteIcon.Bounds = new RectangleF(0, 0, currSize.Width, currSize.Height);
                    }, null);

                    sizeAnimator.Start( );

                    // pos...
                    SimpleAnimator_PointF posAnimator = new SimpleAnimator_PointF(startPos, endPos, animTime,
                                                                                  delegate(float percent, object value)
                    {
                        NoteIcon.Position = (PointF)value;
                    }, null);

                    posAnimator.Start( );

                    // font typesize...
                    SimpleAnimator_Float floatAnimator = new SimpleAnimator_Float(startTypeSize, endTypeSize, animTime * sizeAnimTimeScalar,
                                                                                  delegate(float percent, object value)
                    {
                        NoteIcon.SetFont(PrivateControlStylingConfig.Icon_Font_Secondary, (float)value);
                    }, null);

                    floatAnimator.Start( );
                }
示例#7
0
                void Create(CreateParams parentParams, float deviceHeight, PointF startPos, string startingText, UserNoteChanged onUserNoteChanged)
                {
                    Initialize( );

                    OnUserNoteChanged = onUserNoteChanged;

                    PositionTransform = new PointF(parentParams.Width, parentParams.Height);

                    //setup our timer for allowing movement/

                    /*DeleteTimer = new System.Timers.Timer();
                     * DeleteTimer.Interval = 1000;
                     * DeleteTimer.Elapsed += DeleteTimerDidFire;
                     * DeleteTimer.AutoReset = false;*/

                    // take the UserNote default style, because they aren't part of the XML stream and have nothing to inherit.
                    mStyle = ControlStyles.mUserNote;

                    // flag that we want this text field to grow as more text is added
                    TextView.ScaleHeightForText = true;

                    // Setup the font
                    TextView.SetFont(mStyle.mFont.mName, mStyle.mFont.mSize.Value);
                    TextView.TextColor            = mStyle.mFont.mColor.Value;
                    TextView.Placeholder          = MessagesStrings.UserNote_Placeholder;
                    TextView.PlaceholderTextColor = ControlStylingConfig.TextField_PlaceholderTextColor;
                    TextView.KeyboardAppearance   = GeneralConfig.iOSPlatformUIKeyboardAppearance;
                    TextView.SetOnEditCallback(
                        delegate(PlatformTextView textView)
                    {
                        InvokeChangedCallback( );
                    });

                    // check for border styling
                    if (mStyle.mBorderColor.HasValue)
                    {
                        TextView.BorderColor = mStyle.mBorderColor.Value;
                    }

                    if (mStyle.mBorderRadius.HasValue)
                    {
                        TextView.CornerRadius = mStyle.mBorderRadius.Value;
                    }

                    if (mStyle.mBorderWidth.HasValue)
                    {
                        TextView.BorderWidth = mStyle.mBorderWidth.Value;
                    }

                    if (mStyle.mBackgroundColor.HasValue)
                    {
                        TextView.BackgroundColor = mStyle.mBackgroundColor.Value;
                    }

                    // Setup the anchor BG
                    int area = (int)Rock.Mobile.Graphics.Util.UnitToPx(50);

                    Anchor.BackgroundColor = NoteConfig.UserNote_AnchorColor;
                    Anchor.Bounds          = new RectangleF(0, 0, area, area);

                    // Setup the anchor color
                    NoteIcon.Text      = PrivateNoteConfig.UserNote_Icon;
                    NoteIcon.TextColor = mStyle.mFont.mColor.Value;//NoteConfig.UserNote_IconColor;

                    // get the small and large sizes for the note icon, so we can animate correctly
                    NoteIcon.SetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.UserNote_IconOpenSize);
                    NoteIcon.Bounds = new RectangleF(0, 0, area, 0);
                    NoteIcon.SizeToFit();
                    NoteIconOpenSize = NoteIcon.Bounds.Size;

                    NoteIcon.SetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.UserNote_IconClosedSize);
                    NoteIcon.Bounds = new RectangleF(0, 0, area, 0);
                    NoteIcon.SizeToFit( );
                    NoteIconClosedSize = NoteIcon.Bounds.Size;
                    ////


                    // store the width of the screen so we know
                    // what the remaining width is when moving the note around.
                    ScreenWidth = parentParams.Width * .95f;

                    // Don't let the note's width be less than twice the anchor width. Any less
                    // and we end up with text clipping.
                    MinNoteWidth = (Anchor.Bounds.Width * 2);

                    // Dont let the note be any wider than the screen - twice the min width. This allows a little
                    // free play so it doesn't feel like the note is always attached to the right edge.
                    MaxNoteWidth = Math.Min(ScreenWidth - MinNoteWidth, (MinNoteWidth * 6));

                    // set the allowed X/Y so we don't let the user move the note off-screen.

                    // for x, we need 3 values. Open, Closed, and current
                    MaxAllowedX_Open   = (ScreenWidth - MinNoteWidth - Anchor.Bounds.Width);
                    MaxAllowedX_Closed = (ScreenWidth - Anchor.Bounds.Width);

                    CurrMaxAllowedX = MaxAllowedX_Open;


                    MaxAllowedY  = (parentParams.Height - Anchor.Bounds.Height);
                    MaxAllowedY *= 1.05f;

                    float width = Math.Max(MinNoteWidth, Math.Min(MaxNoteWidth, MaxAllowedX_Open - startPos.X));

                    TextView.Bounds = new RectangleF(0, 0, width, 0);

                    UtilityLayer.BackgroundColor = TextView.BackgroundColor;
                    UtilityLayer.CornerRadius    = TextView.CornerRadius;
                    UtilityLayer.BorderWidth     = TextView.BorderWidth;
                    UtilityLayer.BorderColor     = TextView.BorderColor;
                    UtilityLayer.Bounds          = new RectangleF(0, 0, MinNoteWidth, 0);

                    // setup the delete button
                    DeleteButton.Text      = PrivateNoteConfig.UserNote_DeleteIcon;
                    DeleteButton.TextColor = mStyle.mFont.mColor.Value;//NoteConfig.UserNote_IconColor;
                    DeleteButton.SetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.UserNote_DeleteIconSize);
                    DeleteButton.SizeToFit( );

                    // setup the close button
                    CloseButton.Text      = PrivateNoteConfig.UserNote_CloseIcon;
                    CloseButton.TextColor = mStyle.mFont.mColor.Value;//NoteConfig.UserNote_IconColor;
                    CloseButton.SetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.UserNote_CloseIconSize);
                    CloseButton.SizeToFit( );



                    // Setup the initial positions
                    Anchor.Position = startPos;
                    AnchorFrame     = Anchor.Frame;

                    AnchorTouchMaxDist  = AnchorFrame.Width / 2;
                    AnchorTouchMaxDist *= AnchorTouchMaxDist;

                    NoteIcon.Position = new PointF(Anchor.Frame.Left + (Anchor.Frame.Width - NoteIconClosedSize.Width) / 2,
                                                   Anchor.Frame.Top + (Anchor.Frame.Height - NoteIconClosedSize.Height) / 2);

                    // set the actual note TextView relative to the anchor
                    TextView.Position = new PointF(AnchorFrame.Left + AnchorFrame.Width / 2,
                                                   AnchorFrame.Top + AnchorFrame.Height / 2);

                    UtilityLayer.Position = new PointF((TextView.Position.X + width) - UtilityLayer.Bounds.Width,
                                                       TextView.Position.Y - Rock.Mobile.Graphics.Util.UnitToPx(UtilityLayerHeight) + 1);

                    // set the position for the delete button
                    DeleteButton.Position = new PointF(UtilityLayer.Position.X + DeleteButton.Bounds.Width / 2,
                                                       UtilityLayer.Position.Y + (Rock.Mobile.Graphics.Util.UnitToPx(UtilityLayerHeight) - DeleteButton.Bounds.Height) / 2);

                    CloseButton.Position = new PointF(UtilityLayer.Frame.Right - (CloseButton.Bounds.Width + (CloseButton.Bounds.Width / 2)),
                                                      UtilityLayer.Position.Y + (Rock.Mobile.Graphics.Util.UnitToPx(UtilityLayerHeight) - CloseButton.Bounds.Height) / 2);

                    // validate its bounds
                    ValidateBounds( );


                    // set the starting text if it was provided
                    if (startingText != null)
                    {
                        TextView.Text = startingText;
                    }

                    TextView.Hidden = true;

                    SetDebugFrame(TextView.Frame);
                }