예제 #1
0
        public bool DropItem(Item item, Player player)
        {
            if (item.Name == ItemName.Empty)
            {
                return(false);
            }
            Item invItem = Items.Find(i => i.Name == item.Name);

            if (invItem != null)
            {
                if (invItem.Type == ItemType.Passive)
                {
                    invItem.Drop(player);
                }
                Items.Remove(invItem);
            }
            else if (LeftWeapon.Name == item.Name)
            {
                LeftWeapon = new EmptyItem();
            }
            else if (RightWeapon.Name == item.Name)
            {
                RightWeapon = new EmptyItem();
            }
            else if (Armor.Name == item.Name)
            {
                Armor = new EmptyItem();
            }
            else
            {
                return(false);
            }
            Drop++;
            return(true);
        }
예제 #2
0
 /// <summary>
 /// Default constructor used during file parsing.
 /// </summary>
 /// <param name="stf">The STFreader containing the file stream</param>
 internal RoadTrackDB(STFReader stf)
 {
     stf.MustMatchBlockStart();
     stf.ParseBlock(new STFReader.TokenProcessor[] {
         new STFReader.TokenProcessor("tracknodes", () => {
             stf.MustMatchBlockStart();
             int count  = stf.ReadInt(null);
             TrackNodes = new TrackNode[count + 1];
             int idx    = 1;
             stf.ParseBlock(new STFReader.TokenProcessor[] {
                 new STFReader.TokenProcessor("tracknode", () => { TrackNodes[idx] = TrackNode.ReadTrackNode(stf, idx, count); ++idx; }),
             });
         }),
         new STFReader.TokenProcessor("tritemtable", () => {
             stf.MustMatchBlockStart();
             int count   = stf.ReadInt(null);
             TrItemTable = new TrackItem[count];
             int idx     = -1;
             stf.ParseBlock(() => ++ idx == -1, new STFReader.TokenProcessor[] {
                 new STFReader.TokenProcessor("levelcritem", () => { TrItemTable[idx] = new RoadLevelCrossingItem(stf, idx); }),
                 new STFReader.TokenProcessor("emptyitem", () => { TrItemTable[idx] = new EmptyItem(stf, idx); }),
                 new STFReader.TokenProcessor("carspawneritem", () => { TrItemTable[idx] = new RoadCarSpawner(stf, idx); })
             });
         }),
     });
 }
예제 #3
0
 public Inventory()
 {
     LeftWeapon  = new EmptyItem();
     RightWeapon = new EmptyItem();
     Armor       = new EmptyItem();
     Items       = new List <Item>();
     Drop        = 0;
 }
 /// <summary>
 /// swaps inventory with one of the slots
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="z">1 = primary slot, 2 = secondary slot</param>
 public void Swap(int x, int y, int z)
 {
     if (z == 1)
     {
         Item tempItemId = slot1;
         if (tempItemId == null)
         {
             tempItemId = new EmptyItem();
         }
         slot1           = inventory[x, y];
         inventory[x, y] = tempItemId;
     }
     if (z == 2)
     {
         Item tempItemId = slot1;
         if (tempItemId == null)
         {
             tempItemId = new EmptyItem();
         }
         slot2           = inventory[x, y];
         inventory[x, y] = tempItemId;
     }
     if (z == 3)
     {
         Item tempItemId = slot1;
         if (tempItemId == null)
         {
             tempItemId = new EmptyItem();
         }
         slot3           = inventory[x, y];
         inventory[x, y] = tempItemId;
     }
     if (z == 4)
     {
         Item tempItemId = slot1;
         if (tempItemId == null)
         {
             tempItemId = new EmptyItem();
         }
         slot4           = inventory[x, y];
         inventory[x, y] = tempItemId;
     }
     if (z == 5)
     {
         Item tempItemId = slot1;
         if (tempItemId == null)
         {
             tempItemId = new EmptyItem();
         }
         slot5           = inventory[x, y];
         inventory[x, y] = tempItemId;
     }
 }
        void InitializeInventory(int inventoryWidth, int inventoryHeight)
        {
            inventory = new Item[inventoryWidth, inventoryHeight];

            for (int y = 0; y < inventoryHeight; y++)
            {
                for (int x = 0; x < inventoryWidth; x++)
                {
                    // -1 empty Item
                    inventory[x, y] = new EmptyItem();
                }
            }
        }
예제 #6
0
 private void AddEmptyItemAtTail()
 {
     if (this._emptyItemTemplate != null)
     {
         int num = this.ItemCount % this.JumpSeparatorInterval;
         while (num != 0 && num < this.JumpSeparatorInterval)
         {
             EmptyItem emptyItem = new EmptyItem();
             this._emptyItemTemplate.InstantiateIn(emptyItem);
             this.Controls.Add(emptyItem);
             num++;
         }
     }
 }
 /// <summary>
 /// finds item with the same id and then removes it by setting it to id -1 (Empty)
 /// </summary>
 /// <param name="itemId"></param>
 private void RemoveItem(int itemId)
 {
     for (int y = 0; y < height; y++)
     {
         for (int x = 0; x < width; x++)
         {
             if (inventory[x, y].itemID == itemId)
             {
                 inventory[x, y] = new EmptyItem();
                 return;
             }
         }
     }
 }
