Esempio n. 1
0
        public void SetUp()
        {
            var vest = LeatherBody.LeatherVest();

            vestName = vest.name;

            var sword = ShortSwordBasic.RustedShortSword();

            swordName = sword.name;

            container.Add(vest);
            container.Add(sword);
            container.Add(sword);
        }
Esempio n. 2
0
    public override void DoAction(ItemData itemData)
    {
        ///Tmp moves all to vault on backend
        MoveMultipleStacks stacks = new MoveMultipleStacks();

        stacks.StackInfos = new List <MoveItemStackInfo>();
        foreach (ItemData item in SourceContainer.containerItems)
        {
            MoveItemStackInfo info = new MoveItemStackInfo();
            info.MoveAmount = item.stackSize;
            info.StackID    = item.stackID;
            stacks.StackInfos.Add(info);
        }
        string convert = JsonConvert.SerializeObject(stacks);

        WebserviceCalls.webservice.MoveItemStacks(convert, ItemSystemGameData.UserID.ToString(), "User", ItemSystemGameData.AppID, DestinationLocation, delegate(MoveMultipleItemsResponse x)
        {
            ItemData[] containerItems = new ItemData[SourceContainer.containerItems.Count];
            SourceContainer.containerItems.CopyTo(containerItems);

            foreach (MovedItemsInfo info in x.movedItems)
            {
                foreach (ItemData data in containerItems)
                {
                    if (data.stackID == info.OriginalStackID)
                    {
                        data.stackID = info.NewStackID;
                        SourceContainer.Remove(data, true);
                        DestinationContainer.Add(data, -1, false);
                    }
                }
            }
        });
    }
Esempio n. 3
0
    internal void OnClick(ItemSlot itemSlot, ItemContainer container)//przyjmuje "kliknięty" item i ekwipunek z którego pochodzi
    {
        ItemContainer shop      = GameManager.instance.shopContainer;
        ItemContainer inventory = GameManager.instance.inventoryContainer;

        if (shopPanel.activeInHierarchy && container == shop)//jeśli sklep jest otwarty i item kliknięty jest w panelu sklepu
        {
            //zakup

            if ((GameManager.instance.money - itemSlot.item.price) >= 0)//jeśli starcza nam pieniędzy
            {
                GameManager.instance.money -= itemSlot.item.price;
                inventory.Add(itemSlot.item, 1, inventory);//dodaje do ekwipunku przedmiot
                UpdateInventoryAndMoney();

                //**********QUEST 1**************
                if ((itemSlot.item.name == "Sword" || itemSlot.item.name == "FireSword" || itemSlot.item.name == "IceSword") && (GameManager.instance.fableController.GetCurQuest() == 1))
                {
                    GameManager.instance.fableController.NextQuest();
                }
            }
            else
            {
                GameManager.instance.eventController.ShowEvent("Nie stać cię na to!", "", 3);
            }
        }
        else if (shopPanel.activeInHierarchy && container == inventory)//jeśli sklep jest otwarty i item kliknięty jest w panelu ekwipunku
        {
            //sprzedaż
            GameManager.instance.money += itemSlot.item.price;
            inventory.Remove(itemSlot);
            UpdateInventoryAndMoney();
        }
    }
Esempio n. 4
0
    public void merge_click()
    {
        if (obj_count > 1)
        {
            col /= obj_count;
            Renderer rend = sphere.GetComponent <Renderer> ();
            rend.material       = new Material(Shader.Find("Specular"));
            rend.material.color = col;

            items new_item = new items();
            //new_item.name = gen_name();
            new_item.name  = makeName.newString();
            new_item.red   = col.r;
            new_item.green = col.g;
            new_item.blue  = col.b;

            ic.Add(new_item);
            ic.SaveItems();
            text.text = new_item.name;
            print(new_item.name);
            obj_count = 0;
        }
        else
        {
            print("You have to pick colors!!!");
        }
    }
