Exemplo n.º 1
0
        public Cursor Move(Buffer buf, MoveDirection direction)
        {
            switch (direction)
            {
                case MoveDirection.Up:
                    if (AtFirstLine(buf))
                        return new Cursor(0, 0);
                    else
                        return new Cursor(Line - 1, Math.Min(Column, buf.Lines[Line - 1].Data.Length));
                case MoveDirection.Down:
                    if (AtLastLine(buf))
                        return new Cursor(Line, buf.Lines[Line].Data.Length);
                    else
                        return new Cursor(Line + 1, Math.Min(Column, buf.Lines[Line + 1].Data.Length));
                case MoveDirection.Left:
                    if (AtStart(buf))
                        return this;
                    else if (AtFirstColumn(buf))
                        return new Cursor(Line - 1, buf.Lines[Line - 1].Data.Length);
                    else
                        return new Cursor(Line, Column - 1);
                case MoveDirection.Right:
                    if (AtEnd(buf))
                        return this;
                    else if (AtLastColumn(buf))
                        return new Cursor(Line + 1, 0);
                    else
                        return new Cursor(Line, Column + 1);
            }

            return this;
        }
Exemplo n.º 2
0
        private void PrepareLookResult(MoveDirection direction, int distance)
        {
            if (distance == 0) {

                lookResult [direction].Clear ();
                lookResult [direction].Add (lookable.Look (pov));

            } else {

                if (lookResult [direction].Count < distance)
                    PrepareLookResult (direction, distance - 1);

                pointsInDirectionCache [direction] =
                    pov.LookInDirection (direction, distance, pointsInDirectionCache [direction]);

                Point[] pointsToCount = pointsInDirectionCache [direction] [distance];

                int result = 0;
                foreach (Point p in pointsToCount)
                    result += lookable.Look (p);

                lookResult [direction].Add (result + lookResult [direction] [distance - 1]);

            }
        }
Exemplo n.º 3
0
        protected virtual void Move(MoveDirection direction)
        {
            switch (direction) {

            case MoveDirection.Down:
                MoveDown ();
                break;

            case MoveDirection.Left:
                MoveLeft ();
                break;

            case MoveDirection.Right:
                MoveRight ();
                break;

            case MoveDirection.Up:
                MoveUp ();
                break;

            default:
                // just chill!
                break;
            }
        }
    private Vector2 _NewPosition; // So we don't have to redefine the variable each time. Player nicer with the Garbage Collect.

    #endregion Fields

    #region Methods

    /// <summary>
    /// Move Object
    /// </summary>
    /// <param name="Direction"></param>
    private void Move(MoveDirection Direction)
    {
        // Assign appropriate movement base on input key.
        switch (Direction)
        {
            case MoveDirection.Up:
                _NewPosition = new Vector2(transform.position.x, transform.position.y + _MovementValue);
                break;

            case MoveDirection.Left:
                _NewPosition = new Vector2(transform.position.x - _MovementValue, transform.position.y);
                break;

            case MoveDirection.Down:
                _NewPosition = new Vector2(transform.position.x, transform.position.y - _MovementValue);
                break;

            case MoveDirection.Right:
                _NewPosition = new Vector2(transform.position.x + _MovementValue, transform.position.y);
                break;

            default:
                _NewPosition = transform.position;
                break;
        }

        // Finally, update our position.
        transform.position = Vector3.Lerp(transform.position, _NewPosition, Time.deltaTime);
    }
 private void Move(MoveDirection direction)
 {
     MoveCommand moveCommand = new MoveCommand(moveCommandReciever, direction, moveDistance, objectToMove);
     moveCommand.Execute();
     commands.Add(moveCommand);
     currentCommandNum++;
 }
Exemplo n.º 6
0
        public void Fire(Vector2 theStartPosition, Vector2 theSpeed, Vector2 theDirection, MoveDirection playerDirection, TimeSpan gameTime)
        {
            _direction = playerDirection;
              if (playerDirection == MoveDirection.Right)
            Position = new Vector2(theStartPosition.X - 80, theStartPosition.Y);
              else
            Position = new Vector2(theStartPosition.X - 50, theStartPosition.Y);

              StartPosition = theStartPosition;
              mSpeed = theSpeed;
              mDirection = theDirection;

              if (Data.Effect == ProjectileEffect.Burn)
              {
            mSpeed.X = 0;
            if (_direction == MoveDirection.Left)
            {
              int width = SpriteTexture.Width / Columns;
              if (playerDirection == MoveDirection.Right)
            Position = new Vector2(theStartPosition.X - 80, theStartPosition.Y);
              else
            Position = new Vector2(theStartPosition.X - 50 - width, theStartPosition.Y);
            }
            _burnStart = gameTime;
              }
        }
Exemplo n.º 7
0
        public override void Move(MoveDirection dir)
        {
            Position to;
            switch (dir)
            {
                case MoveDirection.UpLeft:
                    to = new Position(Pos.Row - 1, Pos.Col - 1);
                    break;
                case MoveDirection.UpRight:
                    to = new Position(Pos.Row - 1, Pos.Col + 1);
                    break;
                case MoveDirection.DownLeft:
                    to = new Position(Pos.Row + 1, Pos.Col - 1);
                    break;
                case MoveDirection.DownRight:
                    to = new Position(Pos.Row + 1, Pos.Col + 1);
                    break;
                default: // Should cover all cases
                    return;
            }

            if (!_board.IsValidPosition(to))
                return;

            Move m = new Move(Pos, to);

            _board.Move(m);

            Pos = to;
        }
        public bool Move(MoveDirection movedirection)
        {
            bool moved = false;

            if (!isOutsideOfSea(movedirection))
            {
                switch (movedirection)
                {
                    case MoveDirection.Left:
                        foreach (Block b in this.blocks)
                            b.xPos -= 1;
                        break;
                    case MoveDirection.Right:
                        foreach (Block b in this.blocks)
                            b.xPos += 1;
                        break;
                    case MoveDirection.Up:
                        foreach (Block b in this.blocks)
                            b.yPos -= 1;
                        break;
                    case MoveDirection.Down:
                        foreach (Block b in this.blocks)
                            b.yPos += 1;
                        break;
                    default:
                        break;
                }
            }

            return moved;
        }
