public async void points_controller_post_should_return_accepted() { var busClientMock = new Mock <IBusClient>(); var controller = new PointsController(busClientMock.Object); var userId = Guid.NewGuid(); controller.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(new ClaimsIdentity( new Claim[] { new Claim(ClaimTypes.Name, userId.ToString()) }, "test")) } }; var command = new CreatePoint { Id = Guid.NewGuid(), UserId = userId }; var result = await controller.Post(command); var contentResult = result as AcceptedResult; contentResult.Should().NotBeNull(); contentResult.Location.Should().BeEquivalentTo("points/" + command.Id); }
public async Task <IActionResult> Post([FromBody] CreatePoint command) { command.Id = Guid.NewGuid(); command.CreatedAt = DateTime.UtcNow; command.UserId = Guid.Parse(User.Identity.Name); await _busClient.PublishAsync(command); return(Accepted("points/" + command.Id)); }
/// <summary> /// 排序卡牌的UI /// </summary> /// <param name="cards">有序序列</param> public void SortCardUI(List <Card> cards) { CardUI[] cardUIs = CreatePoint.GetComponentsInChildren <CardUI>(); for (int i = 0; i < cards.Count; i++) { for (int j = 0; j < cardUIs.Length; j++) { if (cards[i] == cardUIs[j].Card) { cardUIs[j].SetPosition(CreatePoint, i); } } } }
/// <summary> /// 获取选中的牌的集合 /// </summary> /// <returns></returns> public List <Card> FindCards() { cards = new List <Card>(); cardsUI = new List <CardUI>(); CardUI[] uIs = CreatePoint.GetComponentsInChildren <CardUI>(); for (int i = 0; i < uIs.Length; i++) { if (uIs[i].IsSelected) { cards.Add(uIs[i].Card); cardsUI.Add(uIs[i]); } } ToolsManager.SortList(cards, true);//排列选中的牌 return(cards); }
private void OnMouseDown(object sender, MouseEventArgs e) { CreatePoint newPoint = new CreatePoint(modelSpace.Project.CreateNewOperationId()); //Get the refPoint Vector3 point = modelSpace.SceneRender.DisplayedGridPoint; newPoint.Position = new Vector3WithUnit(point, modelSpace.Project.Environment.DefaultLengthUnit); //Create the new single modelSpace.Project.CreateNewSingle(newPoint); OnDeactivate(); workspace.SelectTool(); }
/// <summary> /// 找到选中的牌 /// </summary> /// <returns>选中的牌</returns> public List <Card> FindSelected() { CardUI[] cardUIs = CreatePoint.GetComponentsInChildren <CardUI>(); tempCard = new List <Card>(); tempUI = new List <CardUI>(); for (int i = 0; i < cardUIs.Length; i++) { if (cardUIs[i].IsSelected) { tempUI.Add(cardUIs[i]); tempCard.Add(cardUIs[i].Card); } } //***// Tools.Sort(tempCard, true); return(tempCard); }
private void Grid_KeyUp(object sender, KeyEventArgs e) { switch (e.Key) { case Key.Left: { CreatePoint createPoint = new CreatePoint(Convert.ToDouble(ResultAX.Text), Convert.ToDouble(ResultAY.Text), Convert.ToDouble(Length.Text)); CreateSquare createSquare = new CreateSquare(createPoint); ShowCoordinates(createSquare.MoveLeft()); DrawSquare(createSquare.MoveLeft()); break; } case Key.Right: { CreatePoint createPoint = new CreatePoint(Convert.ToDouble(ResultAX.Text), Convert.ToDouble(ResultAY.Text), Convert.ToDouble(Length.Text)); CreateSquare createSquare = new CreateSquare(createPoint); ShowCoordinates(createSquare.MoveRight()); DrawSquare(createSquare.MoveRight()); break; } case Key.Up: { CreatePoint createPoint = new CreatePoint(Convert.ToDouble(ResultAX.Text), Convert.ToDouble(ResultAY.Text), Convert.ToDouble(Length.Text)); CreateSquare createSquare = new CreateSquare(createPoint); ShowCoordinates(createSquare.MoveUP()); DrawSquare(createSquare.MoveUP()); break; } case Key.Down: { CreatePoint createPoint = new CreatePoint(Convert.ToDouble(ResultAX.Text), Convert.ToDouble(ResultAY.Text), Convert.ToDouble(Length.Text)); CreateSquare createSquare = new CreateSquare(createPoint); ShowCoordinates(createSquare.MoveDown()); DrawSquare(createSquare.MoveDown()); break; } } }
/// <summary> /// 清空卡牌 /// </summary> /// <param name="type"></param> public void ClearList(ShowPoint type) { switch (type) { case ShowPoint.Desk: Cards.Clear(); CardUI[] cardUI = CreatePoint.GetComponentsInChildren <CardUI>(); for (int i = 0; i < cardUI.Length; i++) { cardUI[i].Destory(); } break; case ShowPoint.Player: m_PlayerList.Clear(); CardUI[] PcardUI = PlayPoint.GetComponentsInChildren <CardUI>(); for (int i = 0; i < PcardUI.Length; i++) { PcardUI[i].Destory(); } break; case ShowPoint.ComputerRight: m_RComputerList.Clear(); CardUI[] RcardUI = ComputerRightPoint.GetComponentsInChildren <CardUI>(); for (int i = 0; i < RcardUI.Length; i++) { RcardUI[i].Destory(); } break; case ShowPoint.ComputerLeft: m_LComputerList.Clear(); CardUI[] LcardUI = ComputerLeftPoint.GetComponentsInChildren <CardUI>(); for (int i = 0; i < LcardUI.Length; i++) { LcardUI[i].Destory(); } break; default: break; } }
/// <summary> /// 桌面清空 /// </summary> /// <param name="pos"></param> public void Clear(ShowPoint pos) { switch (pos) { case ShowPoint.Desk: Cards.Clear(); CardUI[] cardUIs = CreatePoint.GetComponentsInChildren <CardUI>(); for (int i = 0; i < cardUIs.Length; i++) { cardUIs[i].Destroy(); } break; case ShowPoint.Player: PlayerCardList.Clear(); CardUI[] cardUIPlayer = PlayerPoint.GetComponentsInChildren <CardUI>(); for (int i = 0; i < cardUIPlayer.Length; i++) { cardUIPlayer[i].Destroy(); } break; case ShowPoint.ComputerRight: ComputerRightCardList.Clear(); CardUI[] cardUIRight = ComputerRightPoint.GetComponentsInChildren <CardUI>(); for (int i = 0; i < cardUIRight.Length; i++) { cardUIRight[i].Destroy(); } break; case ShowPoint.ComputerLeft: ComputerLeftCardList.Clear(); CardUI[] cardUILeft = ComputerLeftPoint.GetComponentsInChildren <CardUI>(); for (int i = 0; i < cardUILeft.Length; i++) { cardUILeft[i].Destroy(); } break; default: break; } }
/// <summary> /// 出牌成功后删除出的牌 /// </summary> public void DestoryCard() { CardUI[] cardUIs = CreatePoint.GetComponentsInChildren <CardUI>(); foreach (Card item in SelectedCard) { foreach (CardUI uI in cardUIs) { if (item == uI.Card) { uI.Destory(); Cards.Remove(item); } } } //排序UI显示 //更新剩余牌数显示 CardUISort(Cards); m_characterUI.SetRemainCard(RemainCardCount); }
private void DestroyCards() { //删数据 //删UI CardUI[] cardsUi = CreatePoint.GetComponentsInChildren <CardUI>(); for (int i = 0; i < cardsUi.Length; i++) { for (int j = 0; j < SelectCards.Count; j++) { //是否出牌与UI一样 if (SelectCards[j] == cardsUi[i].Card) { cardsUi[i].Destroy(); Cards.Remove(SelectCards[j]); } } } //Ui排序 SortCardUI(Cards); characterUI.SetRemain(CardCount); }
private void Create_Click(object sender, RoutedEventArgs e) { if (CoordinateX.Text != null || CoordinateY.Text != null || Length.Text != null) { try { CreatePoint createPoint = new CreatePoint(Convert.ToDouble(CoordinateX.Text), Convert.ToDouble(CoordinateY.Text), Convert.ToDouble(Length.Text)); CreateSquare createSquare = new CreateSquare(createPoint); ShowCoordinates(createSquare); DrawSquare(createSquare); } catch { throw new Exception("Произошла ошибка"); } } else { return; } }
public Stack <GameObject> levelText; //声明关卡字幕的对象池 void Awake() { cp = FindObjectOfType <CreatePoint>(); CreatePool(); levelText = new Stack <GameObject>(); }
IEnumerator JohnsonSupport() { AlgoSearch.waitTime = 0.2f; int realSelected = EdgeCreate.selectedNumber; //Point[] sPoints = new Point[100]; //Point.Points.CopyTo(sPoints,0); //Edge[] sEdges = new Edge[100]; //Edge.edges.CopyTo(sEdges,0); //int sedgeCount = Edge.edgeCount; //int spointCount = Point.pointCount; int[] sWeights = new int[100]; for (int i = 1; i <= Edge.edgeCount; i++) { sWeights [i] = Edge.edges [i].weight; } Vector3 sPos = new Vector3(0, 12, 0); while (!CreatePoint.checkDistance(sPos)) { sPos += new Vector3(2, 2, 2); } GameObject sBody = (GameObject)Instantiate(instance, sPos, Quaternion.identity); List <Edge>[] sConnected = new List <Edge> [1000]; for (int i = 1; i <= Point.pointCount; i++) { sConnected[i] = Point.Points[i].connected; } Point s = new Point(sPos, sBody); int sNum = Point.pointCount; Debug.Log("Modifying graph ..."); yield return(new WaitForSeconds(0.5f)); for (int i = 1; i < Point.pointCount; i++) { GameObject cylinder = (GameObject)Instantiate(edgeInstance, Vector3.zero, Quaternion.identity); Edge.edgeCount++; Edge current; current = new Edge(sNum, i, 0, cylinder, Edge.edgeCount, true); Edge.edges [Edge.edgeCount] = current; EdgeCreate.InitializeEdge(sBody, Point.Points [i].body, cylinder, current.label); if (Point.Points [sNum].connected == null) { Point.Points [sNum].connected = new List <Edge> (); } Point.Points [sNum].connected.Add(current); yield return(new WaitForSeconds(0.5f)); } EdgeCreate.selectedNumber = Point.pointCount; Debug.Log("Running Bellman ..."); Bellman(); yield return(new WaitForSeconds(command.load * AlgoSearch.waitTime)); yield return(new WaitForSeconds(1)); Debug.Log("Changing weights ..."); for (int i = 1; i <= Edge.edgeCount - Point.pointCount + 1; i++) { int nWeight = Point.Points [Edge.edges [i].start].supportNumber - Point.Points [Edge.edges [i].end].supportNumber; Edge.edges [i].ChangeWeight(Edge.edges [i].weight + nWeight); yield return(new WaitForSeconds(0.5f)); } yield return(new WaitForSeconds(1)); for (int i = 1; i < Edge.edgeCount; i++) { Edge curr = Edge.edges [i]; Table.values [curr.start, curr.end] = curr.weight; if (!curr.oriented) { Table.values [curr.end, curr.start] = curr.weight; } } EdgeCreate.selectedNumber = realSelected; Debug.Log("Running Dijkstra ... "); Dijkstra(); yield return(new WaitForSeconds(command.load * AlgoSearch.waitTime)); Debug.Log("Gathering result ... "); List <int> path = shortPath [EdgeCreate.anotherNumber]; GameObject.DestroyObject(Point.Points [Point.pointCount].body); GameObject.DestroyObject(Point.Points [Point.pointCount].label); Point.Points [Point.pointCount].DestroySupportLabel(); for (int j = 1; j <= Point.pointCount - 1; j++) { GameObject.Destroy(Edge.edges [Edge.edgeCount].body); GameObject.Destroy(Edge.edges [Edge.edgeCount].label); Table.values [Point.pointCount, j] = Edge.MaxW; Table.values [j, Point.pointCount] = Edge.MaxW; Edge.edgeCount--; } Point.pointCount--; for (int i = 1; i <= Edge.edgeCount; i++) { Edge.edges [i].ChangeWeight(sWeights [i]); } //Redraw(); int another = EdgeCreate.anotherNumber; List <int> cList = shortPath [another]; int result = 0; if (cList.Count == 0) { Debug.Log("No path available"); command.CancelAll(); return(true); } cList.Add(another); for (int k = 0; k < cList.Count - 1; k++) { Edge nextDraw = getEdge(cList [k], cList [k + 1]); // add connected result += nextDraw.weight; command.AddCommand(-nextDraw.number, Color.red); } string str = " Shortest path: "; for (int i = 0; i < cList.Count - 1; i++) { str += cList[i].ToString(); str += " -> "; } str += cList[cList.Count - 1]; Debug.Log("Johnsons Done. Result : " + result.ToString() + str); EdgeCreate.anotherPoint = null; EdgeCreate.anotherNumber = 0; EdgeCreate.selectedNumber = 0; EdgeCreate.selectedPoint = null; Redraw(); for (int i = 1; i < Point.pointCount; i++) { Point.Points[i].connected = sConnected[i]; } StartCoroutine(command.support()); AlgoSearch.waitTime = 1f; }