Esempio n. 5
0
            public void Load(Adventure adventure, DataNode node)
            {
                this.name        = node.GetString("name", "???");
                this.description = node.GetString("desc");

                foreach (var child in node.Children)
                {
                    if (child.Name == "contains")
                    {
                        var ammount = child.GetInt32("ammount", 1);
                        var item_id = child.GetString("item");

                        var item = adventure.FindItem(item_id);

                        items.Add(item, ammount);
                    }

                    if (child.Name == "connects")
                    {
                        var connection = new Connection(adventure, child);

                        this.connections.Add(connection);
                    }

                    if (child.Name == "prop")
                    {
                        var prop = new Prop(adventure, child);
                        props.Add(prop);
                    }
                }
            }
    public static ContainerAddState.ActionState MoveItem(ItemData movingItemData, ItemContainer lastContainer, 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");
            }

            if (lastContainer != null)
            {
                Debug.Log(lastContainer.GetContainerRemoveState(movingItemData));
                if (lastContainer.GetContainerRemoveState(movingItemData) == false)
                {
                    return(ContainerAddState.ActionState.No);
                }
            }

            ContainerAddState targetAddState = targetContainer.GetContainerAddState(movingItemData);

            switch (targetAddState.actionState)
            {
            case ContainerAddState.ActionState.Add:

                ItemData newItemData = new ItemData();
                newItemData.SetItemData(movingItemData);

                if (movingItemData.ownerContainer != null)
                {
                    movingItemData.ownerContainer.Remove(movingItemData, true, targetAddState.possibleAddAmount);
                }

                targetContainer.Add(newItemData, targetAddState.possibleAddAmount);

                break;

            case ContainerAddState.ActionState.No:
                break;

            default:
                break;
            }

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

            return(ContainerAddState.ActionState.No);
        }
    }
Esempio n. 7
0
    private int AddItem(ItemContainer pCon, CItem item, int nCmd)
    {
        if (item == null)
        {
            return(-1);
        }

        pCon.Add(item);

        return(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);
        }
    }
Esempio n. 9
0
    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);
        }
    }
    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);
        }
    }
Esempio n. 11
0
        private void CreateReplaceButton()
        {
            mReplaceButton = new Button();
            var mReplaceButtonStyle = new ButtonStyle
            {
                Text            = null,
                BackgroundColor = new Selector <Color>(),
                BackgroundImage = new Selector <string>()
                {
                    Normal = REPLACE_IMAGE, Selected = REPLACE_IMAGE_SELECTED
                }
            };

            mReplaceButton.ApplyStyle(mReplaceButtonStyle);
            mReplaceButton.IsSelectable           = true;
            mReplaceButton.ParentOrigin           = ParentOrigin.BottomRight;
            mReplaceButton.PivotPoint             = PivotPoint.BottomRight;
            mReplaceButton.PositionUsesPivotPoint = true;
            mReplaceButton.DrawMode      = DrawModeType.Overlay2D;
            mReplaceButton.Size          = new Size(50, 50);
            mReplaceButton.LeaveRequired = true;
            mReplaceButton.Hide();
            mReplaceButton.Clicked += (obj, e) =>
            {
                ItemContainer replaceList = new ItemContainer();
                Random        random      = new Random();
                for (uint i = 0; i < mItemView.GetChildCount(); ++i)
                {
                    View child = mItemView.GetChildAt(i);
                    if (child != null)
                    {
                        View tick = child.FindChildByName("Tick");

                        if (tick != null && tick.Visibility)
                        {
                            replaceList.Add(new Item(mItemView.GetItemId(child), NewItemView((uint)random.Next(52))));
                        }
                    }
                }

                if (replaceList.Count != 0)
                {
                    mItemView.ReplaceItems(replaceList, 0.5f);
                }
            };
            NUIApplication.GetDefaultWindow().Add(mReplaceButton);
        }
    protected void RecivedItems(List <ItemData> receivedItems)
    {
        if (CloudGoods.itemDataConverter == null)
        {
            throw new Exception("Item conversion is not setup correctly!");
        }

        foreach (ItemData item in receivedItems)
        {
            Container.Add(item, -1, false);
        }

        if (LoadedItemsForContainerEvent != null)
        {
            LoadedItemsForContainerEvent(receivedItems, Container);
        }
    }
    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;
        }
    }