Exemplo n.º 9
0
        public void Move(MoveDirection direction)
        {
            switch (direction)
            {
                case MoveDirection.Up:
                    this.RemoveFromPreviousPosition();
                    this.posY -= 1;
                    this.Draw();
                    break;
                case MoveDirection.Down:
                    this.RemoveFromPreviousPosition();
                    this.posY += 1;
                    this.Draw();
                    break;
                case MoveDirection.Left:
                    this.RemoveFromPreviousPosition();
                    this.posX -= 1;
                    this.Draw();
                    break;
                case MoveDirection.Right:
                    this.RemoveFromPreviousPosition();
                    this.posX += 1;
                    this.Draw();
                    break;
                default:
                    break;
            }

            this.direct = direction;
        }
Exemplo n.º 10
0
 public void Move(MoveDirection direction)
 {
     if(this.OnMoveReceived != null)
     {
         this.OnMoveReceived(direction, new MoveEventArgs());
     }
 }
Exemplo n.º 11
0
        private bool CanMoveInDirection(Position position, MoveDirection direction)
        {
            if (direction == MoveDirection.Up &&
                position.Row <= 0)
            {
                return false;
            }

            if (direction == MoveDirection.Down &&
                position.Row >= BOARD_SIZE - 1)
            {
                return false;
            }

            if (direction == MoveDirection.Left &&
                position.Column <= 0)
            {
                return false;
            }

            if (direction == MoveDirection.Right &&
                position.Column >= BOARD_SIZE - 1)
            {
                return false;
            }

            Position newPosition = CalculatePositionWithDirection(position, direction);
            if (this.matrix[newPosition.Row, newPosition.Column] != " ")
            {
                return false;
            }

            return true;
        }
 //Constructor
 public MoveCommand(MoveCommandReceiver reciever, MoveDirection direction, float distance, GameObject gameObjectToMove)
 {
     this._receiver = reciever;
     this._direction = direction;
     this._distance = distance;
     this._gameObject = gameObjectToMove;
 }
Exemplo n.º 13
0
        public Point GetNewLocation(Point oldLocation, MoveDirection? direction)
        {
            var newLocation = new Point(oldLocation.X, oldLocation.Y);

            if (direction == null)
            {
                return newLocation;
            }

            switch (direction)
            {
                case MoveDirection.Up:
                    newLocation.Y--;
                    break;
                case MoveDirection.Down:
                    newLocation.Y++;
                    break;
                case MoveDirection.Right:
                    newLocation.X++;
                    break;
                case MoveDirection.Left:
                    newLocation.X--;
                    break;
            }

            return newLocation;
        }
Exemplo n.º 14
0
		public Vector2 Move( MoveDirection move ) {
			switch( move ) {
				case MoveDirection.Up:
					this.playerPosition.Y--;
					currentDirection = MoveDirection.Up;
					break;
				case MoveDirection.Down:
					this.playerPosition.Y++;
					currentDirection = MoveDirection.Down;
					break;
				case MoveDirection.Left:
					this.playerPosition.X--;
					currentDirection = MoveDirection.Left;
					break;
				case MoveDirection.Right:
					this.playerPosition.X++;
					currentDirection = MoveDirection.Right;
					break;
				default:
					currentDirection = MoveDirection.Idle;
					break;
			}
			center.X = playerPosition.X + 11;
			center.Y = playerPosition.Y + 11;

			return new Vector2( 0, 0 );
		}
Exemplo n.º 15
0
    public void Jump(MoveDirection inputDirection)
    {
        if (isOnGround)
        {
          Vector2 force;

          if (inputDirection == MoveDirection.Right)
          {
        force.x = Vector2.right.x * jumpForce.x;
          }
          else if (inputDirection == MoveDirection.Left)
          {
        force.x = Vector2.left.x * jumpForce.x;
          }
          else
          {
        force.x = 0;
          }

          force.y = jumpForce.y;

          m_Body.AddForce(force);

          m_AnimationController.SetFloat("JumpDirection", force.x);

          m_AnimationController.SetTrigger("Jump");
        }
    }
Exemplo n.º 16
0
  public void RequestMove(MoveDirection direction)
  {
    //-- get the tile in the direction
    TileScript nextTile = levelManager.GetTile(direction, m_CurrentTile.myLaneNumber, m_CurrentTile.myElevation);
    //if( nextTile.myTileType != TileType.Blocker )
    if (nextTile != null)
    {
      if (direction == MoveDirection.MoveUp)
      {
        m_PlayerController.SetPlayerState(PlayerState.Hop_Up);
        levelManager.MoveTiles(MoveDirection.MoveUp, playerMoveTime);
      }
      if (direction == MoveDirection.MoveDown)
      {
        m_PlayerController.SetPlayerState(PlayerState.Hop_Down);
        levelManager.MoveTiles(MoveDirection.MoveDown, playerMoveTime);
      }
      if (direction == MoveDirection.MoveLeft)
      {
        m_PlayerController.SetPlayerState(PlayerState.Hop_Left);
      }
      if (direction == MoveDirection.MoveRight)
      {
        m_PlayerController.SetPlayerState(PlayerState.Hop_Right);
      }

      //-- let the player controller know we are preparing to switch ik targets
      m_PlayerController.SetNextIKSet(nextTile.ikTarget);

      //-- cache the current tile
      m_CurrentTile = nextTile;

    }
  }
