Beispiel #1
0
    public static ItemPO GetByRow(int i) // 1 ~ Count
    {
        i = i + 1;
        ItemPO item = new ItemPO();

        item.name = instance.csvArray[i, 0];

        string type = instance.csvArray[i, 1];

        if (type == "h")
        {
            item.type = ItemType.Horizontal;
        }
        else if (type == "v")
        {
            item.type = ItemType.Vertical;
        }

        string[] sizeArray = instance.csvArray[i, 2].Split(',');
        int      x         = Int32.Parse(sizeArray[0]);
        int      y         = Int32.Parse(sizeArray[1]);
        int      z         = Int32.Parse(sizeArray[2]);

        item.size = new Vector3Int(x, y, z);

        item.isOccupied = instance.csvArray[i, 3] == "1";

        return(item);
    }
Beispiel #2
0
    private void AddItem(ItemPO itemPO)
    {
        if (isItemEdited)
        {
            return;
        }

        GameObject itemGO = null;

        itemGO = Instantiate(Resources.Load("Prefabs/Items/" + itemPO.name)) as GameObject;

        ItemObject item = itemGO.AddComponent <ItemObject>();

        item.Init(itemPO);

        SuspendItem suspendItem = itemGO.AddComponent <SuspendItem>();

        suspendItem.Init();
        suspendItem.OnClick = ClickItem;

        SetEdited(item);

        Direction dir = room.ShowWallsDirection()[0];

        SetCurrentItemDirection(item, dir);
    }
Beispiel #3
0
 public static ItemPO[] GetAll()
 {
     ItemPO[] items = new ItemPO[Count()];
     for (int i = 0; i < Count(); i++)
     {
         items[i] = GetByRow(i);
     }
     return(items);
 }
Beispiel #4
0
    private void HandleUIItemBeginDrag(ItemPO item, Vector2 screenPosition)
    {
        isUIHandleDrag = true;

        AddItem(item);
        Vector3 worldPosition = ScreenToWorldOfOutside(room, currentItem.Item, screenPosition, Vector2.zero);

        SetCurrentItemPosition(room, currentItem, worldPosition);
        editedItem.SetDragOffset(worldPosition);
    }
        public PartialViewResult ViewDropsFrom(int id)
        {
            PartialViewResult response = new PartialViewResult();

            //try to connect to the database via multiple DAO's
            try
            {
                //creating and populating a list, describing Enemy and Item Relationship based on a JunctionTable
                List <EnemyItemDO> doList = linkDAO.ViewByItemID(id);

                //gathering selected items information for View Model
                ItemDO tempItem = iDAO.ViewItemSingle(id);
                ItemPO viewItem = Mapper.Mapper.ItemDOtoPO(tempItem);

                //gathering enemy information using the EnemyID's found in out Enemy Item Relationship list
                List <EnemyDO> tempEnemyList = new List <EnemyDO>();
                foreach (EnemyItemDO item in doList)
                {
                    //adding each Enemy to our EnemyDO list
                    tempEnemyList.Add(eDAO.ViewSingleEnemy(item.EnemyID));
                }

                //converting our EnemyDO List to an EnemyPO List
                List <EnemyPO> enemyList = Mapper.Mapper.EnemyDOListToPO(tempEnemyList);

                //instantiatin our View Model
                ItemDropsVM itemVM = new ItemDropsVM();

                //settingg View Model values to our collected information
                //---Item information
                //---EnemyPO List
                itemVM.item    = viewItem;
                itemVM.enemies = enemyList;

                //setting our response to our target Partial View, passing in our View Model
                response = PartialView("_ViewDropsFrom", itemVM);
            }
            //catch and log any unlogged sqlExceptions
            catch (SqlException sqlEx)
            {
                if (!((bool)sqlEx.Data["Logged"] == true) || !sqlEx.Data.Contains("Logged"))
                {
                    Logger.LogSqlException(sqlEx);
                }
            }
            catch (Exception ex)
            {
                if (!ex.Data.Contains("Logged") || (bool)ex.Data["Logged"] == false)
                {
                    Logger.LogException(ex);
                }
            }

            return(response);
        }
        public JsonResult GetItemData()
        {
            //pullingg linkList from db
            List <EnemyItemDO> list = linkDAO.ViewAllLinks();
            //stripping itemID's off of the list and storing them in a list
            List <int> idList = Mapper.BLLMapper.LinkListToItemIdList(list);

            //sending the idList to a BLL method to find unique id's and count their occurances
            Dictionary <int, int> countDictionary = AnalyzeItemList.ItemDropCount(idList);

            //instantiating a dictionary that will hold item names(based on ids) and how many times they were used
            Dictionary <string, int> itemDropCount = new Dictionary <string, int>();

            //creating a list of ItemPO to hold item information, to pull names from items based on ids in idList
            List <ItemPO> itemList = new List <ItemPO>();

            //foreach unique itemID, add that item's information to the itemList
            foreach (KeyValuePair <int, int> idLink in countDictionary)
            {
                ItemPO item = Mapper.Mapper.ItemDOtoPO(iDAO.ViewItemSingle(idLink.Key));
                itemList.Add(item);
            }

            //foreach item in the itemList, create a key based on item name, and set its base value to 0
            foreach (ItemPO item in itemList)
            {
                itemDropCount.Add(item.Name, 0);
                //for each key value pair in our count dictionary which holds our item id and how many times that item has been used
                //we check if the key value pair's key is the same as the item's id in the outer for each
                //if it matches we update the value of our itemDropCount
                foreach (KeyValuePair <int, int> itemCount in countDictionary)
                {
                    if (itemCount.Key == item.ItemID)
                    {
                        itemDropCount[item.Name] = itemCount.Value;
                    }
                }
            }

            //creating an object that holds 2 lists, one of type string, one of type int
            //holds our item names in one list, and our item occurance in the other
            ChartData <string, int> chartData = new ChartData <string, int>();

            chartData.Labels = new List <string>();
            chartData.Values = new List <int>();

            foreach (KeyValuePair <string, int> itemDrop in itemDropCount)
            {
                chartData.Labels.Add(itemDrop.Key);
                chartData.Values.Add(itemDrop.Value);
            }

            return(Json(chartData, JsonRequestBehavior.AllowGet));
        }
