Пример #1
0
 void Awake()
 {
     if (Container == null)
     {
         Container = this.GetComponent<ItemContainer>();
     }
 }
        public object GiveItem(BasePlayer player, string itemname, int amount, ItemContainer pref)
        {
            itemname = itemname.ToLower();

            bool isBP = false;
            if (itemname.EndsWith(" bp"))
            {
                isBP = true;
                itemname = itemname.Substring(0, itemname.Length - 3);
            }
            if (displaynameToShortname.ContainsKey(itemname))
                itemname = displaynameToShortname[itemname];
            var definition = ItemManager.FindItemDefinition(itemname);
            if (definition == null)
                return string.Format("{0} {1}", "Item not found: ", itemname);
            int giveamount = 0;
            int stack = (int)definition.stackable;
            if (isBP)
                stack = 1;
            if (stack < 1) stack = 1;
            for (var i = amount; i > 0; i = i - stack)
            {
                if (i >= stack)
                    giveamount = stack;
                else
                    giveamount = i;
                if (giveamount < 1) return true;
                player.inventory.GiveItem(ItemManager.CreateByItemID((int)definition.itemid, giveamount, isBP), pref);
            }
            return true;
        }
Пример #3
0
    public void CreateItem()
    {
        GetIDCount();
        ItemContainer itemContainer = new ItemContainer();

        System.Type[] itemTypes = { typeof(Equipment), typeof(Weapon), typeof(Consumable) };

        XmlSerializer serializer = new XmlSerializer(typeof(ItemContainer), itemTypes);

        FileStream fs = new FileStream(Path.Combine(Application.streamingAssetsPath, "Items.xml"), FileMode.Open);

        itemContainer = (ItemContainer)serializer.Deserialize(fs);

        fs.Close();

        switch (category)
        {
            case Category.Equipment:
                itemContainer.Equipments.Add(new Equipment(currentId, itemName, description, itemType, quality, spritePath, malePath, femalePath, maxStackSize, strenght, dexterity, stamina, magic));
                break;
            case Category.Weapon:
                itemContainer.Weapons.Add(new Weapon(currentId, itemName, description, itemType, quality, spritePath, malePath, femalePath, maxStackSize, strenght, dexterity, stamina, magic, attack, defence));
                break;
            case Category.Consumable:
                itemContainer.Consumables.Add(new Consumable(currentId, itemName, description, itemType, quality, spritePath, maxStackSize, health, mana));
                break;
            default:
                break;
        }

        fs = new FileStream(Path.Combine(Application.streamingAssetsPath, "Items.xml"), FileMode.Create);
        serializer.Serialize(fs, itemContainer);
        fs.Close();
    }
Пример #4
0
	public void CreateItem () {
		ItemContainer itemContainer = new ItemContainer ();

		Type[] itemTypes = { typeof(Equipment), typeof(Weapon), typeof(Consumeable)};
		FileStream fs = new FileStream (Path.Combine (Application.streamingAssetsPath, "Items.xml"), FileMode.Open);
		XmlSerializer serializer = new XmlSerializer (typeof(ItemContainer), itemTypes);
		itemContainer = (ItemContainer)serializer.Deserialize (fs);
		serializer.Serialize (fs, itemContainer);	 
		fs.Close ();

		switch (category) {
			case Category.EQUIPMENT:
			itemContainer.Equipment.Add(new Equipment(itemName, description, itemType, quality, spriteNeutral, spriteHighlighted, maxSize, intellect, agility, stamina, strength));
				break;
			case Category.WEAPON:
			itemContainer.Weapons.Add(new Weapon(itemName, description, itemType, quality, spriteNeutral, spriteHighlighted, maxSize, intellect, agility, stamina, strength, attackSpeed));
				break;
			case Category.CONSUMEABLE:
			    itemContainer.Consumable.Add(new Consumeable(itemName, description, itemType, quality, spriteNeutral, spriteHighlighted, maxSize, health, mana, rage));
				break;
        }

		fs = new FileStream (Path.Combine (Application.streamingAssetsPath, "Items.xml"), FileMode.Create); 
		serializer.Serialize (fs, itemContainer);
		fs.Close ();
	}
 protected override async Task SaveDataAsync(ItemContainer container)
 {
     StorageFolder local = ApplicationData.Current.LocalFolder;
     StorageFolder dataFolder = await local.CreateFolderAsync("data", CreationCollisionOption.OpenIfExists);
     StorageFile file = await dataFolder.CreateFileAsync(FileName, CreationCollisionOption.ReplaceExisting);
     using (Stream storageFileStream = await file.OpenStreamForWriteAsync())
         Serializer.WriteObject(storageFileStream, container);
 }
Пример #6
0
        private void OnJoin(Packet packet)
        {
            //TODO: Use all fields.

            var characterId = packet.ReadInt32();
            var patchVersion = packet.ReadByte();
            var hdInfo = packet.ReadString();

            Character = User.Characters.FirstOrDefault(c => c.Id == characterId);

            if (Character != null)
            {
                Console.WriteLine(Character.GetHashCode());

                InventoryItems = new ItemContainer<InventoryItem>(Character, Character.InventoryItems, (byte) Define.MAX_INVENTORY, (byte) Define.MAX_HUMAN_PARTS, Constants.InventorySlots);
                QuestItems = new ItemContainer<QuestItem>(Character, Character.QuestItems, (byte) Define.MAX_INVENTORY, 0, Constants.QuestSlots);

                StorageItems = new ItemContainer<StorageItem>(Character, Character.StorageItems, 0, 0, new byte[] { }); //TODO: Implement storage items.

                var response = new Packet(Opcode.JOIN_RIGHT);

                response.WriteInt32(characterId);

                response.WriteInt32(Character.WorldId);
                response.WritePosition(Character.Position);

                response.WriteBoolean(false); //Is festival
                response.WriteInt32(0); //Festival 'yday'

                Send(response);

                var joinSnapshot = new Snapshot();

                joinSnapshot.SetType(SnapshotType.UPDATE_SERVER_TIME);
                joinSnapshot.WriteInt32(DateTime.UtcNow.GetUnixTimestamp());

                WriteObjectData(joinSnapshot, Character, true);

                Send(joinSnapshot);

                var spawnNearPlayers = new Snapshot();
                foreach (var player in NearPlayers)
                    WriteObjectData(spawnNearPlayers, player.Character);

                Send(spawnNearPlayers);

                var spawnNewPlayer = new Snapshot();
                WriteObjectData(spawnNewPlayer, Character);

                SendNearPlayers(spawnNewPlayer);
            }
            else
            {
                //NOTE: In theory, it's possible to send JOIN_ERROR and an error code, but the client doesn't seem to use it.

                Disconnect();
            }
        }
 protected override List<ItemContainerStackRestrictions> GetRestrictionsFor(ItemContainer target)
 {
     List<ItemContainerStackRestrictions> restrictions = new List<ItemContainerStackRestrictions>();
     foreach (ItemContainerStackRestrictions res in target.GetComponentsInChildren<ItemContainerStackRestrictions>())
     {
         restrictions.Add(res);
     }
     return restrictions;
 }
Пример #8
0
        public InventoryModEvent(ItemContainer ic, Item i)
        {
            _item = new InvItem(i);
            _itemContainer = ic;

            if (ic.entityOwner != null)
                _entity = new Entity(ic.entityOwner);
            if (ic.playerOwner != null)
                _owner = Server.GetPlayer(ic.playerOwner);
        }
 protected override Task SaveDataAsync(ItemContainer container)
 {
     using (var memoryStream = new MemoryStream())
     {
         Serializer.WriteObject(memoryStream, container);
         string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, FileName);
         File.WriteAllBytes(path, memoryStream.ToArray());
         return Empty.TrueTask;
     }
 }
Пример #10
0
        public InventoryModEvent(ItemContainer itemContainer, Item item)
        {
            ItemContainer = itemContainer;
            Item = new InvItem(item);

            if (itemContainer.playerOwner != null)
                Player = Server.GetPlayer(itemContainer.playerOwner);

            if (itemContainer.entityOwner != null)
                Entity = new Entity(itemContainer.entityOwner);
        }
 protected override Task SaveDataAsync(ItemContainer container)
 {
     using (var memoryStream = new MemoryStream())
     {
         string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
         string path = Path.Combine(folderPath, FileName);
         Serializer.WriteObject(memoryStream, container);
         File.WriteAllBytes(path, memoryStream.ToArray());
         return Empty.Task;
     }
 }
 public virtual int GetRestrictedAmount(ItemData data,ItemContainer target)
 {
     restrictions = GetRestrictionsFor(target);
     foreach (ItemContainerStackRestrictions restriction in restrictions)
     {
         int restrictedAmount = restriction.GetRestrictionForType(data.classID);
         if (restrictedAmount!= -1)
         {
             return restrictedAmount;
         }             
     }
     return -1;
 }
Пример #13
0
 public static void OpenPanelContainerUI(ItemContainer container)
 {
     _panel.SetActive(true);
     _itemContainer = container;
     _containerName.text = _itemContainer.Name;
     //Enable or disable previous/next buttons:
     if (_itemContainer.Content.Length >= _buttons.Length)
         _nextButton.SetActive(true);
     else
         _nextButton.SetActive(false);
     _previousButton.SetActive(false);
     UpdateButtonAtPage(0);
 }
 protected override Task SaveDataAsync(ItemContainer container)
 {
     return Task.Factory.StartNew(() =>
     {
         using (var memoryStream = new MemoryStream())
         {
             string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
             string path = Path.Combine(folderPath, FileName);
             Serializer.WriteObject(memoryStream, container);
             File.WriteAllBytes(path, memoryStream.ToArray());
         }
     });
 }
    void OnContainerLoadItems(List<ItemData> items, ItemContainer container)
    {
        foreach (ItemData item in items)
        {
            ItemData itemData = ItemConverter.ConvertItemDataToNGUIItemDataObject(item);

            List<ItemData> componentInitailizerList = new List<ItemData>();

            componentInitailizerList.Add(itemData);
            container.Add(itemData, -1, false);
            Destroy(item.gameObject);
        }
    }
 protected override async Task SaveDataAsync(ItemContainer container)
 {
     StorageFile file = await ApplicationData
         .Current
         .LocalFolder
         .CreateFileAsync(FileName, CreationCollisionOption.ReplaceExisting);
     using (var ms = new MemoryStream())
     using (Stream fileStream = await file.OpenStreamForWriteAsync())
     {
         Serializer.WriteObject(ms, container);
         ms.Seek(0, SeekOrigin.Begin);
         await ms.CopyToAsync(fileStream);
     }
 }