Exemplo n.º 17
0
 /// <summary>
 /// アカウントの並び順を変更します。
 /// </summary>
 /// <param name="elem">対象アカウント</param>
 /// <param name="dir">移動先</param>
 public static void MoveAccountElement(string id, MoveDirection dir)
 {
     var elem = GetAccountElement(id);
     if(elem==null)return;
     var idx = accountModels.IndexOf(elem);
     if (idx < 0) return;
     switch (dir)
     {
         case MoveDirection.Up:
             if (idx > 0)
             {
                 accountModels.RemoveAt(idx);
                 accountModels.Insert(idx - 1, elem);
             }
             break;
         case MoveDirection.Down:
             if (idx < accountModels.Count - 1)
             {
                 accountModels.RemoveAt(idx);
                 accountModels.Insert(idx + 1, elem);
             }
             break;
         default:
             throw new ArgumentException("移動方向指定がちゃんちゃらおかしい :" + dir.ToString());
     }
     AccountsChanged();
 }
Exemplo n.º 18
0
    void Update()
    {
        var v = Input.GetAxis("Vertical");
        var h = Input.GetAxis("Horizontal");

        MoveDirection md = _GetMoveDirection(v , h);

        if (md != _Current)
        {

            MoveCommandParam mcp = _GetMoveCommandParam(md);

            _Current = md;

            if (mcp.ActionStatus == Regulus.Project.TurnBasedRPG.ActionStatue.Idle)
            {

                _GamePlayer.Stop(mcp.Direction);
            }
            else
            {
                _GamePlayer.Walk(mcp.Direction);
            }
        }
    }
Exemplo n.º 19
0
 public override Projectile[] Shoot( MoveDirection direction, Microsoft.Xna.Framework.Vector2 startPos )
 {
     if ( fireRate-- > 0 )
         return new Projectile[0];
     fireRate = FireRate;
     return new[] { new Bullet( startPos, direction ) };
 }
Exemplo n.º 20
0
 public static Point MoveDirectionConvertToPoint(MoveDirection dire)
 {
     Point offsetPos = new Point();
     switch (dire)
     {
         case MoveDirection.Left:
             offsetPos = new Point(-1, 0);
             break;
         case MoveDirection.Right:
             offsetPos = new Point(1, 0);
             break;
         case MoveDirection.Up:
             offsetPos = new Point(0, -1);
             break;
         case MoveDirection.Down:
             offsetPos = new Point(0, 1);
             break;
         case MoveDirection.LeftUp:
             offsetPos = new Point(-1, -1);
             break;
         case MoveDirection.LeftDown:
             offsetPos = new Point(-1, 1);
             break;
         case MoveDirection.RightUp:
             offsetPos = new Point(1, -1);
             break;
         case MoveDirection.RightDown:
             offsetPos = new Point(1, 1);
             break;
         default:
             break;
     }
     return offsetPos;
 }
Exemplo n.º 21
0
        public GameState MakeMove(MoveDirection direction)
        {
            _BoardWriter.Clear();

            if (!_Board.CanMoveInDirection(direction))
            {
                _BoardWriter.WriteBoard(_Board);
                _BoardWriter.WriteMessage("No available moves in that direction.");
            }
            else
            {
                _Board.Move(direction);
                _Board.PlaceRandomCell();
                _BoardWriter.WriteBoard(_Board);
            }

            var gameState = CheckGameState();

            if (gameState == GameState.Won)
            {
                _BoardWriter.WriteMessage("You won! Or there was a severe programming error.");
            }
            else if (gameState == GameState.Lost)
            {
                _BoardWriter.WriteMessage("No more moves! Game over man! Game over!");
            }

            return gameState;
        }
Exemplo n.º 22
0
        /// <summary>
        /// All logic about collision and physics is kept here.
        /// </summary>
        public static bool ObjectCollisionDetector(IMoveable moveableObject, MoveDirection moveDirection, out GameObject collisionObj)
        {
            Vector2 currentPosition = moveableObject.Position;
            float x = currentPosition.X;
            float y = currentPosition.Y;

            switch (moveDirection)
            {
                case MoveDirection.Up:
                    y -= moveableObject.Speed;
                    break;
                case MoveDirection.Down:
                    y += moveableObject.Speed;
                    break;
                case MoveDirection.Left:
                    x -= moveableObject.Speed;
                    break;
                case MoveDirection.Right:
                    x += moveableObject.Speed;
                    break;
            }

            Rectangle futureBounds = new Rectangle((int)x, (int)y, moveableObject.Bounds.Width, moveableObject.Bounds.Height);
            foreach (GameObject gameObject in ObjectFactory.AllObjects.Where(obj => !(obj is Player)))
            {
                if (futureBounds.Intersects(gameObject.Bounds))
                {
                    if (moveableObject is Player)
                    {
                        collisionObj = gameObject;
                        Console.WriteLine("collision detected!");
                        return true;
                    }
                    if (moveableObject is NPC)
                    {
                        if (gameObject is NPC)
                        {
                            collisionObj = gameObject;
                            return false;
                        }
                        else if (gameObject is Player)
                        {
                            collisionObj = gameObject;
                            return true;
                        }
                    }
                }
            }
            if (futureBounds.X <= 0 ||
               !(futureBounds.X + futureBounds.Width <= Constants.WINDOW_DEFAULT_WIDTH) ||
               futureBounds.Y <= 0 ||
               futureBounds.Y + futureBounds.Height >= Constants.WINDOW_DEFAULT_HEIGHT)
            {
                collisionObj = ObjectFactory.PLAYER;
                Console.WriteLine("Collision detected at ({0},{1})", futureBounds.X, futureBounds.Y);
                return true;
            }
            collisionObj = null;
            return false;
        }
