예제 #1
0
        public int                Index;               // the index inside the inventory at which the event happened

        public InventoryEvent(InventoryEventType eventType, InventorySlot slot, string targetInventoryName, InventoryItem eventItem, int quantity, int index)
        {
            InventoryEventType = eventType;
            Slot = slot;
            TargetInventoryName = targetInventoryName;
            EventItem           = eventItem;
            Quantity            = quantity;
            Index = index;
        }
예제 #2
0
 public static void Trigger(InventoryEventType eventType, InventorySlot slot, string targetInventoryName, InventoryItem eventItem, int quantity, int index)
 {
     e.InventoryEventType = eventType;
     e.Slot = slot;
     e.TargetInventoryName = targetInventoryName;
     e.EventItem           = eventItem;
     e.Quantity            = quantity;
     e.Index = index;
     EventManager.TriggerEvent(e);
 }
        public void AssemblerCorrectlyWritesInventoryEventTypeDto()
        {
            var inventoryEventType = new InventoryEventType();
            inventoryEventType.EventType = Constants.InventoryEventTypes.RECEIPT_FROM_VENDOR;

            var invEventTypeDto = _assembler.WriteDto(inventoryEventType);

            Assert.IsNotNull(invEventTypeDto);
            Assert.AreEqual(inventoryEventType.EventType, invEventTypeDto.EventType);
        }
        public InventoryEventTypeDto WriteDto(InventoryEventType inventoryEventType)
        {
            if (inventoryEventType == null)
                throw new ArgumentNullException();

            var invEventTypeDto = new InventoryEventTypeDto();

            invEventTypeDto.EventType = inventoryEventType.EventType;

            return invEventTypeDto;
        }
 public void Save(InventoryEventType inventoryEventType)
 {
     using (var session = ObjectFactory.GetInstance<IMySessionFactory>().OpenSession())
     using (var transaction = session.BeginTransaction())
     {
         try
         {
             session.SaveOrUpdate(inventoryEventType);
             session.Flush();
             transaction.Commit();
         }
         catch (Exception)
         {
             transaction.Rollback();
             throw;
         }
     }
 }
예제 #6
0
        /**
         * <summary>Triggers either the OnInventoryAdd, OnInventoryRemove, OnInventorySelect or OnInventoryDeselect events.<summary>
         * <param name = "invItem">The inventory item that was manipulated</param>
         * <param name = "inventoryEventType">How the inventory item was manipulated (Add, Remove, Select, Deselect)</param>
         * <param name = "amount">How many instances of the inventory item were affected, if appropriate</param>
         */
        public void Call_OnChangeInventory(InvItem invItem, InventoryEventType inventoryEventType, int amount = 1)
        {
            if (invItem == null)
            {
                return;
            }

            if (inventoryEventType == InventoryEventType.Add && OnInventoryAdd != null)
            {
                OnInventoryAdd(invItem, amount);
            }
            else if (inventoryEventType == InventoryEventType.Remove && OnInventoryRemove != null)
            {
                OnInventoryRemove(invItem, amount);
            }
            else if (inventoryEventType == InventoryEventType.Select && OnInventorySelect != null)
            {
                OnInventorySelect(invItem);
            }
            else if (inventoryEventType == InventoryEventType.Deselect && OnInventoryDeselect != null)
            {
                OnInventoryDeselect(invItem);
            }
        }
        public void Setup()
        {
            _mockSessionFactory = new Mock<IMySessionFactory>();
            _mockSettingsFactory = new Mock<ISettingsFactory>();
            _session = new Mock<ISession>();
            _transaction = new Mock<ITransaction>();
            _repository = new InventoryEventTypeRepository();
            _inventoryEventType = new InventoryEventType();

            Bootstrapper.BootstrapStructureMap();
            ObjectFactory.Inject(typeof(IMySessionFactory), _mockSessionFactory.Object);
            ObjectFactory.Inject(typeof(ISettingsFactory), _mockSettingsFactory.Object);

            _mockSessionFactory.Setup(x => x.OpenSession()).Returns(_session.Object);
            _session.Setup(x => x.BeginTransaction()).Returns(_transaction.Object);
        }
 public Inventory_GameEvent(InventoryEventType t, Weapons w)
 {
     InventoryEventType = t;
     Weapon             = w;
 }
예제 #9
0
    public ItemData item;           // Reference to the item data

    // Constructor
    public InventoryEventArgs(InventoryEventType type, ItemData item)
    {
        this.type = type;
        this.item = item;
    }