Пример #1
0
        /// <summary>
        ///  Gives a mob a permission to place a given Tile.
        /// </summary>
        public void AssignBuildPermissionTile(Entity mob, int range, string tileType, string alignOption)
        {
            var newPermission = new PlacementInformation
                                    {
                                        MobUid = mob.Uid,
                                        Range = range,
                                        IsTile = true,
                                        TileType = tileType,
                                        PlacementOption = alignOption
                                    };

            IEnumerable<PlacementInformation> mobPermissions = from PlacementInformation permission in BuildPermissions
                                                               where permission.MobUid == mob.Uid
                                                               select permission;

            if (mobPermissions.Any()) //Already has one? Revoke the old one and add this one.
            {
                RevokeAllBuildPermissions(mob);
                BuildPermissions.Add(newPermission);
            }
            else
            {
                BuildPermissions.Add(newPermission);
            }
        }
Пример #2
0
        private void NewButtonClicked(EntitySpawnSelectButton sender, EntityTemplate template, string templateName)
        {
            if (sender.selected)
            {
                sender.selected = false;
                _placementManager.Clear();
                return;
            }

            foreach (
                GuiComponent curr in
                    _entityList.components.Where(curr => curr.GetType() == typeof (EntitySpawnSelectButton)))
                ((EntitySpawnSelectButton) curr).selected = false;

            string overrideMode = "";
            if (_lstOverride.CurrentlySelected != null)
                if (_lstOverride.CurrentlySelected.Text.Text != "None")
                    overrideMode = _lstOverride.CurrentlySelected.Text.Text;

            var newObjInfo = new PlacementInformation
                                 {
                                     PlacementOption = overrideMode.Length > 0 ? overrideMode : template.PlacementMode,
                                     EntityType = templateName,
                                     Range = -1,
                                     IsTile = false
                                 };

            _placementManager.BeginPlacing(newObjInfo);

            sender.selected = true; //This needs to be last.
        }
Пример #3
0
        private void _lstOverride_ItemSelected(Label item, Listbox sender)
        {
            var pMan = (PlacementManager) _placementManager;

            if (pMan.CurrentMode != null)
            {
                var newObjInfo = new PlacementInformation
                                     {
                                         PlacementOption = item.Text.Text,
                                         EntityType = pMan.CurrentPermission.EntityType,
                                         Range = -1,
                                         IsTile = pMan.CurrentPermission.IsTile
                                     };

                _placementManager.Clear();
                _placementManager.BeginPlacing(newObjInfo);
            }
        }
Пример #4
0
 public void Clear()
 {
     CurrentBaseSprite = null;
     CurrentTemplate = null;
     CurrentPermission = null;
     CurrentMode = null;
     if (PlacementCanceled != null && IsActive && !Eraser) PlacementCanceled(this, null);
     IsActive = false;
     Eraser = false;
 }
Пример #5
0
        private void HandleStartPlacement(NetIncomingMessage msg)
        {
            CurrentPermission = new PlacementInformation
                                    {
                                        Range = msg.ReadInt32(),
                                        IsTile = msg.ReadBoolean()
                                    };

            var mapMgr = (MapManager) IoCManager.Resolve<IMapManager>();

            if (CurrentPermission.IsTile) CurrentPermission.TileType = mapMgr.GetTileString(msg.ReadByte());
            else CurrentPermission.EntityType = msg.ReadString();
            CurrentPermission.PlacementOption = msg.ReadString();

            BeginPlacing(CurrentPermission);
        }
Пример #6
0
        public void BeginPlacing(PlacementInformation info)
        {
            Clear();

            IoCManager.Resolve<IUserInterfaceManager>().CancelTargeting();
            IoCManager.Resolve<IUserInterfaceManager>().DragInfo.Reset();

            CurrentPermission = info;

            if (!_modeDictionary.Any(pair => pair.Key.Equals(CurrentPermission.PlacementOption)))
            {
                Clear();
                return;
            }

            Type modeType = _modeDictionary.First(pair => pair.Key.Equals(CurrentPermission.PlacementOption)).Value;
            CurrentMode = (PlacementMode) Activator.CreateInstance(modeType, this);

            if (info.IsTile)
                PreparePlacementTile(info.TileType);
            else
                PreparePlacement(info.EntityType);
        }
Пример #7
0
        private void TileLabelClicked(Label sender, MouseInputEventArgs e)
        {
            foreach (GuiComponent curr in _tileList.components.Where(curr => curr.GetType() == typeof (Label)))
                ((Label) curr).BackgroundColor = Color.Gray;

            var newObjInfo = new PlacementInformation
                                 {
                                     PlacementOption = "AlignTileAny",
                                     TileType = sender.Text.Text,
                                     Range = 400,
                                     IsTile = true
                                 };

            if (sender.Text.Text == "Wall")
            {
                newObjInfo.PlacementOption = "AlignWallPlace";
            }

            _placementManager.BeginPlacing(newObjInfo);

            sender.BackgroundColor = Color.ForestGreen;
        }