Exemplo n.º 23
0
        public MoveDirection CanMove(float gameWindowWidth, float gameWindowHeight, MoveDirection playerMoveDirection)
        {
            var _MaxX = gameWindowWidth - (Size.Width / Columns ) - 100;
              var _MinX = 100;
              var _MaxY = gameWindowHeight - Size.Height - 100;
              var _MinY = 0;

              // Check for bounce.
              if (Position.X > _MaxX)
              {
            if (playerMoveDirection == MoveDirection.Right)
              return MoveDirection.Stop;
              }
              else if (Position.X < _MinX)
              {
            if (playerMoveDirection == MoveDirection.Left)
              return MoveDirection.Stop;
              }

              if (Position.Y > _MaxY)
              {
            if (playerMoveDirection == MoveDirection.Up)
              return MoveDirection.Stop;
              }
              else if (Position.Y < _MinY)
              {
            if (playerMoveDirection == MoveDirection.Down)
              return MoveDirection.Stop;
              }
              return playerMoveDirection;
        }
Exemplo n.º 24
0
 public void FillPathVolume(MoveDirection dir, int step)
 {
     int index = 0;
     while (index <= step) {
         pathFillers.Add((GameObject)Instantiate(invisibleObstacle, transform.position + dir.AsVector() * index, transform.rotation));
         ++index;
     }
 }
Exemplo n.º 25
0
 public static void ChangeOrder(int DeptID, int priorityId, MoveDirection direction)
 {
     UpdateData("sp_UpdatePriorityOrder", new SqlParameter[]{
         new SqlParameter("@DepartmentId", DeptID),
         new SqlParameter("@PriorityId", priorityId),
         new SqlParameter("@MoveUp", (int)direction)
     });
 }
Exemplo n.º 26
0
 // implement movement interface
 public void PlayerMovement(MoveDirection moveDirection)
 {
     //see if need to flip the direction
     if(moveDirection != MoveDirection.NONE && computerLane == ComputerLane.LEFT){
         int newDirection = ((int) moveDirection + 4 ) % 8;
         moveDirection = (MoveDirection) newDirection;
     }
     this.moveDirection = moveDirection;
 }
Exemplo n.º 27
0
    public SimpleStarBehaviour(ICatchable obj)
    {
        this.catchable = obj;
        this.obj = obj.GameObject.transform;
        this.sea = obj.Sea;
        //		this.speed = obj.GameObject.GetComponent<Fish>().speed;

        this.moveDirection = (UnityEngine.Random.Range (0, 2) == 1 ? MoveDirection.Up : MoveDirection.Down);
    }
Exemplo n.º 28
0
 void FindPathToTarget()
 {
     // TODO intelligent pathfinding
     if (target.position.x > this.transform.position.x) {
         moveDirection = MoveDirection.RIGHT;
     } else {
         moveDirection = MoveDirection.LEFT;
     }
 }
Exemplo n.º 29
0
        public void SnakeMoveInEachDirectionCorrect(MoveDirection changeDirection, int resultX, int resultY)
        {
            var snake = new Snake(1, 1);

            snake.ChangeDirection(changeDirection);
            snake.Move();
            Assert.IsTrue(snake.Head.X == resultX);
            Assert.IsTrue(snake.Head.Y == resultY);
            Assert.IsNull(snake.Head.Next);
        }
Exemplo n.º 30
0
        internal BattleSnake GetTailOwner(BattleSnake snake, MoveDirection moveDirection)
        {
           //var coordinates =  GetRelativeToMoveDirectionCoordinates(snake, moveDirection); //translate relative coordinates to absolute
           //var tailOwner = snakes.Where(snake => snake.Tail.Coordinates == coordinates).SingleOrDefault():
           /* 
            * return tailOwner;
            */

            throw new NotImplementedException();
        }
 public MotorDirectionChangedEventArgs(MoveDirection direction)
 {
     Direction = direction;
 }
Exemplo n.º 32
0
 internal MoveBlockBuilderViewModel()
 {
     currentDirection = MoveDirection.Forward;
     Speed            = 80;
     DirectionOptions = Enum.GetNames(typeof(MoveDirection));
 }
Exemplo n.º 33
0
 public void BindUnidirectional(GameObject source, GameObject target, MoveDirection direction,
                                Func <bool> condition = null)
 {
     AddBinding(source, target, direction, false, condition);
 }
Exemplo n.º 34
0
 public void BindBidirectional(Component source, Component target, MoveDirection direction,
                               Func <bool> condition = null, Func <bool> backwardCondition = null)
 {
     BindBidirectional(source.gameObject, target.gameObject, direction, condition, backwardCondition);
 }
Exemplo n.º 35
0
 public MoveSelect(Selection tool, string id, MoveDirection direction, Keys modifier, Keys accelerator)
     : base(tool.Handler, id, direction, accelerator | modifier)
 {
     this.tool = tool;
     this.ID  += "_Select";
 }
Exemplo n.º 36
0
 public void SetUp()
 {
     _grid          = new Grid(4, 4, new Position(0, 0));
     _directionMove = new DirectionMove(_grid);
     direction      = MoveDirection.North;
 }
Exemplo n.º 37
0
 public WalkByDirection(MoveDirection defaultDirection)
 {
     currentDirection = defaultDirection;
 }
Exemplo n.º 38
0
        /// <summary>
        /// Moves the head based on direction and speed
        /// </summary>
        /// <remarks>Requires behavior control; see <see cref="ControlComponent.RequestControl(int)"/>.</remarks>
        /// <param name="moveDirection">The move direction.</param>
        /// <param name="speed">The speed.</param>
        /// <returns>A task that represents the asynchronous operation; the task result contains the result from the robot.</returns>
        public async Task <StatusCode> MoveHead(MoveDirection moveDirection, MotorSpeed speed = MotorSpeed.Medium)
        {
            float headSpeed = PickSpeed(speed, 0.5f, 1, 2);

            return(await SetHeadMotor((float)moveDirection *headSpeed).ConfigureAwait(false));
        }
