当前位置: 首页>>代码示例>>C#>>正文


C# ItemClass类代码示例

本文整理汇总了C#中ItemClass的典型用法代码示例。如果您正苦于以下问题:C# ItemClass类的具体用法?C# ItemClass怎么用?C# ItemClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ItemClass类属于命名空间,在下文中一共展示了ItemClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeepClone_ClassWithFieldsRef_AsReference

		public void DeepClone_ClassWithFieldsRef_AsReference(TypeModel model)
		{
			var classWithFields = new ClassWithFieldsRef();
			var item = new ItemClass() { Message = "Hi there!" };
			classWithFields._item1 = item;
			classWithFields._item2 = item;
			var list = new List<int> { 2, 4, 5 };
			classWithFields._list1 = list;
			classWithFields._list2 = list;

			var clone = (ClassWithFieldsRef)model.DeepClone(classWithFields);

			Assert.AreEqual(classWithFields._item1.Message, clone._item1.Message);
			Assert.AreEqual(classWithFields._item2.Message, clone._item2.Message);

			Assert.AreEqual(classWithFields._list1.Count, clone._list1.Count);
			for (int i = 0; i < classWithFields._list1.Count; i++)
			{
				Assert.AreEqual(classWithFields._list1[i], clone._list1[i]);
			}

			Assert.AreEqual(classWithFields._list2.Count, clone._list2.Count);
			for (int i = 0; i < classWithFields._list2.Count; i++)
			{
				Assert.AreEqual(classWithFields._list2[i], clone._list2[i]);
			}

			Assert.IsTrue(object.ReferenceEquals(classWithFields._item1, classWithFields._item2));
			Assert.IsTrue(object.ReferenceEquals(classWithFields._list1, classWithFields._list2));
			Assert.IsTrue(object.ReferenceEquals(clone._item1, clone._item2));
			Assert.IsTrue(object.ReferenceEquals(clone._list1, clone._list2));
		}
开发者ID:JayCap,项目名称:Protobuf-net-Patch-and-T4-TypeModel-Generator,代码行数:32,代码来源:Core_Fields.cs

示例2: ItemType

 public ItemType(string name, ItemClass itemClass, int weight, int price = 0)
 {
     Name = name;
     Class = itemClass;
     Weight = weight;
     Price = price;
 }
开发者ID:ZeroByte1987,项目名称:ConsoleGames,代码行数:7,代码来源:ItemType.cs

示例3: DeepClone_DictionaryOfClassRef_AsReference

		public void DeepClone_DictionaryOfClassRef_AsReference(TypeModel model)
		{
			var itemClass = new ItemClass() { Message = "hello"};

			var dictionary = new DictionaryOfClass()
			{
				Collection = new Dictionary<int, ItemClass>
				{
				    { 1, itemClass },   
					{ 2, itemClass }
				}
			};

			var clone = (DictionaryOfClass)model.DeepClone(dictionary);

			Assert.AreEqual(dictionary.Collection.Count, clone.Collection.Count);

			foreach (var key in dictionary.Collection.Keys)
			{
				Assert.AreEqual(dictionary.Collection[key].Message, clone.Collection[key].Message);
			}

			Assert.IsTrue(object.ReferenceEquals(dictionary.Collection[1], dictionary.Collection[2]), "Original reference failed");
			Assert.IsTrue(object.ReferenceEquals(clone.Collection[1], clone.Collection[2]), "Clone reference not maintained");
		}
开发者ID:JayCap,项目名称:Protobuf-net-Patch-and-T4-TypeModel-Generator,代码行数:25,代码来源:Core_Collection.cs

示例4: CreatePath

        public new bool CreatePath(out uint unit, ref Randomizer randomizer, uint buildIndex, PathUnit.Position startPosA, PathUnit.Position startPosB, PathUnit.Position endPosA, PathUnit.Position endPosB, PathUnit.Position vehiclePosition, NetInfo.LaneType laneTypes, VehicleInfo.VehicleType vehicleTypes, float maxLength, bool isHeavyVehicle, bool ignoreBlocked, bool stablePath, bool skipQueue, ItemClass.Service vehicleService)
        {
            while (!Monitor.TryEnter(this.m_bufferLock, SimulationManager.SYNCHRONIZE_TIMEOUT))
            {
            }
            uint num;
            try
            {
                if (!this.m_pathUnits.CreateItem(out num, ref randomizer))
                {
                    unit = 0u;
                    bool result = false;
                    return result;
                }
                this.m_pathUnitCount = (int)(this.m_pathUnits.ItemCount() - 1u);
            }
            finally
            {
                Monitor.Exit(this.m_bufferLock);
            }
            unit = num;

            byte simulationFlags = createSimulationFlag(isHeavyVehicle, ignoreBlocked, stablePath, vehicleService);
            assignPathProperties(unit, buildIndex, startPosA, startPosB, endPosA, endPosB, vehiclePosition, laneTypes, vehicleTypes, maxLength, simulationFlags);

            return findShortestPath(unit, skipQueue);
        }