Beispiel #7
0
        public static List <ItemPO> MapDOtoPO(List <IItemDO> iFrom)
        {
            List <ItemPO> iMap = new List <ItemPO>(); //Creating a new instance

            foreach (IItemDO prop in iFrom)
            {
                ItemPO map = MapDOtoPO(prop); //Going thourgh the other DOtoPO method
                iMap.Add(map);                //Adding each property allow it to be mapped
            }

            return(iMap); //Return the mapped list
        }
Beispiel #8
0
        public static ItemPO ItemDOtoPO(ItemDO from)
        {
            ItemPO to = new ItemPO();

            to.ItemID      = from.ItemID;
            to.Name        = from.Name;
            to.Description = from.Description;
            to.ImagePath   = from.ImagePath;
            to.Purchasable = from.Purchasable;
            to.Validated   = from.Validated;

            return(to);
        }
Beispiel #9
0
        public static ItemPO MapDOtoPO(IItemDO iFrom)
        {
            ItemPO oTo = new ItemPO(); //creating a new instance

            //PO            //DO
            oTo.ItemID      = iFrom.ItemID;
            oTo.UserID      = iFrom.UserID;
            oTo.ItemName    = iFrom.ItemName;
            oTo.Used        = iFrom.Used;
            oTo.Description = iFrom.Description;

            return(oTo); //return PO
        }
Beispiel #10
0
        public static IItemDO MapPOtoDO(ItemPO iFrom)
        {
            IItemDO oTo = new ItemDO();//creating new instance

            //DO            //PO
            oTo.ItemID      = iFrom.ItemID;
            oTo.UserID      = iFrom.UserID;
            oTo.ItemName    = iFrom.ItemName;
            oTo.Used        = iFrom.Used;
            oTo.Description = iFrom.Description;

            return(oTo); //return DO
        }
Beispiel #11
0
    public void SetItem(ItemPO item)
    {
        nameText.text = item.name;
        string path   = string.Format("Images/Items/{0}_512", item.name);
        Sprite sprite = Resources.Load <Sprite>(path) as Sprite;

        if (sprite)
        {
            image.sprite = sprite;
        }
        else
        {
            image.color = Color.clear;
        }
    }
