Exemplo n.º 1
0
        public IHttpActionResult PutStoreTree(int id, StoreTree storeTree)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != storeTree.ID)
            {
                return(BadRequest());
            }

            db.Entry(storeTree).State = EntityState.Modified;

            try
            {
                db.SaveChanges();

                var subscribed = Hub.Clients.Group(storeTree.Name.ToLower());
                subscribed.updateItem(storeTree);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StoreTreeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        public IHttpActionResult GetStoreTree(int id)
        {
            StoreTree storeTree = db.StoreTrees.Find(id);

            if (storeTree == null)
            {
                return(NotFound());
            }

            return(Ok(storeTree));
        }
Exemplo n.º 3
0
        public IHttpActionResult PostStoreTree(StoreTree storeTree)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.StoreTrees.Add(storeTree);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = storeTree.ID }, storeTree));
        }
Exemplo n.º 4
0
        // POST: odata/StoreTreesOD
        public IHttpActionResult Post(StoreTree storeTree)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.StoreTrees.Add(storeTree);
            db.SaveChanges();

            return(Created(storeTree));
        }
Exemplo n.º 5
0
    private void LoadTreeStore()
    {
        //dont select tree, get the tree node from current zone content
        //assuming the parent is a zone type for now
        ZoneTree parentTree = (ZoneTree)gameDataObject.treeStore.getCurrentTree();
        ZoneTreeNode parentTreeNode = (ZoneTreeNode)parentTree.getNode(parentTree.currentIndex);
        long storeLink = parentTreeNode.content.linkIndex;

        parentTreeLink = gameDataObject.treeStore.currentTreeIndex;

        gameDataObject.treeStore.SelectTree(storeLink);
        storeTree = (StoreTree)gameDataObject.treeStore.getCurrentTree();
    }
Exemplo n.º 6
0
    private void LoadTreeStore()
    {
        //dont select tree, get the tree node from current zone content
        //assuming the parent is a zone type for now
        ZoneTree     parentTree     = (ZoneTree)gameDataObject.treeStore.getCurrentTree();
        ZoneTreeNode parentTreeNode = (ZoneTreeNode)parentTree.getNode(parentTree.currentIndex);
        long         storeLink      = parentTreeNode.content.linkIndex;

        parentTreeLink = gameDataObject.treeStore.currentTreeIndex;

        gameDataObject.treeStore.SelectTree(storeLink);
        storeTree = (StoreTree)gameDataObject.treeStore.getCurrentTree();
    }
Exemplo n.º 7
0
        public IHttpActionResult DeleteStoreTree(int id)
        {
            StoreTree storeTree = db.StoreTrees.Find(id);

            if (storeTree == null)
            {
                return(NotFound());
            }

            db.StoreTrees.Remove(storeTree);
            db.SaveChanges();

            return(Ok(storeTree));
        }
Exemplo n.º 8
0
        // DELETE: odata/StoreTreesOD(5)
        public IHttpActionResult Delete([FromODataUri] int key)
        {
            StoreTree storeTree = db.StoreTrees.Find(key);

            if (storeTree == null)
            {
                return(NotFound());
            }

            db.StoreTrees.Remove(storeTree);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 9
0
        // PUT: odata/StoreTreesOD(5)
        public IHttpActionResult Put([FromODataUri] int key, Delta <StoreTree> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            StoreTree storeTree = db.StoreTrees.Find(key);

            if (storeTree == null)
            {
                return(NotFound());
            }

            patch.Put(storeTree);

            try
            {
                db.SaveChanges();

                var subscribed = Hub.Clients.Group(storeTree.Name.ToLower());
                subscribed.updateItem(storeTree);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StoreTreeExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(storeTree));
        }
Exemplo n.º 10
0
        public IHttpActionResult Patch([FromODataUri] int key, Delta <StoreTree> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            StoreTree storeTree = db.StoreTrees.Find(key);

            if (storeTree == null)
            {
                return(NotFound());
            }

            patch.Patch(storeTree);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StoreTreeExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(storeTree));
        }