Esempio n. 14
0
                public Prop(Adventure adventure, DataNode node)
                {
                    this.name = node.GetString("name");
                    this.desc = node.GetString("desc");

                    foreach (var child in node.Children)
                    {
                        if (child.Name == "contains")
                        {
                            var ammount = child.GetInt32("ammount", 1);
                            var item_id = child.GetString("item");

                            var item = adventure.FindItem(item_id);

                            items.Add(item, ammount);
                        }
                    }
                }
Esempio n. 15
0
        static void Main(string[] args)
        {
            List <int> list = new List <int> {
                2, 4, 7, 1
            };
            Queue <int> queue = new Queue <int>(new int[] { 1, 2, 3, 4 });
            Stack <int> stack = new Stack <int>(new int[] { 1, 2, 3, 4 });

            Console.WriteLine(GetSumOfElements(list));
            Console.WriteLine(GetSumOfElements(queue));
            Console.WriteLine(GetSumOfElements(stack));

            Console.WriteLine(MagicMethod(list));

            ItemContainer container = new ItemContainer();

            container.Add(new Item("SuperItem"));

            Console.ReadKey();
        }
Esempio n. 16
0
        private void CreateReplaceButton()
        {
            mReplaceButton = new PushButton();
            //mReplaceButton.BackgroundColor = Color.Red;
            mReplaceButton.ParentOrigin           = ParentOrigin.BottomRight;
            mReplaceButton.PivotPoint             = PivotPoint.BottomRight;
            mReplaceButton.PositionUsesPivotPoint = true;
            mReplaceButton.Position2D             = new Position2D(BUTTON_BORDER, BUTTON_BORDER);
            mReplaceButton.DrawMode = DrawModeType.Overlay2D;
            mReplaceButton.UnselectedBackgroundVisual = CreateImageVisual(REPLACE_IMAGE);
            mReplaceButton.SelectedBackgroundVisual   = CreateImageVisual(REPLACE_IMAGE_SELECTED);
            mReplaceButton.Size2D        = new Size2D(50, 50);
            mReplaceButton.LeaveRequired = true;
            mReplaceButton.Hide();
            mReplaceButton.Clicked += (obj, e) =>
            {
                ItemContainer replaceList = new ItemContainer();
                Random        random      = new Random();
                for (uint i = 0; i < mItemView.GetChildCount(); ++i)
                //for (uint i = 0; i < ITEM_COUNT; ++i)
                {
                    View child = mItemView.GetChildAt(i);
                    if (child != null)
                    {
                        View tick = child.FindChildByName("Tick");

                        if (tick != null && tick.Visibility)
                        {
                            replaceList.Add(new Item(mItemView.GetItemId(child), NewItemView((uint)random.Next(52))));
                        }
                    }
                }

                if (replaceList.Count != 0)
                {
                    mItemView.ReplaceItems(replaceList, 0.5f);
                }
                return(true);
            };
            Window.Instance.Add(mReplaceButton);
        }
    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);
        }

    }
Esempio n. 18
0
        private void CreateInsertButton()
        {
            mInsertButton = new PushButton();
            mInsertButton.ParentOrigin           = ParentOrigin.BottomRight;
            mInsertButton.PivotPoint             = PivotPoint.BottomRight;
            mInsertButton.PositionUsesPivotPoint = true;
            mInsertButton.Position2D             = new Position2D(BUTTON_BORDER, BUTTON_BORDER);
            mInsertButton.DrawMode = DrawModeType.Overlay2D;
            mInsertButton.UnselectedBackgroundVisual = CreateImageVisual(INSERT_IMAGE);
            mInsertButton.SelectedBackgroundVisual   = CreateImageVisual(INSERT_IMAGE_SELECTED);
            mInsertButton.Size2D        = new Size2D(50, 50);
            mInsertButton.LeaveRequired = true;
            mInsertButton.Hide();
            mInsertButton.Clicked += (obj, e) =>
            {
                ItemContainer insertList = new ItemContainer();
                Random        random     = new Random();
                for (uint i = 0; i < mItemView.GetChildCount(); ++i)
                {
                    View child = mItemView.GetChildAt(i);
                    if (child != null)
                    {
                        View tick = child.FindChildByName("Tick");

                        if (tick != null && tick.Visibility)
                        {
                            insertList.Add(new Item(mItemView.GetItemId(child), NewItemView((uint)random.Next(52))));
                        }
                    }
                }
                if (insertList.Count != 0)
                {
                    mItemView.InsertItems(insertList, 0.5f);
                }
                return(true);
            };
            NUIApplication.GetDefaultWindow().Add(mInsertButton);
        }
    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);
        }
    }
