Пример #1
0
 public ChangeInfo SetIconText(StringBuilder newIconText)
 {
     if (newIconText == null)
     {
         return(ChangeInfo.None);
     }
     if (IconText.CompareTo(newIconText) == 0)
     {
         return(ChangeInfo.None);
     }
     IconText.Clear();
     IconText.AppendStringBuilder(newIconText);
     return(ChangeInfo.IconText);
 }
Пример #2
0
        private void ParseMuniRoute(NextbusRoute routeData)
        {
            if (routeData.Title.Contains("-"))
            {
                Title = routeData.Title.Split(new char[] { '-' }, 2)[1];
            }

            if (new string[] { "59, 60, 61" }.Any(routeData.Tag.Contains))
            {
                // Cable Car lines
                IconText = "CC";
                Color    = _routeColorDictionary["CC"];
            }
            else if (routeData.Tag.Contains("_OWL"))
            {
                // OWL Lines
                Color    = _routeColorDictionary["OWL"];
                IconText = routeData.Tag.Replace("_", "");
                Title    = routeData.Title;
            }
            else
            {
                IconText = routeData.Tag;

                if (_routeColorDictionary.ContainsKey(IconText))
                {
                    Color = _routeColorDictionary[IconText];
                }
                else if (IconText.EndsWith("X"))
                {
                    Color = _routeColorDictionary["X"];
                }
                else if (IconText.EndsWith("R"))
                {
                    Color = _routeColorDictionary["R"];
                }
                else
                {
                    Color = _routeColorDictionary["Local"];
                }
            }
        }
        public override ChangeInfo Update(MyEntity owner, long playerID = 0)
        {
            bool       thisWeaponIsCurrent    = false;
            bool       shipHasThisWeapon      = false;
            var        character              = MySession.LocalCharacter;
            bool       characterHasThisWeapon = character != null && (character.GetInventory().ContainItems(1, Definition.Id) || !character.WeaponTakesBuilderFromInventory(Definition.Id));
            ChangeInfo changed = ChangeInfo.None;

            if (characterHasThisWeapon)
            {
                var currentWeapon = character.CurrentWeapon;
                if (currentWeapon != null)
                {
                    thisWeaponIsCurrent = (MyDefinitionManager.Static.GetPhysicalItemForHandItem(currentWeapon.DefinitionId).Id == Definition.Id);
                }
                if (thisWeaponIsCurrent && currentWeapon is MyAutomaticRifleGun)
                {
                    int amount = character.CurrentWeapon.GetAmmunitionAmount();
                    if (m_lastAmmoCount != amount)
                    {
                        m_lastAmmoCount = amount;
                        IconText.Clear().AppendInt32(amount);
                        changed |= ChangeInfo.IconText;
                    }
                }
            }

            var shipControler = MySession.ControlledEntity as MyShipController;

            if (shipControler != null && shipControler.GridSelectionSystem.WeaponSystem != null)
            {
                //    var shipWeaponType = shipControler.GetWeaponType(Definition.Id.TypeId);
                //    shipHasThisWeapon = shipWeaponType.HasValue && shipControler.GridSelectionSystem.WeaponSystem.HasGunsOfId(shipWeaponType.Value);
                shipHasThisWeapon = shipControler.GridSelectionSystem.WeaponSystem.HasGunsOfId(Definition.Id);
                if (shipHasThisWeapon)
                {
                    IMyGunObject <MyDeviceBase> gunObject = shipControler.GridSelectionSystem.WeaponSystem.GetGun(Definition.Id);
                    if (gunObject.GunBase is MyGunBase)
                    {
                        int ammo = 0;
                        foreach (var gun in shipControler.GridSelectionSystem.WeaponSystem.GetGunsById(Definition.Id))
                        {
                            ammo += gun.GetAmmunitionAmount();
                        }
                        if (ammo != m_lastAmmoCount)
                        {
                            m_lastAmmoCount = ammo;
                            IconText.Clear().AppendInt32(ammo);
                            changed |= ChangeInfo.IconText;
                        }
                    }
                }

                thisWeaponIsCurrent = shipControler.GridSelectionSystem.GetGunId() == Definition.Id;
            }

            changed               |= SetEnabled(characterHasThisWeapon || shipHasThisWeapon);
            WantsToBeSelected      = thisWeaponIsCurrent;
            m_needsWeaponSwitching = !thisWeaponIsCurrent;
            return(changed);
        }