Exemplo n.º 39
0
        public void test_that_position_in_the_Middle_of_Chessboard_Is_available_for_all_moves(int column, int row, MoveDirection moveDirection)
        {
            var board  = new Board(cols, rows, new List <Tuple <int, int> >());
            var actual = board.IsMoveAvailable(new BoardPosition(column, row), moveDirection);

            Assert.IsTrue(actual);
        }
Exemplo n.º 40
0
    public HashSet <Selectable> GetUITargets(GraphicRaycaster gRay, PointerEventData pD)
    {
        if (cam != gRay.eventCamera)
        {
            cam = gRay.eventCamera;
        }

        aD.Reset();
        aD.moveVector = (this.pD.position - pD.position);

        float x1 = this.pD.position.x,
              x2 = pD.position.x,
              y1 = this.pD.position.y,
              y2 = pD.position.y;

        float xDiff = x1 - x2;
        float yDiff = y1 - y2;

        MoveDirection dir = MoveDirection.None;

        if (xDiff > yDiff)
        {
            if (xDiff > 0f)
            {
                dir = MoveDirection.Right;
            }
            else if (xDiff < 0f)
            {
                dir = MoveDirection.Left;
            }
            else if (yDiff > xDiff)
            {
                if (yDiff > 0f)
                {
                    dir = MoveDirection.Up;
                }
                else if (yDiff < 0f)
                {
                    dir = MoveDirection.Down;
                }
            }
        }

        aD.moveDir = dir;

        var ray = cam.ScreenPointToRay(pD.position);

        Debug.DrawRay(ray.origin, ray.direction * 10, Color.yellow);

        List <RaycastResult> hits = new List <RaycastResult>();
        HashSet <Selectable> uibT = new HashSet <Selectable>();

        gRay.Raycast(pD, hits);

        if (hits.Count > 0)
        {
            pD.pointerCurrentRaycast = pD.pointerPressRaycast = hits[0];
        }

        for (int i = 0; i < hits.Count; i++)
        {
            var        go = hits[i].gameObject;
            Selectable u  = GOGetter(go);

            if (u)
            {
                uibT.Add(u);
            }
        }

        this.pD = pD;

        return(uibT);
    }
Exemplo n.º 41
0
 private void OnMove(MoveDirection direction)
 {
     moveDirection = direction;
 }
Exemplo n.º 42
0
        private void ForceMove(MoveDirection dir)
        {
            List <MoveDirection> otherdir = new List <MoveDirection>();

            if (dir != MoveDirection.up)
            {
                otherdir.Add(MoveDirection.up);
            }
            if (dir != MoveDirection.down)
            {
                otherdir.Add(MoveDirection.down);
            }
            if (dir != MoveDirection.left)
            {
                otherdir.Add(MoveDirection.left);
            }
            if (dir != MoveDirection.right)
            {
                otherdir.Add(MoveDirection.right);
            }
            bool forcechanged;



            for (int n = 0; n < 3; n++)
            {
                int a = Convert.ToInt32(r.NextDouble() * otherdir.Count - .5);
                forcechanged = false;
                switch (otherdir[a])
                {
                case MoveDirection.up:
                    for (int y = 1; y < Height; y++)
                    {
                        for (int x = 0; x < Width; x++)
                        {
                            MoveTile(x, y, 0, -y, forcechanged, out forcechanged);
                        }
                    }
                    break;

                case MoveDirection.down:
                    for (int y = Height - 2; y >= 0; y--)
                    {
                        for (int x = 0; x < Width; x++)
                        {
                            MoveTile(x, y, 0, (Height - 1) - y, forcechanged, out forcechanged);
                        }
                    }
                    break;

                case MoveDirection.left:
                    for (int x = 1; x < Width; x++)
                    {
                        for (int y = 0; y < Height; y++)
                        {
                            MoveTile(x, y, -x, 0, forcechanged, out forcechanged);
                        }
                    }
                    break;

                case MoveDirection.right:
                    for (int x = Width - 2; x >= 0; x--)
                    {
                        for (int y = 0; y < Height; y++)
                        {
                            MoveTile(x, y, (Width - 1) - x, 0, forcechanged, out forcechanged);
                        }
                    }
                    break;
                }
                if (forcechanged)
                {
                    ChangedThisMove = true;
                    return;
                }
                otherdir.RemoveAt(a);
            }
        }
Exemplo n.º 43
0
 private MoveAction(MoveDirection direction)
 {
     Direction = direction;
 }
Exemplo n.º 44
0
        public void Move(MoveDirection dir)
        {
            LastMove        = dir;
            ChangedThisMove = false;
            switch (dir)
            {
            case MoveDirection.up:
                for (int y = 1; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        MoveTile(x, y, 0, -y);
                    }
                }
                break;

            case MoveDirection.down:
                for (int y = Height - 2; y >= 0; y--)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        MoveTile(x, y, 0, (Height - 1) - y);
                    }
                }
                break;

            case MoveDirection.left:
                for (int x = 1; x < Width; x++)
                {
                    for (int y = 0; y < Height; y++)
                    {
                        MoveTile(x, y, -x, 0);
                    }
                }
                break;

            case MoveDirection.right:
                for (int x = Width - 2; x >= 0; x--)
                {
                    for (int y = 0; y < Height; y++)
                    {
                        MoveTile(x, y, (Width - 1) - x, 0);
                    }
                }
                break;
            }


            if (DoForceMove && !ChangedThisMove)
            {
                ForceMove(dir);
            }

            if (ChangedThisMove)
            {
                BadMovesTillLose = BadMovesTillLoseMax;
                DoForceMove      = false;
                EmptyTiles       = new List <Point>();
                for (int x = 0; x < Width; x++)
                {
                    for (int y = 0; y < Height; y++)
                    {
                        if (Grid[x, y] == 0)
                        {
                            EmptyTiles.Add(new Point(x, y));
                        }
                    }
                }

                int n = Convert.ToInt32(r.NextDouble() * EmptyTiles.Count - 0.5);
                Grid[EmptyTiles[n].X, EmptyTiles[n].Y] = r.NextDouble() > 0.9 ? 4 : 2;
                EmptyCount = EmptyTiles.Count - 1;
            }
            else
            {
                BadMovesTillLose--;
                DoForceMove = true;
                if (BadMovesTillLose == 0)
                {
                    Lose();
                }
            }
        }