开发者ID:robbiemu,项目名称:Skylines-Traffic-Manager,代码行数:27,代码来源:CustomPathManager.cs

示例5: DeepClone_ClassFieldMaintainsReference

		public void DeepClone_ClassFieldMaintainsReference(TypeModel model)
		{
			var item = new ItemClass() { Message = "Bob yo" };

			var container = new ContainerItemClass()
			{
				Item1 = item,
				Item2 = item
			};

			var clone = (ContainerItemClass)model.DeepClone(container);

			Assert.IsTrue(object.ReferenceEquals(container.Item1, container.Item2));
			Assert.IsTrue(object.ReferenceEquals(clone.Item1, clone.Item2));

			Assert.AreEqual(container.Item1.Message, clone.Item1.Message);
			Assert.AreEqual(container.Item2.Message, clone.Item2.Message);

			container.Item1.Message = "New original";
			clone.Item1.Message = "New clone";

			Assert.AreEqual(container.Item1.Message, container.Item2.Message);
			Assert.AreEqual(clone.Item1.Message, clone.Item2.Message);

			container.Item2.Message = "New original 2";
			clone.Item2.Message = "New clone 2";

			Assert.AreEqual(container.Item1.Message, container.Item2.Message);
			Assert.AreEqual(clone.Item1.Message, clone.Item2.Message);
		}
开发者ID:JayCap,项目名称:Protobuf-net-Patch-and-T4-TypeModel-Generator,代码行数:30,代码来源:Core_Container.cs

示例6: Add

    public bool Add(ItemClass item, int amount, int foodType, int index = 0)
    {
        if (Type == InventoryType.MULTIPLE) {
            if (index < 0 || index >= Size) return false;
            if (Items[index].item_id > -1 &&  Items[index].item_id != item.item_id) return false;

            Items[index].Update(item.item_id, amount);

            AddCollection(item, amount, foodType);
            return true;

        }

        foreach (InventoryItem inve in Items.Values) {
            if (inve.item_id != item.item_id) continue;
            inve.Update(item.item_id, amount);
            AddCollection(item, amount, foodType);
            return true;
        }

        foreach (InventoryItem inve in Items.Values) {
            if (inve.item_id != -1) continue;
            inve.Update(item.item_id, amount);
            AddCollection(item, amount, foodType);
            return true;
        }

        return false;
    }
开发者ID:raimis001,项目名称:raWorld,代码行数:29,代码来源:Inventory.cs

示例7: Item

        /// <summary>
        /// Initializes a new instance of the Item class.
        /// </summary>
        /// <param name="itemTypeId">The ID of the item to create.</param>
        /// <param name="itemClass">The type of item that this is.</param>
        /// <param name="name">The item's name.</param>
        /// <param name="description">The item's description.</param>
        /// <exception cref="System.ArgumentNullException">Any parameter is null.</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">Item type ID is less than zero.</exception>
        /// <exception cref="System.ArgumentException">Item class is ItemClass.Undefined.</exception>
        protected Item(long itemTypeId, ItemClass itemClass, string name, string description)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (description == null)
            {
                throw new ArgumentNullException("description");
            }

            if (itemTypeId < 0)
            {
                throw new ArgumentOutOfRangeException("itemTypeId", "must be greater than or equal to zero.");
            }

            if (itemClass == ItemClass.Undefined)
            {
                throw new ArgumentException("cannot be ItemClass.Undefined", "itemClass");
            }

            this.ItemTypeId = itemTypeId;
            this.ItemClass = itemClass;
            this.Name = name;
            this.Description = description;
        }
开发者ID:jakepetroules,项目名称:jakes-3d-mmo,代码行数:37,代码来源:Item.cs