Beispiel #12
0
        public ActionResult Index()
        {
            ActionResult response;
            HomePageVM   items = new HomePageVM();

            try
            {
                ItemPO mostCommonItem  = new ItemPO();
                ItemPO leastCommonItem = new ItemPO();

                int mostCommonID;
                int leastCommonID;
                List <EnemyItemDO> fullLinkList = linkDAO.ViewAllLinks();
                List <int>         itemIdList   = new List <int>();
                itemIdList = Mapper.BLLMapper.LinkListToItemIdList(fullLinkList);

                mostCommonID  = AnalyzeItemList.MostCommonID(itemIdList);
                leastCommonID = AnalyzeItemList.LeastCommonID(itemIdList);

                mostCommonItem  = Mapper.Mapper.ItemDOtoPO(iDAO.ViewItemSingle(mostCommonID));
                leastCommonItem = Mapper.Mapper.ItemDOtoPO(iDAO.ViewItemSingle(leastCommonID));

                items.MostCommonItem  = mostCommonItem;
                items.LeastCommonItem = leastCommonItem;

                response = View(items);
            }
            catch (SqlException sqlEx)
            {
                if (!sqlEx.Data.Contains("Logged") || (bool)sqlEx.Data["Logged"] == false)
                {
                    Logger.LogSqlException(sqlEx);
                }
                response = View(items);
            }
            catch (Exception ex)
            {
                if (!ex.Data.Contains("Logged") || (bool)ex.Data["Logged"] == false)
                {
                    Logger.LogException(ex);
                }
                response = View(items);
            }

            return(response);
        }
Beispiel #13
0
    // public PlaceableItem PlaceableItem {
    //  get {
    //      return Item.PlaceableItem;
    //  }
    //  set {
    //      Item.PlaceableItem = value;
    //  }
    // }
    public void Init(ItemPO itemPO)
    {
        ItemType   type = itemPO.type;
        Vector3Int size = itemPO.size;

        if (type == ItemType.Horizontal)
        {
            Item = new HorizontalItem();
        }
        else if (type == ItemType.Vertical)
        {
            Item = new VerticalItem();
        }
        this.Type        = type;
        Item.Dir         = Direction.A; // TODO
        Item.Size        = size;
        Item.FlippedSize = new Vector3Int(size.z, size.y, size.x);
        Item.RotateSize  = Item.Dir.IsFlipped() ? Item.FlippedSize : Item.Size;
        Item.IsOccupid   = itemPO.isOccupied;

        gameObject.name = itemPO.name;
    }
Beispiel #14
0
        public ActionResult UpdateEnemy(EnemyUpdateVM form)
        {
            ActionResult response;

            //checks to make sure that all required fields are filled out
            if (ModelState.IsValid)
            {
                //if all fields are filled out, try to connect to the server
                try
                {
                    //if a file was submited, update the image of the enemy to the given file, and rename the file to the
                    //enemies name
                    if (form.File != null && form.File.ContentLength > 0)
                    {
                        //if the enemy already has an image, delete that image
                        if (System.IO.File.Exists(Server.MapPath(form.Enemy.ImagePath)))
                        {
                            System.IO.File.Delete(Server.MapPath(form.Enemy.ImagePath));
                        }
                        //find the filepath for the enemies image
                        string path = Server.MapPath(form.Enemy.ImagePath);
                        //saves the new image to the enemies image filepath
                        form.File.SaveAs(path);
                    }

                    //map the new enemy information to an EnemyDO
                    EnemyDO enemy = Mapper.Mapper.EnemyPOtoDO(form.Enemy);

                    //sending enemydo object to enemy dao, passing in the EnemyDo object
                    eDAO.UpdateEnemy(enemy);

                    //instantiate enemy_itemDAO

                    //collecting old item drop information and deleting it
                    List <EnemyItemIDLink> dropList = Mapper.Mapper.DetailsDOtoPO(linkDAO.ViewByEnemyID(form.Enemy.EnemyID));

                    //for every item linked to the enemy, delete that link. Destroys old enemy drop information
                    foreach (EnemyItemIDLink item in dropList)
                    {
                        linkDAO.DeleteEnemyItems(item.LinkID);
                    }

                    //if item1 = item2, default item2 to 0. prevents enemy from having 2 links to 1 item.
                    if (form.Item1 == form.Item2)
                    {
                        form.Item2 = 0;
                    }

                    //instantiats a new EnemyItemIDLink (object holds the information about which item drops form the enemy)
                    EnemyItemIDLink newLink = new EnemyItemIDLink();
                    //sets the newLinks enemyid to the id of the id of the enemy being updated
                    newLink.EnemyID = form.Enemy.EnemyID;

                    //creating new links for item 1 if one was selected. if the item does not exist, no link is made
                    if (form.Item1 != 0)
                    {
                        //sets the newLinks item id to the new item id found in Item1
                        newLink.ItemID = form.Item1;
                        //creates a new link between the enemy and the item. Enemy will now display the item as a drop
                        linkDAO.CreateEnemyDetails(Mapper.Mapper.DetailsPOtoDO(newLink));
                    }

                    //creating new links for item 2 if one was selected. if the item does not exist, no link is made
                    if (form.Item2 != 0)
                    {
                        //sets the newLink item id to the id found in Item2
                        newLink.ItemID = form.Item2;
                        //creates a new link between the enemy and item. Enemy will now display the item as a drop
                        linkDAO.CreateEnemyDetails(Mapper.Mapper.DetailsPOtoDO(newLink));
                    }

                    //set response to redirect to enemies homepage
                    response = RedirectToAction("Index", "Enemy");
                }
                //log any sql exceptions encountered
                catch (SqlException sqlEx)
                {
                    //checks to see if the exception has been logged, and logs it if it hasn't been
                    if (!sqlEx.Data.Contains("Logged") || (bool)sqlEx.Data["Logged"] == false)
                    {
                        Logger.LogSqlException(sqlEx);
                    }
                    //redirects to the enemy list page
                    response = RedirectToAction("Index", "Enemy");
                }
                //catches any exceptions that occure due to mapping or otherwise
                catch (Exception ex)
                {
                    //checks to see if the exception has been logged, and logs it if it hasn't been
                    if (!ex.Data.Contains("Logged") || (bool)ex.Data["Logged"] == false)
                    {
                        Logger.LogException(ex);
                    }
                    //redirects to the enemy list page
                    response = RedirectToAction("Index", "Enemy");
                }
            }
            //if modelstate is false
            else
            {
                //refills the item list for the drop down menus
                form.itemList = Mapper.Mapper.ItemDOListToPO(iDAO.ViewAllItems());

                //adds teh default item of "None" to the list in case the enemy doesn't drop an itme
                ItemPO @default = new ItemPO
                {
                    Name        = "None",
                    ItemID      = 0,
                    Description = ""
                };
                form.itemList.Add(@default);

                //creates a modelstate error stating that the form is missing information
                ModelState.AddModelError("Validated", "Missing information. Please fill in all fields.");
                //sets response to the View() and passes in the old form information including the newly populated item list
                response = View(form);
            }

            return(response);
        }