Exemplo n.º 45
0
 public override void Move(MoveDirection direction)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 46
0
 public Trigger(TriggerType Type, MoveDirection EnterDirection, Image image, int Layer, bool HasCollision, RectangleF collision, bool DrawAsSprite, bool AnimateImage) : base(image, Layer, HasCollision, collision, DrawAsSprite, AnimateImage)
 {
     this.Type           = Type;
     this.EnterDirection = EnterDirection;
 }
Exemplo n.º 47
0
        //	1フレームに1回呼ばれる更新メソッド
        private void Update()
        {
            //	移動中フラグ
            bool moveFlag = false;

            //	弾連続生成のクールタイムに加算
            nowCoolTime += Time.deltaTime;

            //	左移動チェック。弾の発射モーション中は移動できない
            if (Input.GetKey(KeyCode.LeftArrow) && !bulletAnimation)
            {
                //	左に移動しているので、移動状態を設定
                moveFlag     = true;
                nowDirection = MoveDirection.Left;
                //	体の向いている角度を直指定する
                this.gameObject.transform.localEulerAngles = new Vector3(0, 90, 0);

                //	座標は計算してから入れる
                Vector3 nowPosition = this.gameObject.transform.localPosition;

                //	地面の左端より遠くに行かないように監視
                if (nowPosition.x > -(groundObject.transform.localScale.x / 2f))
                {
                    nowPosition -= new Vector3(moveSpeed, 0, 0);
                    this.gameObject.transform.localPosition = nowPosition;
                }
            }

            //	右移動チェック。弾の発射モーション中は移動できない
            if (Input.GetKey(KeyCode.RightArrow) && !bulletAnimation)
            {
                //	右に移動しているので、移動状態を設定
                moveFlag     = true;
                nowDirection = MoveDirection.Right;
                //	角度を直指定する
                this.gameObject.transform.localEulerAngles = new Vector3(0, -90, 0);

                //	座標は計算してから入れる
                Vector3 nowPosition = this.gameObject.transform.localPosition;

                //	地面の右端より遠くに行かないように監視
                if (nowPosition.x < (groundObject.transform.localScale.x / 2f))
                {
                    nowPosition += new Vector3(moveSpeed, 0, 0);
                    this.gameObject.transform.localPosition = nowPosition;
                }
            }

            //	腕と足回転クラスに移動フラグをアニメーションフラグとして渡す
            rotAnimation.SetAnimationFlag(moveFlag);

            //	スペースキーと向きチェック。発射間隔や発射モーションの状態も考慮する
            if (Input.GetKey(KeyCode.Space) && (nowDirection != MoveDirection.None) &&
                (nowCoolTime >= bulletCoolTime) && !bulletAnimation)
            {
                //	弾の再生性までの時間を適応
                nowCoolTime = 0f;
                //	弾発射モーションフラグをON
                bulletAnimation = true;
                //	弾の発射アニメーションを開始する
                StartCoroutine(StartBulletAnimation());
            }
        }
Exemplo n.º 48
0
 public Trigger(TriggerType Type, MoveDirection EnterDirection, Image image, int Layer, bool HasCollision, PointF pt, bool DrawAsSprite) : base(image, Layer, HasCollision, pt, DrawAsSprite, false)
 {
     this.Type           = Type;
     this.EnterDirection = EnterDirection;
 }
Exemplo n.º 49
0
 public void BindBidirectional(GameObject source, GameObject target, MoveDirection direction,
                               Func <bool> condition = null, Func <bool> backwardCondition = null)
 {
     AddBinding(source, target, direction, true, condition, backwardCondition ?? condition);
 }
Exemplo n.º 50
0
 public Trigger_Change_Layer(TriggerType Type, MoveDirection EnterDirection, int LayerToChangeTo, Image image, int Layer, bool HasCollision, RectangleF collision, bool DrawAsSprite, bool AnimateImage) : base(Type, EnterDirection, image, Layer, HasCollision, collision, DrawAsSprite, AnimateImage)
 {
     this.LayerToChangeTo = LayerToChangeTo;
 }