Пример #17
0
    public static ContainerAddState.ActionState MoveItem(ItemData movingItemData, ItemContainer targetContainer)
    {
        try
        {
            if (movingItemData == null)
                throw new Exception("Can Not Move null item");

            if (targetContainer == null)
                throw new Exception("Can not move item to null container");

            ContainerAddState targetAddState = targetContainer.GetContainerAddState(movingItemData);

            switch (targetAddState.actionState)
            {
                case ContainerAddState.ActionState.Add:
                    if (movingItemData.ownerContainer != null)
                    {
                        movingItemData.ownerContainer.Remove(movingItemData, true, targetAddState.possibleAddAmount);
                    }
                    targetContainer.Add(ItemConverter.ConvertItemDataToNGUIItemDataObject(movingItemData), targetAddState.possibleAddAmount);
                    break;
                case ContainerAddState.ActionState.Swap:
                    if (movingItemData.ownerContainer != null)
                    {
                        CheckSwapability(ItemConverter.ConvertItemDataToNGUIItemDataObject(movingItemData), targetContainer, targetAddState);
                    }
                    else
                    {
                        return ContainerAddState.ActionState.No;
                    }
                    break;
                case ContainerAddState.ActionState.No:
                    break;
                default:
                    break;
            }

            return targetAddState.actionState;
        }
        catch (Exception e)
        {
            Debug.Log(e.Message);

            return ContainerAddState.ActionState.No;
        }
    }
Пример #18
0
    public void CreateItem()
    {
        //Creates a container for the items
        ItemContainer itemContainer = new ItemContainer();

        //Defines the item types that we can serialize
        Type[] itemTypes = { typeof(Equipment), typeof(Weapon), typeof(Consumeable) };

        //Cretes a file stream, so that we can read the xml file
        FileStream fs = new FileStream(Path.Combine(Application.streamingAssetsPath, "Items.xml"), FileMode.Open);

        //Creates a serializer so that we can serialize the items
        XmlSerializer serializer = new XmlSerializer(typeof(ItemContainer), itemTypes);

        //Deserializes the items into the container
        itemContainer = (ItemContainer)serializer.Deserialize(fs);

        //Serializes the stream
        serializer.Serialize(fs, itemContainer);

        //Closes the stream
        fs.Close();

        switch (categeory) //Adds the correct item to the itemContainer
        {
            case Category.EQUIPMENT:
            itemContainer.Equipment.Add(new Equipment(itemName, description, itemType, quality, spriteNeutral, spriteHighlighted, maxSize, strength, endurance, dexterity, intellect, willpower, charisma, luck));
                break;
            case Category.WEAPON:
            itemContainer.Weapons.Add(new Weapon(itemName, description, itemType, quality, spriteNeutral, spriteHighlighted, maxSize, strength, endurance, dexterity, intellect, willpower, charisma, luck, attackSpeed));
                break;
            case Category.CONSUMEABLE:
                itemContainer.Consumeables.Add(new Consumeable(itemName, description, itemType, quality, spriteNeutral, spriteHighlighted, maxSize,health,mana));
                break;

        }

        //Oprens the file
        fs = new FileStream(Path.Combine(Application.streamingAssetsPath, "Items.xml"), FileMode.Create);

        //Adds the item
        serializer.Serialize(fs, itemContainer);

        fs.Close();
    }
Пример #19
0
 public object GiveItem(BasePlayer player, string itemname, int amount, ItemContainer pref, out string description)
 {
     description = itemname;
     itemname = itemname.ToLower();
     if (amount < 1) amount = 1;
     bool isBP = false;
     if (itemname.EndsWith(" bp"))
     {
         isBP = true;
         itemname = itemname.Substring(0, itemname.Length - 3);
     }
     if (displaynameToShortname.ContainsKey(itemname))
         itemname = displaynameToShortname[itemname];
     var definition = ItemManager.FindItemDefinition(itemname);
     if (definition == null)
         return string.Format("{0} {1}",itemNotFound,itemname);
     description = definition.displayName.english.ToString();
     int giveamount = 0;
     int stack = (int)definition.stackable;
     if (stack < 1) stack = 1;
     if (isBP)
     {
         stack = 1;
         description = description + " BP";
     }
     if (Stackable && !isBP)
     {
         player.inventory.GiveItem(ItemManager.CreateByItemID((int)definition.itemid, amount, isBP), pref);
         SendReply(player, string.Format("You've received {0} x {1}", description, amount.ToString()));
     }
     else
     {
         for (var i = amount; i > 0; i = i - stack)
         {
             if (i >= stack)
                 giveamount = stack;
             else
                 giveamount = i;
             if (giveamount < 1) return true;
             player.inventory.GiveItem(ItemManager.CreateByItemID((int)definition.itemid, giveamount, isBP), pref);
             SendReply(player, string.Format("You've received {0} x {1}", description, giveamount.ToString()));
         }
     }
     return true;
 }
Пример #20
0
    public void Show(ItemContainer container)
    {
        if (container == null)
        {
            Enabled = false;
            return;
        }

        Enabled = true;

        Container = container;

        NameLabel.Name = Container.Name;
        GoldButton.Name = Container.Items.GoldCoins.ToString();

        foreach (GUIElement element in Items)
            SetElementImage(element, Container.Items.GetItem(element.ID));
    }
    void OnContainerLoadItems(List<ItemData> items, ItemContainer container)
    {
        foreach (ItemData item in items)
        {
            ItemData itemData = ItemConverter.ConvertItemDataToNGUIItemDataObject(item);

            foreach (SlottedContainerSlotData slot in (container as SlottedItemContainer).slots.Values)
            {
                if (slot.persistantID == item.persistantLocation && slot.slotData == null)
                {
                    (container as SlottedItemContainer).AddToSlot(itemData, int.Parse(slot.slotNameID), -1, false);
                    break;
                }
                Destroy(itemData.gameObject);
            }
            Destroy(item.gameObject);
        }
    }
Пример #22
0
        /// <summary>
        /// Creates new instance of the class and initializes it with the parent RibbonStrip control.
        /// </summary>
        /// <param name="parent">Reference to parent MetroToolbar control</param>
        public MetroToolbarContainer(MetroToolbar parent)
        {
            _MetroToolbar = parent;

            // We contain other controls
            m_IsContainer = true;
            this.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;

            _MainItemsContainer = new ItemContainer();
            _MainItemsContainer.LayoutOrientation = eOrientation.Horizontal;
            _MainItemsContainer.GlobalItem = false;
            _MainItemsContainer.Displayed = true;
            _MainItemsContainer.ItemSpacing = 0;
            _MainItemsContainer.SetSystemContainer(true);
            _MainItemsContainer.ContainerControl = parent;
            _MainItemsContainer.DesignTimeVisible = false;
            _MainItemsContainer.Name = "_MainItemsContainer";
            this.SubItems.Add(_MainItemsContainer);

            _ExpandButton = new ButtonItem();
            _ExpandButton.Click += new EventHandler(ExpandButtonClick);
            _ExpandButton.ImagePaddingHorizontal = 12;
            _ExpandButton.ImagePaddingVertical = 10;
            _ExpandButton.Name = "sysMetroToolbarExpandButton";
            _ExpandButton.SetSystemItem(true);
            _ExpandButton.ContainerControl = parent;
            _ExpandButton.DesignTimeVisible = false;
            UpdateExpandButtonImage();
            this.SubItems.Add(_ExpandButton);

            _ExtraItemsContainer = new ItemContainer();
            _ExtraItemsContainer.LayoutOrientation = eOrientation.Horizontal;
            _ExtraItemsContainer.GlobalItem = false;
            _ExtraItemsContainer.Displayed = true;
            _ExtraItemsContainer.MultiLine = true;
            _ExtraItemsContainer.SetSystemContainer(true);
            _ExtraItemsContainer.ContainerControl = parent;
            _ExtraItemsContainer.DesignTimeVisible = false;
            _ExtraItemsContainer.Name = "_ExtraItemsContainer";
            this.SubItems.Add(_ExtraItemsContainer);
        }
Пример #23
0
        public override void InitializeAllContainers()
        {
            MapIds = new[]
            {
                Maps.MapIds.Test
            };
            MapModelContainer = new MapModelContainer();
            MapLogicContainer = new MapLogicContainer();
            MapNpcContainer = new MapNpcContainer();

            PartyMemberIds = new[]
            {
                Party.PartyMemberIds.Test1,
                Party.PartyMemberIds.Test2,
                Party.PartyMemberIds.Test3,
                Party.PartyMemberIds.Test4
            };
            PartyMemberStatsContainer = new PartyMemberStatsContainer();
            PartyMemberBattleLogicContainer = new PartyMemberBattleLogicContainer();
            PartyMemberPowerSetContainer = new PartyMemberPowerSetContainer();
            PartyMemberEquipmentLayoutContainer = new PartyMemberEquipmentLayoutContainer();

            EnemyIds = new[]
            {
                Enemies.EnemyIds.AmethystGolem,
                Enemies.EnemyIds.CaveBug,
                Enemies.EnemyIds.GraveHand
            };
            EnemyMetadataContainer = new EnemyMetadataContainer();
            EnemyAiContainer = new EnemyAiContainer();
            EnemyStatsContainer = new EnemyStatsContainer();
            EnemyBattleLogicContainer = new EnemyBattleLogicContainer();

            AbilityAnimationContainer = new AbilityAnimationContainer();
            AbilityContainer = new AbilityContainer();
            GiftContainer = new GiftContainer();
            GiftTypeContainer = new GiftTypeContainer();

            ItemTypeDetailsContainer = new ItemTypeDetailsContainer();
            ItemContainer = new ItemContainer();
        }
Пример #24
0
    static void GetIDCount()
    {
        ItemContainer itemContainer = new ItemContainer();

        System.Type[] itemTypes = { typeof(Equipment), typeof(Weapon), typeof(Consumable) };

        XmlSerializer serializer = new XmlSerializer(typeof(ItemContainer), itemTypes);

        FileStream fs = new FileStream(Path.Combine(Application.streamingAssetsPath, "Items.xml"), FileMode.Open);

        itemContainer = (ItemContainer)serializer.Deserialize(fs);

        fs.Close();

        int minId = 0;
        foreach (Item item in itemContainer.Consumables)
        {
            if (item.Id == minId)
            {
                minId = item.Id + 1;
            }
        }
        foreach (Item item in itemContainer.Equipments)
        {
            if (item.Id == minId)
            {
                minId = item.Id + 1;
            }
        }
        foreach (Item item in itemContainer.Weapons)
        {
            if (item.Id == minId)
            {
                minId = item.Id + 1;
            }
        }

        currentId = minId;
    }