Пример #4
0
        /// <summary>
        /// Draw text on board
        /// </summary>
        void DrawText()
        {
            var centerX = canvasTitle.CanvasSize.Width / 2f;
            var centerY = canvasTitle.CanvasSize.Height / 2f;

            string versionString = "";

            if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.iOS)
            {
                versionString = Xamarin.Forms.DependencyService.Get <Interfaces.InterfaceVersioning>().GetBuildString();
            }
            else if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.Android)
            {
                versionString = Xamarin.Forms.DependencyService.Get <Interfaces.InterfaceVersioning>().GetVersionString();
            }

            #region Upper Text

            var topText = new IconText("Developed by Shawn Gilroy (C) 2017 " + string.Format("({0})", versionString))
            {
                Size      = new SKSize(canvasTitle.CanvasSize.Width, canvasTitle.CanvasSize.Height / 10f),
                ForeColor = SKColors.White,
                FontSize  = textSize,
            };

            topText.X = centerX - topText.Width / 2f;
            topText.Y = topText.Height / 2f;

            canvasTitle.Controller.Icons.Add(topText);

            var subText = new IconText("Released under the Mozilla Public License, Version 2.0")
            {
                Size      = new SKSize(canvasTitle.CanvasSize.Width, canvasTitle.CanvasSize.Height / 10f),
                ForeColor = SKColors.White,
                FontSize  = textSize,
            };

            subText.X = centerX - subText.Width / 2f;
            subText.Y = topText.Bottom + subText.Height / 2f;

            canvasTitle.Controller.Icons.Add(subText);

            #endregion

            #region Lower Text

            var iconsText = new IconText("Copyright 2008-2012 Garry Paxton (CC-BY-SA 2.0). http://straight-street.com")
            {
                Size      = new SKSize(canvasTitle.CanvasSize.Width, canvasTitle.CanvasSize.Height / 10f),
                ForeColor = SKColors.White,
                FontSize  = textSize,
            };

            iconsText.X = centerX - iconsText.Width / 2f;
            iconsText.Y = canvasTitle.CanvasSize.Height - iconsText.Height;

            canvasTitle.Controller.Icons.Add(iconsText);

            var iconsText2 = new IconText("Visual symbols from \"Mulberry Symbol Set\"")
            {
                Size      = new SKSize(canvasTitle.CanvasSize.Width, canvasTitle.CanvasSize.Height / 10f),
                ForeColor = SKColors.White,
                FontSize  = textSize,
            };

            iconsText2.X = centerX - iconsText2.Width / 2f;
            iconsText2.Y = iconsText.Top - (iconsText2.Height + 5f);

            canvasTitle.Controller.Icons.Add(iconsText2);

            #endregion

            #region Button

            var sizeBtn = Constants.DeviceLayout.GetSizeByGrid(canvasTitle.CanvasSize, 8f, 2f);

            var xOffset = Constants.DeviceLayout.GetSizeByGrid(canvasTitle.CanvasSize, 1, 7f).Width;

            SKRect rect = new SKRect(xOffset,
                                     sizeOfStrip.Height,
                                     sizeBtn.Width + xOffset,
                                     sizeBtn.Height / 2f);

            var button = new IconSquareRounded(rect)
            {
                BorderColor  = SKColors.Black,
                FillColor    = SKColors.IndianRed,
                BorderWidth  = 6,
                CornerRadius = new SKPoint(25, 25),
                Tag          = 999,
            };

            button.Height = sizeBtn.Height / 2f;
            button.Y      = ((canvasTitle.CanvasSize.Height / 2f) + (iconsText2.Top)) / 2f - button.Height / 2f;

            canvasTitle.Controller.Icons.Add(button);

            #endregion

            #region Button Text

            var btnText = new IconText("Load Communication Board")
            {
                Size      = new SKSize(button.Width, button.Height),
                ForeColor = SKColors.White,
                FontSize  = btnTextSize,
                Tag       = 999
            };

            btnText.X = centerX - btnText.Width / 2f;
            btnText.Y = button.Top + (button.Height / 2f) - (btnText.Height / 2f) + 10;

            canvasTitle.Controller.Icons.Add(btnText);

            #endregion

            // Cleanup
            topText.Dispose();
            topText = null;

            subText.Dispose();
            subText = null;

            iconsText.Dispose();
            iconsText = null;

            iconsText2.Dispose();
            iconsText2 = null;

            button = null;

            btnText.Dispose();
            btnText = null;
        }