Exemplo n.º 51
0
        /// <summary>
        /// Adjust the selected item and range based on keyboard input.
        /// This is used to override the listview behavious for up/down arrow manipulation vs left/right for a horizontal control
        /// </summary>
        /// <param name="direction">direction to move the selection</param>
        /// <returns>True if the focus was moved, false otherwise</returns>
        private bool MoveFocusAndSelection(MoveDirection direction)
        {
            bool retVal = false;
            var  currentContainerItem = FocusManager.GetFocusedElement() as TokenizingTextBoxItem;

            if (currentContainerItem != null)
            {
                var currentItem   = ItemFromContainer(currentContainerItem);
                var previousIndex = Items.IndexOf(currentItem);
                var index         = previousIndex;

                if (direction == MoveDirection.Previous)
                {
                    if (previousIndex > 0)
                    {
                        index -= 1;
                    }
                    else
                    {
                        if (TabNavigateBackOnArrow)
                        {
                            FocusManager.TryMoveFocus(FocusNavigationDirection.Previous);
                        }

                        retVal = true;
                    }
                }
                else if (direction == MoveDirection.Next)
                {
                    if (previousIndex < Items.Count - 1)
                    {
                        index += 1;
                    }
                }

                // Only do stuff if the index is actually changing
                if (index != previousIndex)
                {
                    var newItem = ContainerFromIndex(index) as TokenizingTextBoxItem;

                    // Check for the new item being a text control.
                    // this must happen before focus is set to avoid seeing the caret
                    // jump in come cases
                    if (Items[index] is PretokenStringContainer && !IsShiftPressed)
                    {
                        newItem._autoSuggestTextBox.SelectionLength = 0;
                        newItem._autoSuggestTextBox.SelectionStart  = direction == MoveDirection.Next
                            ? 0
                            : newItem._autoSuggestTextBox.Text.Length;
                    }

                    newItem.Focus(FocusState.Keyboard);

                    // if no control keys are selected then the selection also becomes just this item
                    if (IsShiftPressed)
                    {
                        // What we do here depends on where the selection started
                        // if the previous item is between the start and new position then we add the new item to the selected range
                        // if the new item is between the start and the previous position then we remove the previous position
                        int newDistance = Math.Abs(SelectedIndex - index);
                        int oldDistance = Math.Abs(SelectedIndex - previousIndex);

                        if (newDistance > oldDistance)
                        {
                            SelectedItems.Add(Items[index]);
                        }
                        else
                        {
                            SelectedItems.Remove(Items[previousIndex]);
                        }
                    }
                    else if (!IsControlPressed)
                    {
                        SelectedIndex = index;

                        // This looks like a bug in the underlying ListViewBase control.
                        // Might need to be reviewed if the base behaviour is fixed
                        // When two consecutive items are selected and the navigation moves between them,
                        // the first time that happens the old focused item is not unselected
                        if (SelectedItems.Count > 1)
                        {
                            SelectedItems.Clear();
                            SelectedIndex = index;
                        }
                    }

                    retVal = true;
                }
            }

            return(retVal);
        }
Exemplo n.º 52
0
 public Trigger_Change_Layer(TriggerType Type, MoveDirection EnterDirection, int LayerToChangeTo, Image image, int Layer, bool HasCollision, PointF pt, bool DrawAsSprite) : base(Type, EnterDirection, image, Layer, HasCollision, pt, DrawAsSprite, false)
 {
     this.LayerToChangeTo = LayerToChangeTo;
 }
Exemplo n.º 53
0
 private void TryMove(MoveDirection moveDirection)
 {
     Debug.Log(moveDirection);
 }
Exemplo n.º 54
0
 public Trigger_Damage(int Damage, TriggerType Type, MoveDirection EnterDirection, Image image, int Layer, bool HasCollision, RectangleF collision, bool DrawAsSprite, bool AnimateImage) : base(Type, EnterDirection, image, Layer, HasCollision, collision, DrawAsSprite, AnimateImage)
 {
 }
Exemplo n.º 55
0
    public IEnumerator MoveCoroutine(MoveDirection md)
    {
        State = GameState.WaitingForMoveToEnd;
        bool MovedUp = false;

        //start moving each line with delays depending on MoveDirection md
        switch (md)
        {
        case MoveDirection.Down:
            for (int i = 0; i < columns.Count; i++)
            {
                MoveOneLineUpIndexCoroutineIdentifier = MoveOneLineUpIndexCoroutine(columns [i], i);
                StartCoroutine(MoveOneLineUpIndexCoroutineIdentifier);
                MovedUp = true;
            }
            break;

        case MoveDirection.Left:
            for (int i = 0; i < rows.Count; i++)
            {
                MoveOneLineDownIndexCoroutineIdentifier = MoveOneLineDownIndexCoroutine(rows [i], i);
                StartCoroutine(MoveOneLineDownIndexCoroutineIdentifier);
            }
            break;

        case MoveDirection.Right:
            for (int i = 0; i < rows.Count; i++)
            {
                MoveOneLineUpIndexCoroutineIdentifier = MoveOneLineUpIndexCoroutine(rows [i], i);
                StartCoroutine(MoveOneLineUpIndexCoroutineIdentifier);
                MovedUp = true;
            }
            break;

        case MoveDirection.Up:
            for (int i = 0; i < columns.Count; i++)
            {
                MoveOneLineDownIndexCoroutineIdentifier = MoveOneLineDownIndexCoroutine(columns [i], i);
                StartCoroutine(MoveOneLineDownIndexCoroutineIdentifier);
            }
            break;
        }

        // Wait until the move is over in all lines
        while (!(lineMoveComplete [0] && lineMoveComplete [1] && lineMoveComplete [2] && lineMoveComplete [3]))
        {
            yield return(null);
        }

        if (moveMade)
        {
            UpdateEmptyTiles();
            Generate();

            if (!CanMove())
            {
                GameOver();
            }
        }

        State = GameState.Playing;
        StopCoroutine(MoveCoroutineIdentifier);
        if (MovedUp)
        {
            StopCoroutine(MoveOneLineUpIndexCoroutineIdentifier);
        }
        else
        {
            StopCoroutine(MoveOneLineDownIndexCoroutineIdentifier);
        }
    }
Exemplo n.º 56
0
 public Trigger_Damage(int Damage, TriggerType Type, MoveDirection EnterDirection, Image image, int Layer, bool HasCollision, PointF pt, bool DrawAsSprite) : base(Type, EnterDirection, image, Layer, HasCollision, pt, DrawAsSprite, false)
 {
 }