Пример #25
0
    private static void CheckSwapability(ItemData movingItemData, ItemContainer targetContainer, ContainerAddState possibleSwapState)
    {
        if (possibleSwapState.possibleSwapItem == null)
            return;

        movingItemData.ownerContainer.Remove(movingItemData, true, possibleSwapState.possibleAddAmount);
        ContainerAddState sourceAddState = movingItemData.ownerContainer.GetContainerAddState(possibleSwapState.possibleSwapItem);
        ItemContainer SourceContainer = movingItemData.ownerContainer;

        if (sourceAddState.actionState == ContainerAddState.ActionState.Add)
        {
            SourceContainer.Add(possibleSwapState.possibleSwapItem, -1);
            targetContainer.Remove(possibleSwapState.possibleSwapItem, true);
            targetContainer.Add(movingItemData, -1);
            return;
        }
        else
        {
            movingItemData.ownerContainer.Add(movingItemData, possibleSwapState.possibleAddAmount);
        }

    }
Пример #26
0
    public void ShowItens()
    {
        container = GameObject.FindGameObjectWithTag("Player").gameObject.GetComponent<ItemContainer>();
        foreach (Transform child in transform){
                Destroy(child.gameObject);
        }
        /**
        foreach (var item in container.items) {
            var i = Instantiate(itemContent);
            i.transform.SetParent(this.transform);
            i.transform.Find("Name").GetComponent<Text>().text = item.itemName;
            i.transform.Find("Description").GetComponent<Text>().text = item.description;
            i.transform.Find("RawImage").GetComponent<RawImage>().texture = item.spriteTexture;
            if (item.moreAbout == null)
                i.transform.Find("Button").gameObject.SetActive(false);
            else{
                Debug.Log(item.moreAbout);
                i.GetComponent<ItemButtons>().image = item.moreAbout;
            }

        }
        **/
    }
Пример #27
0
        void OnItemAddedToContainer(ItemContainer container, Item item) {
            //get container entity
            BaseEntity entity = container.entityOwner as BaseEntity;
            
            //check entity is repair bench
            if(entity == null) return;
            if(entity.ShortPrefabName != "repairbench_deployed"
              && entity.ShortPrefabName != "repairbench_static") return;

            //get player from bench map
            BasePlayer player = null;
            foreach(BasePlayer key in benchMap.Keys)
                if(benchMap[key] == entity) {
                    player = key;
                    break;
                }
            
            //check player
            if(player == null) return;
            
            //salvage item
            SalvageItem(player, item);
        }
Пример #28
0
 public virtual void CreatNew(out ItemData newItem, int amount, ItemContainer ownerContainer)
 {
     newItem = NewItem();
     newItem.stackSize = amount;
     newItem.ownerContainer = ownerContainer;
     newItem.itemName = itemName;
     newItem.classID = classID;
     newItem.itemID = itemID;
     newItem.stackID = stackID;
     newItem.totalEnergy = totalEnergy;
     newItem.baseEnergy = baseEnergy;
     newItem.salePrice = salePrice;
     newItem.behaviours = behaviours;
     newItem.description = description;
     newItem.quality = quality;
     newItem.imageName = imageName;
     newItem.isOwned = isOwned;
     newItem.varianceID = varianceID;
     newItem.stats = stats;
     newItem.assetURL = assetURL;
     newItem.tags = tags;
     newItem.persistantLocation = persistantLocation;
     newItem.isLocked = isLocked;
 }
Пример #29
0
        private void OnItemRemovedFromContainer(ItemContainer container, Item item)
        {
            if (item.info.itemid != 107868)
            {
                return;
            }
            BasePlayer player = container.GetOwnerPlayer();

            if (player == null)
            {
                return;
            }
            if (container == player.inventory.containerBelt)
            {
                NextTick(() =>
                {
                    if (container.GetSlot(6) != null)
                    {
                        Item unknownItem = container.GetSlot(6);
                        if (unknownItem.info.itemid == 107868)
                        {
                            return;
                        }
                        if (!player.inventory.containerMain.IsFull())
                        {
                            unknownItem.MoveToContainer(player.inventory.containerMain);
                        }
                        else
                        {
                            unknownItem.Drop(player.transform.position, Vector3.down);
                        }
                    }
                    item.MoveToContainer(container, 6);
                });
            }
        }
Пример #30
0
        //上面一排 镶嵌宝石的Item
        private void SmeltBtnClick(GameObject go)
        {
            ItemContainer ic = go.GetComponent <ItemContainer>();

            if (ic.Id == 0)
            {
            }
            else  //移除
            {
                int pos = 1;
                foreach (ItemContainer container in itemList)
                {
                    if (container.Equals(ic))
                    {
                        break;
                    }
                    else
                    {
                        pos++;
                    }
                }
                Singleton <Equip1Control> .Instance.EquipRemove(uid, EquipLeftView.Instance.Repos, pos);
            }
        }
Пример #31
0
 public void TakeFrom(params ItemContainer[] source)
 {
     Assert.IsTrue(containers == null, "Initializing Twice");
     using (TimeWarning.New("Corpse.TakeFrom"))
     {
         containers = new ItemContainer[source.Length];
         for (int i = 0; i < source.Length; i++)
         {
             containers[i] = new ItemContainer();
             containers[i].ServerInitialize(null, source[i].capacity);
             containers[i].GiveUID();
             containers[i].entityOwner = this;
             Item[] array = source[i].itemList.ToArray();
             foreach (Item item in array)
             {
                 if (!item.MoveToContainer(containers[i]))
                 {
                     item.DropAndTossUpwards(base.transform.position);
                 }
             }
         }
         ResetRemovalTime();
     }
 }
Пример #32
0
 public static bool GenerateItem(ItemContainer _container, BasicItemDrop _itemDrop, ref int _spawnAmount)
 {
     try
     {
         _itemDrop.DroppedItem.InitCachedInfos();
         //MoreGatherableLoot.MyLogger.LogDebug($"{_itemDrop.DroppedItem.DisplayName}");
         if (_container.GetType() == typeof(Gatherable) &&
             (_itemDrop.DroppedItem.IsFood || _itemDrop.DroppedItem.IsIngredient) &&
             !_itemDrop.DroppedItem.IsDrink &&
             !_itemDrop.DroppedItem.IsEquippable &&
             !_itemDrop.DroppedItem.IsDeployable &&
             _itemDrop.MaxDropCount < MoreGatherableLoot.Instance.configAmountMax.Value)
         {
             int _amountMax = MoreGatherableLoot.Instance.configAmountMax.Value;
             int _amountMin = MoreGatherableLoot.Instance.configAmountMin.Value;
             int minDrop    = _itemDrop.MinDropCount * _amountMin;
             int maxDrop    = _itemDrop.MaxDropCount * _amountMax;
             if (_itemDrop.MaxDropCount > 1 && _itemDrop.MaxDropCount < _amountMax)
             { // If already multiple quantities, increase instead of multiply
                 minDrop = _amountMin;
                 maxDrop = _amountMax;
             }
             // Increase count of items on specific resources (like champignons !)
             //MoreGatherableLoot.MyLogger.LogDebug($"{_container.GetType().Name}: {_container.name.Split(new char[] { '_' })[1]}");
             //MoreGatherableLoot.MyLogger.LogDebug($"{_itemDrop.DroppedItem.name.Split(new char[] { '_' })[1]} ({_itemDrop.MinDropCount} - {_itemDrop.MaxDropCount})");
             _spawnAmount = UnityEngine.Random.Range(minDrop, maxDrop + 1);
             //MoreGatherableLoot.MyLogger.LogDebug($"{_itemDrop.DroppedItem.DisplayName}={_spawnAmount} ({minDrop} - {maxDrop})");
             //MoreGatherableLoot.MyLogger.LogDebug($"\t|- New amount={_spawnAmount} ({minDrop} - {maxDrop})");
         }
     }
     catch (Exception ex)
     {
         MoreGatherableLoot.MyLogger.LogError(ex.Message);
     }
     return(true);
 }
Пример #33
0
        List <Item> GetExistingItems(ItemContainer primary, ItemContainer secondary)
        {
            var existingItems = new List <Item>();

            if (primary == null || secondary == null)
            {
                return(existingItems);
            }

            foreach (var t in primary.itemList)
            {
                foreach (var t1 in secondary.itemList)
                {
                    if (t.info.itemid != t1.info.itemid)
                    {
                        continue;
                    }
                    existingItems.Add(t);
                    break;
                }
            }

            return(existingItems);
        }
Пример #34
0
 public virtual void CreatNew(out ItemData newItem, int amount, ItemContainer ownerContainer)
 {
     newItem                    = new ItemData();
     newItem.stackSize          = amount;
     newItem.ownerContainer     = ownerContainer;
     newItem.itemName           = itemName;
     newItem.classID            = classID;
     newItem.CollectionID       = CollectionID;
     newItem.stackID            = stackID;
     newItem.totalEnergy        = totalEnergy;
     newItem.baseEnergy         = baseEnergy;
     newItem.salePrice          = salePrice;
     newItem.behaviours         = behaviours;
     newItem.description        = description;
     newItem.quality            = quality;
     newItem.imageName          = imageName;
     newItem.isOwned            = isOwned;
     newItem.ItemID             = ItemID;
     newItem.stats              = stats;
     newItem.assetURL           = assetURL;
     newItem.tags               = tags;
     newItem.persistantLocation = persistantLocation;
     newItem.isLocked           = isLocked;
 }
Пример #35
0
 public static void TryAddItem(ItemContainer container, ItemDefinition definition, int amount)
 {
     int amountLeft = amount;
     foreach (var item in container.itemList)
     {
         if (item.info != definition)
         {
             continue;
         }
         if (amountLeft <= 0)
         {
             return;
         }
         if (item.amount < item.MaxStackable())
         {
             int amountToAdd = Mathf.Min(amountLeft, item.MaxStackable() - item.amount);
             item.amount += amountToAdd;
             item.MarkDirty();
             amountLeft -= amountToAdd;
         }
     }
     if (amountLeft <= 0)
     {
         return;
     }
     var smeltedItem = ItemManager.Create(definition, amountLeft);
     if (!smeltedItem.MoveToContainer(container))
     {
         smeltedItem.Drop(container.dropPosition, container.dropVelocity);
         var oven = container.entityOwner as BaseOven;
         if (oven != null)
         {
             oven.OvenFull();
         }
     }
 }
