예제 #1
0
        public void Awake()
        {
            Button             = GetComponent <Button>();
            Tooltip            = GetComponent <UITooltip>();
            SelectedBackground = transform.Find("Selected").gameObject;
            SelectedBackground.SetActive(false);
            Icon            = transform.Find("Icon").GetComponent <Image>();
            NameText        = transform.Find("Name").GetComponent <Text>();
            RewardLabel     = transform.Find("Rewards/RewardLabel").gameObject;
            InProgressLabel = transform.Find("Rewards/InProgressLabel").gameObject;
            CompleteLabel   = transform.Find("Rewards/CompleteLabel").gameObject;
            RewardTextIron  = transform.Find("Rewards/IronElement/Amount").GetComponent <Text>();
            RewardTextGold  = transform.Find("Rewards/GoldElement/Amount").GetComponent <Text>();

            var iconMaterial = StoreGui.instance.m_listElement.transform.Find("icon").GetComponent <Image>().material;

            if (iconMaterial != null)
            {
                Icon.material = iconMaterial;
            }
        }
예제 #2
0
        public void Awake()
        {
            Button             = GetComponent <Button>();
            Tooltip            = GetComponent <UITooltip>();
            SelectedBackground = transform.Find("Selected").gameObject;
            SelectedBackground.SetActive(false);
            Icon           = transform.Find("Icon").GetComponent <Image>();
            NameText       = transform.Find("Name").GetComponent <Text>();
            PriceContainer = transform.Find("Price").gameObject;
            PriceContainer.SetActive(true);
            PurchasedLabel = transform.Find("Purchased").gameObject;
            PurchasedLabel.SetActive(false);
            CoinsCostText = transform.Find("Price/PriceElementCoins/Amount").GetComponent <Text>();

            var iconMaterial = InventoryGui.instance.m_dragItemPrefab.transform.Find("icon").GetComponent <Image>().material;

            if (iconMaterial != null)
            {
                Icon.material = iconMaterial;
            }
        }
예제 #3
0
        public void Awake()
        {
            Button             = GetComponent <Button>();
            Tooltip            = GetComponent <UITooltip>();
            SelectedBackground = transform.Find("Selected").gameObject;
            SelectedBackground.SetActive(false);
            Icon                    = transform.Find("Icon").GetComponent <Image>();
            MagicBG                 = transform.Find("MagicBG").GetComponent <Image>();
            NameText                = transform.Find("Name").GetComponent <Text>();
            CoinsCostText           = transform.Find("Price/Coins/Amount").GetComponent <Text>();
            ForestTokenCostText     = transform.Find("Price/ForestTokens/Amount").GetComponent <Text>();
            IronBountyTokenCostText = transform.Find("Price/IronBountyToken/Amount").GetComponent <Text>();
            GoldBountyTokenCostText = transform.Find("Price/GoldBountyToken/Amount").GetComponent <Text>();

            var iconMaterial = StoreGui.instance.m_listElement.transform.Find("icon").GetComponent <Image>().material;

            if (iconMaterial != null)
            {
                Icon.material    = iconMaterial;
                MagicBG.material = iconMaterial;
            }
        }
