public Queue <Clickable> GetWayToClickable(Clickable currentClickable, Clickable finalClickable) { Vector2 currentPosInMatrix = Lee.GetPosInMatrix(currentClickable.num, currentClickable.GetFloor()); Vector2 finalPosInMatrix = Lee.GetPosInMatrix(finalClickable.num, finalClickable.GetFloor()); Vector2[] vectArr = Lee.GetRecoveryWay((int)currentPosInMatrix.x, (int)currentPosInMatrix.y, (int)finalPosInMatrix.x, (int)finalPosInMatrix.y); Queue <Clickable> tempQueue = new Queue <Clickable>(); for (int i = 0; i < vectArr.Length; i++) { // Debug.Log(vectArr[i]); if (i == vectArr.Length - 1) { tempQueue.Enqueue(GetClickableByPosInMatrix(vectArr[i])); break; } if (IsJumping(GetClickableByPosInMatrix(vectArr[i])) && GetClickableByPosInMatrix(vectArr[i + 1]) == null) { tempQueue.Enqueue(GetClickableByPosInMatrix(vectArr[i])); i += 2; } } //Debug.Log(" "); return(tempQueue); }
void AlienMoveTo(Alien alien) { List <Clickable> tempClickable = null; /* * if (alien.GetCurrentClickable().GetBuildingType().Equals(Clickable.BuildingType.Wall)) * { * tempClickable = library.map.GetAcceptableClickedWithWall(alien); * }*/ // на основе алгоритма ли надо найти ближайшие точки // library.map.GetClickableInArea(); /*Изменить grid в lee*/ Vector2 pos = new Vector2(-1, -1); if (alien.GetIgnoreWallClickable() != null) { pos = Lee.GetPosInMatrix(alien.GetIgnoreWallClickable().num, alien.GetIgnoreWallClickable().GetFloor()); Lee.startGrid[(int)pos.y, (int)pos.x] = Lee.WALL; } /* * for (int j = Lee.startGrid.GetLength(0) - 1; j >= 0; j--) * { * string str = ""; * for (int i = 0; i < Lee.startGrid.GetLength(1); i++) * { * string qwe = " "; * if (Lee.startGrid[j, i] >= 0 && Lee.startGrid[j, i] < 10) * { * qwe = " "; * } * str += Lee.startGrid[j, i] + qwe; * } * Debug.Log(str); * } * Debug.Log(" ");*/ Clickable clickable = library.map.GetRandomFreeCellToMove(alien.GetCurrentClickable(), tempClickable); // if (alien.GetIgnoreWallClickable() != null) // { // Debug.Log(clickable.num); // } Queue <Clickable> wayToClickable = library.map.GetWayToClickable(alien.GetCurrentClickable(), clickable); if (pos != new Vector2(-1, -1)) { Lee.startGrid[(int)pos.y, (int)pos.x] = Lee.BLANK; } /*Вернуть обратно*/ // foreach (Clickable cl in wayToClickable) // Debug.Log(cl.num); //alien.SetTarget(clickable); alien.SetWayQueue(wayToClickable); }
int GetLenToPos(Clickable firstClickable, Clickable secondClickable) { Vector2 aVector = Lee.GetPosInMatrix(firstClickable.num, firstClickable.GetFloor()); Vector2 bVector = Lee.GetPosInMatrix(secondClickable.num, secondClickable.GetFloor()); return(Lee.GetLength((int)aVector.x, (int)aVector.y, (int)bVector.x, (int)bVector.y)); }
private static void Lee_HappyTest( LeeEnum[,] tab, int expectedStartRow, int expectedStartCol, int expectedEndRow, int expectedEndCol, int expectedLastRow, int expectedLastCol, int expectedPathLength) { // Arrange var expectedStart = new Position(expectedStartCol, expectedStartRow); var expectedEnd = new Position(expectedEndCol, expectedEndRow); var sut = new Lee(tab, Movements); // Act var result = sut.Execute(); // Assert Assert.Equal(expectedLastRow, result.LastY); Assert.Equal(expectedLastCol, result.LastX); Assert.Equal(expectedStart, result.Start); Assert.Equal(expectedEnd, result.End); Assert.True(result.HasSolution); Assert.Equal(expectedPathLength - 1, result.SolutionLength); var path = result.GetOneRoute().ToArray(); Assert.Equal(expectedPathLength, path.Length); Assert.Equal(path[0], expectedStart); Assert.Equal(path[path.Length - 1], expectedEnd); }
IEnumerator StorySequence() { switch (StoryState) { case State.執行任務: while (StoryState == State.執行任務) { yield return(Lee.StartTalkNpcSequence(new string[] { "WaitPos(Player,X-22.5Y0)", "CheckPlayer(找隊長說話,2)" })); } break; default: break; } yield break; }
void ChangeStoryState(State _state) { StoryState = _state; //改變state後的一次性處理 switch (StoryState) { case State.指派任務: Lee.StartTalkNpcSequence(new string[] { "CamFree(true)", "Wait(0.1)", "PlayerControl(2,false)", "CamAnim(4.8,X-27.6Y3.3,3)", "Wait(4)", "CamFree(false)", "PlayerControl(2,true)", "CheckPlayer(開場,2)" }); break; case State.執行任務: StartCoroutine(StorySequence()); Kai.SetAnim("idle"); Kai.SetMove(false, false, true); Kai.StartTalkNpcSequence(new string[] { "Move(X8.88Y12.5)", "Face(Right)", "Wait(0.2)", "Anim(Interact)", "CheckPlayer(29f碰面,2)", "Plot(ChangeState)" }); break; case State.回報任務: dialGod.CheckDialogComplete(); //reset dialog complete state break; case State.結束: ChangeScene(false, 3, 0); break; default: break; } }
public List <Clickable> GetClickableInArea(Clickable currentClickable, int min, int length) { Vector2 currentPosInMatrix = Lee.GetPosInMatrix(currentClickable.num, currentClickable.GetFloor()); Vector2[] vectArr = Lee.GetPositionInArea((int)currentPosInMatrix.x, (int)currentPosInMatrix.y, min, length); List <Clickable> listClickable = new List <Clickable>(); foreach (Vector2 vect in vectArr) { Clickable clickable = GetClickableByPosInMatrix(vect); if (clickable != null) { listClickable.Add(clickable); } } return(listClickable); }
public bool AlienFindFountain(Alien alien) { List <Clickable> tempClickable = null; /*if (alien.GetCurrentClickable().GetBuildingType().Equals(Clickable.BuildingType.Wall)) * { * tempClickable = library.map.GetAcceptableClickedWithWall(alien); * }*/ Vector2 pos = new Vector2(-1, -1); if (alien.GetIgnoreWallClickable() != null) { pos = Lee.GetPosInMatrix(alien.GetIgnoreWallClickable().num, alien.GetIgnoreWallClickable().GetFloor()); Lee.startGrid[(int)pos.y, (int)pos.x] = Lee.WALL; } Clickable clickable = library.map.FindNearestFountain(alien, tempClickable); if (clickable != null /*&& !alien.IsFountainTimeOut()*/) { Queue <Clickable> wayToClickable = library.map.GetWayToClickable(alien.GetCurrentClickable(), clickable); if (pos != new Vector2(-1, -1)) { Lee.startGrid[(int)pos.y, (int)pos.x] = Lee.BLANK; } alien.SetFountainWayQueue(wayToClickable); // alien.SetTarget(library.map.FindNearestFountain(alien.GetCurrentClickable())); // alien.SetFoundFountain(true); return(true); } else { if (pos != new Vector2(-1, -1)) { Lee.startGrid[(int)pos.y, (int)pos.x] = Lee.BLANK; } return(false); } }
public static void Test() { var system = new ActorSystem(); var pingPong = new CountdownEvent(PingPongCount); var bruce = new Bruce(pingPong); var lee = new Lee(pingPong); system.Add(bruce, ctx => { ctx.Actor.Bus = ctx.Bus; }); system.Add(lee, ctx => { ctx.Actor.Bus = ctx.Bus; }); var c = system.Start(); var p = new Pong(); c.Publish(ref p); var ended = pingPong.Wait(TimeSpan.FromSeconds(10)); c.Stop(); Assert.True(ended, "Bruce/Lee didn't ping/pong"); }
internal static void OnLoad() { LogHelper.OnLoad(); MenuGenerator.Generate(); Lee.OnLoad(); }
private void UpdateClients(Lee game, dynamic audience = null) { audience = audience ?? Clients.Group(game.Id); var playerId = Context.User.Identity.GetUserId(); switch (game.State) { case LeeState.WaitingForPlayers: //TODO: Determin who the admin is instead of sending true var lobbyResponse = new GameLobbyResponse { GameId = game.Id, Names = game.PlayerGames.Select(pg => pg.Name).ToArray(), RoundNumber = game.CurrentRoundNum }; foreach (var player in game.PlayerGames) { lobbyResponse.Admin = player.PlayerId == game.Admin; Clients.Group(UserPrefix + player.PlayerId).DisplayLobby(lobbyResponse); } break; case LeeState.QuestionAndAnswer: var playerInputAnswer = game.CurrentRound.PlayerInputs.FirstOrDefault(pi => pi.PlayerId == playerId); if (string.IsNullOrEmpty(playerInputAnswer.Answer)) { var questionResponse = new QuestionResponse { Question = game.CurrentRound.Question, GameId = game.Id, RoundNumber = game.CurrentRoundNum }; audience.DisplayQuestion(questionResponse); } else { var playersReady = game.CurrentRound.PlayerInputs.Select(p => new ReadyStatus { Name = p.Name, Status = string.IsNullOrEmpty(p.Answer) ? "Not Answered" : "Answered" }).ToArray(); ; audience.DisplayWaiting(new WaitingResponse { Players = playersReady, GameId = game.Id, RoundNumber = game.CurrentRoundNum }); } break; case LeeState.Vote: var playerInputVote = game.CurrentRound.PlayerInputs.FirstOrDefault(pi => pi.PlayerId == playerId); if (string.IsNullOrEmpty(playerInputVote.Vote)) { var answers = game.CurrentRound.PlayerInputsShuffled.Select(pi => new PlayerAnswer { PlayerId = pi.PlayerId, Answer = pi.Answer }).ToArray(); audience.DisplayVote(new VoteResponse { PlayerAnswers = answers, GameId = game.Id, RoundNumber = game.CurrentRoundNum, Question = game.CurrentRound.Question }); } else { var playersReady = game.CurrentRound.PlayerInputs.Select(p => new ReadyStatus { Name = p.Name, Status = string.IsNullOrEmpty(p.Vote) ? "Not Voted" : "Voted" }).ToArray(); audience.DisplayWaiting(new WaitingResponse { Players = playersReady, GameId = game.Id, RoundNumber = game.CurrentRoundNum }); } break; case LeeState.Results: case LeeState.End: var voteResponse = new ResultsResponse { PlayerGames = game.PlayerGames.ToArray(), GameId = game.Id, PlayerInputs = game.CurrentRound.PlayerInputs.ToArray(), RoundNumber = game.CurrentRoundNum }; foreach (var resultPlayer in game.PlayerGames) { voteResponse.Admin = resultPlayer.PlayerId == game.Admin; if (game.State == LeeState.Results) Clients.Group(UserPrefix + resultPlayer.PlayerId).DisplayResults(voteResponse); if (game.State == LeeState.End) audience.DisplayEndOfGame(voteResponse); } break; default: break; } }