Exemplo n.º 11
0
    public static ITree getTreeFromString(string data, TreeType treeType, GlobalFlags gf)
    {
        ITree            t            = null;
        List <ITreeNode> treeNodeList = null;

        switch (treeType)
        {
        case TreeType.World:
            WorldTree worldTree = new WorldTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            worldTree.treeNodeDictionary = getWorldTreeNodeFromList(treeNodeList);
            worldTree.currentIndex       = treeNodeList[0].index;
            t = worldTree;
            break;

        case TreeType.Zone:
            ZoneTree zoneTree = new ZoneTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            zoneTree.treeNodeDictionary = getZoneTreeNodeFromList(treeNodeList);
            zoneTree.currentIndex       = treeNodeList[0].index;
            t = zoneTree;
            break;

        case TreeType.Dialog:
            DialogTree dialogTree = new DialogTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            dialogTree.treeNodeDictionary = getDialogTreeNodeFromList(treeNodeList);
            dialogTree.currentIndex       = treeNodeList[0].index;
            t = dialogTree;
            break;

        case TreeType.Quest:
            QuestTree questTree = new QuestTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            questTree.treeNodeDictionary = getQuestTreeNodeFromList(treeNodeList);
            questTree.currentIndex       = treeNodeList[0].index;
            t = questTree;
            break;

        case TreeType.Battle:
            BattleTree battleTree = new BattleTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            battleTree.treeNodeDictionary = getBattleTreeNodeFromList(treeNodeList);
            battleTree.currentIndex       = treeNodeList[0].index;
            t = battleTree;
            break;

        case TreeType.Info:
            InfoTree infoTree = new InfoTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            infoTree.treeNodeDictionary = getInfoTreeNodeFromList(treeNodeList);
            infoTree.currentIndex       = treeNodeList[0].index;
            t = infoTree;
            break;

        case TreeType.Store:
            StoreTree storeTree = new StoreTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            storeTree.treeNodeDictionary = getStoreTreeNodeFromList(treeNodeList);
            storeTree.currentIndex       = treeNodeList[0].index;
            t = storeTree;
            break;

        case TreeType.Cutscene:
            CutsceneTree cutsceneTree = new CutsceneTree(gf, treeType);
            treeNodeList = getTreeNodeListFromString(data, treeType);
            cutsceneTree.treeNodeDictionary = getCutsceneTreeNodeFromList(treeNodeList);
            cutsceneTree.currentIndex       = treeNodeList[0].index;
            t = cutsceneTree;
            break;

        default:
            break;
        }
        return(t);
    }
Exemplo n.º 12
0
 public static ITree getTreeFromString(string data, TreeType treeType, GlobalFlags gf)
 {
     ITree t = null;
     List<ITreeNode> treeNodeList = null;
     switch (treeType)
     {
         case TreeType.World:
             WorldTree worldTree = new WorldTree(gf, treeType);
             treeNodeList = getTreeNodeListFromString(data, treeType);
             worldTree.treeNodeDictionary = getWorldTreeNodeFromList(treeNodeList);
             worldTree.currentIndex = treeNodeList[0].index;
             t = worldTree;
             break;
         case TreeType.Zone:
             ZoneTree zoneTree = new ZoneTree(gf, treeType);
             treeNodeList = getTreeNodeListFromString(data, treeType);
             zoneTree.treeNodeDictionary = getZoneTreeNodeFromList(treeNodeList);
             zoneTree.currentIndex = treeNodeList[0].index;
             t = zoneTree;
             break;
         case TreeType.Dialog:
             DialogTree dialogTree = new DialogTree(gf, treeType);
             treeNodeList = getTreeNodeListFromString(data, treeType);
             dialogTree.treeNodeDictionary = getDialogTreeNodeFromList(treeNodeList);
             dialogTree.currentIndex = treeNodeList[0].index;
             t = dialogTree;
             break;
         case TreeType.Quest:
             QuestTree questTree = new QuestTree(gf, treeType);
             treeNodeList = getTreeNodeListFromString(data, treeType);
             questTree.treeNodeDictionary = getQuestTreeNodeFromList(treeNodeList);
             questTree.currentIndex = treeNodeList[0].index;
             t = questTree;
             break;
         case TreeType.Battle:
             BattleTree battleTree = new BattleTree(gf, treeType);
             treeNodeList = getTreeNodeListFromString(data, treeType);
             battleTree.treeNodeDictionary = getBattleTreeNodeFromList(treeNodeList);
             battleTree.currentIndex = treeNodeList[0].index;
             t = battleTree;
             break;
         case TreeType.Info:
             InfoTree infoTree = new InfoTree(gf, treeType);
             treeNodeList = getTreeNodeListFromString(data, treeType);
             infoTree.treeNodeDictionary = getInfoTreeNodeFromList(treeNodeList);
             infoTree.currentIndex = treeNodeList[0].index;
             t = infoTree;
             break;
         case TreeType.Store:
             StoreTree storeTree = new StoreTree(gf, treeType);
             treeNodeList = getTreeNodeListFromString(data, treeType);
             storeTree.treeNodeDictionary = getStoreTreeNodeFromList(treeNodeList);
             storeTree.currentIndex = treeNodeList[0].index;
             t = storeTree;
             break;
         case TreeType.Cutscene:
             CutsceneTree cutsceneTree = new CutsceneTree(gf, treeType);
               treeNodeList = getTreeNodeListFromString(data, treeType);
               cutsceneTree.treeNodeDictionary = getCutsceneTreeNodeFromList(treeNodeList);
               cutsceneTree.currentIndex = treeNodeList[0].index;
               t = cutsceneTree;
             break;
         default:
             break;
     }
     return t;
 }