Beispiel #15
0
        public ActionResult UpdateEnemy(int id)
        {
            ActionResult  response;
            EnemyUpdateVM enemy = new EnemyUpdateVM();

            try
            {
                //mapping an enemypo to our VM
                enemy.Enemy = Mapper.Mapper.EnemyDOtoPO(eDAO.ViewSingleEnemy(id));

                //instantiating an enemy_itemDAO
                EnemyItemDAO linkDAO = new EnemyItemDAO(connectionString, logPath);

                //collecting item id's linked to the enemy id
                List <EnemyItemDO> itemDrops = linkDAO.ViewByEnemyID(id);

                //assigning items 1 and 2 based on what was returned from the enemy_itemDAO
                if (itemDrops.Count >= 1)
                {
                    //sets Item1 to the itemid from the link table in the database
                    enemy.Item1 = itemDrops[0].ItemID;
                    //checks to see if there was a second item linked to the enemy
                    if (itemDrops.Count == 2)
                    {
                        //sets Item2 to the second items id
                        enemy.Item2 = itemDrops[1].ItemID;
                    }
                }
                //setting default values to 0 if no items where linked to enemy
                else
                {
                    enemy.Item1 = 0;
                    enemy.Item2 = 0;
                }


                //creating and adding default item "none" to drop down list
                ItemPO @default = new ItemPO
                {
                    Name        = "None",
                    ItemID      = 0,
                    Description = ""
                };

                enemy.itemList.Add(@default);

                //adds list to existing list, does not delete old information.
                enemy.itemList.AddRange(Mapper.Mapper.ItemDOListToPO(iDAO.ViewAllItems()));

                response = View(enemy);
            }
            //catches any slqexceptions that occur during our DAO call
            catch (SqlException sqlEx)
            {
                //logs the exception IF it has not already been marked as logged
                if (!sqlEx.Data.Contains("Logged") || (bool)sqlEx.Data["Logged"] == false)
                {
                    Logger.LogSqlException(sqlEx);
                }
                //redirects to the index page of the enemy controller. The page containing the full list of enemies.
                response = RedirectToAction("Index", "Enemy");
            }
            //catches any non-sqlexceptions that may occure during mapping or otherwise
            catch (Exception ex)
            {
                //logs the exception if it has not already been marked as logged
                if (!ex.Data.Contains("Logged") || (bool)ex.Data["Logged"] == false)
                {
                    Logger.LogException(ex);
                }
                //redirects to the index page of the enemy controller. The page containing the full list of enemies.
                response = RedirectToAction("Index", "Enemy");
            }
            //passing enemy view model to view
            return(response);
        }
Beispiel #16
0
 public ItemVM()                     //Constructor
 {
     Item     = new ItemPO();        //new instance
     ItemList = new List <ItemPO>(); //new instance of list
 }