Ejemplo n.º 1
0
        public Item Find(EQUIP_PART part)
        {
            if (_Items.ContainsKey(part))
                return _Items[part];

            return null;
        }
Ejemplo n.º 2
0
        public Item[] Unequip(EQUIP_PART equip_type)
        {
            Item item;

            _Items.TryGetValue(equip_type, out item);
            if (Item.IsValid(item))
            {
                _Items.Remove(equip_type);
                RemoveEvent(item.Id);
            }
            if (equip_type == EQUIP_PART.RIGHT_HAND)
            {
                Item leftItem;
                if (_Items.TryGetValue(EQUIP_PART.LEFT_HAND, out leftItem) && Item.IsValid(leftItem))
                {
                    _Items.Remove(EQUIP_PART.LEFT_HAND);
                    RemoveEvent(leftItem.Id);
                    return(new[] { item, leftItem });
                }
            }

            return(new [] { item });
        }
        private TICKRESULT _Equip(EQUIP_PART part)
        {
            if(_InventoryController == null)
                return TICKRESULT.FAILURE;
            var items = _Bag.FindByPart(part);
            var item = items.Concat(new Item[] {null}).Shuffle().FirstOrDefault();
            if (item != null)
            {
                _InventoryController.Equip(item.Id);
                return TICKRESULT.SUCCESS;
            }

            return _Unequip(part);
        }
Ejemplo n.º 4
0
        public Item[] Unequip(EQUIP_PART equip_type)
        {
            Item item;
            _Items.TryGetValue(equip_type, out item);
            if (Item.IsValid(item))
            {
                _Items.Remove(equip_type);
                RemoveEvent(item.Id);
            }
            if (equip_type == EQUIP_PART.RIGHT_HAND)
            {
                Item leftItem;
                if (_Items.TryGetValue(EQUIP_PART.LEFT_HAND, out leftItem) && Item.IsValid(leftItem))
                {
                    _Items.Remove(EQUIP_PART.LEFT_HAND);
                    RemoveEvent(leftItem.Id);
                    return new[] { item, leftItem };
                }
            }

            return new [] { item } ;
        }
 private TICKRESULT _Unequip(EQUIP_PART part)
 {
     var item = _Equipment.FindByPart(part).FirstOrDefault();
     if (item != null)
     {
         _InventoryController.Unequip(item.Id);
         return TICKRESULT.SUCCESS;
     }
     return TICKRESULT.FAILURE;
 }
Ejemplo n.º 6
0
        public void OnGUI()
        {
            EditorGUILayout.BeginVertical();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Load"))
            {
                var path = EditorUtility.OpenFilePanel("select", "", "txt");
                _ItemSet = new ItemPrototypeSet(Regulus.Utility.Serialization.Read <ItemPrototype[]>(path));
            }
            if (GUILayout.Button("Save"))
            {
                var path = EditorUtility.SaveFilePanel("select", "", "items.txt", "txt");
                Regulus.Utility.Serialization.Write(_ItemSet.GetItems().ToArray(), path);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            _Begin = EditorGUILayout.IntField("Begin", _Begin);
            _End   = EditorGUILayout.IntField("End", _End);
            EditorGUILayout.EndHorizontal();

            var set         = _ItemSet.GetItems().Skip(_Begin).Take(_End - _Begin).ToArray();
            var length      = set.Length;
            var fieldLength = 5;
            var lineLength  = length / fieldLength;

            EditorGUILayout.BeginVertical();
            for (int i = 0; i <= lineLength; i++)
            {
                int index = i * fieldLength;
                int end   = index + fieldLength;
                EditorGUILayout.BeginHorizontal();
                for (; index < end && index < length; index++)
                {
                    EditorGUILayout.SelectableLabel(set[index].Name);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();



            EditorGUILayout.BeginHorizontal();

            _ItemName = EditorGUILayout.TextField("Name", _ItemName);


            _EquipPart    = (EQUIP_PART)EditorGUILayout.EnumPopup("EquipPart", _EquipPart);
            _ItemFeatures = (ITEM_FEATURES)EditorGUILayout.EnumPopup("Features", _ItemFeatures);
            _Description  = EditorGUILayout.TextField("Description", _Description);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Set/Add"))
            {
                _ItemSet.Add(new ItemPrototype()
                {
                    Name      = _ItemName,
                    Features  = _ItemFeatures,
                    EquipPart = _EquipPart
                });
            }
            if (GUILayout.Button("Load"))
            {
                var item = _ItemSet.Find(_ItemName);
                _ItemFeatures = item.Features;
                _Description  = item.Description;
                _EquipPart    = item.EquipPart;
            }
            if (GUILayout.Button("Remove"))
            {
                _ItemSet.Remove(_ItemName);
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
 public IEnumerable <Item> FindByPart(EQUIP_PART part)
 {
     return(from item in _Items where item.GetEquipPart() == part select item);
 }
Ejemplo n.º 8
0
        public void OnGUI()
        {
            EditorGUILayout.BeginVertical();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Load"))
            {
                var path = EditorUtility.OpenFilePanel("select", "", "txt");
                _ItemSet = new ItemPrototypeSet(Regulus.Utility.Serialization.Read<ItemPrototype[]>(path));
            }
            if (GUILayout.Button("Save"))
            {
                var path = EditorUtility.SaveFilePanel("select", "", "items.txt", "txt");
                Regulus.Utility.Serialization.Write(_ItemSet.GetItems().ToArray() , path);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            _Begin = EditorGUILayout.IntField("Begin", _Begin);
            _End = EditorGUILayout.IntField("End", _End);
            EditorGUILayout.EndHorizontal();

            var set = _ItemSet.GetItems().Skip(_Begin).Take(_End - _Begin).ToArray();
            var length = set.Length;
            var fieldLength = 5;
            var lineLength = length  / fieldLength ;
            EditorGUILayout.BeginVertical();
            for (int i = 0; i <= lineLength ; i++)
            {
                int index = i * fieldLength;
                int end = index + fieldLength ;
                EditorGUILayout.BeginHorizontal();
                for (; index < end && index < length; index++)
                {
                    EditorGUILayout.SelectableLabel(set[index].Id);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginHorizontal();

            _ItemName = EditorGUILayout.TextField("Name", _ItemName);

            _EquipPart = (EQUIP_PART)EditorGUILayout.EnumPopup("EquipPart", _EquipPart);

            _Description = EditorGUILayout.TextField("Description", _Description);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Set/Add"))
            {

                _ItemSet.Add(new ItemPrototype()
                {
                    Id = _ItemName,

                    EquipPart = _EquipPart

                } );
            }
            if (GUILayout.Button("Load"))
            {
                var item = _ItemSet.Find(_ItemName);
                _Description = item.Description;
                _EquipPart = item.EquipPart;
            }
            if (GUILayout.Button("Remove"))
            {
                _ItemSet.Remove(_ItemName);
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
 public IEnumerable<Item> FindByPart(EQUIP_PART part)
 {
     return from item in _Items where item.GetEquipPart() == part select item;
 }