void MoveLevelLayout(ref Queue <AbstractCursorCommand> cursorCommands) { var levelLayoutElements = GameObject.FindObjectsOfType <LevelLayoutElement>(); levelLayoutElements = levelLayoutElements.OrderBy(x => x.PriorityOrder).ToArray(); for (int i = 0; i < levelLayoutElements.Length; i++) { var element = levelLayoutElements[i]; var moveToWindow = new MoveToCommand(element.transform); var dragWindow = new StartDragCommand(element.transform); var moveToNewPosition = new MoveToCommand(element.GetPosition(LevelLayoutManager.Instance.LevelLayoutState)); var stopDrag = new StopDragCommand(); // OPTIMIZATION: sortir cette line de la loop cursorCommands.Enqueue(moveToWindow); cursorCommands.Enqueue(dragWindow); cursorCommands.Enqueue(moveToNewPosition); cursorCommands.Enqueue(stopDrag); } var moveOutScreen = new MoveToCommand(Vector3.right * 10); cursorCommands.Enqueue(moveOutScreen); }
void ReleaseStickman() { // foreach stickman for (int i = 0; i < GameManager.Instance.Characters.Count; i++) { var charId = (CharId)i; var character = GameManager.Instance.Characters[charId]; var cursor = _owner.GrabStickmanCursors[i]; if (character == null) { continue; } // unfreeze character character.Freeze = false; character.enabled = true; Queue <AbstractCursorCommand> cursorCommands = new Queue <AbstractCursorCommand>(); // cursor commands var stopDrag = new StopDragCommand(); var moveOutScreen = new MoveToCommand(new Vector3(10, cursor.transform.position.y)); cursorCommands.Enqueue(stopDrag); cursorCommands.Enqueue(moveOutScreen); cursor.StartCommandsSequence(cursorCommands); } }
protected IEnumerator Move() { inCoroutine = true; // Find a random destination if the player character is not the target if (!targetFound) { int i = 0; // Make sure the path is valid do { targetPos = GetRandomPosition(); i += 1; }while (!agent.CalculatePath(targetPos, path) && i < maxTimes); if (i >= maxTimes) { gameObject.SetActive(false); Debug.Log(gameObject.name + " is deactivated."); inCoroutine = false; yield return(null); } } // Enemy moves until it reaches closely enough to targetPos // (until the player target is within enemy's attacking distance) while (!InAttackRange(targetPos) && !agent.isStopped) { Vector3 destination = targetPos; ICommand command = new MoveToCommand(destinationMover, transform.position, destination); commandProcessor.ProcessCommand(command); yield return(null); } inCoroutine = false; }
void GrabStickmanToNextSpawnPoints() { // foreach stickman for (int i = 0; i < GameManager.Instance.Characters.Count; i++) { var charId = (CharId)i; var character = GameManager.Instance.Characters[charId]; var cursor = _owner.GrabStickmanCursors[i]; if (character == null) { continue; } // freeze character input character.Freeze = true; character.enabled = false; Queue <AbstractCursorCommand> cursorCommands = new Queue <AbstractCursorCommand>(); // cursor commands Vector3 spawnPosition = LevelDataLocator.GetLevelData().GetDefaultSpawnPoint(charId); var moveToStickman = new MoveToCommand(character.transform); var drag = new StartDragCommand(character.transform, character.ForceJumpSprite); var moveToSpawnPoint = new MoveToCommand(spawnPosition); cursorCommands.Enqueue(moveToStickman); cursorCommands.Enqueue(drag); cursorCommands.Enqueue(moveToSpawnPoint); cursor.StartCommandsSequence(cursorCommands); } }
public void MoveTo(MoveToCommand moveToCommand) { if (commands == null) { commands = new Queue <MoveToCommand>(); } commands.Enqueue(moveToCommand); }
public static void OnMovementRequest(GameClient client, ClientMovementRequestPacket packet) { var command = new MoveToCommand(packet.Path); var commandQueue = client.Hero.Components.Get<CommandQueue>(); commandQueue.Enqueue(command); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Execute a MoveTo command. </summary> /// /// <remarks> Darrellp, 10/14/2011. </remarks> /// /// <param name="command"> The MoveTo command to be executed. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// private void MoveTo(MoveToCommand command) { // If there isn't already a creature there if (Map.CreatureAt(command.Location) == null) { // Then move the creature there _game.CurrentLevel.Map.MoveCreatureTo(command.Creature, command.Location); } }
void OpenShortcuts(ref Queue <AbstractCursorCommand> cursorCommands) { // Shortcut must be open to don't forget window var shortcuts = GameObject.FindObjectsOfType <Shortcut>(); for (int i = 0; i < shortcuts.Length; i++) { var shortcut = shortcuts[i]; var moveToShortcut = new MoveToCommand(shortcut.transform.position); var openWindow = new OpenWindowCommand(shortcut); cursorCommands.Enqueue(moveToShortcut); cursorCommands.Enqueue(openWindow); } }
private bool SetPath() { if (commands.Count > 0) { currentCommand = commands.Dequeue(); endTile = currentCommand.Tile; if (endTile == null || endTile == baseCharacter.Tile) { return(false); } path = new Pathfinding(baseCharacter.Tile, endTile, baseCharacter); path.PreviewPath(); nextTile = path.Next(); if (nextTile != null || nextTile != endTile || nextTile != baseCharacter.Tile) { return(true); } } return(false); }
private void Update() { foreach (InputButton button in buttonList.Buttons) { if (destinationMover != null) { if (Input.GetButton(button.Name)) { Vector3 destination = mousePositionDetector.CalculateWorldPosition(); // Only move if destination is valid (not clicked on // the void). if (mousePositionDetector.IsValid(destination)) { ICommand moveToCommand = new MoveToCommand(destinationMover, transform.position, destination); commandProcessor.ProcessCommand(moveToCommand); } } } } }
public override CmdResult ExecuteRequest(CmdRequest args) { args.SetValue("sproc", MovementProceedure.AStar); return(MoveToCommand.ExecuteRequestProc(args, this)); }
public void MoveTo(double x, double y, double z) { MoveToCommand?.Invoke(this, new CameraCommandsEventArgs(x, y, z)); }