예제 #8
0
 public void Clear(Player player)
 {
     LeftWeapon  = new EmptyItem();
     RightWeapon = new EmptyItem();
     Armor       = new EmptyItem();
     for (int i = 0; i < Items.Count; i++)
     {
         if (Items[i].Type == ItemType.Passive)
         {
             Items[i].Drop(player);
         }
     }
     Items = new List <Item>();
     Drop  = 0;
 }
예제 #9
0
 protected override void OnItemCreated(RepeaterItemEventArgs e)
 {
     if (this.EmptyItemCountBeforeItem > 0 && this.JumpSeparatorInterval > 0 && this.EmptyItemCountBeforeItem >= this.JumpSeparatorInterval)
     {
         throw new Exception("EmptyItemCountBeforeItem 는 JumpSeparatorInterval 보다 작아야 합니다. ");
     }
     base.OnItemCreated(e);
     if (e.Item.ItemType == ListItemType.Item && this.DataCount > 0 && this.EmptyItemCountBeforeItem > 0 && this._emptyItemTemplate != null && this.Items.Count == 0)
     {
         for (int i = 0; i < this.EmptyItemCountBeforeItem; i++)
         {
             EmptyItem emptyItem = new EmptyItem();
             this._emptyItemTemplate.InstantiateIn(emptyItem);
             this.Controls.Add(emptyItem);
             this._emptyItemCount++;
         }
     }
     if (e.Item.ItemType == ListItemType.Footer)
     {
         this._renderFooter = true;
         if (this.DataCount == 0)
         {
             this.AddAllEmptyItem();
         }
         if (this.JumpSeparatorInterval > 0 && this._jumpSeparatorTemplate != null && this.Items.Count > 0)
         {
             this.AddEmptyItemAtTail();
         }
     }
     if (this.JumpSeparatorInterval > 0 && this._jumpSeparatorTemplate != null && this.Items.Count > 0 && (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) && this.ItemCount % this.JumpSeparatorInterval == 0)
     {
         if (this.SeparatorTemplate != null)
         {
             this.Controls.RemoveAt(this.Controls.Count - 1);
         }
         JumpSeparator jumpSeparator = new JumpSeparator();
         this._jumpSeparatorTemplate.InstantiateIn(jumpSeparator);
         this.Controls.Add(jumpSeparator);
     }
 }
예제 #10
0
 public void Saveitem(Item item, int num)
 {
     for (int i = 0; i < Items.Count; i++)
     {
         if (Items[i].GetType().Equals(item.GetType()))
         {
             Items[i].Number += num;
             if (Items[i].Number <= 0)
             {
                 Items[i] = new EmptyItem();
             }
             return;
         }
     }
     for (int i = 0; i < Items.Count; i++)
     {
         if (Items[i].GetType().Equals(typeof(EmptyItem)))
         {
             Items[i] = item;
             return;
         }
     }
 }
예제 #11
0
        public static DropDownItem GetEmptyItem(EmptyItem pEmptyItem)
        {
            var oItemVacio = new DropDownItem {
                Selected = true
            };

            if (pEmptyItem == EmptyItem.Select_Numeric || pEmptyItem == EmptyItem.All_Numerics)
            {
                oItemVacio.Id = "-1";
            }
            else
            {
                oItemVacio.Id = string.Empty;
            }
            if (pEmptyItem == EmptyItem.Select_Numeric || pEmptyItem == EmptyItem.Select_String)
            {
                oItemVacio.Description = "-- Seleccione --";
            }
            else
            {
                oItemVacio.Description = "-- Todos --";
            }
            return(oItemVacio);
        }
예제 #12
0
        public static DropDownItems PopulateDropDown <T>(List <T> pList, string pShowProperty, string pPropertyValue, string pPropertyGroup, EmptyItem pEmptyItem)
        {
            var oRtn = new DropDownItems();

            if (pEmptyItem != EmptyItem.None)
            {
                oRtn.Add(GetEmptyItem(pEmptyItem));
            }
            foreach (var item in pList)
            {
                var    wPropiedadMostrar = item.GetType().GetProperty(pShowProperty);
                var    wPropiedadValor   = item.GetType().GetProperty(pPropertyValue);
                var    wPropiedadGrupo   = item.GetType().GetProperty(pPropertyGroup);
                var    oTextField        = wPropiedadMostrar.GetValue(item, null);
                var    oPropiedadValor   = wPropiedadValor.GetValue(item, null);
                object oPropiedadGrupo   = string.Empty;
                if (wPropiedadGrupo != null)
                {
                    oPropiedadGrupo = wPropiedadGrupo.GetValue(item, null);
                }
                oRtn.Add(new DropDownItem(oPropiedadValor.ToString(), oTextField.ToString(), (oPropiedadGrupo != null ? oPropiedadGrupo.ToString() : string.Empty), false));
            }
            return(oRtn);
        }
예제 #13
0
 public static DropDownItems PopulateDropDown <T>(List <T> pList, string pShowProperty, string pPropertyValue, EmptyItem pEmptyItem)
 {
     return(PopulateDropDown <T>(pList, pShowProperty, pPropertyValue, string.Empty, pEmptyItem));
 }