示例8: DeepCloneMaintainReference

		public void DeepCloneMaintainReference(TypeModel model)
		{
			var collection = new List<ItemClass>() { new ItemClass() { Message = "Hello" } };
			var itemClass = new ItemClass() { Message = "Haha" };

			var obj = new ComplexTestOfMaintainedReference()
			{
				Collection1 = collection,
				Collection2 = collection,
				Item1 = itemClass,
				Item2 = itemClass,
				Primitive1 = 1,
				Primitive2 = 2,
				String1 = "Test"
			};

			var clone = (ComplexTestOfMaintainedReference)model.DeepClone(obj);

			Assert.AreEqual(obj.Collection1.Count, clone.Collection1.Count);
			Assert.AreEqual(obj.Collection1[0].Message, clone.Collection1[0].Message);

			Assert.AreEqual(obj.Collection2.Count, clone.Collection2.Count);
			Assert.AreEqual(obj.Collection2[0].Message, clone.Collection2[0].Message);

			Assert.IsTrue(object.ReferenceEquals(clone.Collection1, clone.Collection2), "Collection reference");

			Assert.AreEqual(obj.Item1.Message, clone.Item1.Message);
			Assert.AreEqual(obj.Item2.Message, clone.Item2.Message);

			Assert.IsTrue(object.ReferenceEquals(clone.Item1, clone.Item2), "Item reference");

			Assert.AreEqual(obj.Primitive1, clone.Primitive1);
			Assert.AreEqual(obj.Primitive2, clone.Primitive2);
			Assert.AreEqual(obj.String1, clone.String1);
		}
开发者ID:JayCap,项目名称:Protobuf-net-Patch-and-T4-TypeModel-Generator,代码行数:35,代码来源:Core_AutoProperties.cs

示例9: Item

 public Item(ItemClass type, int amount)
     : base(ThingType.OBJECT_ITEM)
 {
     mType=type;
     mAmount=amount;
     mLifetime = Configuration.getValue("game_floorItemDecayTime", 0) * 10;
 }
开发者ID:Invertika,项目名称:server,代码行数:7,代码来源:Item.cs

示例10: GetRandomBuildingInfo_Upgrade

        // Called every frame on building upgrade
        public static BuildingInfo GetRandomBuildingInfo_Upgrade(Vector3 position, ushort prefabIndex, ref Randomizer r, ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level, int width, int length, BuildingInfo.ZoningMode zoningMode, int style)
        {
            // This method is very fragile, no logging here!
            
            var districtId = Singleton<DistrictManager>.instance.GetDistrict(position);

            // See if there is a special upgraded building
            var buildingInfo = BuildingThemesManager.instance.GetUpgradeBuildingInfo(prefabIndex, districtId);
            if (buildingInfo != null) 
            {
                return buildingInfo;
            }

            var areaIndex = BuildingThemesManager.GetAreaIndex(service, subService, level, width, length, zoningMode);

            // list of possible prefabs
            var fastList = Singleton<BuildingThemesManager>.instance.GetAreaBuildings(districtId, areaIndex);

            if (fastList == null || fastList.m_size == 0)
            {
                return (BuildingInfo)null;
            }

            // select a random prefab from the list
            int index = r.Int32((uint)fastList.m_size);
            return PrefabCollection<BuildingInfo>.GetPrefab((uint)fastList.m_buffer[index]);
        }
开发者ID:aoighost,项目名称:BuildingThemes,代码行数:28,代码来源:BuildingManagerDetour.cs

