Пример #1
0
        public void OnMouseDown(UIElement element)
        {
            if (element.GetType() == typeof(UIListButton))
            {
                Item item = ((UIListButton) element).Item;
                if (item.GetType() == typeof (Visier))
                {
                    constructionPanel.SetVisier((Visier) item);
                }
                else if (item.GetType() == typeof (Antrieb))
                {
                    constructionPanel.SetAntrieb((Antrieb) item);
                }
                else if (item.GetType() == typeof (Stabilisator))
                {
                    constructionPanel.SetStabilisator((Stabilisator) item);
                }
                else if (item.GetType() == typeof (Hauptteil))
                {
                    constructionPanel.SetHauptteil((Hauptteil) item);
                }
            }
            else if(element.GetType() == typeof(UIButton))
            {
                Visier v = constructionPanel.Visier;
                Antrieb a = constructionPanel.Antrieb;
                Stabilisator s = constructionPanel.Stabilisator;
                Hauptteil h = constructionPanel.Hauptteil;
                Weapon newWeapon = new Weapon(v, a, s, h, Item.StaticID, 0, constructionPanel.InputText, 0, "", new MapLocation(new Vector2(0,0)));

                player.RemoveItemFromInventar(v);
                player.RemoveItemFromInventar(a);
                player.RemoveItemFromInventar(s);
                player.RemoveItemFromInventar(h);

                Item.AllItems.Add(Item.StaticID++, newWeapon);
                player.AddItemToInventar(newWeapon);
                filteredConstructorList.RefreshItemList();

                player.ReduceLiquid(newWeapon.GetTotalRequeredLiquids());

                constructionPanel.ResetPanel();
            }
        }