/// <summary> /// 209 设置移动路线 /// lua移动指令 /// 移动对象 /// 是否等待结束 /// </summary> /// <returns></returns> public bool command_moveByRoute() { XLua.LuaTable scriptEnv = LuaManager.getInterpreterEnvTable(this); Debug.Log("route:"); Debug.Log(this.currentParam[0]); object[] result = LuaManager.LuaEnv.DoString(this.currentParam[0], string.Format("command_move_by_route_{0}", this.eventId), scriptEnv); // 移动对象 GameCharacterBase character = this.getCharacter(int.Parse(this.currentParam[1])); // 是否等待移动结束 if (bool.Parse(this.currentParam[2])) { this.movingCharacter = character; } // 处理移动指令 List <MoveRoute> list = new List <MoveRoute>(); for (int i = 0; i < ((XLua.LuaTable)result[0]).Length; i += 1) { MoveRoute route = ((XLua.LuaTable)result[0]).Get <int, MoveRoute>(i + 1); route.args.Add(this.currentParam[1]); // 操作的事件id route.args.Add(this.eventId.ToString()); // 当前解释器所属事件id list.Add(route); Debug.Log(route); } character.setMoveRoute(list); return(true); }
public void GetUnitMove(int unitId, int[] moveTileXy) { var moveUnit = Unit.GetUnitById(unitId); var moveTile = MapTile.GetMapTileFromPos(moveTileXy[0], moveTileXy[1]); var rTiles = MoveRoute.GetMoveRoute(moveUnit.GetCurrentMapTile(), moveTile); Unit.GetUnitById(unitId).MoveUnit(rTiles); }
private static void UpdateMovementUi() { if (_hoverTile.MoveNum > 0 && !_hoverTile.TileProp) { var rTiles = MoveRoute.GetMoveRoute(_currentUnit.GetCurrentMapTile(), _hoverTile); RouteLine.DrawMoveLine(rTiles); } else { RouteLine.DestroyMoveLine(); } }
private static void MoveTileSelected(object sender, EventArgs args) { if (_hoverTile == null || _hoverTile.MoveNum < 1) { return; } _currentUnit.moveTaken = true; DestroyMovementUI(); var rTiles = MoveRoute.GetMoveRoute(_currentUnit.GetCurrentMapTile(), _hoverTile); _currentUnit.MoveUnit(rTiles); GameManager.SendUnitMove(_currentUnit, _hoverTile); }
/// <summary> /// Uncode parameters to Get Move Route object /// </summary> MoveRoute getMoveRoute() { MoveRoute moveRoute = new MoveRoute(); moveRoute.List = new MoveCommand[Math.Max(0, intParams.Length - 3) / 5]; moveRoute.Repeat = (intParams[1] == 1); moveRoute.Skippable = (intParams[2] == 1); int countString = 0; int j = 0; for (int i = 3; i < intParams.Length; i += 5) { moveRoute.List[j++] = getMoveCommand(intParams[i], intParams[i + 1], intParams[i + 2], intParams[i + 3], intParams[i + 4], stringParams[countString++]); } return(moveRoute); }
public void SetStopMode(MoveRoute move_direction) { resetStop(); if (move_direction != MoveRoute.NotMove) { switch (move_direction) { case MoveRoute.Up: OnlineDataBlock.H_Up_Stop = true; break; case MoveRoute.Down: OnlineDataBlock.H_Down_Stop = true; break; case MoveRoute.Forward: OnlineDataBlock.T_Forward_Stop = true; break; case MoveRoute.Reverse: OnlineDataBlock.T_Reverse_Stop = true; break; case MoveRoute.UpForward: OnlineDataBlock.H_Up_Stop = true; OnlineDataBlock.T_Forward_Stop = true; break; case MoveRoute.UpReverse: OnlineDataBlock.H_Up_Stop = true; OnlineDataBlock.T_Reverse_Stop = true; break; case MoveRoute.DownForward: OnlineDataBlock.H_Down_Stop = true; OnlineDataBlock.T_Forward_Stop = true; break; case MoveRoute.DownReverse: OnlineDataBlock.H_Down_Stop = true; OnlineDataBlock.T_Reverse_Stop = true; break; } WriteStruct(); } }
public static void Setup() { Ruby.Initialize(); RPG.Create(); Table.Create(); Tone.Create(); Map.Create(); AudioFile.Create(); Event.Create(); Page.Create(); EventCommand.Create(); Condition.Create(); MoveRoute.Create(); MoveCommand.Create(); Graphic.Create(); MapInfo.Create(); Tileset.Create(); }
/// <summary> /// Move Type : Custom /// </summary> public void MoveTypeCustom() { // Interrupt if not stopping if (MoveRoute==null || IsJumping || IsMoving || MoveRoute.List.Length == 0) return; // Loop until finally arriving at move command list while (MoveRouteIndex <= MoveRoute.List.Length) { // If command code is 0 (last part of list) #region Methods - move_type_custom = 0 // Acquiring move command MoveCommand command = MoveRoute.List[0]; if (MoveRouteIndex != MoveRoute.List.Length) { command = MoveRoute.List[MoveRouteIndex]; } if (MoveRouteIndex == MoveRoute.List.Length || command.Code == 0) { // If [IsRepeated action] option is ON if (MoveRoute.Repeat) { // First return to the move route index MoveRouteIndex = 0; } else // If [IsRepeated action] option is OFF { // If move route is forcing if (MoveRouteForcing && !MoveRoute.Repeat) { // Release forced move route MoveRouteForcing = false; // Restore original move route MoveRoute = OriginalMoveRoute; MoveRouteIndex = OriginalMoveRouteIndex; OriginalMoveRoute = null; } // Clear stop count StopCount = 0; } return; } #endregion // During move command (from move down to jump) #region Methods - move_type_custom <14 if (command.Code <= 14) { // Branch by command code switch (command.Code) { case 1: // Move down MoveDown(true,GeexEdit.TileSize); break; case 2: // Move left MoveLeft(true, GeexEdit.TileSize); break; case 3: // Move right MoveRight(true, GeexEdit.TileSize); break; case 4: // Move up MoveUp(true, GeexEdit.TileSize); break; case 5: // Move lower left MoveLowerLeft(true,GeexEdit.TileSize); break; case 6: // Move lower right MoveLowerRight(true, GeexEdit.TileSize); break; case 7: // Move upper left MoveUpperLeft(true, GeexEdit.TileSize); break; case 8: // Move upper right MoveUpperRight(true, GeexEdit.TileSize); break; case 9: // Move at random MoveRandom(); break; case 10: // Move toward player MoveTowardPlayer(); break; case 11: // Move away from player MoveAwayFromPlayer(); break; case 12: // 1 step forward MoveForward(); break; case 13: // 1 step backward MoveBackward(); break; case 14: // Jump Jump(command.IntParams[0]*GeexEdit.TileSize, command.IntParams[1]*GeexEdit.TileSize); break; } // If movement failure occurs when [Ignore if can't move] option is OFF if (!MoveRoute.Skippable && !IsMoving && !IsJumping) return; MoveRouteIndex += 1; return; } #endregion // If waiting #region Methods - move_type_custom = 15 if (command.Code == 15) { // Set wait count WaitCount = command.IntParams[0] * 2 - 1; MoveRouteIndex += 1; return; } // If direction change command if (command.Code >= 16 & command.Code <= 26) { // Branch by command code switch (command.Code) { case 16: // Turn down TurnDown(); break; case 17: // Turn left TurnLeft(); break; case 18: // Turn right TurnRight(); break; case 19: // Turn up TurnUp(); break; case 20: // Turn 90° right TurnRight90(); break; case 21: // Turn 90° left TurnLeft90(); break; case 22: // Turn 180° Turn180(); break; case 23: // Turn 90° right or left TurnRightOrLeft90(); break; case 24: // Turn at Random TurnRandom(); break; case 25: // Turn toward player TurnTowardPlayer(); break; case 26: // Turn away from player TurnAwayFromPlayer(); break; } MoveRouteIndex += 1; return; } #endregion // If other command #region Methods - move_type_custom >= 27 if (command.Code >= 27) { // Branch by command code switch (command.Code) { case 27: // Switch ON InGame.Switches.Arr[(int)command.IntParams[0]] = true; InGame.Map.IsNeedRefresh = true; break; case 28: // Switch OFF InGame.Switches.Arr[(int)command.IntParams[0]] = false; InGame.Map.IsNeedRefresh = true; break; case 29: // Change speed MoveSpeed = (int)command.IntParams[0]; break; case 30: // Change freq MoveFrequency = (int)command.IntParams[0]; break; case 31: // Move Animation ON IsWalkAnim = true; break; case 32: // Move Animation OFF IsWalkAnim = false; break; case 33: // Stop Animation ON IsStepAnime = true; break; case 34: // Stop Animation OFF IsStepAnime = false; break; case 35: // Direction fix ON IsDirectionFix = true; break; case 36: // Direction fix OFF IsDirectionFix = false; break; case 37: // Through ON Through = true; break; case 38: // Through OFF Through = false; break; case 39: // Always on top ON IsAlwaysOnTop = true; break; case 40: // Always on top OFF IsAlwaysOnTop = false; break; case 41: // Change Graphic TileId = 0; CharacterName = command.StringParams; CharacterHue = command.IntParams[0]; if (OriginalDirection != command.IntParams[1]) { Dir = command.IntParams[1]; OriginalDirection = Dir; PrelockDirection = 0; } if (OriginalPattern != command.IntParams[2]) { Pattern = command.IntParams[2]; OriginalPattern = Pattern; } break; case 42: // Change Opacity Opacity = (byte)command.IntParams[0]; break; case 43: // Change Blending BlendType = command.IntParams[0]; break; case 44: // Play SE InGame.System.SoundPlay(new AudioFile(command.StringParams, command.IntParams[0], command.IntParams[1])); break; case 45: // Script //result = eval(command.BaseParameters[0]) break; } MoveRouteIndex += 1; } #endregion } }
/// <summary> /// Force Move Route /// </summary> /// <param Name="_move_route">new move route</param> public void ForceMoveRoute(MoveRoute _move_route) { // Save original move route if (OriginalMoveRoute == null) { OriginalMoveRoute = MoveRoute; OriginalMoveRouteIndex = MoveRouteIndex; } // Change move route MoveRoute = _move_route; MoveRouteIndex = 0; // Set forced move route flag MoveRouteForcing = true; // Clear prelock direction PrelockDirection = 0; // Clear wait count WaitCount = 0; // Move cutsom MoveTypeCustom(); }
/// <summary> /// Creates a new Character /// </summary> public GameCharacter() { Id = 0; X = 0; Y = 0; RealX = 0; RealY = 0; TileId = 0; CharacterName = ""; CharacterHue = 0; Opacity = 255; BlendType = 0; Dir = 2; Pattern = 0; MoveRouteForcing = false; Through = false; AnimationId = 0; IsTransparent = false; OriginalDirection = 2; OriginalPattern = 0; MoveType = 0; MoveSpeed = 4; MoveFrequency = 6; MoveRoute = null; MoveRouteIndex = 0; OriginalMoveRoute = null; OriginalMoveRouteIndex = 0; IsWalkAnim = true; IsStepAnime = false; IsDirectionFix = false; IsAlwaysOnTop = false; AnimeCount = 0; StopCount = 0; JumpCount = 0; JumpPeak = 0; WaitCount = 0; Locked = false; PrelockDirection = 0; }
private GeometryModel3D createVirtualBox(Point3D spreader_point, Point3D next_point, MoveRoute move_direction) { GeometryModel3D geometry_model = new GeometryModel3D(); MeshGeometry3D triangle_mesh = new MeshGeometry3D(); Point3D holding_container_point = new Point3D(spreader_point.X, spreader_point.Y + ConfigParameters.CONTAINER_HEIGHT, spreader_point.Z); // holding container first square points: 0 -> 3 triangle_mesh.Positions.Add(holding_container_point); triangle_mesh.Positions.Add(new Point3D(holding_container_point.X, holding_container_point.Y - ConfigParameters.CONTAINER_HEIGHT, holding_container_point.Z)); triangle_mesh.Positions.Add(new Point3D(holding_container_point.X + ConfigParameters.CONTAINER_WIDTH, holding_container_point.Y - ConfigParameters.CONTAINER_HEIGHT, holding_container_point.Z)); triangle_mesh.Positions.Add(new Point3D(holding_container_point.X + ConfigParameters.CONTAINER_WIDTH, holding_container_point.Y, holding_container_point.Z)); // holding container second square points: 4 -> 7 triangle_mesh.Positions.Add(new Point3D(holding_container_point.X, holding_container_point.Y, holding_container_point.Z - ConfigParameters.MIDDLE_STACK_CONTAINER_LENGTH)); triangle_mesh.Positions.Add(new Point3D(holding_container_point.X, holding_container_point.Y - ConfigParameters.CONTAINER_HEIGHT, holding_container_point.Z - ConfigParameters.MIDDLE_STACK_CONTAINER_LENGTH)); triangle_mesh.Positions.Add(new Point3D(holding_container_point.X + ConfigParameters.CONTAINER_WIDTH, holding_container_point.Y - ConfigParameters.CONTAINER_HEIGHT, holding_container_point.Z - ConfigParameters.MIDDLE_STACK_CONTAINER_LENGTH)); triangle_mesh.Positions.Add(new Point3D(holding_container_point.X + ConfigParameters.CONTAINER_WIDTH, holding_container_point.Y, holding_container_point.Z - ConfigParameters.MIDDLE_STACK_CONTAINER_LENGTH)); // virtual box first square : 8 -> 11 triangle_mesh.Positions.Add(next_point); triangle_mesh.Positions.Add(new Point3D(next_point.X, next_point.Y - ConfigParameters.CONTAINER_HEIGHT, next_point.Z)); triangle_mesh.Positions.Add(new Point3D(next_point.X + ConfigParameters.CONTAINER_WIDTH, next_point.Y - ConfigParameters.CONTAINER_HEIGHT, next_point.Z)); triangle_mesh.Positions.Add(new Point3D(next_point.X + ConfigParameters.CONTAINER_WIDTH, next_point.Y, next_point.Z)); // virtual second square points : 12-15 triangle_mesh.Positions.Add(new Point3D(next_point.X, next_point.Y, next_point.Z - ConfigParameters.MIDDLE_STACK_CONTAINER_LENGTH)); triangle_mesh.Positions.Add(new Point3D(next_point.X, next_point.Y - ConfigParameters.CONTAINER_HEIGHT, next_point.Z - ConfigParameters.MIDDLE_STACK_CONTAINER_LENGTH)); triangle_mesh.Positions.Add(new Point3D(next_point.X + ConfigParameters.CONTAINER_WIDTH, next_point.Y - ConfigParameters.CONTAINER_HEIGHT, next_point.Z - ConfigParameters.MIDDLE_STACK_CONTAINER_LENGTH)); triangle_mesh.Positions.Add(new Point3D(next_point.X + ConfigParameters.CONTAINER_WIDTH, next_point.Y, next_point.Z - ConfigParameters.MIDDLE_STACK_CONTAINER_LENGTH)); // _______ // 2| |1 // | | // 3|_______|0 List <int> list_indices = new List <int>(); switch (move_direction) { case MoveRoute.DownReverse: list_indices.AddRange(new int[] { 9, 1, 0, 0, 8, 9, 8, 0, 3, 3, 11, 8 }); break; case MoveRoute.DownForward: // left side list_indices.AddRange(new int[] { 3, 2, 10, 10, 11, 3, 0, 3, 11, 11, 8, 0 }); break; } foreach (int indice_pos in list_indices) { triangle_mesh.TriangleIndices.Add(indice_pos); } geometry_model.Geometry = triangle_mesh; geometry_model.Material = new DiffuseMaterial(new SolidColorBrush(Colors.LimeGreen)); return(geometry_model); }
public void DisplayVirtualBox(Point3D next_point, MoveRoute move_direction) { GeometryModel3D virtual_box_model = createVirtualBox(PlcManager.GetInstance.SpreaderPosition, next_point, move_direction); model_group.Children.Add(virtual_box_model); }
public void CheckCollision() { // current stack container map that may contains obstacle containers Stack current_stack_map = ProfileController.GetInstance.Profile.GetMiddleContainerMap(); //Point3D slow_next_point = getLimitSlowPoint(); //ViewPortManager.GetInstance.DisplayVirtualBox(slow_next_point, MoveRoute.DownForward); double trolley_speed = PlcManager.GetInstance.RealTrolleySpeed; double hoist_speed = PlcManager.GetInstance.RealHoistSpeed; Vector movement_vector = new Vector(trolley_speed, hoist_speed); //double stop_range = movement_vector.Length * ConfigParameters.STOP_RANGE_SPEED_RATE; double stop_range = 20; double slow_range = movement_vector.Length * ConfigParameters.SLOW_RANGE_SPEED_RATE; if (slow_range < ConfigParameters.MINIMUM_SLOW_RANGE_LIMIT) { slow_range = ConfigParameters.MINIMUM_SLOW_RANGE_LIMIT; } // TODO: Check whether spreader holds container or not // Default is holding container Point lowest_spreader_complex_point = new Point(PlcManager.GetInstance.SpreaderPosition.X, PlcManager.GetInstance.SpreaderPosition.Y + ConfigParameters.CONTAINER_HEIGHT); if (current_stack_map.Columns.Count == 0) { return; } MoveRoute current_move_direction = getDirection(); double shortest_collision_distance = getDistanceCollision(movement_vector, lowest_spreader_complex_point, current_stack_map); Logger.Log("Distance to collision: " + shortest_collision_distance + " - Slow range: " + slow_range); //if (shortest_collision_distance != 99999) if (shortest_collision_distance < stop_range) { PlcManager.GetInstance.SetStopMode(current_move_direction); isWarningMode = true; //Logger.Log("Stop mode for anticollison is turned on."); } else if (shortest_collision_distance < slow_range) { PlcManager.GetInstance.SetSlowMode(current_move_direction); isWarningMode = true; //Logger.Log("Slow mode for anticollison is turned on."); } else { // if in slow or stop mode and not change direction if (current_move_direction == move_direction) { if (!isWarningMode) { PlcManager.GetInstance.ResetNormalMode(); } } else { PlcManager.GetInstance.ResetNormalMode(); isWarningMode = false; } } }
public static void EventCommandsOwnerTest() { var assignValue = new AssignValue(); var assignValue2 = new AssignValue(); var addValue = new AddValue(); var addValue2 = new AddValue(); // この時点で EventCommand の Owner が null であることを確認 Assert.IsNull(assignValue.Owner); Assert.IsNull(assignValue2.Owner); Assert.IsNull(addValue.Owner); Assert.IsNull(addValue2.Owner); var commonEvent = new CommonEvent(); var list = new EventCommandList(); var moveRoute = new MoveRoute(); var actionEntry = new ActionEntry(); actionEntry.CommandList.Add(assignValue); actionEntry.CommandList.Add(addValue); // この時点で EventCommandList, MoveRoute, ActionEntry, EventCommand の Owner が null であることを確認 Assert.IsNull(list.Owner); Assert.IsNull(moveRoute.Owner); Assert.IsNull(actionEntry.Owner); Assert.IsNull(assignValue.Owner); Assert.IsNull(assignValue2.Owner); Assert.IsNull(addValue.Owner); Assert.IsNull(addValue2.Owner); moveRoute.ActionEntry = actionEntry; list.Add(moveRoute); // この時点で EventCommand の Owner が null であることを確認 Assert.IsNull(assignValue.Owner); Assert.IsNull(assignValue2.Owner); Assert.IsNull(addValue.Owner); Assert.IsNull(addValue2.Owner); commonEvent.EventCommands = list; // この時点で EventCommandList, MoveRoute, ActionEntry, セット済みのEventCommand の // Owner がセットされていることを確認 Assert.AreEqual(list.Owner, TargetAddressOwner.CommonEvent); Assert.AreEqual(moveRoute.Owner, TargetAddressOwner.CommonEvent); Assert.AreEqual(assignValue.Owner, TargetAddressOwner.CommonEvent); Assert.AreEqual(addValue.Owner, TargetAddressOwner.CommonEvent); actionEntry.CommandList.Add(assignValue2); moveRoute.ActionEntry.CommandList.Add(addValue2); // EventCommand の Owner に適切な値が設定されること Assert.AreEqual(assignValue2.Owner, TargetAddressOwner.CommonEvent); Assert.AreEqual(addValue2.Owner, TargetAddressOwner.CommonEvent); // commonEvent をここまで開放したくないので無駄な処理を入れる commonEvent.Memo = ""; }