Esempio n. 20
0
        private async Task DoForaging(Player player, Room room)
        {
            player.Status = Player.PlayerStatus.Busy;

            await Task.Delay(500);

            HubContext.Instance.SendToClient("You continue searching the area.",
                                             player.HubGuid);


            player.PlayerIsForaging = true;
            foreach (var character in room.players)
            {
                if (character != player)
                {
                    var roomMessage =
                        $"{Helpers.ReturnName(player, character, string.Empty)} continues searching the area.";

                    HubContext.Instance.SendToClient(roomMessage, character.HubGuid);
                }
            }

            await Task.Delay(500);

            var    foragingAB   = player.Skills.FirstOrDefault(x => x.Name.Equals("Foraging"));
            double getSkillProf = 0;

            if (foragingAB != null)
            {
                getSkillProf = foragingAB.Points;
            }

            var getItems = room.ForageItems.Where(x => x.ForageRank <= player.ForageRank).ToList();

            if (getItems.Count == 0 && room.terrain == Room.Terrain.City)
            {
                getItems = new ItemContainer();

                if (Helpers.Rand(1, 100) <= 50)
                {
                    getItems.Add(Held.TatteredRag());

                    getItems.Add(Held.ScrapMetal());
                }
            }
            else if (room.terrain == Room.Terrain.City)
            {
                if (Helpers.Rand(1, 100) <= 50)
                {
                    getItems.Add(Held.TatteredRag());

                    getItems.Add(Held.ScrapMetal());
                }
            }

            var successChance = Helpers.Rand(1, 100);

            if (getSkillProf >= successChance && getItems.Count > 0)
            {
                var YouFound = "You found " +
                               Helpers.ReturnName(null, null, getItems[Helpers.Rand(0, getItems.Count)].name).ToLower() + ".";


                var item = getItems[Helpers.Rand(0, getItems.Count)];

                item.location = Item.Item.ItemLocation.Inventory;
                item.type     = Item.Item.ItemType.Food;
                item.hidden   = false;

                PlayerSetup.Player.AddItem(player, item);

                HubContext.Instance.SendToClient(YouFound, player.HubGuid);
            }

            else
            {
                var failMessage = "";

                if (room.terrain == Room.Terrain.City)
                {
                    failMessage = "You fail to find anything.";
                }
                else
                {
                    switch (Helpers.Rand(1, 4))
                    {
                    case 1:
                        failMessage = "A bee has stung you on the hand, Ouch!";
                        break;

                    case 2:
                    case 3:
                        failMessage = "You fail to find anything worth taking.";
                        break;

                    default:
                        failMessage = "You don't recognise any of the flora here.";
                        break;
                    }
                }



                HubContext.Instance.SendToClient(failMessage, player.HubGuid);


                if (getSkillProf < 99)
                {
                    HubContext.Instance.SendToClient("You learn from your mistakes and gain 100 experience points",
                                                     player.HubGuid);

                    var xp = new Experience();
                    player.Experience += 100;

                    xp.GainLevel(player);

                    foragingAB.Points += Helpers.Rand(1, 5);


                    if (foragingAB.Points > 99)
                    {
                        foragingAB.Points = 99;
                    }
                }

                if (foragingAB.Points == 99)
                {
                    HubContext.Instance.SendToClient("You must commit to a craft to progress further",
                                                     player.HubGuid);
                }



                Score.ReturnScoreUI(player);
            }

            player.ActiveSkill      = null;
            player.PlayerIsForaging = false;
        }
Esempio n. 21
0
 public void Move(Item item, ItemContainer other, int ammount = 1)
 {
     ammount = Remove(item, ammount);
     other.Add(item, ammount);
 }