Пример #36
0
        void OnItemRemovedFromContainer(ItemContainer container, Item item)
        {
            if (container.playerOwner is BasePlayer)
            {
                OnlinePlayer onlinePlayer;
                if (onlinePlayers.TryGetValue(container.playerOwner, out onlinePlayer) && onlinePlayer.Trade != null)
                {
                    OpenTrade t = onlinePlayers [container.playerOwner].Trade;
                    if (!t.complete)
                    {
                        t.ResetAcceptance();

                        if (t.IsValid())
                        {
                            ShowTrades(t, "Trade: Pending");
                        }
                        else
                        {
                            TradeCloseBoxes(t);
                        }
                    }
                }
            }
        }
Пример #37
0
    public void AddItem(Item itm, int amount)
    {
        foreach (ItemContainer item in inventory)
        {
            if (item == null)
            {
                continue;
            }
            if (item.isEmpty())
            {
                continue;                 // if item slot is empty then we can ignore it and continue to next slot
            }
            if (!item.matches(itm))
            {
                continue;                     // if item slot doesn't match then we can ignore it and continue to next slot
            }
            if (item.stackedAmount >= itm.maxStackSize)
            {
                continue;                                         // test if the slot is full, if it is another might not be so continue to next slot
            }
            item.stackedAmount++;
            NotifyDisplay();
            return; // item has been handled and placed in inventory
        }

        for (int i = 0; i < inventory.Length; i++) // either item wasn't found in inventory already or other slots were full
        {
            if (inventory[i] == null || inventory[i].isEmpty())
            {
                inventory[i] = new ItemContainer(itm, amount);
                print("Item added to new slot");
                NotifyDisplay();
                return; // Item was added to inventory in a new slow
            }
        }
    }
