private void constructItem()
        {
            List <Tuple <resource.resourceTypes, int> > costs = new List <Tuple <resource.resourceTypes, int> >();

            foreach (constructionItem item in items)
            {
                if (item.selected)
                {
                    costs = item.cost;

                    foreach (Tuple <resource.resourceTypes, int> cost in costs)
                    {
                        if (!playerInv.contains(cost.Item1, cost.Item2))
                        {
                            //do nothing
                            return;
                        }
                    }

                    foreach (Tuple <resource.resourceTypes, int> cost in costs)
                    {
                        playerInv.decreaseResource(cost.Item1, cost.Item2);
                    }

                    if (item.appearsInInventory)
                    {
                        playerInv.addToInventory(item.type, 1);
                    }
                    else if (item.appearsOnMap)
                    {
                        Vector2 location = new Vector2();
                        location.X = currPlayer.getCurrentPos().X + currPlayer.getTexture().Width + currMap.getViewport().X;
                        location.Y = currPlayer.getCurrentPos().Y + currPlayer.getTexture().Height + currMap.getViewport().Y;
                        //add spike pits and trees to the world.
                        if (item.type == resource.resourceTypes.Tree)
                        {
                            currMap.addTree(location);
                        }
                        else if (item.type == resource.resourceTypes.SpikePit)
                        {
                            currMap.addTrapToMap(location);
                        }
                    }

                    break;
                }
            }
        }
Beispiel #2
0
        public void interactWithAdjacentObj()
        {
            if (adjacentObject != null)
            {
                //do stuff
                foreach (resource.resourceTypes res in adjacentObject.getToolsRequiredForHarvesting())
                {
                    if (inv.contains(res, 1))
                    {
                        foreach (resource.resourceTypes addRes in adjacentObject.getTypesOfResoucesProvided())
                        {
                            inv.addToInventory(addRes, adjacentObject.getAmountOfResourceProvided());
                        }
                    }
                }

                adjacentObject.Destroy();
                adjacentObject = null;
            }
        }