Exemplo n.º 57
0
        /// <summary>
        /// Moves the lift based on direction and speed
        /// </summary>
        /// <remarks>Requires behavior control; see <see cref="ControlComponent.RequestControl(int)"/>.</remarks>
        /// <param name="moveDirection">The move direction.</param>
        /// <param name="speed">The speed.</param>
        /// <returns>A task that represents the asynchronous operation.</returns>
        public async Task <StatusCode> MoveLift(MoveDirection moveDirection, MotorSpeed speed = MotorSpeed.Medium)
        {
            float liftSpeed = PickSpeed(speed, 2, 4, 8);

            return(await SetLiftMotor((float)moveDirection *liftSpeed).ConfigureAwait(false));
        }
Exemplo n.º 58
0
        public async Task DoMove(MoveDirection direction)
        {
            if (bot.Energy > MainGame.Settings.EnergyLostByMove)
            {
                bot.Energy -= MainGame.Settings.EnergyLostByMove;
            }
            else
            {
                bot.Energy = 0;
            }
            int x = 0;
            int y = 0;

            switch (direction)
            {// TODO: check if it is ok for east/west. Ok for north/south
            // pour l'instant, on se déplace haut/bas/gauche/droite, pas de diagonale
            case MoveDirection.North: y = 1; break;

            case MoveDirection.South: y = -1; break;

            case MoveDirection.East: x = -1; break;

            case MoveDirection.West: x = 1; break;

                /*case MoveDirection.NorthWest: y = 1; x = 1; break;
                 * case MoveDirection.NorthEast: y = 1; x = -1; break;
                 * case MoveDirection.SouthWest: y = -1; x = 1; break;
                 * case MoveDirection.SouthEast: y = -1; x = -1; break;
                 */
            }
            switch (MainGame.TheMap[bot.X + x, bot.Y + y])
            {
            case CaseState.Empty:
                MainGame.ViewerMovePlayer(bot.X, bot.Y, (byte)(bot.X + x), (byte)(bot.Y + y));
                MainGame.TheMap[bot.X, bot.Y] = CaseState.Empty;
                bot.X = (byte)(bot.X + x);
                bot.Y = (byte)(bot.Y + y);
                MainGame.TheMap[bot.X, bot.Y] = CaseState.Ennemy;
                SendPositionToCockpit();
                break;

            case CaseState.Energy:
                MainGame.ViewerClearCase((byte)(bot.X + x), (byte)(bot.Y + y));
                MainGame.ViewerMovePlayer(bot.X, bot.Y, (byte)(bot.X + x), (byte)(bot.Y + y));
                MainGame.TheMap[bot.X, bot.Y] = CaseState.Empty;
                bot.X = (byte)(bot.X + x);
                bot.Y = (byte)(bot.Y + y);
                MainGame.TheMap[bot.X, bot.Y] = CaseState.Ennemy;
                UInt16 temp = (UInt16)(MainGame.RND.Next(1 + MainGame.Settings.EnergyPodMax - MainGame.Settings.EnergyPodFrom) + MainGame.Settings.EnergyPodFrom);
                bot.Energy += temp;
                Console.WriteLine($"Bot {bot.Name} win energy: {temp}");
                bot.Score += MainGame.Settings.PointByEnergyFound;
                SendPositionToCockpit();
                break;

            case CaseState.Ennemy:     // on tamponne un bot adverse
                if (bot.ShieldLevel >= MainGame.Settings.EnergyLostContactEnemy)
                {
                    bot.ShieldLevel -= MainGame.Settings.EnergyLostContactEnemy;
                    MainGame.ViewerPlayerShield(bot.X, bot.Y, bot.ShieldLevel);
                }
                else
                {
                    UInt16 tmp = bot.ShieldLevel;
                    bot.ShieldLevel = 0;
                    tmp             = (UInt16)(2 * (MainGame.Settings.EnergyLostContactEnemy - tmp));
                    if (bot.Energy >= tmp)
                    {
                        bot.Energy -= tmp;
                    }
                    else
                    {
                        bot.Energy = 0;
                    }
                }
                // perte du champ occultant
                if (bot.CloakLevel > 0)
                {
                    bot.CloakLevel = 0;
                    MainGame.ViewerPlayerCloak(bot.X, bot.Y, bot.CloakLevel);
                }
                bot.Score += MainGame.Settings.PointByEnnemyTouch;
                Console.WriteLine($"Bot {bot.Name} tamponne un bot ennemi !");
                TouchEnemy((UInt16)(bot.X + x), (UInt16)(bot.Y + y));
                break;

            case CaseState.Wall:
                if (bot.ShieldLevel > 0)
                {
                    bot.ShieldLevel--;
                    MainGame.ViewerPlayerShield(bot.X, bot.Y, bot.ShieldLevel);
                }
                else
                {
                    if (bot.Energy > MainGame.Settings.EnergyLostContactWall)
                    {
                        bot.Energy -= MainGame.Settings.EnergyLostContactWall;
                    }
                    else
                    {
                        bot.Energy = 0;
                    }
                }
                // perte du champ occultant
                if (bot.CloakLevel > 0)
                {
                    bot.CloakLevel = 0;
                    MainGame.ViewerPlayerCloak(bot.X, bot.Y, bot.CloakLevel);
                }
                break;
            }
            await SendChangeInfo();

            //MainGame.RefreshViewer();
            if (bot.Energy == 0)
            {
                await SendDead();
            }
        } // DoMove
Exemplo n.º 59
0
 public void ChangeDirection(MoveDirection newDirection)
 {
     this.snakeDirection = newDirection;
 }
Exemplo n.º 60
0
 public MainFieldSquareState(bool isActive, uint obstacle, Direction direction)
 {
     Obstacle  = obstacle;
     IsActive  = isActive;
     Direction = new MoveDirection(direction);
 }