Inheritance: MonoBehaviour
Exemplo n.º 1
0
        /// <summary>
        /// Get color of an item
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public string GetColor(MapItems item)
        {
            if (item.TypeId == 0)
            {
                return(ItemColors.UNAVAILABLE);
            }
            else
            {
                if (_default_storage == null)
                {
                    throw new Exception("At Singleton.GetColor....Can not find DEFAULT_STORAGE Type, pelase check whether the database and code are the same.");
                }

                if (item.TypeId != _default_storage.Id)//not a storage
                {
                    return(Map.Types.Single(t => t.Id == item.TypeId).Color);
                }
                else if (item.ZoneId != 0)//default storage but has no zone
                {
                    return(Map.Zones.Single(z => z.Id == item.ZoneId).Color);
                }
                else//storage with zone
                {
                    return(_default_storage.Color);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Middle button - for editing purposes
        /// </summary>
        /// <param name="e"></param>
        void MapMouseMiddleButtonUp(MouseButtonEventArgs e)
        {
            var stretchedPosition = e.GetPosition(_map);
            var realCoords        = _zoomer.TranslatePointBack(stretchedPosition);
            var position          = _zoomer.TranslatePoint(realCoords);

            switch (_editController.EditMode)
            {
            case EditModeType.NewPoint:
                var item = new MapDataItemVM(realCoords.X, realCoords.Y, position.X, position.Y,
                                             Properties.Resources.NewPointDefaultName,
                                             Properties.Resources.NewPointDefaultDescription);
                item.Selected += OnSelectCurrentItem;
                MapItems.Add(item);
                OnSelectCurrentItem(item, new EventArgs());
                break;

            case EditModeType.MovePoint:
                if (CurrentMapItem != null)
                {
                    CurrentMapItem.X          = position.X;
                    CurrentMapItem.Y          = position.Y;
                    CurrentMapItem.RealCoords = realCoords;
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
 public override bool updateItem(MapItem prev, MapItem next)
 {
     if (MapItems.doesSymbolBelongToItems(next.symbol, new string[] { MapItems.PREFAB_TANK, MapItems.PREFAB_BULLET }) ||
         MapItems.doesSymbolBelongToItems(prev.symbol, new string[] { MapItems.PREFAB_TANK, MapItems.PREFAB_BULLET }))
     {
         // Do nothing until bullet or tank on obstacle
         return(true);
     }
     if (!canProcess(prev.symbol) && canProcess(next.symbol) && findByPosition(prev.row, prev.column) == null)
     {
         // Hack: when on field is tank and item -> server returns only tank symbol
         // Hack: same for bullets
         // If before there wasn't item and it added, then create item
         createItem(next);
         return(true);
     }
     else if (canProcess(prev.symbol) && MapItems.MAP_KEYS[next.symbol] == MapItems.KEY_NONE)
     {
         // Hack: when on field is tank and item -> server returns only tank symbol
         // Hack: same for bullets
         // If before there was item and it became none field, then destroy item
         destroyItem(prev.row, prev.column);
         return(true);
     }
     return(false);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Reads the .data file of the sector.
        /// </summary>
        /// <param name="path">The .data file of the sector.</param>
        private void ReadData(string path)
        {
            using var fs = CreateOpenFileStream(path);
            using var r  = new BinaryReader(fs);

            // Header
            var dataHeader = new Header();

            dataHeader.Deserialize(r);

            // Items
            while (r.BaseStream.Position < r.BaseStream.Length)
            {
                var uid = r.ReadUInt64();
                if (uid == dataEof)
                {
                    break;
                }

                MapItem item;
                if (!MapItems.TryGetValue(uid, out item))
                {
                    throw new KeyNotFoundException($"{ToString()}.data contains " +
                                                   $"unknown UID {uid} - can't continue.");
                }
                var serializer = (IDataPayload)MapItemSerializerFactory.Get(item.ItemType);
                serializer.DeserializeDataPayload(r, item);
            }
        }
Exemplo n.º 5
0
        private void SpawnAttributeItem(int x, int y)
        {
            var item = ItemBase.Get(((MapItemAttribute)Attributes[x, y]).ItemId);

            if (item != null)
            {
                MapItems.Add(
                    new MapItem(
                        ((MapItemAttribute)Attributes[x, y]).ItemId, ((MapItemAttribute)Attributes[x, y]).Quantity
                        )
                    );

                MapItems[MapItems.Count - 1].X               = x;
                MapItems[MapItems.Count - 1].Y               = y;
                MapItems[MapItems.Count - 1].DespawnTime     = -1;
                MapItems[MapItems.Count - 1].AttributeSpawnX = x;
                MapItems[MapItems.Count - 1].AttributeSpawnY = y;
                if (item.ItemType == ItemTypes.Equipment)
                {
                    MapItems[MapItems.Count - 1].Quantity = 1;
                    var r = new Random();
                    for (var i = 0; i < (int)Stats.StatCount; i++)
                    {
                        MapItems[MapItems.Count - 1].StatBuffs[i] = r.Next(-1 * item.StatGrowth, item.StatGrowth + 1);
                    }
                }

                PacketSender.SendMapItemUpdate(Id, MapItems.Count - 1);
            }
        }
Exemplo n.º 6
0
        private void createMap()
        {
            IEnumerable <TweetsInfo> sortTweets = TwitterDB.TweetsTable.ToList().OrderBy(x => x.CreationDate);
            List <MapItems>          map        = new List <MapItems>();

            foreach (var i in sortTweets)
            {
                if (!String.IsNullOrEmpty(i.Latitude))
                {
                    var item = new MapItems
                    {
                        latitude = i.Latitude,
                        longtude = i.Longitude,
                        UserName = i.Useritem.Name,
                    };
                    map.Add(item);
                }
                else
                {
                    continue;
                }
            }
            string mapItemsString = map.ToJSON();

            ViewBag.MapData = mapItemsString;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Load data from file
        /// </summary>
        private void LoadData()
        {
            var     adapter = new MapDataAdapter(DATAFILE);
            MapData data;

            try
            {
                data = adapter.Load();
            }
            catch (Exception ex)
            {
                MessageBox.Show(Properties.Resources.ErrorOnLoad + " " + ex);
                return;
            }

            foreach (var d in data.Items)
            {
                var mapItem = new MapDataItemVM(d);
                mapItem.Selected += new EventHandler <EventArgs>(OnSelectCurrentItem);
                MapItems.Add(mapItem);
            }

            // from now on, track changes
            MapItems.CollectionChanged +=
                new System.Collections.Specialized.NotifyCollectionChangedEventHandler((o, e) => { _itemCollectionChanged = true; });
        }
Exemplo n.º 8
0
 /// <summary>
 /// to make sure if an item is a storage grid
 /// </summary>
 /// <param name="item"></param>
 /// <returns>true if is; false if not</returns>
 public bool IsStorage(MapItems item)
 {
     if (_default_storage == null)
     {
         throw new Exception("At Singleton.IsStorage....Can not find DEFAULT_STORAGE Type, pelase check whether the database and code are the same.");
     }
     return(item.TypeId == _default_storage.Id);
 }
        void populateMapItems()
        {
            this.MapItems = new Dictionary <string, Tuple <string, string, string, string> >();
            XmlElement coaMap = (XmlElement)financialStatements.GetElementsByTagName("COAMap")[0];

            foreach (XmlNode nod in coaMap.ChildNodes)
            {
                MapItems.Add(nod.Attributes["coaItem"].InnerText, Tuple.Create(nod.Attributes["statementType"].InnerText, nod.Attributes["lineID"].InnerText, nod.Attributes["precision"].InnerText, nod.InnerText));
            }
        }
Exemplo n.º 10
0
        public void DespawnItems()
        {
            //Kill all items resting on map
            ItemRespawns.Clear();
            for (var i = 0; i < MapItems.Count; i++)
            {
                RemoveItem(i, false);
            }

            MapItems.Clear();
        }
Exemplo n.º 11
0
        public bool IsValid(System.Windows.Point Player)
        {
            Point f = new Point(ScenePoint.X - Player.X, ScenePoint.Y - Player.Y);

            if (MapItems.OutofBounds(f, 450))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 12
0
        public void SpawnItem(int x, int y, Item item, int amount)
        {
            if (item == null)
            {
                Log.Warn($"Tried to spawn {amount} of a null item at ({x}, {y}) in map {Id}.");

                return;
            }

            var itemBase = ItemBase.Get(item.ItemId);

            if (itemBase == null)
            {
                Log.Warn($"No item found for {item.ItemId}.");

                return;
            }

            var mapItem = new MapItem(item.ItemId, item.Quantity, item.BagId, item.Bag)
            {
                X           = x,
                Y           = y,
                DespawnTime = Globals.Timing.TimeMs + Options.ItemDespawnTime
            };

            if (itemBase.ItemType == ItemTypes.Equipment)
            {
                mapItem.Quantity = 1;
                if (mapItem.StatBuffs != null && item.StatBuffs != null)
                {
                    for (var i = 0; i < mapItem.StatBuffs.Length; ++i)
                    {
                        mapItem.StatBuffs[i] = item.StatBuffs.Length > i ? item.StatBuffs[i] : 0;
                    }
                }
                else if (mapItem.StatBuffs == null)
                {
                    Log.Warn($"Unexpected null: {nameof(mapItem)}.{nameof(mapItem.StatBuffs)}");
                }
                else
                {
                    Log.Warn($"Unexpected null: {nameof(item)}.{nameof(item.StatBuffs)}");
                }
            }
            else
            {
                mapItem.Quantity = amount;
            }

            MapItems.Add(mapItem);
            PacketSender.SendMapItemUpdate(Id, MapItems.Count - 1);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Deletes current point
        /// </summary>
        /// <param name="param"></param>
        private void DeleteCurrentPoint(object param)
        {
            var message = Properties.Resources.DeleteConfirmationText;
            var caption = Properties.Resources.ConfirmationCaption;
            var result  = MessageBox.Show(message, caption, MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                var item = CurrentMapItem;
                CurrentMapItem = null;
                MapItems.Remove(item);
            }
        }
Exemplo n.º 14
0
        public Item GetItem(string name)
        {
            Item item;

            if (MapItems.TryGetValue(name, out item))
            {
                return(item);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Returns the <see cref="DataModelMap"/> that is associated
        /// with the specified CLR <paramref name="type"/>. This value
        /// contains all the mapping information needed to bind a CLR
        /// type to a database table and its relationships.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static DataModelMap GetEntityMapping(Type type)
        {
            if (type.IsDataModelWrapper(false))
            {
                type = type.GetDataModelWrapperGenericTypeArg();
            }
            if (!MapItems.ContainsKey(type))
            {
                return(GetEntityMapping(type, MapItems));
            }

            return(MapItems[type]);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 扫描一个方向
        /// </summary>
        /// <param name="caltmp">栅格集</param>
        /// <param name="fromItem">单次扫描的起始点</param>
        /// <param name="toItem">单次扫描的重点</param>
        /// <param name="rack">rack移动基数</param>
        /// <param name="column">column移动基数</param>
        /// <param name="oneceTemp">单次入口扫描的本地结果集</param>
        /// <param name="queue">缓存队列,存储下一次的单次扫描起始点</param>
        /// <param name="_map"></param>
        /// <param name="threshold_bt_cargopaths">货到轨道距离阈值</param>
        /// <param name="threshold_bt_rails">轨道距离阈值</param>
        /// <param name="StorageRail">货道轨道ID</param>
        /// <param name="Storage">货位ID</param>
        /// <param name="Rail">轨道ID</param>
        private void ScanOneDirection(MapItems[,,] caltmp, MapItems fromItem, MapItems toItem, int rack, int column, double[,] oneceTemp, Queue <Entity.MapItems> queue,
                                      Models.Entity.Map _map,
                                      double threshold_bt_rails, double threshold_bt_cargopaths, int StorageRail, int Storage, int Rail)
        {
            if (oneceTemp[toItem.Rack, toItem.Column] != 0)
            {
                return;
            }
            int orig = toItem.TypeId;

            while (toItem.TypeId == orig)
            {
                double maxSpeed  = 0;
                double acc       = 0;
                double dec       = 0;
                double distance  = 0;
                double threshold = 0;
                if (fromItem.TypeId == Rail && toItem.TypeId == Rail)
                {
                    maxSpeed  = _map.PSMaxSpeed;
                    acc       = _map.PSAcceleration;
                    dec       = _map.PSDeceleration;
                    threshold = threshold_bt_rails;
                    //as we dont know which direction, but we can know that the scan is on one direction and the grids are straightly on the same line
                    distance = Math.Abs(fromItem.Rack - toItem.Rack) * _map.GapAlongCloumn + Math.Abs(fromItem.Column - toItem.Column) * _map.GapAlongRack;
                }
                else if ((fromItem.TypeId == StorageRail || fromItem.TypeId == Storage) && toItem.TypeId == Rail ||
                         fromItem.TypeId == Rail && (toItem.TypeId == StorageRail || toItem.TypeId == Storage))//we assume storage and storageRail as the same for now
                {
                    maxSpeed  = _map.CSMaxSpeed;
                    acc       = _map.CSAcceleration;
                    dec       = _map.CSDeceleration;
                    threshold = threshold_bt_cargopaths;
                    distance  = Math.Abs(fromItem.Rack - toItem.Rack) * _map.GapAlongCloumn + Math.Abs(fromItem.Column - toItem.Column) * _map.GapAlongRack;
                }
                else
                {
                    break;
                }
                oneceTemp[toItem.Rack, toItem.Column] = CalculateTime(threshold, distance, maxSpeed, acc, dec) + oneceTemp[fromItem.Rack, fromItem.Column];
                //Utils.Logger.WriteMsgAndLog(fromItem.Layer + ", " + fromItem.Rack + ", " + fromItem.Column + " --> "
                //    + toItem.Layer + ", " + toItem.Rack + ", " + toItem.Column + " -- > " + oneceTemp[toItem.Rack, toItem.Column]);
                queue.Enqueue(toItem);
                toItem = caltmp[fromItem.Layer, toItem.Rack + rack + 1, toItem.Column + column + 1];
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Reads items from a .base or .aux file.
        /// </summary>
        /// <param name="r">The reader.</param>
        /// <param name="file">The file which is being read.</param>
        private void ReadItems(BinaryReader r, ItemFile file)
        {
            var itemCount = r.ReadUInt32();

            MapItems.EnsureCapacity(MapItems.Count + (int)itemCount);
            for (int i = 0; i < itemCount; i++)
            {
                var itemType = (ItemType)r.ReadInt32();

                var serializer = MapItemSerializerFactory.Get(itemType);
                var item       = serializer.Deserialize(r);

                // deal with signs which can be in aux *and* base
                if (item is Sign sign && file != sign.DefaultItemFile)
                {
                    sign.ItemFile = file;
                }
Exemplo n.º 18
0
 public MapItems.MapItemStatus GetMapItemStatus(MapItems item)
 {
     if (item.TypeId != Type_GetStorageId())
     {
         return(MapItems.MapItemStatus.STATUS_NOT_STORAGE);
     }
     if (_map.Goods.Any(g => g.MapItemsId == item.MapItemID))
     {
         return(MapItems.MapItemStatus.STATUS_FULL);
     }
     else if (_map.CargoWaysLocks.Any(cwl => cwl.CargoWayId == item.CargowayId))
     {
         return(MapItems.MapItemStatus.STATUS_LOCK);
     }
     else
     {
         return(MapItems.MapItemStatus.STATUS_EMPTY);
     }
 }
        public void LoadDefaultFeatures()
        {
            if (Config.Get <FKConfig>().General.DamageNumber.Enabled&& Config.Get <FKConfig>().General.Experience.Enabled)
            {
                GameManager.Instance.GManager.GRef.Actors.Features.Add(() => GameManager.Instance.GManager.GRef.Actors.DamangeNumbers.Update());
            }

            if (Config.Get <FKAffixes>().Settings.Enabled)
            {
                GameManager.Instance.GManager.GRef.Actors.Features.Add(() => Affix.NewLoop());
            }

            if (Config.Get <FKConfig>().General.Skills.Skill)
            {
                GameManager.Instance.GManager.GRef.Actors.Features.Add(() =>
                {
                    if (UIObjects.SkillsBar.Cache & !UIObjects.SkillsBar.TryGetValue <Enigma.D3.UI.Controls.UXControl>()) // Skills updated
                    {
                        GameManagerAccountHelper.Current.LevelAreaHelper.ResetSkillbar();
                    }
                });
            }

            if ((Config.Get <FKConfig>().General.MiniMapSettings.RevealMapLargemap.Reveal || Config.Get <FKConfig>().General.MiniMapSettings.RevealMapMinimap.Reveal))
            {
                GameManager.Instance.GManager.GRef.Actors.Features.Add(() =>
                {
                    SceneHelper.LoadScenes();
                    MapItems.Scene();
                });
            }

            GameManager.Instance.GManager.GRef.Actors.Features.Add(() =>
            {
                if (TownHelper.InTown)
                {
                    TownHelper.GetStash();
                    TownHelper.Gambling();
                }
            });
        }
Exemplo n.º 20
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Items.Clear();
                var items = await LocationDataStore.GetItemsAsync(true);

                foreach (var item in items)
                {
                    Items.Add(item);
                }

                foreach (var locationItem in Items)
                {
                    try
                    {
                        MapItems.Add(locationItem);
                    }
                    catch (Exception ex)
                    {
                        continue;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Save data to file
        /// </summary>
        /// <param name="param"></param>
        private void SaveData(object param)
        {
            var data = new MapData();

            data.Items.AddRange(
                MapItems.Select(i =>
                                new MapDataItem {
                X                    = i.RealCoords.X,
                Y                    = i.RealCoords.Y,
                Name                 = i.Title,
                Description          = i.Description,
                PresentationFileName = i.PresentationFile
            }));

            var adapter = new MapDataAdapter(DATAFILE);

            adapter.Save(data);

            foreach (var item in MapItems)
            {
                item.ResetChanged();
            }
            _itemCollectionChanged = false;
        }
Exemplo n.º 22
0
        public void LoadSheet(Game1 game)
        {
            string pathIO = Game1.content.RootDirectory.ToString() + "\\Levels";

            GameDebug.Log(pathIO);

            if (Directory.Exists(pathIO))
            {
                string[] data;

                FileStream fileStream = File.OpenRead(pathIO + "\\test.map");

                byte[] bytes = new byte[fileStream.Length];

                fileStream.Read(bytes, 0, bytes.Length);
                data = System.Text.Encoding.UTF8.GetString(bytes).Split('\n');

                if (!data[0].Contains("sheetmap"))
                {
                    throw new Exception(String.Format("Wrong Map Format"));
                }

                for (int i = 0; i < data.Length; i++)
                {
                    string match = Regex.Match(data[i], @"\[([^]]*)\]").Groups[1].Value;

                    match = match.Replace(" ", "");

                    string[] cords = match.Split(',');

                    if (cords[0].Contains("Block"))
                    {
                        Console.WriteLine("Item Found!");

                        MapItems _mapitems = new MapItems();

                    //    _mapitems.itemTile = new ItemTile(_mapitems.pos, 1f, ItemTileType.Blank);
                        _mapitems.pos = new Vector2(float.Parse(cords[1]), float.Parse(cords[2]));
                       // _mapitems.itemTile.Init(_mapitems.pos, 1f);
                      //  _mapitems.itemTile.LoadBlock();
                        _mapItemList.Add(_mapitems);

                        //GameDebug.Log((cords[3]).ToString());

                    }
                    /*     else if (cords[0].Contains("Start"))
                         {
                             GameObject.Instantiate(Startline, new Vector3(float.Parse(cords[1]), float.Parse(cords[2]), float.Parse(cords[3])), Quaternion.identity);
                         }
                         else if (cords[0].Contains("Finish"))
                         {
                             GameObject.Instantiate(Finish, new Vector3(float.Parse(cords[1]), float.Parse(cords[2]), float.Parse(cords[3])), Quaternion.identity);
                         }
                         */
                }

                // Console.WriteLine("Loaded File !");
                return;
            }
            else
            {
                // Console.WriteLine("Directory is not existing !");
                throw new Exception(String.Format("Directory is not existing !"));
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Spawn an item to this map instance.
        /// </summary>
        /// <param name="x">The horizontal location of this item</param>
        /// <param name="y">The vertical location of this item.</param>
        /// <param name="item">The <see cref="Item"/> to spawn on the map.</param>
        /// <param name="amount">The amount of times to spawn this item to the map. Set to the <see cref="Item"/> quantity, overwrites quantity if stackable!</param>
        /// <param name="owner">The player Id that will be the temporary owner of this item.</param>
        public void SpawnItem(int x, int y, Item item, int amount, Guid owner)
        {
            if (item == null)
            {
                Log.Warn($"Tried to spawn {amount} of a null item at ({x}, {y}) in map {Id}.");

                return;
            }

            var itemDescriptor = ItemBase.Get(item.ItemId);

            if (itemDescriptor == null)
            {
                Log.Warn($"No item found for {item.ItemId}.");

                return;
            }

            // if we can stack this item or the user configured to drop items consolidated, simply spawn a single stack of it.
            if (itemDescriptor.Stackable || Options.Loot.ConsolidateMapDrops)
            {
                var mapItem = new MapItem(item.ItemId, amount, item.BagId, item.Bag)
                {
                    X             = x,
                    Y             = y,
                    DespawnTime   = Globals.Timing.Milliseconds + Options.Loot.ItemDespawnTime,
                    Owner         = owner,
                    OwnershipTime = Globals.Timing.Milliseconds + Options.Loot.ItemOwnershipTime,
                    VisibleToAll  = Options.Loot.ShowUnownedItems
                };

                // If this is a piece of equipment, set up the stat buffs for it.
                if (itemDescriptor.ItemType == ItemTypes.Equipment)
                {
                    mapItem.SetupStatBuffs(item);
                }

                MapItems.Add(mapItem);
                PacketSender.SendMapItemUpdate(Id, MapItems.Count - 1);
            }
            else
            {
                // Oh boy here we go! Set quantity to 1 and drop multiple!
                for (var i = 0; i < amount; i++)
                {
                    var mapItem = new MapItem(item.ItemId, amount, item.BagId, item.Bag)
                    {
                        X             = x,
                        Y             = y,
                        DespawnTime   = Globals.Timing.Milliseconds + Options.Loot.ItemDespawnTime,
                        Owner         = owner,
                        OwnershipTime = Globals.Timing.Milliseconds + Options.Loot.ItemOwnershipTime,
                        VisibleToAll  = Options.Loot.ShowUnownedItems
                    };

                    // If this is a piece of equipment, set up the stat buffs for it.
                    if (itemDescriptor.ItemType == ItemTypes.Equipment)
                    {
                        mapItem.SetupStatBuffs(item);
                    }

                    MapItems.Add(mapItem);
                }
                PacketSender.SendMapItemsToProximity(Id);
            }
        }
Exemplo n.º 24
0
        public bool HasGood(MapItems item)
        {
            bool has = _map.Goods.Any(g => g.MapItemsId == item.MapItemID);

            return(has);
        }
Exemplo n.º 25
0
        public void PlaceItem(int cavern, MapItems item)
        {
            if (CavernDoesntExist(cavern))
                cave[cavern] = new Cavern();

            if (HasPlayer() && item == MapItems.Player)
                cave[(int) PlayersCurrentCavern()].MapItems.Remove(MapItems.Player);

            if (WumpusCavern != null && item == MapItems.Wumpus)
                cave[(int) WumpusCavern].MapItems.Remove(MapItems.Wumpus);

            cave[cavern].MapItems.Add(item);
        }
Exemplo n.º 26
0
 public LipSyncMapItem FindMapItem(Guid id)
 {
     return(MapItems.Find(x => x.ElementGuid.Equals(id)));
 }
Exemplo n.º 27
0
        private void LoadItems()
        {
            var e = new ItemEnergi();

            MapItems.Add("energi", e);
        }
        private void AssignTheChanges(List <Models.Entity.Goods> toDeleleList,
                                      List <Models.Entity.MapItems> toDeleteMIList, List <Models.Entity.MapItems> toAddMIList)
        {
            int Unavailabe = _map.Types.SingleOrDefault(z => z.Name == Models.Service.MapSingletonService.ItemTypesString.ITEM_TYPE_UNAVAILABLE).Id;
            int Input      = _map.Types.SingleOrDefault(z => z.Name == Models.Service.MapSingletonService.ItemTypesString.ITEM_TYPE_INPUT_POINT).Id;
            int Output     = _map.Types.SingleOrDefault(z => z.Name == Models.Service.MapSingletonService.ItemTypesString.ITEM_TYPE_OUTPUT_POINT).Id;
            int Lifter     = _map.Types.SingleOrDefault(z => z.Name == Models.Service.MapSingletonService.ItemTypesString.ITEM_TYPE_LIFTER).Id;

            for (int i = 0; i < SelectedMapItems.Count; i++)
            {
                if (!ApplyToAllLayers)
                {
                    //for current layer
                    if (SelectedMapItems[i].SingleStorage.Rack < 0 || SelectedMapItems[i].SingleStorage.Rack >= _map.RackCount ||
                        SelectedMapItems[i].SingleStorage.Column < 0 || SelectedMapItems[i].SingleStorage.Column >= _map.ColumnCount)
                    {
                        Models.Entity.MapItems tmp = _map.SpecialMapItems.SingleOrDefault(item => item.Layer == SelectedLayer && item.Rack == SelectedMapItems[i].SingleStorage.Rack && item.Column == SelectedMapItems[i].SingleStorage.Column);
                        if (Types[SelectedTypeIndex].Id == Unavailabe && SelectedMapItems[i].SingleStorage.MapItemID != 0)
                        {
                            //DELETE
                            if (tmp != null)
                            {
                                toDeleteMIList.Add(tmp);
                            }
                        }
                        else if (Types[SelectedTypeIndex].Id == Input || Types[SelectedTypeIndex].Id == Output || Types[SelectedTypeIndex].Id == Lifter)
                        {
                            //UPDATE or ADD
                            SelectedMapItems[i].SingleStorage.Layer  = SelectedLayer;
                            SelectedMapItems[i].SingleStorage.TypeId = Types[SelectedTypeIndex].Id;
                            if (tmp == null)
                            {
                                toAddMIList.Add(SelectedMapItems[i].SingleStorage);
                            }
                        }
                        continue;
                    }
                    //dont forget to reset these items, maybe need to recalculate the logics cargoways
                    SelectedMapItems[i].SingleStorage.TypeId = Types[SelectedTypeIndex].Id;
                    SelectedMapItems[i].SingleStorage.ZoneId = 0;
                    if (Models.Service.MapSingletonService.Instance.HasGood(SelectedMapItems[i].SingleStorage))
                    {
                        //add to to delete Good Lists
                        toDeleleList.Add(_map.Goods.Single(g => g.MapItemsId == SelectedMapItems[i].SingleStorage.MapItemID));
                    }
                }
                else
                {
                    //for each layers
                    for (int j = 0; j < _map.LayerCount; j++)
                    {
                        if (SelectedMapItems[i].SingleStorage.Rack < 0 || SelectedMapItems[i].SingleStorage.Rack >= _map.RackCount ||
                            SelectedMapItems[i].SingleStorage.Column < 0 || SelectedMapItems[i].SingleStorage.Column >= _map.ColumnCount)
                        {
                            Models.Entity.MapItems tmp = _map.SpecialMapItems.SingleOrDefault(item => item.Layer == j && item.Rack == SelectedMapItems[i].SingleStorage.Rack && item.Column == SelectedMapItems[i].SingleStorage.Column);
                            if (Types[SelectedTypeIndex].Id == Unavailabe)
                            {
                                //DELETE
                                if (tmp != null)
                                {
                                    toDeleteMIList.Add(tmp);
                                }
                            }
                            else if (Types[SelectedTypeIndex].Id == Input || Types[SelectedTypeIndex].Id == Output || Types[SelectedTypeIndex].Id == Lifter)
                            {
                                //UPDATE or ADD
                                //new one
                                if (tmp == null)
                                {
                                    MapItems newone = new MapItems();
                                    newone.Layer  = j;
                                    newone.Rack   = SelectedMapItems[i].SingleStorage.Rack;
                                    newone.Column = SelectedMapItems[i].SingleStorage.Column;
                                    newone.TypeId = Types[SelectedTypeIndex].Id;
                                    toAddMIList.Add(newone);
                                }
                                else
                                {
                                    tmp.TypeId = Types[SelectedTypeIndex].Id;
                                }
                            }
                            continue;
                        }
                        _map[j, SelectedMapItems[i].SingleStorage.Rack, SelectedMapItems[i].SingleStorage.Column].TypeId = Types[SelectedTypeIndex].Id;
                        _map[j, SelectedMapItems[i].SingleStorage.Rack, SelectedMapItems[i].SingleStorage.Column].ZoneId = 0;
                        if (Models.Service.MapSingletonService.Instance.HasGood(_map[j, SelectedMapItems[i].SingleStorage.Rack, SelectedMapItems[i].SingleStorage.Column]))
                        {
                            //add to to delete Good Lists
                            toDeleleList.Add(_map.Goods.Single(g => g.MapItemsId == _map[j, SelectedMapItems[i].SingleStorage.Rack, SelectedMapItems[i].SingleStorage.Column].MapItemID));
                        }
                    }
                }
            }
        }
Exemplo n.º 29
0
 public LipSyncMapItem FindMapItem(string itemName)
 {
     return(MapItems.Find(x => x.Name.Equals(itemName)));
 }
Exemplo n.º 30
0
        public void LoadSheet(Game1 game)
        {
            string pathIO = Game1.content.RootDirectory.ToString() + "\\Levels";

            GameDebug.Log(pathIO);

            if (Directory.Exists(pathIO))
            {
                string[] data;

                FileStream fileStream = File.OpenRead(pathIO + "\\test.map");

                byte[] bytes = new byte[fileStream.Length];

                fileStream.Read(bytes, 0, bytes.Length);
                data = System.Text.Encoding.UTF8.GetString(bytes).Split('\n');

                if (!data[0].Contains("sheetmap"))
                {
                    throw new Exception(String.Format("Wrong Map Format"));
                }

                for (int i = 0; i < data.Length; i++)
                {
                    string match = Regex.Match(data[i], @"\[([^]]*)\]").Groups[1].Value;

                    match = match.Replace(" ", "");

                    string[] cords = match.Split(',');

                    if (cords[0].Contains("Block"))
                    {
                        Console.WriteLine("Item Found!");

                        MapItems _mapitems = new MapItems();

                        //    _mapitems.itemTile = new ItemTile(_mapitems.pos, 1f, ItemTileType.Blank);
                        _mapitems.pos = new Vector2(float.Parse(cords[1]), float.Parse(cords[2]));
                        // _mapitems.itemTile.Init(_mapitems.pos, 1f);
                        //  _mapitems.itemTile.LoadBlock();
                        _mapItemList.Add(_mapitems);

                        //GameDebug.Log((cords[3]).ToString());
                    }

                    /*     else if (cords[0].Contains("Start"))
                     *   {
                     *       GameObject.Instantiate(Startline, new Vector3(float.Parse(cords[1]), float.Parse(cords[2]), float.Parse(cords[3])), Quaternion.identity);
                     *   }
                     *   else if (cords[0].Contains("Finish"))
                     *   {
                     *       GameObject.Instantiate(Finish, new Vector3(float.Parse(cords[1]), float.Parse(cords[2]), float.Parse(cords[3])), Quaternion.identity);
                     *   }
                     */
                }

                // Console.WriteLine("Loaded File !");
                return;
            }
            else
            {
                // Console.WriteLine("Directory is not existing !");
                throw new Exception(String.Format("Directory is not existing !"));
            }
        }