예제 #4
0
        /// <summary>
        /// Draw the specified canvas.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        /// <param name="rect">Rect.</param>
        public void DrawCalendar(NGraphics.ICanvas canvas, NGraphics.Rect rect)
        {
            _monthYearLabel.Text = _currentMonth.ToString("MMMMM yyyy");

            base.Draw(canvas, rect);

            // Should we use last line?
            // var drawLastLine = true;

            var colWidth    = rect.Width / 7;
            var rowHeight   = rect.Height / 6;
            var hasEmptyRow = false;

            // Find first week of day
            var firstWeekDay = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
            var date         = _currentMonth;

            while (date.DayOfWeek != firstWeekDay)
            {
                date = date.AddDays(-1);
            }
            _firstDate = date;

            // Set up brushes
            var selectedBrush   = new NGraphics.SolidBrush(SelectedBackground.ToNColor());
            var regularBrush    = new NGraphics.SolidBrush(RegularBackground.ToNColor());
            var weekendBrush    = new NGraphics.SolidBrush(WeekendBackground.ToNColor());
            var notInMonthBrush = new NGraphics.SolidBrush(NotInMonthBackground.ToNColor());
            var disabledBrush   = new NGraphics.SolidBrush(DisabledBackground.ToNColor());

            var col = 0;
            var row = 0;

            for (int d = 0; d < _dayNumberLabels.Length; d++)
            {
                // Update text
                var label = _dayNumberLabels[d];
                label.XAlign = TextAlignment.Center;
                label.YAlign = TextAlignment.Center;

                if (hasEmptyRow || (date.DayOfWeek == firstWeekDay && date >= _currentMonth.AddMonths(1)))
                {
                    hasEmptyRow     = true;
                    label.IsVisible = false;
                }
                else
                {
                    label.IsVisible = true;
                    label.Text      = date.Day.ToString();
                    _lastDate       = date;

                    if (HighlightDisabled && (date < MinDate - MinDate.TimeOfDay || date > MaxDate))
                    {
                        _dayNumberLabels[d].TextColor = DisabledColor;
                        canvas.DrawRectangle(new NGraphics.Rect(col * colWidth, row * rowHeight,
                                                                colWidth, rowHeight), null, disabledBrush);
                    }
                    else if (IsSameDay(SelectedDate, date))
                    {
                        // Selected date
                        _dayNumberLabels[d].TextColor = SelectedColor;
                        canvas.DrawRectangle(new NGraphics.Rect(col * colWidth, row * rowHeight,
                                                                colWidth, rowHeight), null, selectedBrush);
                    }
                    else if (date.Month != _currentMonth.Month)
                    {
                        // Prev/next month
                        _dayNumberLabels[d].TextColor = NotInMonthColor;
                        canvas.DrawRectangle(new NGraphics.Rect(col * colWidth, row * rowHeight, colWidth, rowHeight), null, notInMonthBrush);
                    }
                    else if (date.DayOfWeek == DayOfWeek.Sunday || date.DayOfWeek == DayOfWeek.Saturday)
                    {
                        // Weekends
                        _dayNumberLabels[d].TextColor = WeekendColor;
                        canvas.DrawRectangle(new NGraphics.Rect(col * colWidth, row * rowHeight, colWidth, rowHeight), null, weekendBrush);
                    }
                    else
                    {
                        // Regular days
                        _dayNumberLabels [d].TextColor = RegularColor;
                        canvas.DrawRectangle(new NGraphics.Rect(col * colWidth, row * rowHeight, colWidth, rowHeight), null, regularBrush);
                    }


                    if (IsSameDay(DateTime.Now, date))
                    {
                        // Today

                        // Background and color if not selected
                        if (!IsSameDay(SelectedDate, date))
                        {
                            _dayNumberLabels[d].TextColor = TodayColor;

                            var wh = Math.Min(colWidth, rowHeight);
                            var dx = (colWidth - wh) / 2;
                            var dy = (rowHeight - wh) / 2;
                            var rc = new NGraphics.Rect((col * colWidth) + dx, (row * rowHeight) + dy, wh, wh);
                            rc.Inflate(-1, -1);

                            canvas.DrawEllipse(rc, null, new NGraphics.SolidBrush(TodayBackground.ToNColor()));
                        }
                        else
                        {
                            _dayNumberLabels[d].TextColor = TodayBackground;
                        }
                    }
                }

                // Col/row-counter
                col++;
                if (col == 7)
                {
                    col = 0;
                    row++;
                }

                date = date.AddDays(1);
            }

            var colRowPen = new NGraphics.Pen(GridColor.ToNColor(), 1);

            // Draw row lines
            for (var r = 0; r < (hasEmptyRow ? 6 : 7); r++)
            {
                canvas.DrawPath(new NGraphics.PathOp[] {
                    new NGraphics.MoveTo(0, r * rowHeight),
                    new NGraphics.LineTo(rect.Width, r * rowHeight)
                }, colRowPen);
            }

            // Draw col lines
            for (var c = 0; c < 7; c++)
            {
                canvas.DrawPath(new NGraphics.PathOp[] {
                    new NGraphics.MoveTo(c * colWidth, 0),
                    new NGraphics.LineTo(c * colWidth, hasEmptyRow ? rect.Height - rowHeight : rect.Height)
                }, colRowPen);
            }
        }