private void _moveItems(MoveType moveType) { if (moveType == MoveType.up) { this._moveUp(); } else if (moveType == MoveType.down) { this._moveDown(); } else if (moveType == MoveType.left) { this._moveLeft(); } else if (moveType == MoveType.right) { this._moveRight(); } else { Debug.Log("no move type! " + moveType.ToString()); return; } this._randomCreateMoveItem(); //Debug.Log("result======================="); //for (var rowIndex = 0; rowIndex < RowNum; rowIndex++) //{ // for (var colIndex = 0; colIndex < ColNum; colIndex++) // { // Debug.Log(rowIndex + "_" + colIndex + ": " + (moveItemMap[rowIndex][colIndex] ? moveItemMap[rowIndex][colIndex].index : -1)); // } //} }
public Vector(MoveType move, int y, int length = 1) { switch (move) { case MoveType.E: X = length; break; case MoveType.W: X = -length; break; case MoveType.SW: Y = length; X = GetWestDX(y, length); break; case MoveType.SE: Y = length; X = GetEastDX(y, length); break; case MoveType.NW: Y = -length; X = GetWestDX(y, length); break; case MoveType.NE: Y = -length; X = GetEastDX(y, length); break; default: throw new ArgumentOutOfRangeException(move.ToString(), move, null); } }
public void OnDrawGizmosSelected() { Gizmos.DrawLine(transform.position, point); Gizmos.color = Color.red; Gizmos.DrawSphere(point, 0.06f); Handles.Label(point, " " + moveType.ToString() + "(" + duration + "s)"); }
public override void Serialize() { Data.SkipBytes(8); Data.ReadIntLE(); // unk Data.ReadShortLE(); // unk var PosY = Data.ReadShortLE(); Data.ReadShortLE(); // unk var PosX = Data.ReadShortLE(); // CONFIRMED CORRECT Data.SkipBytes(15); // unk stuff MoveType moveType = (MoveType)Data.ReadByte(); Data.ReadIntLE(); // unk zeros Data.ResetReaderIndex(); Logger.Debug($"\n{HexUtils.Dump(Data)}"); Logger.Debug($"X,Y[{PosX}, {PosY}] MoveType[{moveType.ToString()}]"); // DEBUG INFO /* * Logger.Debug( * $"\nPos1: {pos1}\n" + * $"Pos2: {pos2}\n" + * $"Pos3: {pos3}\n" + * $"PossibleZone: {possibleZone}\n" + * $"UnkFloatOrInt: {pos4}\n" + * $"IsMoving: {IsMoving}\n" * ); */ }
private void _checkMoveDirection() { if (Vector2.Distance(touchFirst, touchEnd) < 20) { return; } MoveType moveType = MoveType.none; var dir = (touchEnd - touchFirst).normalized; if (dir.y <= 0) { if (Mathf.Abs(dir.x) <= -dir.y) { moveType = MoveType.up; } else { moveType = dir.x > 0 ? MoveType.right : MoveType.left; } } else if (dir.y > 0) { if (Mathf.Abs(dir.x) <= dir.y) { moveType = MoveType.down; } else { moveType = dir.x > 0 ? MoveType.right : MoveType.left; } } Debug.Log("moveType: " + moveType.ToString()); this._moveItems(moveType); }
public override void WriteXml(XmlWriter writer) { writer.WriteAttributeString("MoveType", MoveType.ToString()); writer.WriteAttributeString("Pathing", Pathing.ToString()); writer.WriteAttributeString("Entry", Entry.ToString()); writer.WriteAttributeString("X", loc.X.ToString()); writer.WriteAttributeString("Y", loc.Y.ToString()); writer.WriteAttributeString("Z", loc.Z.ToString()); }
public void Run() { Console.Clear(); Console.WriteLine(_instruction); DisplayCommands(); while (true) { try { bool validNumber = byte.TryParse(Console.ReadLine(), out byte chosenCommand); if (validNumber && chosenCommand <= 5) { MoveType moveChoice = (MoveType)chosenCommand; switch (moveChoice) { case MoveType.PLACE: PlaceCommand(); break; case MoveType.REPORT: var(xAxis, yAxis, currentDirection) = _simulator.MoveRobo(moveChoice.ToString()); Console.Clear(); Console.WriteLine($"The X-Axis is {xAxis}, Y-Axis is {yAxis} and the direction facing is {currentDirection}"); DisplayCommands(); break; case MoveType.LEFT: case MoveType.RIGHT: case MoveType.MOVE: _simulator.MoveRobo(moveChoice.ToString()); Console.Clear(); Console.Write($"Successfully performed the {moveChoice} command!! "); DisplayCommands(); break; default: return; } } else { Console.Clear(); Console.WriteLine("Invalid Selection please try again"); DisplayCommands(); } } catch (Exception ex) { Console.Clear(); Console.WriteLine($" {ex.Message} {Environment.NewLine} Error while parsing the command, please try again "); DisplayCommands(); } } }
//internal MoveType MoveType { get => moveType; set => moveType = value; } public override string GetDescription() { if (moveType.ToString() == "MoverAdelante") { return(base.GetDescription() + string.Format("\n<color=#00ff00ff>Mover adelante!</color>")); } else { return(base.GetDescription() + string.Format("\n<color=#00ff00ff>Hola!</color>") + moveType.ToString()); } }
protected IMove createMoveFromType(MoveType typeOfMove) { Type t = Type.GetType(string.Format("{0}.{1}", Assembly.GetExecutingAssembly().GetName().Name, typeOfMove.ToString())); IMove move = Activator.CreateInstance(t) as IMove; PlayedMoves.Add(move); Console.WriteLine("{0}{1}{2}", Name, Constants.COMPUTER_MOVE, move.TypeOfMove); return(move); }
public override string ToString() { StringBuilder builder = new StringBuilder(); builder.Append(MoveType.ToString()).Append(" ").Append(PointToString(BirthPoint)); foreach (Point point in SacrificePoints) { builder.Append(" ").Append(PointToString(point)); } return(builder.ToString()); }
public override string ToString() { StringBuilder builder = new StringBuilder(); builder.Append(Command.ToString()); for (var i = 0; i < Arguments.Length; i++) { builder.Append(" "); builder.Append(Arguments[i].ToString()); } return(builder.ToString()); }
public override string ToString() { return($"{MoveType.ToString()} {PointToString(KillPoint)}"); }
//------------ Map 控制相關 ------------------- // player click a tile in Map, Top Left is 0, 0 public void MapTileClick(MapBlockData data) { switch (_currentPlayStatus) { // 開始選擇要控制哪個 UNIT case PlayStatus.RoundHumanTurn: case PlayStatus.RoundScarabTurn: if (NowHitter == Creature.None) { DebugLog(" Status error : not round turn status. " + _currentPlayStatus.ToString()); return; } UIManager.Instance.ScarabCount = _logic.ScarabCount; UIManager.Instance.HumanCount = _logic.PeopleCount; IVector2 vec = new IVector2(); vec.x = data.Column; vec.y = data.Row; ControlMessage controlMsg = _logic.CanControl(vec, NowHitter); if (controlMsg != ControlMessage.OK) { UIManager.Instance.ShowCenterMsg("you can't do it !"); return; } // todo: some click effect if (_currentSelection != null) { _currentSelection.Block.CreatureComponent.UnHighLight(); } // ready click 2 if (NowHitter == Creature.People) { _currentPlayStatus = PlayStatus.RoundHumanReadyMove; } else if (NowHitter == Creature.Scarab) { _currentPlayStatus = PlayStatus.RoundScarabReadyMove; } _currentChoosedBlock = data; _currentSelection = _currentChoosedBlock; _currentSelection.Block.CreatureComponent.HighLight(); DebugLog("PlayStatus: " + _currentPlayStatus.ToString()); break; // 開始選擇要移動到哪裡 case PlayStatus.RoundHumanReadyMove: case PlayStatus.RoundScarabReadyMove: //debug //StartCoroutine(WaitReturnToMain()); //準備回到主畫面 if (_currentSelection != null) { _currentSelection.Block.CreatureComponent.UnHighLight(); } //檢查是否為重新選取 unit if ((data.Block.LivingObject == Creature.People) && (_currentPlayStatus == PlayStatus.RoundHumanReadyMove)) { _currentPlayStatus = PlayStatus.RoundHumanTurn; // 回到選取狀態 MapTileClick(data); return; } else if ((data.Block.LivingObject == Creature.Scarab) && (_currentPlayStatus == PlayStatus.RoundScarabReadyMove)) { _currentPlayStatus = PlayStatus.RoundScarabTurn; // 回到選取狀態 MapTileClick(data); return; } bool legal = _logic.IsLegalMove(_currentChoosedBlock.Block.Pos, data.Block.Pos); if (legal == false) { UIManager.Instance.ShowCenterMsg("wrong move position !"); return; } List <IVector2> infectPositions = new List <IVector2>(); IVector2 realEnd; MoveType moveType = _logic.Move(_currentChoosedBlock.Block.Pos, data.Block.Pos, out realEnd, out infectPositions); bool isHoleTeleport = ((data.Block.Pos.x != realEnd.x) && (data.Block.Pos.y != realEnd.y)); DebugLog(" Move Start : " + _currentChoosedBlock.Block.Pos.x.ToString() + "," + _currentChoosedBlock.Block.Pos.y.ToString() + " End: " + data.Block.Pos.x.ToString() + "," + data.Block.Pos.y.ToString() + " Real End " + realEnd.x.ToString() + "," + realEnd.y.ToString() + " MoveType : " + moveType.ToString()); if (moveType == MoveType.Move) { //移動場景物件 MapBlock destBlockMove = _logic.GetMapBlock(realEnd); MapGenerator.CopyMoveUnit(_currentChoosedBlock.Block, destBlockMove); for (int i = 0; i < infectPositions.Count; i++) { MapBlock block = _logic.GetMapBlock(infectPositions[i]); //人類 if (_lastPlayStatus == PlayStatus.RoundHumanReadyMove) { MapGenerator.HumanInfectBlock(block); } //蟲類 else { MapGenerator.ScarabInfectBlock(block); } } if (infectPositions.Count > 0) { UIManager.Instance.ShowCenterMsg((isHoleTeleport? "[Teleport]":"") + " Infect !!! "); } else { UIManager.Instance.ShowCenterMsg((isHoleTeleport ? "[Teleport]" : "") + " Move !"); } DebugLog(" 淫內感染 infect nums. " + infectPositions.Count.ToString()); } else if (moveType == MoveType.Clone) { MapBlock destBlock = _logic.GetMapBlock(realEnd); //人類 if (_lastPlayStatus == PlayStatus.RoundHumanReadyMove) { MapGenerator.HumanInfectBlock(destBlock); } //蟲類 else { MapGenerator.ScarabInfectBlock(destBlock); } for (int i = 0; i < infectPositions.Count; i++) { MapBlock blockClone = _logic.GetMapBlock(infectPositions[i]); //人類 if (_lastPlayStatus == PlayStatus.RoundHumanReadyMove) { MapGenerator.HumanInfectBlock(blockClone); } //蟲類 else { MapGenerator.ScarabInfectBlock(blockClone); } } if (infectPositions.Count > 0) { UIManager.Instance.ShowCenterMsg((isHoleTeleport ? "[Teleport]" : "") + " Clone and Infect !!! "); } else { UIManager.Instance.ShowCenterMsg((isHoleTeleport ? "[Teleport]" : "") + " Clone ! "); } DebugLog("MoveType.Clone " + realEnd.DataToString()); } else { DebugLog("MoveType.None"); } BattleResult res = BattleResult.None; if (_currentPlayStatus == PlayStatus.RoundHumanReadyMove) { _currentPlayStatus = PlayStatus.RoundScarabTurn; // 換蟲方 res = _logic.DecideResult(Creature.Scarab); } else if (_currentPlayStatus == PlayStatus.RoundScarabReadyMove) { _currentPlayStatus = PlayStatus.RoundHumanTurn; // 換人方 res = _logic.DecideResult(Creature.People); } if (res != BattleResult.None) { UIManager.Instance.ShowResult(res); _currentPlayStatus = PlayStatus.BattleResult; //本局結束 StartCoroutine(WaitReturnToMain()); //準備回到主畫面 if (res == BattleResult.Draw) { UIManager.Instance.ShowCenterMsg("Draw !"); } else if (res == BattleResult.PeopleWin) { UIManager.Instance.ShowCenterMsg("Human Win !"); } else if (res == BattleResult.ScarabWin) { UIManager.Instance.ShowCenterMsg("Scarab Win !\n\n Colonization Success !!!"); } } _currentChoosedBlock = null; break; default: DebugLog("Click Tile valid. " + _currentPlayStatus.ToString()); break; } }
public void OnControlType(MoveType move, RotateType rotate) { Debug.Log(move.ToString() + ", " + rotate.ToString()); }
public static int FindSolution(int actionNum, List <Bike> bikes, int steps) { MoveType action = (MoveType)actionNum; if (actionNum != 99) { int numBikesActive = 0; bool goal = false; for (int i = 0; i < bikes.Count; i++) { if (bikes[i].active == 0) { continue; } if (bikes[i].speed == 1 && action == MoveType.Slow) { return(-1); //stopped } if (action == MoveType.Speed && bikes[i].speed < 50) { bikes[i].speed += 1; } if (action == MoveType.Slow && bikes[i].speed > 0) { bikes[i].speed -= 1; } if (action != MoveType.Jump) { for (int z = 0; z < 2; z++) { int y = z; if (action == MoveType.Up) { y = -z; } else if (action == MoveType.Down) { y = z; } if (bikes[i].y + y >= 0 && bikes[i].y + y < road.Length) { bikes[i].y += y; } else if (z > 0) { return(-1);//can't go up or down } for (int x = 1; x < bikes[i].speed; x++) { int xPos = bikes[i].x + x; if (road[0].Length > xPos && road[bikes[i].y][xPos] == '0') { bikes[i].active = 0; } } if (!(action == MoveType.Up || action == MoveType.Down)) { break; } } } bikes[i].x += bikes[i].speed; if (road[0].Length > bikes[i].x && road[bikes[i].y][bikes[i].x] == '0') { bikes[i].active = 0; } string spaces = new String(' ', steps - 1); Console.Error.WriteLine(spaces + steps + "." + action.ToString() + ": " + bikes[i].x + ", " + bikes[i].y); if (bikes[i].x >= road[0].Length) { goal = true; } /*if (steps > 6 && bikes[i].speed > 0) * { * goal = true; * }*/ numBikesActive += bikes[i].active; } if (numBikesActive < bikeMustBeActive) { //Console.Error.WriteLine("Failed"); return(-1); } else if (goal) { return(actionNum); } } foreach (var newAction in Enum.GetValues(typeof(MoveType)).Cast <MoveType>()) { List <Bike> newBikes = new List <Bike>(); for (int i = 0; i < bikes.Count; i++) { if (bikes[i].active > 0) { Bike newBike = new Bike(bikes[i]); newBikes.Add(newBike); } } if (FindSolution((int)newAction, newBikes, steps + 1) >= 0) { if (actionNum == 99) { return((int)newAction); } else { return(actionNum); } } } return(-1); //did not find solution }
/// <summary> /// Move Pony /// </summary> /// <param name="mazeId">Maze Id</param> /// <param name="move">Move Type</param> /// <returns>Return ResponseMove</returns> public ResponseMove Move(string mazeId, MoveType move = MoveType.Stay) => this.restfulClient.Execute <ResponseMove>(new RestClientModel { RequestBody = "{\r\n \"direction\": \"" + move.ToString().ToLower() + "\"\r\n}", RouteValues = new { id = mazeId } });
/// <summary> /// Conver MoveType to string lower /// </summary> /// <param name="moveType">Move Type</param> /// <returns>Return string</returns> private string ConvertToString(MoveType moveType) { return(moveType.ToString().ToLower()); }
public string GetMoveData() { return(name + fieldDelimeter + id + fieldDelimeter + type.ToString() + fieldDelimeter + user.ToString()); }
public void ChangeAiState(MoveType _MoveType) //changes the State of the Ai { _Animator.SetBool(this._MoveType.ToString(), false); _Animator.SetBool(_MoveType.ToString(), true); this._MoveType = _MoveType; }
public override string ToString() { return(_moveType.ToString()); }
public IRoverCommandResult Move(IRoverCommandItemModel rover, MoveType moveItem) { IRoverCommandResult roverCommandResult = new RoverCommandResult { VerboseType = ResultType.Success, Verbose = $"The movement of the rover([{rover.RoverModel.ToString()}]) for [{moveItem.ToString()}]." }; var newRoverModel = rover.RoverModel.Clone(); switch (moveItem) { case MoveType.L: newRoverModel.Direction = newRoverModel.Direction.PreviousValue(); break; case MoveType.R: newRoverModel.Direction = newRoverModel.Direction.NextValue(); break; case MoveType.M: switch (newRoverModel.Direction) { case DirectionType.E: newRoverModel.X++; break; case DirectionType.W: newRoverModel.X--; break; case DirectionType.N: newRoverModel.Y++; break; case DirectionType.S: newRoverModel.Y--; break; default: roverCommandResult.VerboseType = ResultType.Error; roverCommandResult.Verbose = (new NotImplementedException()).Message; return(roverCommandResult); } break; default: roverCommandResult.VerboseType = ResultType.Error; roverCommandResult.Verbose = (new NotImplementedException()).Message; return(roverCommandResult); } RoverMapValidator roverMapValidator = new RoverMapValidator(RoverCommandItemListModel.UpperRight); var result = roverMapValidator.Validate(newRoverModel); if (result.IsValid) { rover.RoverModel = newRoverModel; roverCommandResult.Verbose += $" -> [{newRoverModel.ToString()}]"; } else { roverCommandResult.VerboseType = ResultType.Warn; roverCommandResult.Verbose = string.Join(" ", result.Errors.Select(p => p.ErrorMessage)); } return(roverCommandResult); }
private void HandleMovement(MoveType move) { _log.Log(move.ToString()); _moveHandler.HandleMove(move); }
public Unit Move(MoveType move, int steps = 1) { switch (move) { case MoveType.E: case MoveType.W: case MoveType.SW: case MoveType.SE: case MoveType.NE: case MoveType.NW: return new Unit { pivot = pivot.Move(new Vector(move, pivot.y, steps)), members = new HashSet<Cell>(members.Select(cell => cell.Move(new Vector(move, cell.y, steps)))) }; case MoveType.RotateCW: return new Unit { pivot = pivot, members = new HashSet<Cell>(members.Select(cell => cell.RotateCW(pivot))) }; case MoveType.RotateCCW: return new Unit { pivot = pivot, members = new HashSet<Cell>(members.Select(cell => cell.RotateCCW(pivot))) }; default: throw new ArgumentOutOfRangeException(move.ToString(), move, null); } }
protected override void OnEnter(NodeData wData) { EntityWorkData workData = wData as EntityWorkData; //参数 Vector2 inputMove = workData.GetParam().GetVect2(); //组件 PlayerMoveCom moveCom = workData.MEntity.GetCom <PlayerMoveCom>(); TransformCom transCom = workData.MEntity.GetCom <TransformCom>(); Collider2DCom collider2DCom = workData.MEntity.GetCom <Collider2DCom>(); PropertyCom propertyCom = workData.MEntity.GetCom <PropertyCom>(); //跳跃阶段重置 ResetJumpStep(moveCom, collider2DCom); if (CheckMoveTypeInCD(moveCom)) { moveCom.HasNoReqMove = true; return; } else { moveCom.HasNoReqMove = false; } MoveType moveType = CalcMoveType(collider2DCom, moveCom, inputMove); switch (moveType) { case MoveType.None: moveCom.ReqMoveSpeed = 0; moveCom.ReqJumpSpeed = 0; break; case MoveType.Run: moveCom.ReqMoveSpeed = propertyCom.MoveSpeed.Curr * inputMove.x; moveCom.ReqJumpSpeed = 0; break; case MoveType.Jump: moveCom.JumpStep++; moveCom.ReqMoveSpeed = 0; moveCom.ReqJumpSpeed = propertyCom.JumpSpeed.Curr * inputMove.y; break; case MoveType.Climb: inputMove.x = inputMove.x < 0 ? -inputMove.x : inputMove.x; moveCom.ReqMoveSpeed = 0; moveCom.ReqJumpSpeed = propertyCom.ClimbSpeed.Curr * inputMove.x; break; case MoveType.ClimbJump: int moveValue = inputMove.x < 0 ? -1 : 1; moveCom.ReqMoveSpeed = propertyCom.MoveSpeed.Curr * moveValue; moveCom.ReqJumpSpeed = propertyCom.ClimbSpeed.Curr; break; case MoveType.GrabWall: moveCom.ReqMoveSpeed = 0; moveCom.ReqJumpSpeed = 0; break; default: break; } ClampMoveSpeed(moveCom, collider2DCom); HandleMoveTypeCD(moveType, moveCom); HandleMoveDir(moveCom, transCom); //记录状态 moveCom.CurrMoveType = moveType; if (inputMove.y != 0) { Debug.LogWarningFormat("BEV_ACT_Move>>>>>{0}--ReqMoveSpeed:{1}--ReqJumpSpeed:{2}", moveType.ToString(), moveCom.ReqMoveSpeed, moveCom.ReqJumpSpeed); } }
public async Task <(string Error, string Result)> TryMove(MoveType type, string argument, ILogger log, CancellationToken token) { var error = (string)null; var result = (string)null; var player = _data.Players.FirstOrDefault(x => x.UserName == _userName); switch (type) { case MoveType.Join: if (player != null) { error = "You have already joined this game. Use '/bingo leave' if you'd like to leave the game"; } else { DoJoin(); } break; case MoveType.Start: if (player == null) { error = "You are not a player in this game"; } else if (_data.Started.HasValue) { error = "Game is already in progress"; } else if (_data.Players.Count < 1) { error = "You must have at least two people in the game to play"; } else { result = await DoStart(log, token); } break; case MoveType.Next: if (player == null) { error = "You are not a player in this game"; } else if (!_data.Started.HasValue) { error = "Game has not yet started"; } else if (_data.NextIndex >= _data.WordSet.Count) { error = "All words have been used"; } else { result = _data.WordSet[_data.NextIndex++]; } break; case MoveType.Bingo: if (player == null) { error = "You are not a player in this game"; } else if (!_data.Started.HasValue) { error = "Game has not yet started"; } else { error = DoBingo(player.Card); } break; case MoveType.Leave: if (player == null) { error = "You are not a player in this game"; } else { DoLeave(player); } break; case MoveType.Format: if (player == null) { error = "You are not a player in this game"; } else { result = DoFormat(player, argument); } break; case MoveType.Card: if (player == null) { error = "You are not a player in this game"; } else if (player.Card == null) { error = "You do not have a current card"; } else if (!_data.Started.HasValue) { error = "Game has not yet started"; } else { result = DoCard(player); } break; } if (_data.Activities == null) { _data.Activities = new List <BingoActivity>(); } _data.Activities.Add(new BingoActivity { UserName = _userName, DisplayName = _displayName, DateTime = DateTimeOffset.UtcNow, Activity = type.ToString(), Error = error }); return(error, result); }
public void Print() { Console.Error.WriteLine("Floor: " + floor + " Pos: " + pos + " Dir: " + direction + " Elevators: " + elevatorsLeft + " - " + moveType.ToString()); }
/// <summary> /// Text of unit /// </summary> /// <returns></returns> public override string ToString() { return(MoveType.ToString() + " " + UnitId + "(" + PlayerId + ")"); }