Пример #38
0
 /// <summary>
 /// Try to move item by move conditions set in inspector
 /// </summary>
 /// <returns>True if item was moved.</returns>
 public virtual bool MoveItem()
 {
     if (Container.MoveUsedItem)
     {
         for (int i = 0; i < Container.moveItemConditions.Count; i++)
         {
             ItemContainer.MoveItemCondition condition = Container.moveItemConditions[i];
             ItemContainer itemContainer = WidgetUtility.Find <ItemContainer>(condition.window);
             if (itemContainer == null || (condition.requiresVisibility && !itemContainer.IsVisible))
             {
                 continue;
             }
             if (itemContainer.IsLocked)
             {
                 InventoryManager.Notifications.inUse.Show();
                 continue;
             }
             if (itemContainer.CanAddItem(ObservedItem) && itemContainer.StackOrAdd(ObservedItem))
             {
                 if (!itemContainer.UseReferences || !Container.CanReferenceItems)
                 {
                     Container.RemoveItem(Index);
                 }
                 return(true);
             }
             for (int j = 0; j < itemContainer.Slots.Count; j++)
             {
                 if (itemContainer.CanSwapItems(itemContainer.Slots[j], this) && itemContainer.SwapItems(itemContainer.Slots[j], this))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Пример #39
0
        private void OnItemBeginDrag(object sender, ItemArgs e)
        {
            CursorHelper.SetCursor(this, DragIcon, new Vector2(DragIcon.width / 2, DragIcon.height / 2), CursorMode.Auto);

            ItemContainer itemContainer = m_listBox.GetItemContainer(e.Items[0]);

            if (itemContainer != null)
            {
                ResourcePreview runtimeResource = itemContainer.GetComponentInChildren <ResourcePreview>();
                runtimeResource.BeginSpawn();
            }

            ProjectItemObjectPair objectItemPair = (ProjectItemObjectPair)e.Items[0];

            if (BeginDrag != null)
            {
                BeginDrag(this, new ProjectResourcesEventArgs(new[] { objectItemPair }));
            }

            if (objectItemPair.IsResource)
            {
                DragDrop.RaiseBeginDrag(new[] { objectItemPair.Object });
            }
        }
Пример #40
0
        private static void UpdateOrder(ItemContainer container, IEntityStateEntry entry)
        {
            var model = (OrderModel)entry.Entity;

            switch (entry.State)
            {
            case EntityState.Added:
                container.Orders.Add(model.Id, model);
                break;

            case EntityState.Deleted:
                container.Orders.Remove(model.Id);
                break;

            case EntityState.Modified:
                if (!container.Orders.ContainsKey(model.Id))
                {
                    throw new InvalidOperationException(string.Format("The product with key = {0} not found.",
                                                                      model.Id));
                }
                container.Orders[model.Id] = model;
                break;
            }
        }
Пример #41
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                  AddItemToView()
        //------------------------------------------------------------------------------------------------------------------------
        //Adds a new icon. An icon is a prefab Button with some additional scripts to link it to the store Item
        private void AddItemToView(Item item)
        {
            GameObject newItemIcon = GameObject.Instantiate(_itemPrefab);

            newItemIcon.transform.SetParent(_itemLayoutGroup.transform);
            newItemIcon.transform.localScale = Vector3.one;//The scale would automatically change in Unity so we set it back to Vector3.one.

            ItemContainer itemContainer = newItemIcon.GetComponent <ItemContainer>();

            Debug.Assert(itemContainer != null);
            bool isSelected = (item == _items[_selectedItemId]);

            itemContainer.Initialize(item, isSelected);

            //Click behaviour for the button is done here. It seemed more convenient to do this inline than in the editor.
            Button itemButton = itemContainer.GetComponent <Button>();

            itemButton.onClick.AddListener(
                delegate
            {
                _commandManager.ExecuteCommand(new SelectShopItemCommand(_shopController, item));
            }
                );
        }
Пример #42
0
    private void Awake()
    {
        ItemContainer container = GetComponent <ItemContainer>();

        container.OnRemoveItem += (Item item, int amount, Slot slot) =>
        {
            Debug.Log("[" + Time.time + "]" + "OnRemoveItem: " + item.Name + " Amount: " + amount + " Container: " + slot.Container.Name + " Slot: " + slot.Index);
        };

        container.OnAddItem += (Item item, Slot slot) =>
        {
            Debug.Log("[" + Time.time + "]" + "OnAddItem: " + item.Name + " Amount: " + item.Stack + "Container: " + slot.Container.Name + " Slot: " + slot.Index);
        };

        container.OnFailedToAddItem += (Item item) =>
        {
            Debug.Log("OnFailedToAddItem: " + item.Name);
        };

        container.OnFailedToRemoveItem += (Item item, int amount) =>
        {
            Debug.Log("OnFailedToRemoveItem: " + item.Name + " Amount: " + amount);
        };
    }
Пример #43
0
    /// <summary>
    /// 好友信息解析
    /// </summary>
    /// <param name="respond"></param>
    public void InitShipItemsByByRespond(S2C_SYNC_PLAYERINFO respond)
    {
        PackageProxy packageProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PackageProxy) as PackageProxy;
        ulong        uid          = respond.uid;

        Debug.Log("收到并解析玩家数据" + uid);
        Dictionary <ulong, ItemContainer> items = new Dictionary <ulong, ItemContainer>();

        foreach (var item in respond.item_list)
        {
            ItemContainer itemcon = packageProxy.CreateItem(item.uid, item.tid, item.parent, item.pos, 0, 0, 0, 0);
            itemcon.Lv = item.lv;
            items.Add(item.uid, itemcon);
        }
        RelationData(items);
        // 用最新的
        if (m_ShipItems.ContainsKey(uid))
        {
            RemoveShipItems(uid);
        }

        m_ShipItems.Add(uid, items);
        GameFacade.Instance.SendNotification(NotificationName.MSG_FRIEND_SHIPDATA_CHANGE, uid);
    }
Пример #44
0
        public void SimpleTypeCogsDateList()
        {
            ItemContainer container = new ItemContainer();
            Condiment     condiment = new Condiment
            {
                ID     = Guid.NewGuid().ToString(),
                CDates = new List <CogsDate>
                {
                    new CogsDate(new TimeSpan(1562)),
                    new CogsDate(new GYear(2017, "+01:00")),
                    new CogsDate(new DateTimeOffset(new DateTime(1996, 8, 23, 4, 37, 4),
                                                    new TimeSpan(+3, 0, 0)), false),
                    new CogsDate(new DateTime(2017, 9, 2), true),
                    new CogsDate(new GYearMonth(2017, 7, "+02:00")),
                    new CogsDate(new GYearMonth(2017, 7, null)),
                    new CogsDate(new GYear(2017, null))
                },
                Description = "Dates"
            };

            container.Items.Add(condiment);

            XmlValidation(container.MakeXml());
        }
Пример #45
0
        protected override void  Init()
        {
            ckb_equip = FindInChild <UIToggle>("ckb_equip");
            ckb_equip.FindInChild <UILabel>("label").text = LanguageManager.GetWord("GoodsView.EquipTab");
            ckb_smelt = FindInChild <UIToggle>("ckb_smelt");
            ckb_smelt.FindInChild <UILabel>("label").text = LanguageManager.GetWord("GoodsView.SmeltTab");
            ckb_pet = FindInChild <UIToggle>("ckb_pet");
            ckb_pet.FindInChild <UILabel>("label").text = LanguageManager.GetWord("GoodsView.PetTab");
            ckb_prop = FindInChild <UIToggle>("ckb_prop");
            ckb_prop.FindInChild <UILabel>("label").text = LanguageManager.GetWord("GoodsView.PropTab");

            btn_tujian = FindInChild <Button>("btn_tujian");

            EventDelegate.Add(ckb_equip.onChange, GoodsTypeHandle);
            EventDelegate.Add(ckb_smelt.onChange, GoodsTypeHandle);
            EventDelegate.Add(ckb_pet.onChange, GoodsTypeHandle);
            EventDelegate.Add(ckb_prop.onChange, GoodsTypeHandle);
            btn_tujian.onPress       = TuJianOnPress;
            btn_tujian.clickDelegate = TuJianClick;

            grid               = FindInChild <UIGrid>("content/grid");
            scrollView         = FindInChild <UIScrollView>("content");
            grid.onReposition += scrollView.ResetPosition;
            item               = FindChild("content/grid/item1");
            item.name          = "0000";
            ItemContainer ic = item.AddMissingComponent <ItemContainer>();

            ic.FindInChild <UILabel>("num").text = string.Empty;
            ic.onClick       = ShowRightTips;
            ic.onDoubleClick = RightDoubleClick;
            goodsList.Add(ic);
            item.SetActive(false);
            zhanLi = FindInChild <UILabel>("zl");

            GetLeftItemList();
        }
Пример #46
0
        private static void UpdateOrderProduct(ItemContainer container, IEntityStateEntry entry)
        {
            var model = (OrderProductModel)entry.Entity;
            var key   = new ComplexKey(model.IdOrder, model.IdProduct);

            switch (entry.State)
            {
            case EntityState.Added:
                container.OrderToProducts.Add(key, model);
                break;

            case EntityState.Deleted:
                container.OrderToProducts.Remove(key);
                break;

            case EntityState.Modified:
                if (!container.OrderToProducts.ContainsKey(key))
                {
                    throw new InvalidOperationException(string.Format("The product with key = {0} not found.", key));
                }
                container.OrderToProducts[key] = model;
                break;
            }
        }
Пример #47
0
        protected override void Init()
        {
            mergeTips    = FindInChild <UILabel>("desc");
            bottomSprite = FindInChild <UISprite>("di1");
            GameObject    temp;
            ItemContainer ic;

            for (int i = 1; i < 6; i++)
            {
                temp          = FindChild("item" + i);
                ic            = temp.AddMissingComponent <ItemContainer>();
                ic.onClick    = SmeltBtnClick;
                ic.buttonType = Button.ButtonType.Toggle;
                itemList.Add(ic);
            }
            temp = null;

            item      = FindChild("content/grid/item1");
            item.name = "0000";
            //gridTween = FindInChild<TweenPosition>("content/grid/");
            ic = item.AddMissingComponent <ItemContainer>();
            smeltList.Add(ic);
            item.SetActive(false);
            ic.onClick  = SelectOnClick;
            grid        = FindInChild <UIGrid>("content/grid");
            grid.sorted = true;
            scrollView  = FindInChild <UIScrollView>("content");
            mergeSlider = FindInChild <UISlider>("sld_exp");
            MergeButton = FindInChild <Button>("btn_qh");
            tips        = FindChild("tips");
            sprite2     = NGUITools.FindInChild <UILabel>(tips, "label");
            sprite1     = NGUITools.FindInChild <UISprite>(tips, "sprite1");
            MergeButton.clickDelegate = MergeClick;
            GuideStoneItemContainer   = itemList[0];
            //ClearItemData();
        }
Пример #48
0
        //单击左边装备,显示 Tips 界面
        private void ShowLeftTips(GameObject go)
        {
            ItemContainer ic   = go.GetComponent <ItemContainer>();
            PRank         rank = Singleton <RankMode> .Instance.GetRankInfo(type).info[selectedPos - 1];

            List <PGoods> goods = rank.goodsList;

            if (ic.Id != 0)
            {
                PGoods good = null;
                foreach (PGoods pg in goods)
                {
                    if (pg.id == ic.Id)
                    {
                        good = pg;
                        break;;
                    }
                }
                if (good != null)
                {
                    Singleton <TipsManager> .Instance.OpenPlayerEquipTipsByGoods(good);
                }
            }
        }
Пример #49
0
 public void SendUpdatedInventory(
     PlayerInventory.Type type,
     ItemContainer container,
     bool bSendInventoryToEveryone = false)
 {
     using (UpdateItemContainer updateItemContainer = (UpdateItemContainer)Pool.Get <UpdateItemContainer>())
     {
         updateItemContainer.type = (__Null)type;
         if (container != null)
         {
             container.dirty = false;
             updateItemContainer.container = (__Null)Pool.Get <List <ItemContainer> >();
             ((List <ItemContainer>)updateItemContainer.container).Add(container.Save());
         }
         if (bSendInventoryToEveryone)
         {
             this.baseEntity.ClientRPC <UpdateItemContainer>((Connection)null, "UpdatedItemContainer", updateItemContainer);
         }
         else
         {
             this.baseEntity.ClientRPCPlayer <UpdateItemContainer>((Connection)null, this.baseEntity, "UpdatedItemContainer", updateItemContainer);
         }
     }
 }
Пример #50
0
        private void m_searchBox_TextChanged(object sender, EventArgs e)
        {
            string text = m_searchBox.Text.ToLower();   // force lowering to make case-insensitive comparing faster

            foreach (var item in m_metroTilePanel.Items)
            {
                ItemContainer ic = item as ItemContainer;
                if (ic != null)
                {
                    foreach (var tile in ic.SubItems)
                    {
                        MetroTileItem mt = tile as MetroTileItem;
                        if (mt != null)
                        {
                            if (text.Length == 0)
                            {
                                mt.TileSize = m_show;
                            }
                            else
                            {
                                if (mt.Text.Contains(text))
                                {
                                    mt.TileSize = m_show;
                                }
                                else
                                {
                                    mt.TileSize = m_hidden;
                                }
                            }
                        }
                    }
                }
            }

            m_metroTilePanel.Refresh();
        }
        private void InitTiles()
        {
            metroTilePanelMain.LayoutOrientation = eOrientation.Vertical;

            foreach (var tileGroup in CustomTabInfo.Tiles.Groups)
            {
                var itemContainer = new ItemContainer
                {
                    MultiLine   = true,
                    Orientation = eOrientation.Vertical
                };

                if (!String.IsNullOrWhiteSpace(tileGroup.Title))
                {
                    itemContainer.TitleVisible  = true;
                    itemContainer.Text          =
                        itemContainer.TitleText = tileGroup.Title;
                    if (tileGroup.Font != null)
                    {
                        itemContainer.TitleStyle.Font = tileGroup.Font;
                    }
                    if (tileGroup.ForeColor != Color.Empty)
                    {
                        itemContainer.TitleStyle.TextColor = tileGroup.ForeColor;
                    }
                }
                else
                {
                    itemContainer.TitleVisible = false;
                }

                foreach (var tileItem in tileGroup.Items)
                {
                    var item = new MetroTileItem();
                    item.TitleText     = tileItem.Title;
                    item.Tooltip       = tileItem.Tooltip;
                    item.CheckBehavior = eMetroTileCheckBehavior.None;

                    if (!String.IsNullOrWhiteSpace(tileItem.ImagePath))
                    {
                        var extension = Path.GetExtension(tileItem.ImagePath);
                        if (String.Equals(extension, ".svg", StringComparison.OrdinalIgnoreCase))
                        {
                            var svgBitmap = SvgBitmap.FromFile(tileItem.ImagePath);
                            item.Image = svgBitmap.Render(null, 1.0D);
                        }
                        else
                        {
                            item.Image = Image.FromFile(tileItem.ImagePath);
                        }
                    }

                    if (tileItem.TextAlignment.HasValue)
                    {
                        item.TitleTextAlignment = tileItem.TextAlignment.Value;
                    }

                    if (!tileItem.Size.IsEmpty)
                    {
                        item.TileSize = tileItem.Size;
                    }
                    else if (item.Image != null)
                    {
                        item.TileSize = item.Image.Size;
                    }

                    item.TileColor = tileItem.BackColor;

                    if (!tileItem.ImageIdent.IsEmpty)
                    {
                        item.ImageIndent = tileItem.ImageIdent;
                    }

                    if (!tileItem.ForeColor.IsEmpty)
                    {
                        item.TitleTextColor = tileItem.ForeColor;
                    }

                    if (tileItem.Font != null)
                    {
                        item.TitleTextFont = tileItem.Font;
                    }

                    item.Click += (o, args) =>
                    {
                        try
                        {
                            Process.Start(tileItem.GetExecutablePath());
                        }
                        catch { }
                    };
                    itemContainer.SubItems.Add(item);
                }
                metroTilePanelMain.Items.Add(itemContainer);
            }

            metroTilePanelMain.Invalidate();
        }
Пример #52
0
	public void Awake () {
		Type[] itemTypes = { typeof(Equipment), typeof(Weapon), typeof(Consumeable), typeof(Material) };
		XmlSerializer serializer = new XmlSerializer (typeof(ItemContainer), itemTypes);
		TextReader textReader = new StreamReader (Application.streamingAssetsPath + "/Items.xml");
		itemContainer = (ItemContainer)serializer.Deserialize (textReader);
		textReader.Close ();
        //CraftingBench.Instance.CreateBlueprints();
	}
Пример #53
0
        public override void Start()
        {
            base.Start();

            radioSpeakerName = TextManager.Get("Tutorial.Radio.Speaker");
            engineer         = Character.Controlled;

            var toolbox = engineer.Inventory.FindItemByIdentifier("toolbox");

            toolbox.Unequip(engineer);
            engineer.Inventory.RemoveItem(toolbox);

            var repairOrder = Order.PrefabList.Find(order => order.AITag == "repairsystems");

            engineer_repairIcon      = repairOrder.SymbolSprite;
            engineer_repairIconColor = repairOrder.Color;

            var reactorOrder = Order.PrefabList.Find(order => order.AITag == "operatereactor");

            engineer_reactorIcon      = reactorOrder.SymbolSprite;
            engineer_reactorIconColor = reactorOrder.Color;

            // Other tutorial items
            tutorial_securityFinalDoorLight = Item.ItemList.Find(i => i.HasTag("tutorial_securityfinaldoorlight")).GetComponent <LightComponent>();
            tutorial_mechanicFinalDoorLight = Item.ItemList.Find(i => i.HasTag("tutorial_mechanicfinaldoorlight")).GetComponent <LightComponent>();
            tutorial_submarineSteering      = Item.ItemList.Find(i => i.HasTag("command")).GetComponent <Steering>();

            tutorial_submarineSteering.CanBeSelected = false;
            foreach (ItemComponent ic in tutorial_submarineSteering.Item.Components)
            {
                ic.CanBeSelected = false;
            }

            SetDoorAccess(null, tutorial_securityFinalDoorLight, false);
            SetDoorAccess(null, tutorial_mechanicFinalDoorLight, false);

            // Room 2
            engineer_equipmentObjectiveSensor = Item.ItemList.Find(i => i.HasTag("engineer_equipmentobjectivesensor")).GetComponent <MotionSensor>();
            engineer_equipmentCabinet         = Item.ItemList.Find(i => i.HasTag("engineer_equipmentcabinet")).GetComponent <ItemContainer>();
            engineer_firstDoor      = Item.ItemList.Find(i => i.HasTag("engineer_firstdoor")).GetComponent <Door>();
            engineer_firstDoorLight = Item.ItemList.Find(i => i.HasTag("engineer_firstdoorlight")).GetComponent <LightComponent>();

            SetDoorAccess(engineer_firstDoor, engineer_firstDoorLight, false);

            // Room 3
            engineer_reactorObjectiveSensor = Item.ItemList.Find(i => i.HasTag("engineer_reactorobjectivesensor")).GetComponent <MotionSensor>();
            tutorial_oxygenGenerator        = Item.ItemList.Find(i => i.HasTag("tutorial_oxygengenerator")).GetComponent <Powered>();
            engineer_reactor                       = Item.ItemList.Find(i => i.HasTag("engineer_reactor")).GetComponent <Reactor>();
            engineer_reactor.FireDelay             = engineer_reactor.MeltdownDelay = float.PositiveInfinity;
            engineer_reactor.FuelConsumptionRate   = 0.0f;
            engineer_reactor.OnOffSwitch.BarScroll = 1f;
            reactorOperatedProperly                = false;

            engineer_secondDoor      = Item.ItemList.Find(i => i.HasTag("engineer_seconddoor")).GetComponent <Door>();;
            engineer_secondDoorLight = Item.ItemList.Find(i => i.HasTag("engineer_seconddoorlight")).GetComponent <LightComponent>();

            SetDoorAccess(engineer_secondDoor, engineer_secondDoorLight, false);

            // Room 4
            engineer_repairJunctionBoxObjectiveSensor = Item.ItemList.Find(i => i.HasTag("engineer_repairjunctionboxobjectivesensor")).GetComponent <MotionSensor>();
            engineer_brokenJunctionBox = Item.ItemList.Find(i => i.HasTag("engineer_brokenjunctionbox"));
            engineer_thirdDoor         = Item.ItemList.Find(i => i.HasTag("engineer_thirddoor")).GetComponent <Door>();
            engineer_thirdDoorLight    = Item.ItemList.Find(i => i.HasTag("engineer_thirddoorlight")).GetComponent <LightComponent>();

            engineer_brokenJunctionBox.Indestructible = false;
            engineer_brokenJunctionBox.Condition      = 0f;

            SetDoorAccess(engineer_thirdDoor, engineer_thirdDoorLight, false);

            // Room 5
            engineer_disconnectedJunctionBoxObjectiveSensor = Item.ItemList.Find(i => i.HasTag("engineer_disconnectedjunctionboxobjectivesensor")).GetComponent <MotionSensor>();

            engineer_disconnectedJunctionBoxes    = new PowerTransfer[4];
            engineer_disconnectedConnectionPanels = new ConnectionPanel[4];

            for (int i = 0; i < engineer_disconnectedJunctionBoxes.Length; i++)
            {
                engineer_disconnectedJunctionBoxes[i]           = Item.ItemList.Find(item => item.HasTag($"engineer_disconnectedjunctionbox_{i + 1}")).GetComponent <PowerTransfer>();
                engineer_disconnectedConnectionPanels[i]        = engineer_disconnectedJunctionBoxes[i].Item.GetComponent <ConnectionPanel>();
                engineer_disconnectedConnectionPanels[i].Locked = false;

                for (int j = 0; j < engineer_disconnectedJunctionBoxes[i].PowerConnections.Count; j++)
                {
                    foreach (Wire wire in engineer_disconnectedJunctionBoxes[i].PowerConnections[j].Wires)
                    {
                        if (wire == null)
                        {
                            continue;
                        }
                        wire.Locked = true;
                    }
                }
            }

            engineer_wire_1             = Item.ItemList.Find(i => i.HasTag("engineer_wire_1"));
            engineer_wire_1.SpriteColor = Color.Transparent;
            engineer_wire_2             = Item.ItemList.Find(i => i.HasTag("engineer_wire_2"));
            engineer_wire_2.SpriteColor = Color.Transparent;
            engineer_lamp_1             = Item.ItemList.Find(i => i.HasTag("engineer_lamp_1")).GetComponent <Powered>();
            engineer_lamp_2             = Item.ItemList.Find(i => i.HasTag("engineer_lamp_2")).GetComponent <Powered>();
            engineer_fourthDoor         = Item.ItemList.Find(i => i.HasTag("engineer_fourthdoor")).GetComponent <Door>();
            engineer_fourthDoorLight    = Item.ItemList.Find(i => i.HasTag("engineer_fourthdoorlight")).GetComponent <LightComponent>();
            SetDoorAccess(engineer_fourthDoor, engineer_fourthDoorLight, false);

            // Room 6
            engineer_workingPump = Item.ItemList.Find(i => i.HasTag("engineer_workingpump")).GetComponent <Pump>();
            engineer_workingPump.Item.CurrentHull.WaterVolume += engineer_workingPump.Item.CurrentHull.Volume;
            engineer_workingPump.IsActive = true;
            tutorial_lockedDoor_1         = Item.ItemList.Find(i => i.HasTag("tutorial_lockeddoor_1")).GetComponent <Door>();
            SetDoorAccess(tutorial_lockedDoor_1, null, true);

            // Submarine
            tutorial_submarineDoor      = Item.ItemList.Find(i => i.HasTag("tutorial_submarinedoor")).GetComponent <Door>();
            tutorial_submarineDoorLight = Item.ItemList.Find(i => i.HasTag("tutorial_submarinedoorlight")).GetComponent <LightComponent>();
            SetDoorAccess(tutorial_submarineDoor, tutorial_submarineDoorLight, true);

            tutorial_enteredSubmarineSensor = Item.ItemList.Find(i => i.HasTag("tutorial_enteredsubmarinesensor")).GetComponent <MotionSensor>();
            engineer_submarineJunctionBox_1 = Item.ItemList.Find(i => i.HasTag("engineer_submarinejunctionbox_1"));
            engineer_submarineJunctionBox_2 = Item.ItemList.Find(i => i.HasTag("engineer_submarinejunctionbox_2"));
            engineer_submarineJunctionBox_3 = Item.ItemList.Find(i => i.HasTag("engineer_submarinejunctionbox_3"));
            engineer_submarineReactor       = Item.ItemList.Find(i => i.HasTag("engineer_submarinereactor")).GetComponent <Reactor>();
            engineer_submarineReactor.OnOffSwitch.BarScrollValue = .25f;
            engineer_submarineReactor.IsActive = engineer_submarineReactor.AutoTemp = false;

            engineer_submarineJunctionBox_1.Indestructible = false;
            engineer_submarineJunctionBox_1.Condition      = 0f;
            engineer_submarineJunctionBox_2.Indestructible = false;
            engineer_submarineJunctionBox_2.Condition      = 0f;
            engineer_submarineJunctionBox_3.Indestructible = false;
            engineer_submarineJunctionBox_3.Condition      = 0f;
        }
Пример #54
0
 public virtual void OnInventoryFirstCreated(ItemContainer container)
 {
 }
Пример #55
0
        public override void Start()
        {
            base.Start();

            var firstAidOrder = Order.GetPrefab("requestfirstaid");

            doctor_firstAidIcon      = firstAidOrder.SymbolSprite;
            doctor_firstAidIconColor = firstAidOrder.Color;

            subPatients      = new List <Character>();
            radioSpeakerName = TextManager.Get("Tutorial.Radio.Speaker");
            doctor           = Character.Controlled;

            var bandages = FindOrGiveItem(doctor, "antibleeding1");

            bandages.Unequip(doctor);
            doctor.Inventory.RemoveItem(bandages);

            var syringegun = FindOrGiveItem(doctor, "syringegun");

            syringegun.Unequip(doctor);
            doctor.Inventory.RemoveItem(syringegun);

            var antibiotics = FindOrGiveItem(doctor, "antibiotics");

            antibiotics.Unequip(doctor);
            doctor.Inventory.RemoveItem(antibiotics);

            var morphine = FindOrGiveItem(doctor, "antidama1");

            morphine.Unequip(doctor);
            doctor.Inventory.RemoveItem(morphine);

            doctor_suppliesCabinet = Item.ItemList.Find(i => i.HasTag("doctor_suppliescabinet"))?.GetComponent <ItemContainer>();
            doctor_medBayCabinet   = Item.ItemList.Find(i => i.HasTag("doctor_medbaycabinet"))?.GetComponent <ItemContainer>();

            var patientHull1 = WayPoint.WayPointList.Find(wp => wp.IdCardDesc == "waitingroom").CurrentHull;
            var patientHull2 = WayPoint.WayPointList.Find(wp => wp.IdCardDesc == "airlock").CurrentHull;

            medBay = WayPoint.WayPointList.Find(wp => wp.IdCardDesc == "medbay").CurrentHull;

            var assistantInfo = new CharacterInfo(CharacterPrefab.HumanSpeciesName, jobPrefab: JobPrefab.Get("assistant"));

            patient1        = Character.Create(assistantInfo, patientHull1.WorldPosition, "1");
            patient1.TeamID = CharacterTeamType.Team1;
            patient1.GiveJobItems(null);
            patient1.CanSpeak = false;
            patient1.AddDamage(patient1.WorldPosition, new List <Affliction>()
            {
                new Affliction(AfflictionPrefab.Burn, 15.0f)
            }, stun: 0, playSound: false);
            patient1.AIController.Enabled = false;

            assistantInfo   = new CharacterInfo(CharacterPrefab.HumanSpeciesName, jobPrefab: JobPrefab.Get("assistant"));
            patient2        = Character.Create(assistantInfo, patientHull2.WorldPosition, "2");
            patient2.TeamID = CharacterTeamType.Team1;
            patient2.GiveJobItems(null);
            patient2.CanSpeak             = false;
            patient2.AIController.Enabled = false;

            var mechanicInfo = new CharacterInfo(CharacterPrefab.HumanSpeciesName, jobPrefab: JobPrefab.Get("engineer"));
            var subPatient1  = Character.Create(mechanicInfo, WayPoint.GetRandom(SpawnType.Human, mechanicInfo.Job?.Prefab, Submarine.MainSub).WorldPosition, "3");

            subPatient1.TeamID = CharacterTeamType.Team1;
            subPatient1.AddDamage(patient1.WorldPosition, new List <Affliction>()
            {
                new Affliction(AfflictionPrefab.Burn, 40.0f)
            }, stun: 0, playSound: false);
            subPatients.Add(subPatient1);

            var securityInfo = new CharacterInfo(CharacterPrefab.HumanSpeciesName, jobPrefab: JobPrefab.Get("securityofficer"));
            var subPatient2  = Character.Create(securityInfo, WayPoint.GetRandom(SpawnType.Human, securityInfo.Job?.Prefab, Submarine.MainSub).WorldPosition, "3");

            subPatient2.TeamID = CharacterTeamType.Team1;
            subPatient2.AddDamage(patient1.WorldPosition, new List <Affliction>()
            {
                new Affliction(AfflictionPrefab.InternalDamage, 40.0f)
            }, stun: 0, playSound: false);
            subPatients.Add(subPatient2);

            var engineerInfo = new CharacterInfo(CharacterPrefab.HumanSpeciesName, jobPrefab: JobPrefab.Get("engineer"));
            var subPatient3  = Character.Create(securityInfo, WayPoint.GetRandom(SpawnType.Human, engineerInfo.Job?.Prefab, Submarine.MainSub).WorldPosition, "3");

            subPatient3.TeamID = CharacterTeamType.Team1;
            subPatient3.AddDamage(patient1.WorldPosition, new List <Affliction>()
            {
                new Affliction(AfflictionPrefab.Burn, 20.0f)
            }, stun: 0, playSound: false);
            subPatients.Add(subPatient3);

            doctor_firstDoor        = Item.ItemList.Find(i => i.HasTag("doctor_firstdoor")).GetComponent <Door>();
            doctor_secondDoor       = Item.ItemList.Find(i => i.HasTag("doctor_seconddoor")).GetComponent <Door>();
            doctor_thirdDoor        = Item.ItemList.Find(i => i.HasTag("doctor_thirddoor")).GetComponent <Door>();
            tutorial_upperFinalDoor = Item.ItemList.Find(i => i.HasTag("tutorial_upperfinaldoor")).GetComponent <Door>();
            doctor_firstDoorLight   = Item.ItemList.Find(i => i.HasTag("doctor_firstdoorlight")).GetComponent <LightComponent>();
            doctor_secondDoorLight  = Item.ItemList.Find(i => i.HasTag("doctor_seconddoorlight")).GetComponent <LightComponent>();
            doctor_thirdDoorLight   = Item.ItemList.Find(i => i.HasTag("doctor_thirddoorlight")).GetComponent <LightComponent>();
            SetDoorAccess(doctor_firstDoor, doctor_firstDoorLight, false);
            SetDoorAccess(doctor_secondDoor, doctor_secondDoorLight, false);
            SetDoorAccess(doctor_thirdDoor, doctor_thirdDoorLight, false);
            tutorial_submarineDoor      = Item.ItemList.Find(i => i.HasTag("tutorial_submarinedoor")).GetComponent <Door>();
            tutorial_submarineDoorLight = Item.ItemList.Find(i => i.HasTag("tutorial_submarinedoorlight")).GetComponent <LightComponent>();
            SetDoorAccess(tutorial_submarineDoor, tutorial_submarineDoorLight, false);
            tutorial_lockedDoor_2 = Item.ItemList.Find(i => i.HasTag("tutorial_lockeddoor_2")).GetComponent <Door>();
            SetDoorAccess(tutorial_lockedDoor_2, null, true);


            foreach (var patient in subPatients)
            {
                patient.CanSpeak             = false;
                patient.AIController.Enabled = false;
                patient.GiveJobItems();
            }

            Item reactorItem = Item.ItemList.Find(i => i.Submarine == Submarine.MainSub && i.GetComponent <Reactor>() != null);

            reactorItem.GetComponent <Reactor>().AutoTemp = true;
        }
        //绘制此项目
        public void DrawItem(Graphics g)
        {
            //Debug.WriteLine("DrawItem:" + Index);

            if (ItemContainer.InDisplayRange(this.Index) == false)
            {
                return;
            }

            Rectangle clientRect = this.ItemContainer.GetItemRectangle(this.Index);

            #region 绘制背景和边框

            SolidBrush backBrush;
            Pen        borderPen;

            if (this.Selected)
            {
                backBrush = new SolidBrush(ItemContainer.SelectedColor);
                borderPen = new Pen(ItemContainer.SelectedBorderColor);
            }
            else if (this.ItemContainer.HotedItem == this)
            {
                backBrush = new SolidBrush(ItemContainer.FocusColor);
                borderPen = new Pen(ItemContainer.FocusBorderColor);
            }
            else
            {
                backBrush = new SolidBrush(ItemContainer.BackgroundColor);
                borderPen = new Pen(ItemContainer.BorderColor);
            }

            g.FillRectangle(backBrush, clientRect);
            g.DrawRectangle(borderPen, clientRect);

            backBrush.Dispose();
            borderPen.Dispose();

            #endregion

            #region 绘制标题

            //绘制标题
            string text = String.Empty;
            if (String.IsNullOrEmpty(ItemContainer.DisplayMember) == false)
            {
                if (ItemContainer.DisplayPropertyInfo != null)
                {
                    object textObj = ItemContainer.DisplayPropertyInfo.GetValue(this.Value, null);
                    if (textObj != null)
                    {
                        text = textObj.ToString();
                    }
                }
            }
            else
            {
                text = this.Value.ToString();
            }

            Color textColor;
            if (this.Selected)
            {
                textColor = ItemContainer.SelectedTextColor;
            }
            else if (this.ItemContainer.HotedItem == this)
            {
                textColor = ItemContainer.FocusTextColor;
            }
            else
            {
                textColor = ItemContainer.TextColor;
            }
            //g.DrawString(text, _titleFont, textBrush, textPoint);
            TextRenderer.DrawText(g, text, _titleFont, TitleStringAreaRectangle, textColor, textFlags);
            //textBrush.Dispose();

            #endregion

            #region 绘制Description

            //绘制Description
            string description = String.Empty;
            if (String.IsNullOrEmpty(ItemContainer.DescriptionMember) == false)
            {
                if (ItemContainer.DiscriptionPropertyInfo != null)
                {
                    object descriptionObj = ItemContainer.DiscriptionPropertyInfo.GetValue(this.Value, null);
                    if (descriptionObj != null)
                    {
                        description = descriptionObj.ToString();
                    }
                }
            }

            if (String.IsNullOrEmpty(description) == false)
            {
                Color descriptionColor;
                if (this.Selected)
                {
                    descriptionColor = ItemContainer.SelectedDescriptionColor;
                }
                else if (this.ItemContainer.HotedItem == this)
                {
                    descriptionColor = ItemContainer.FocusDescriptionColor;
                }
                else
                {
                    descriptionColor = ItemContainer.DescriptionColor;
                }
                //g.DrawString(description, _descriptionFont, descriptionBrush, descriptionPoint);
                TextRenderer.DrawText(g, description, _descriptionFont, DescriptionStringAreaRectangle, descriptionColor, textFlags);
                //descriptionBrush.Dispose();
            }

            #endregion

            g.Dispose();
        }
Пример #57
0
        public ExportStudentV2(string title, Image img)
        {
            InitializeComponent();
            _Title = this.Text = title;
            foreach (WizardPage page in wizard1.WizardPages)
            {
                page.PageTitle = _Title;
                if (img != null)
                {
                    Bitmap b = new Bitmap(48, 48);
                    using (Graphics g = Graphics.FromImage(b))
                        g.DrawImage(img, 0, 0, 48, 48);
                    page.PageHeaderImage = b;
                }
            }

            #region 加入進階跟HELP按鈕
            _OptionsContainer                  = new PanelEx();
            _OptionsContainer.Font             = this.Font;
            _OptionsContainer.ColorSchemeStyle = eDotNetBarStyle.Office2007;
            _OptionsContainer.Size             = new Size(100, 100);
            _OptionsContainer.Style.BackColor1.ColorSchemePart  = DevComponents.DotNetBar.eColorSchemePart.PanelBackground;
            _OptionsContainer.Style.BackColor2.ColorSchemePart  = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2;
            _OptionsContainer.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
            _OptionsContainer.Style.ForeColor.ColorSchemePart   = DevComponents.DotNetBar.eColorSchemePart.PanelText;
            _OptionsContainer.Style.GradientAngle = 90;
            _Options = new SmartSchool.API.PlugIn.Collections.OptionCollection();
            _Options.ItemsChanged += new EventHandler(_Options_ItemsChanged);

            advContainer = new ControlContainerItem();
            advContainer.AllowItemResize = false;
            advContainer.GlobalItem      = false;
            advContainer.MenuVisibility  = eMenuVisibility.VisibleAlways;
            advContainer.Control         = _OptionsContainer;

            ItemContainer itemContainer2 = new ItemContainer();
            itemContainer2.LayoutOrientation = DevComponents.DotNetBar.eOrientation.Vertical;
            itemContainer2.MinimumSize       = new System.Drawing.Size(0, 0);
            itemContainer2.SubItems.AddRange(new DevComponents.DotNetBar.BaseItem[] {
                advContainer
            });

            advButton = new ButtonX();
            advButton.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
            advButton.Text           = "    進階";
            advButton.Top            = this.wizard1.Controls[1].Controls[0].Top;
            advButton.Left           = 5;
            advButton.Size           = this.wizard1.Controls[1].Controls[0].Size;
            advButton.Visible        = true;
            advButton.SubItems.Add(itemContainer2);
            advButton.PopupSide           = ePopupSide.Top;
            advButton.SplitButton         = true;
            advButton.Enabled             = false;
            advButton.Anchor              = AnchorStyles.Bottom | AnchorStyles.Left;
            advButton.AutoExpandOnClick   = true;
            advButton.SubItemsExpandWidth = 16;
            advButton.FadeEffect          = false;
            advButton.FocusCuesEnabled    = false;
            this.wizard1.Controls[1].Controls.Add(advButton);

            helpButton           = new LinkLabel();
            helpButton.AutoSize  = true;
            helpButton.BackColor = System.Drawing.Color.Transparent;
            helpButton.Location  = new System.Drawing.Point(81, 10);
            helpButton.Size      = new System.Drawing.Size(69, 17);
            helpButton.TabStop   = true;
            helpButton.Text      = "Help";
            //helpButton.Top = this.wizard1.Controls[1].Controls[0].Top + this.wizard1.Controls[1].Controls[0].Height - helpButton.Height;
            //helpButton.Left = 150;
            helpButton.Visible = false;
            helpButton.Click  += delegate { if (HelpButtonClick != null)
                                            {
                                                HelpButtonClick(this, new EventArgs());
                                            }
            };
            helpButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
            this.wizard1.Controls[1].Controls.Add(helpButton);
            #endregion

            #region 設定Wizard會跟著Style跑
            //this.wizard1.FooterStyle.ApplyStyle(( GlobalManager.Renderer as Office2007Renderer ).ColorTable.GetClass(ElementStyleClassKeys.RibbonFileMenuBottomContainerKey));
            this.wizard1.HeaderStyle.ApplyStyle((GlobalManager.Renderer as Office2007Renderer).ColorTable.GetClass(ElementStyleClassKeys.RibbonFileMenuBottomContainerKey));
            this.wizard1.FooterStyle.BackColorGradientAngle = -90;
            this.wizard1.FooterStyle.BackColorGradientType  = eGradientType.Linear;
            this.wizard1.FooterStyle.BackColor  = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TopBackground.Start;
            this.wizard1.FooterStyle.BackColor2 = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TopBackground.End;
            this.wizard1.BackColor       = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TopBackground.Start;
            this.wizard1.BackgroundImage = null;
            for (int i = 0; i < 6; i++)
            {
                (this.wizard1.Controls[1].Controls[i] as ButtonX).ColorTable = eButtonColor.OrangeWithBackground;
            }
            (this.wizard1.Controls[0].Controls[1] as System.Windows.Forms.Label).ForeColor = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.MouseOver.TitleText;
            (this.wizard1.Controls[0].Controls[2] as System.Windows.Forms.Label).ForeColor = (GlobalManager.Renderer as Office2007Renderer).ColorTable.RibbonBar.Default.TitleText;
            #endregion


            this.checkBox1.ForeColor = (GlobalManager.Renderer as Office2007Renderer).ColorTable.CheckBoxItem.Default.Text;
            listViewEx1.ForeColor    = (GlobalManager.Renderer as Office2007Renderer).ColorTable.CheckBoxItem.Default.Text;

            _CheckAllManager.TargetComboBox = this.checkBox1;
            _CheckAllManager.TargetListView = this.listViewEx1;

            advButton.PopupOpen += delegate { if (ControlPanelOpen != null)
                                              {
                                                  ControlPanelOpen(this, new EventArgs());
                                              }
            };
            advButton.PopupClose += delegate { if (ControlPanelClose != null)
                                               {
                                                   ControlPanelClose(this, new EventArgs());
                                               }
            };

            _ExportableFields = new SmartSchool.API.PlugIn.Collections.FieldsCollection();
            _SelectedFields   = new SmartSchool.API.PlugIn.Collections.FieldsCollection();
            _ExportableFields.ItemsChanged += delegate
            {
                List <string> uncheckItems = new List <string>();
                foreach (ListViewItem item in listViewEx1.Items)
                {
                    if (item != null && item.Checked == false)
                    {
                        uncheckItems.Add(item.Text);
                    }
                }
                listViewEx1.Items.Clear();

                List <string> newFields = new List <string>(new string[] { "學生系統編號", "學號", "班級", "座號", "姓名" });
                //newFields.AddRange(_Process.ExportableFields);
                foreach (string field in _ExportableFields)
                {
                    if (!newFields.Contains(field))
                    {
                        newFields.Add(field);
                    }
                }
                List <ListViewItem> items = new List <ListViewItem>();
                foreach (string var in newFields)
                {
                    ListViewItem item = new ListViewItem(var);
                    item.Checked = !uncheckItems.Contains(var);
                    items.Add(item);
                }
                listViewEx1.Items.AddRange(items.ToArray());
                listViewEx1_ItemChecked(null, null);
            };
        }
Пример #58
0
 void Awake()
 {
     restrictedContainer = GetComponent <ItemContainer>();
     restrictedContainer.containerAddRestrictions.Add(this);
 }
Пример #59
0
        string Find(BasePlayer player, string[] args)
        {
            string returnstring = string.Empty;

            if (!hasPermission(player, findPermission, findAuthlevel))
            {
                return(GetMsg("You don't have the permission to use this command.", player));
            }

            if (args == null || args.Length == 0)
            {
                return(GetMsg("ListCommands", player));
            }
            var puserid = player == null ? 0L : player.userID;

            switch (args[0].ToLower())
            {
            case "player":
            case "bag":
            case "cupboard":
            case "building":
                if (args.Length == 1)
                {
                    return(GetMsg("You need to select a target player.", player));
                }
                var f = FindPlayerID(args[1], player);
                if (!(f is ulong))
                {
                    return(f.ToString());
                }
                ulong targetID = (ulong)f;
                var   d        = GetPlayerInfo(targetID);
                returnstring = d.ToString() + ":\n\r";
                switch (args[0].ToLower())
                {
                case "player":
                    var p = FindPosition(targetID);
                    if (p == null)
                    {
                        returnstring += GetMsg("This player doesn't have a position", player);
                    }
                    else
                    {
                        d.AddFind("Position", (Vector3)p, string.Empty);
                    }
                    break;

                case "bag":
                    var bs = SleepingBag.FindForPlayer(targetID, true).ToList();
                    if (bs.Count == 0)
                    {
                        returnstring += GetMsg("This player doesn't have any bags", player);
                    }
                    foreach (var b in bs)
                    {
                        d.AddFind(b.ShortPrefabName, b.transform.position, b.niceName);
                    }
                    break;

                case "cupboard":
                    var cs = Resources.FindObjectsOfTypeAll <BuildingPrivlidge>().Where(x => x.authorizedPlayers.Any((ProtoBuf.PlayerNameID z) => z.userid == targetID)).ToList();
                    if (cs.Count == 0)
                    {
                        returnstring += GetMsg("This player doesn't have any cupboard privileges", player);
                    }
                    foreach (var c in cs)
                    {
                        d.AddFind("Tool Cupboard", c.transform.position, string.Empty);
                    }
                    break;

                case "building":
                    var bb = Resources.FindObjectsOfTypeAll <BuildingBlock>().Where(x => x.OwnerID == targetID).ToList();
                    if (bb.Count == 0)
                    {
                        returnstring += GetMsg("This player hasn't built anything yet", player);
                    }
                    var dic = new Dictionary <uint, Dictionary <string, object> >();
                    foreach (var b in bb)
                    {
                        if (!dic.ContainsKey(b.buildingID))
                        {
                            dic.Add(b.buildingID, new Dictionary <string, object>
                            {
                                { "pos", b.transform.position },
                                { "num", 0 }
                            });
                        }
                        dic[b.buildingID]["num"] = (int)dic[b.buildingID]["num"] + 1;
                    }
                    foreach (var c in dic)
                    {
                        d.AddFind("Building", (Vector3)c.Value["pos"], c.Value["num"].ToString());
                    }
                    break;

                default:
                    break;
                }
                for (int i = 0; i < d.Data.Count; i++)
                {
                    returnstring += i.ToString() + " - " + d.Data[i].ToString() + "\n\r";
                }
                if (cachedFinder.ContainsKey(puserid))
                {
                    cachedFinder[puserid].Data.Clear();
                    cachedFinder[puserid] = null;
                    cachedFinder.Remove(puserid);
                }
                cachedFinder.Add(puserid, d);
                break;

            case "item":
                if (args.Length < 3)
                {
                    return(GetMsg("usage: /find item ITEMNAME MINAMOUNT optional:STEAMID.", player));
                }
                var   pu       = GetPlayerInfo(puserid);
                var   itemname = args[1].ToLower();
                ulong ownerid  = 0L;
                if (args.Length > 3)
                {
                    ulong.TryParse(args[3], out ownerid);
                }
                var itemamount = 0;
                if (!(int.TryParse(args[2], out itemamount)))
                {
                    return(GetMsg("usage: /find item ITEMNAME MINAMOUNT optional:STEAMID.", player));
                }
                ItemDefinition item = null;
                for (int i = 0; i < ItemManager.itemList.Count; i++)
                {
                    if (ItemManager.itemList[i].displayName.english.ToLower() == itemname)
                    {
                        item = ItemManager.itemList[i];
                        break;
                    }
                }
                if (item == null)
                {
                    return(GetMsg("You didn't use a valid item name.", player));
                }
                foreach (StorageContainer sc in Resources.FindObjectsOfTypeAll <StorageContainer>())
                {
                    ItemContainer inventory = sc.inventory;
                    if (inventory == null)
                    {
                        continue;
                    }
                    List <Item> list   = inventory.itemList.FindAll((Item x) => x.info.itemid == item.itemid);
                    int         amount = 0;
                    if (amount < itemamount)
                    {
                        continue;
                    }
                    pu.AddFind("Box", sc.transform.position, amount.ToString());
                }
                foreach (BasePlayer bp in Resources.FindObjectsOfTypeAll <BasePlayer>())
                {
                    PlayerInventory inventory = player.inventory;
                    if (inventory == null)
                    {
                        continue;
                    }
                    int amount = inventory.GetAmount(item.itemid);
                    if (amount < itemamount)
                    {
                        continue;
                    }
                    Dictionary <string, object> scdata = new Dictionary <string, object>();
                    pu.AddFind(string.Format("{0} {1}", player.userID.ToString(), player.displayName), bp.transform.position, amount.ToString());
                }
                for (int i = 0; i < pu.Data.Count; i++)
                {
                    returnstring += i.ToString() + " - " + pu.Data[i].ToString() + "\n\r";
                }
                if (cachedFinder.ContainsKey(puserid))
                {
                    cachedFinder[puserid].Data.Clear();
                    cachedFinder[puserid] = null;
                    cachedFinder.Remove(puserid);
                }
                cachedFinder.Add(puserid, pu);
                break;

            case "tp":
                if (player == null)
                {
                    return(GetMsg("You are using the console, you can't tp!", player));
                }
                if (!cachedFinder.ContainsKey(puserid))
                {
                    return(GetMsg("You didn't find anything yet", player));
                }
                if (args.Length == 1)
                {
                    return(GetMsg("You need to select a target findid.", player));
                }
                var fp = cachedFinder[puserid];
                var id = 0;
                int.TryParse(args[1], out id);
                if (id >= fp.Data.Count)
                {
                    return(GetMsg("This id is out of range.", player));
                }

                var data = cachedFinder[puserid].Data[id];
                player.MovePosition(data.Pos);
                player.ClientRPCPlayer(null, player, "ForcePositionTo", data.Pos);
                returnstring += data.ToString();
                break;

            default:
                returnstring += GetMsg("ListCommands", player);
                break;
            }



            return(returnstring);
        }
 void Awake()
 {
     restrictedContainer = GetComponent<ItemContainer>();
     restrictedContainer.ContainerAddRestrictions.Add(this);
 }