示例11: FindCargoParent

 private static ushort FindCargoParent(ushort sourceBuilding, ushort targetBuilding, ItemClass.Service service, ItemClass.SubService subService)
 {
     BuildingManager instance = Singleton<BuildingManager>.instance;
     VehicleManager instance2 = Singleton<VehicleManager>.instance;
     ushort num = instance.m_buildings.m_buffer [(int)sourceBuilding].m_ownVehicles;
     int num2 = 0;
     while (num != 0)
     {
         if (instance2.m_vehicles.m_buffer [(int)num].m_targetBuilding == targetBuilding && (instance2.m_vehicles.m_buffer [(int)num].m_flags & Vehicle.Flags.WaitingCargo) != Vehicle.Flags.None)
         {
             VehicleInfo info = instance2.m_vehicles.m_buffer [(int)num].Info;
             if (info.m_class.m_service == service && info.m_class.m_subService == subService)
             {
                 int num3;
                 int num4;
                 info.m_vehicleAI.GetSize (num, ref instance2.m_vehicles.m_buffer [(int)num], out num3, out num4);
                 if (num3 < num4)
                 {
                     return num;
                 }
             }
         }
         num = instance2.m_vehicles.m_buffer [(int)num].m_nextOwnVehicle;
         if (++num2 >= 65536)
         {
             CODebugBase<LogChannel>.Error (LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
             break;
         }
     }
     return 0;
 }
开发者ID:klyte45,项目名称:CS-VehicleLimitExpander,代码行数:31,代码来源:FakeCargoTruckAI.cs

示例12: FindNextCargoParent

 public static ushort FindNextCargoParent(ushort sourceBuilding, ItemClass.Service service, ItemClass.SubService subService)
 {
     BuildingManager instance = Singleton<BuildingManager>.instance;
     VehicleManager instance2 = Singleton<VehicleManager>.instance;
     ushort num = instance.m_buildings.m_buffer [(int)sourceBuilding].m_ownVehicles;
     ushort result = 0;
     int num2 = -1;
     int num3 = 0;
     while (num != 0) {
         if ((instance2.m_vehicles.m_buffer [(int)num].m_flags & Vehicle.Flags.WaitingCargo) != Vehicle.Flags.None) {
             VehicleInfo info = instance2.m_vehicles.m_buffer [(int)num].Info;
             if (info.m_class.m_service == service && info.m_class.m_subService == subService) {
                 int num4;
                 int b;
                 info.m_vehicleAI.GetSize (num, ref instance2.m_vehicles.m_buffer [(int)num], out num4, out b);
                 int num5 = Mathf.Max (num4 * 255 / Mathf.Max (1, b), (int)instance2.m_vehicles.m_buffer [(int)num].m_waitCounter);
                 if (num5 > num2) {
                     result = num;
                     num2 = num5;
                 }
             }
         }
         num = instance2.m_vehicles.m_buffer [(int)num].m_nextOwnVehicle;
         if (++num3 >= 65536) {
             CODebugBase<LogChannel>.Error (LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
             break;
         }
     }
     return result;
 }
开发者ID:klyte45,项目名称:CS-VehicleLimitExpander,代码行数:30,代码来源:FakeCargoTruckAI.cs

示例13: FindPathPosition

 public static bool FindPathPosition(Vector3 position, ItemClass.Service service, NetInfo.LaneType laneType, VehicleInfo.VehicleType vehicleTypes, bool allowUnderground, bool requireConnect, float maxDistance, out PathUnit.Position pathPos, RoadManager.VehicleType vehicleType)
 {
     PathUnit.Position position2;
     float num;
     float num2;
     return CustomPathManager.FindPathPosition(position, service, laneType, vehicleTypes, allowUnderground, requireConnect, maxDistance, out pathPos, out position2, out num, out num2, vehicleType);
 }
开发者ID:Rovanion,项目名称:csl-traffic,代码行数:7,代码来源:CustomPathManager.cs

示例14: Munition

 /// <summary>
 /// Initializes a new instance of the Munition class.
 /// Any out-of-range arguments will be clamped into the proper range automatically.
 /// </summary>
 /// <param name="itemTypeId">The ID of the item to create.</param>
 /// <param name="itemClass">The type of item that this is.</param>
 /// <param name="name">The item's name.</param>
 /// <param name="description">The item's description.</param>
 /// <param name="weight">The weight of the munition.</param>
 /// <param name="integrity">The munition's current integrity.</param>
 /// <param name="maximumIntegrity">The munition's maximum integrity.</param>
 /// <param name="integrityLevel">The munition's integrity level.</param>
 /// <param name="evasionBonus">The munition's evasion bonus.</param>
 /// <exception cref="System.ArgumentNullException">Any parameter is null.</exception>
 /// <exception cref="System.ArgumentOutOfRangeException">ItemTypeId is less than zero.</exception>
 /// <exception cref="System.ArgumentException">ItemClass is ItemClass.Undefined.</exception>
 protected Munition(long itemTypeId, ItemClass itemClass, string name, string description, float weight, short integrity, short maximumIntegrity, byte integrityLevel, byte evasionBonus)
     : base(itemTypeId, itemClass, name, description)
 {
     this.Weight = weight;
     this.Integrity = integrity;
     this.MaximumIntegrity = maximumIntegrity;
     this.IntegrityLevel = integrityLevel;
     this.EvasionBonus = evasionBonus;
 }
开发者ID:jakepetroules,项目名称:jakes-3d-mmo,代码行数:25,代码来源:Munition.cs

示例15: EquipmentSlot

 public EquipmentSlot(int id, StringName sn, ItemClass[] itemClass, SlotType slot)
 {
     _id = id;
     _displayedName = sn;
     _allowedItemType = new ItemClass[itemClass.GetLength(0)];
     _allowedItemType = itemClass;
     _item = null;
     _fullInfo = "-";
     _slotType = slot;
 }
开发者ID:Gnusznak,项目名称:CrystalsOfTime,代码行数:10,代码来源:EquipmentSlot.cs


注:本文中的ItemClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。