private void LoadSuppliersTag(IList <PromoteVO> promoteList) { ltlSuppliersTag.Text = string.Empty; StringBuilder sb = new StringBuilder(); //搜尋條件 IList <NodeVO> list = m_PostService.GetNodeListByParentId(9); if (list != null && list.Count > 0) { for (int i = 0; i < list.Count; i++) { NodeVO vo = list[i]; if (promoteList.Count(p => p.WarrantySuppliers.Equals(vo.Name)) > 0) { string lastCss = ""; if (i <= list.Count - 1) { lastCss = " store_item_a_last"; } sb.AppendFormat("<a href='#pro_{0}'><li class='store_item_a store_item_logo border' style=\"background-image: url('upload/{1}');\"><div class='corner_bg corner_img {2}'></div></li></a>" , vo.NodeId, vo.PicFileName, lastCss); } } ltlSuppliersTag.Text = sb.ToString(); LoadSuppliers(list, promoteList); } }
protected void btnSave_Click(object sender, EventArgs e) { DateTime date; if (DateTime.TryParse(txtDate.Text.Trim(), out date)) { NodeVO nodeSpecial = m_PostService.GetNodeByName("#特別現金收支"); PostVO postVO = new PostVO(); postVO.Node = nodeSpecial; postVO.CloseDate = date; postVO.Title = txtTitle.Text.Trim(); postVO.Type = int.Parse(ddlType.SelectedValue); if (postVO.Type == 1) { postVO.Price = -1 * (int.Parse(txtPrice.Text.Trim())); } else { postVO.Price = (int.Parse(txtPrice.Text.Trim())); } m_PostService.CreatePost(postVO); UIHelper.ClearUI(pnlSpecialToday); ddlType.SelectedValue = ""; LoadDataToUI(); } else { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "js", JavascriptUtil.AlertJS("日期格式錯誤!"), false); return; } }
/** * Removes walls between two specified nodes */ private void Merge(NodeVO from, NodeVO to) { int dx = to.pos.x - from.pos.x; int dy = to.pos.y - from.pos.y; if (dx != 0) { if (dx > 0) { to.RemoveWall(NodeVO.DIRECTION_LEFT_IDX); from.RemoveWall(NodeVO.DIRECTION_RIGHT_IDX); } else { to.RemoveWall(NodeVO.DIRECTION_RIGHT_IDX); from.RemoveWall(NodeVO.DIRECTION_LEFT_IDX); } } else if (dy != 0) { if (dy > 0) { to.RemoveWall(NodeVO.DIRECTION_DOWN_IDX); from.RemoveWall(NodeVO.DIRECTION_UP_IDX); } else { to.RemoveWall(NodeVO.DIRECTION_UP_IDX); from.RemoveWall(NodeVO.DIRECTION_DOWN_IDX); } } }
private string Get4gPart(NodeVO vo) { StringBuilder sb = new StringBuilder(); //搜尋條件 Dictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("NodeId", "5"); conditions.Add("WarrantySuppliers", vo.Name); conditions.Add("Type", "1"); conditions.Add("Flag", "1"); conditions.Add("Order", string.Format("order by {0}", "p.WarrantySuppliers, p.Type, p.SortNo, p.PostId")); IList <PostVO> list = m_PostService.GetPostList(conditions); if (list != null && list.Count > 0) { sb.AppendFormat("<tr class='discount_list_contant'><td rowspan='{0}' class='discount_list_type discount_list_type_4G' >4G</td></tr>" , (list.Count + 1)); for (int i = 0; i < list.Count; i++) { PostVO post = list[i]; string lastCss = ""; if (i <= list.Count - 1) { lastCss = " discount_list_contant-last"; } sb.AppendFormat("<tr class='discount_list_contant {0}'><td class='discount_list_pro'>{1}</td><td class='discount_list_dis'>{2}</td><td class='discount_list_pre'>{3}</td><td class='discount_list_tran'>{4}</td><td class='discount_list_con'>{5}</td></tr>" , lastCss, post.Title, post.CustomField1, post.CustomField2, post.Summary, post.HtmlContent); } } return(sb.ToString()); }
public static void Apply(MazeModel mazeData) { foreach (NodeVO deadEnd in mazeData.deadEnds) { NodeVO node = deadEnd; int currentScore = DifficultyModel.Instance().minScore; int ds = 1; while (node != null && node.score == 0) { currentScore += ds; node.score = currentScore; //define score delta if (node.score <= DifficultyModel.Instance().minScore) { ds = 1; } if (node.score >= DifficultyModel.Instance().maxScore) { ds = -1; } node = node.previousNode; } } }
private string GetProductList(NodeVO vo) { StringBuilder sb = new StringBuilder(); //搜尋條件 string keyword = Request["keyword"]; Dictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("NodeId", "3"); conditions.Add("Flag", "1"); conditions.Add("ProductKeyWord", keyword); conditions.Add("WarrantySuppliers", vo.Name); conditions.Add("Order", string.Format("order by {0}", "p.WarrantySuppliers, p.SortNo, p.PostId")); IList <PostVO> list = m_PostService.GetPostList(conditions); if (list != null && list.Count > 0) { for (int i = 0; i < list.Count; i++) { PostVO post = list[i]; sb.AppendFormat("<tr onclick=\"window.location='product.aspx?id={0}';\" style='cursor:pointer;'><td class='product_ov_type'>{1}</td><td class='product_ov_price'>${2}</td></tr>" , post.PostId, post.Title, post.SellPrice); } } return(sb.ToString()); }
/// <summary> /// 取得主視覺的內容 /// </summary> /// <param name="server"></param> /// <param name="mainAdvNodeId">主視覺設定檔代碼</param> /// <returns>主視覺的內容</returns> public static string GetMainAdvContent(HttpServerUtility server, int mainAdvNodeId) { string content = string.Empty; PostFactory postFactory = new PostFactory(); IPostService postService = postFactory.GetPostService(); NodeVO nodeVO = postService.GetNodeById(mainAdvNodeId); if (nodeVO != null) { if (nodeVO.UType == NodeVO.UnitType.Flash) { string advFile = server.MapPath("~/template/") + "main-adv-flash01.txt"; string fileContent = File.ReadAllText(advFile, System.Text.Encoding.UTF8); content = fileContent.Replace("(#FILENAME)", nodeVO.PicFileName); } //暫時不用圖片,僅flash //else if (nodeVO.UType == NodeVO.UnitType.Pic) //{ // string advFile = server.MapPath("~/template/") + "main-adv-pic01.txt"; // string fileContent = File.ReadAllText(advFile, System.Text.Encoding.UTF8); // content = fileContent.Replace("(#FILENAME)", nodeVO.PicFileName); //} } return(content); }
private GameObject PutTempNodeOnRoad(Vector2 position, int index) { GameObject nodeGO = null; if (index < nodeInTempRoad.Count) { nodeGO = nodeInTempRoad[index]; } else { nodeGO = GameObject.Instantiate(nodePrefab); nodeInTempRoad.Add(nodeGO); } nodeGO.SetActive(true); NodeVO nodeVO = nodeGO.GetComponent <NodeVO>(); Node node = new Node(); nodeVO.node = node; node.X = position.x; node.Y = position.y; nodeVO.Update(); nodeGO.tag = "Untagged"; nodeGO.transform.SetParent(tempRoad.transform); nodeGO.transform.FindChild("NodeDot").GetComponent <SpriteRenderer>().color = Color.blue; return(nodeGO); }
protected void gvList_RowCommand1(object sender, GridViewCommandEventArgs e) { string cmdName = e.CommandName; int nodeId = int.Parse(e.CommandArgument.ToString()); NodeVO nodeVO = m_PostService.GetNodeById(nodeId); switch (cmdName) { case "myModify": m_Mode = nodeId; txtNodeName.Text = nodeVO.Name; txtSortNo.Text = nodeVO.SortNo.ToString(); //txtContent.Text = nodeVO.HtmlContent; ShowMode(); break; case "myDel": try { m_PostService.DeleteNode(nodeVO); m_WebLogService.AddSystemLog(MsgVO.Action.刪除, nodeVO); } catch (Exception ex) { ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "js", JavascriptUtil.AlertJS("無法刪除品名,尚有關聯資料。"), false); m_Log.Error(ex); } break; default: break; } GetList(); }
public float getMoveTime(NodeVO node) { float moveTime = DifficultyModel.Instance().moveTime; if (node.HasFlag(NodeVO.SPECIALS_SPEEDUP_UP)) { if (directionIdx == NodeVO.DIRECTION_UP_IDX) { moveTime /= 2; } if (directionIdx == NodeVO.DIRECTION_DOWN_IDX) { moveTime *= 2; } } if (node.HasFlag(NodeVO.SPECIALS_SPEEDUP_RIGHT)) { if (directionIdx == NodeVO.DIRECTION_RIGHT_IDX) { moveTime /= 2; } if (directionIdx == NodeVO.DIRECTION_LEFT_IDX) { moveTime *= 2; } } if (node.HasFlag(NodeVO.SPECIALS_SPEEDUP_DOWN)) { if (directionIdx == NodeVO.DIRECTION_DOWN_IDX) { moveTime /= 2; } if (directionIdx == NodeVO.DIRECTION_UP_IDX) { moveTime *= 2; } } if (node.HasFlag(NodeVO.SPECIALS_SPEEDUP_LEFT)) { if (directionIdx == NodeVO.DIRECTION_LEFT_IDX) { moveTime /= 2; } if (directionIdx == NodeVO.DIRECTION_RIGHT_IDX) { moveTime *= 2; } } return(moveTime); }
public void Recreate(int size, int startX, int startY) { this.size = size; _data = new NodeVO[size * size]; deadEnds = new List <NodeVO> (); crossRoads = new List <NodeVO> (); for (int j = 0; j < size; j++) { for (int i = 0; i < size; i++) { _data [i + j * size] = new NodeVO(i, j); } } //1. get starting point startingNode = GetNode(startX, startY); startingNode.AddFlag(NodeVO.PROCESSED); //2. init edge nodes from its neighbours List <NodeVO> edgeNodes = GetNotProcessedNeighboursOf(startingNode); foreach (NodeVO nodeData in edgeNodes) { Link(startingNode, nodeData); } //3. create branches from edge nodes while (edgeNodes.Count > 0) { //3.1 find a random edge node and remove it from array int idx = _rnd.Next(0, edgeNodes.Count); NodeVO edgeNode = edgeNodes [idx]; edgeNodes.RemoveAt(idx); if (!edgeNode.HasFlag(NodeVO.PROCESSED)) { //3.2 attach it to current tree NodeVO processedNeighbour = GetRandomNeighbour(edgeNode, true); if (processedNeighbour != null) { Merge(processedNeighbour, edgeNode); Link(processedNeighbour, edgeNode); if (!crossRoads.Contains(processedNeighbour)) { crossRoads.Add(processedNeighbour); } } //3.3 create the branch CreateBranch(edgeNode, edgeNodes); } } }
/// <summary> /// 新增Node /// </summary> /// <param name="nodeVO">被新增的Node</param> /// <returns>新增後的Node</returns> public NodeVO CreateNode(NodeVO nodeVO) { //return PostDao.CreateNode(nodeVO); nodeVO = PostDao.CreateNode(nodeVO); if (nodeVO.SortNo == 0) { nodeVO.SortNo = nodeVO.NodeId; nodeVO = PostDao.UpdateNode(nodeVO); } return(nodeVO); }
protected void btnSave_Click(object sender, EventArgs e) { NodeVO nodeVO = m_PostService.GetNodeById(m_Mode); nodeVO.Name = txtNodeName.Text.Trim(); nodeVO.PicFileName = m_PicFileName; m_PostService.UpdateNode(nodeVO); m_WebLogService.AddSystemLog(MsgVO.Action.修改, nodeVO); GetList(); ClearUI(); ShowMode(); }
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e) { GridView gv = (GridView)sender; if (e.Row.RowIndex != -1) { Control ctrl = e.Row; int postId = int.Parse(UIHelper.FindHiddenValue(ref ctrl, "hdnPostId")); PostVO postVO = m_PostService.GetPostById(postId); NodeVO node = m_PostService.GetNodeById(postVO.Node.NodeId); } }
static void SetDirectionsFrom(NodeVO deadEnd) { var currentNode = deadEnd; var previousNode = currentNode.previousNode; while (previousNode != null && currentNode.directionToExit == NodeVO.DIRECTION_INVALID_IDX) { currentNode.directionToExit = currentNode.GetDirectionTowards(previousNode); currentNode = previousNode; previousNode = currentNode.previousNode; } }
protected void btnAdd_Click(object sender, EventArgs e) { NodeVO nodeVO = new NodeVO(); nodeVO.Name = txtNodeName.Text.Trim(); nodeVO.PicFileName = m_PicFileName; nodeVO.ParentNode = m_PostService.GetNodeById(m_NodeId);; nodeVO = m_PostService.CreateNode(nodeVO); m_WebLogService.AddSystemLog(MsgVO.Action.新增, nodeVO); ClearUI(); GetList(); }
private void CreateBranch(NodeVO startNode, List <NodeVO> edgeNodes) { NodeVO randomNeighbour; NodeVO currentNode = startNode; do { //1. if node exists in edge nodes, remove it if (edgeNodes.Contains(currentNode)) { edgeNodes.Remove(currentNode); } //1.1 append new edge nodes List <NodeVO> notProcessedNeighbours = GetNotProcessedNeighboursOf(currentNode); foreach (NodeVO nodeData in notProcessedNeighbours) { if (!edgeNodes.Contains(nodeData)) { edgeNodes.Add(nodeData); } } currentNode.AddFlag(NodeVO.PROCESSED); //2. go to random direction and get a neighbour randomNeighbour = GetRandomNeighbour(currentNode, false); //3. if it exists (didn't got a dead end) - expand the maze if (randomNeighbour != null) { Link(currentNode, randomNeighbour); //3.1 attach it to tree Merge(currentNode, randomNeighbour); //3.2 process it on next loop entry currentNode = randomNeighbour; } else { if (deadEnds.Count > 0 && (currentNode.GetDistance() > deadEnds [0].GetDistance())) { deadEnds.Insert(0, currentNode); } else { deadEnds.Add(currentNode); } } } while (randomNeighbour != null); }
protected void btnAdd_Click(object sender, EventArgs e) { NodeVO nodeVO = new NodeVO(); nodeVO.Name = txtNodeName.Text.Trim(); nodeVO.SortNo = int.Parse(txtSortNo.Text.Trim()); //nodeVO.HtmlContent = txtContent.Text.Trim(); nodeVO.ParentNode = m_PostService.GetNodeById(m_NodeId);; m_PostService.CreateNode(nodeVO); m_WebLogService.AddSystemLog(MsgVO.Action.新增, nodeVO); ClearUI(); GetList(); }
protected void btnSave_Click(object sender, EventArgs e) { NodeVO nodeVO = m_PostService.GetNodeById(m_Mode); nodeVO.Name = txtNodeName.Text.Trim(); nodeVO.SortNo = int.Parse(txtSortNo.Text.Trim()); //nodeVO.HtmlContent = txtContent.Text.Trim(); m_PostService.UpdateNode(nodeVO); m_WebLogService.AddSystemLog(MsgVO.Action.修改, nodeVO); GetList(); ClearUI(); ShowMode(); }
private string GetSupplierTable(NodeVO vo) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("<div class='product_ov_br' id='pro_{0}'>", vo.NodeId); sb.AppendFormat("<div class='product_ovlogo' style=\"background-image:url('upload/{0}')\"></div>" , vo.PicFileName); sb.Append("<table class='product_ov'><tr><th class='product_ov_thtype'></th><th class='product_ov_thprice'></th></tr>"); sb.Append("{0}"); sb.Append("</table>"); sb.Append("</div>"); return(sb.ToString()); }
void Proceed(NodeVO node) { float moveTime = PlayerModel.Instance().getMoveTime(node); if (moveTime > 0) { transform.DOMove(transform.position + new Vector3( NodeVO.DIRECTIONS [PlayerModel.Instance().directionIdx, 0] * DifficultyModel.NODE_SIZE, NodeVO.DIRECTIONS [PlayerModel.Instance().directionIdx, 1] * DifficultyModel.NODE_SIZE, 0 ), moveTime).OnComplete(OnMoveCompleted).SetEase(Ease.Linear); } ; }
private bool HasProduct(NodeVO vo) { StringBuilder sb = new StringBuilder(); //搜尋條件 string keyword = Request["keyword"]; Dictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("NodeId", "3"); conditions.Add("Flag", "1"); conditions.Add("ProductKeyWord", keyword); conditions.Add("WarrantySuppliers", vo.Name); return(m_PostService.GetPostCount(conditions) > 0); }
private NodeVO CreateNode(string name, NodeVO parentNode, int sort) { NodeVO rootNodeVO = new NodeVO(); rootNodeVO.Name = name; rootNodeVO.ParentNode = parentNode; rootNodeVO.SortNo = sort; rootNodeVO.Flag = 1; rootNodeVO.CreatedBy = "admin"; rootNodeVO.UpdatedBy = "admin"; rootNodeVO.CreatedDate = DateTime.Now; rootNodeVO.UpdatedDate = DateTime.Now; return(m_PostService.CreateNode(rootNodeVO)); }
override public PrefromResult Perform (float delta) { var player = PlayerModel.Instance (); IntPointVO pos = player.cellPosition; int directionIdx = player.directionIdx; NodeVO node = MazeModel.Instance ().GetNode (pos.x, pos.y); GameModel game = GameModel.Instance (); game.AddScore ((int)((float)node.score * game.timeBonus)); node.score = 0; game.movesLeft.Dec (1); if (game.state == GameModel.STATE_INITED || game.state == GameModel.STATE_STUCK) { game.state = GameModel.STATE_MOVING; game.score.Freeze(); game.timeBonus.Freeze(); } if (node.HasFlag (NodeVO.SPECIALS_EXIT)) { game.state = GameModel.STATE_ENDED; MazePaceNotifications.EXIT_REACHED.Dispatch (); } else { if (node.HasFlag (NodeVO.SPECIALS_HIDE_WALLS)) { MazePaceNotifications.TOGGLE_WALLS_VISIBILITY.Dispatch (false); } if (node.HasFlag (NodeVO.SPECIALS_SHOW_WALLS)) { MazePaceNotifications.TOGGLE_WALLS_VISIBILITY.Dispatch (true); } bool shouldRotate = node.HasWall (directionIdx) || player.moved; if (node.HasFlag (NodeVO.SPECIALS_ROTATOR_CW | NodeVO.SPECIALS_ROTATOR_CCW) && shouldRotate) { MazePaceNotifications.ROTATE_AT_NODE.Dispatch (node); player.moved = false; } else if (!node.HasWall (directionIdx)) { player.cellPosition.x += NodeVO.DIRECTIONS [player.directionIdx, 0]; player.cellPosition.y += NodeVO.DIRECTIONS [player.directionIdx, 1]; player.moved = true; MazePaceNotifications.PROCEED_FROM_NODE.Dispatch (node); } else { game.state = GameModel.STATE_STUCK; game.score.SetValue (game.score, 0, DifficultyModel.Instance ().scoreDrainTime); MazePaceNotifications.PLAYER_STUCK.Dispatch (); } } MazePaceNotifications.GAME_UPDATED.Dispatch (); return PrefromResult.COMPLETED; }
private PostVO CreatePost(string title, NodeVO nodeVO, int sort) { PostVO postVO = new PostVO(); postVO.Node = nodeVO; postVO.Title = title; postVO.SortNo = sort; postVO.Flag = 1; postVO.CreatedBy = "admin"; postVO.UpdatedBy = "admin"; postVO.CreatedDate = DateTime.Now; postVO.UpdatedDate = DateTime.Now; postVO.ShowDate = DateTime.Today; return(m_PostService.CreatePost(postVO)); }
private NodeVO CreateNode(string name, NodeVO parentNode, int sort, NodeVO.UnitType unitType, string filePath) { NodeVO rootNodeVO = new NodeVO(); rootNodeVO.Name = name; rootNodeVO.ParentNode = parentNode; rootNodeVO.SortNo = sort; rootNodeVO.Flag = 1; rootNodeVO.CreatedBy = "admin"; rootNodeVO.UpdatedBy = "admin"; rootNodeVO.CreatedDate = DateTime.Now; rootNodeVO.UpdatedDate = DateTime.Now; rootNodeVO.UType = unitType; rootNodeVO.PicFileName = filePath; return(m_PostService.CreateNode(rootNodeVO)); }
public static void Apply(MazeModel mazeData) { if (DifficultyModel.Instance().hidersCount == 0) { return; } for (int i = 0; i < mazeData.deadEnds.Count; i++) { if (i >= DifficultyModel.Instance().hidersCount) { break; } int distance = (int)mazeData.deadEnds [i].GetDistance(); if (distance < 4) { return; } int showIndex = _rnd.Next((int)distance / 4, (int)distance / 2); int hideIndex = _rnd.Next(showIndex + 2, showIndex + (int)Math.Min((int)(distance / 2), 8)); NodeVO node = mazeData.deadEnds [i].previousNode; int index = 0; while (node != null) { index++; if (index == showIndex) { node.AddFlag(NodeVO.SPECIALS_SHOW_WALLS); } if (index == hideIndex) { node.AddFlag(NodeVO.SPECIALS_HIDE_WALLS); } node = node.previousNode; } } }
private PostVO CreatePost(string title, NodeVO nodeVO, int sort, string linkUrl, string picFileName) { PostVO postVO = new PostVO(); postVO.Node = nodeVO; postVO.Title = title; postVO.SortNo = sort; postVO.Flag = 1; postVO.CreatedBy = "admin"; postVO.UpdatedBy = "admin"; postVO.CreatedDate = DateTime.Now; postVO.UpdatedDate = DateTime.Now; postVO.ShowDate = DateTime.Today; postVO.LinkUrl = linkUrl; postVO.PicFileName = picFileName; return(m_PostService.CreatePost(postVO)); }
private string GetSupplierTable2(NodeVO vo) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("<div class='product_ov_br' id='pro_{0}'>", vo.NodeId); sb.Append("<table class='product_ov' style='width: 100%;'><tr>"); sb.AppendFormat("<th><div style='position: relative; height: 25px;'><img src='upload/{0}' width='94' height='42' style='position: absolute;' /></div></th>" , vo.PicFileName); sb.Append("<th class='promote_title'>單機價</th>"); sb.AppendFormat("<th class='promote_title'>{0}</th>", GetPromoteTitle("中華電信")); sb.AppendFormat("<th class='promote_title'>{0}</th>", GetPromoteTitle("遠傳")); sb.AppendFormat("<th class='promote_title'>{0}</th>", GetPromoteTitle("台哥大")); sb.AppendFormat("<th class='promote_title'>{0}</th>", GetPromoteTitle("亞太電信")); sb.AppendFormat("<th class='promote_title'>{0}</th></tr>", GetPromoteTitle("台灣之星")); sb.Append("{0}"); sb.Append("</table>"); sb.Append("</div>"); return(sb.ToString()); }
private string GetSupplierTable(NodeVO vo) { StringBuilder sb = new StringBuilder(); sb.Append("<table class='discount_list border'>"); sb.Append("<tr class='discount_list_title border'>"); sb.AppendFormat("<th class='discount_list_img' style=\"background-image:url('upload/{1}')\"><a name='pro_{0}' id='pro_{0}'></a></th>" , vo.NodeId, vo.PicFileName); sb.Append("<th class='discount_list_pro bg_disfrom_pro'></th>"); sb.Append("<th class='discount_list_dis bg_disfrom_dis'></th>"); sb.Append("<th class='discount_list_pre bg_disfrom_pre'></th>"); sb.Append("<th class='discount_list_tran bg_disfrom_tran'></th>"); sb.Append("<th class='discount_list_con bg_disfrom_con'></th>"); sb.Append("</tr>"); sb.Append("{0}"); sb.Append("{1}"); sb.Append("</table>"); return(sb.ToString()); }