Exemple #1
0
 public void MoveNorth()
 {
     if (Instructions.Count == 0)
     {
         mController.Row = mController.Row + 1;
         InstructionManager.MoveToAccurate(this, X, Y + Square.kPixelSize, Z, sTimeToTake);
     }
 }
Exemple #2
0
 public void MoveEast()
 {
     if (Instructions.Count == 0)
     {
         mController.Column = mController.Column + 1;
         InstructionManager.MoveToAccurate(this, X + Square.kPixelSize, Y, Z, sTimeToTake);
     }
 }
Exemple #3
0
        private bool ApplyDesiredDirectionToMovement(Direction desiredDirection, TileShapeCollection collision,
                                                     PositionedObjectList <Character> characters)
        {
            bool movedNewDirection = false;

            if (isMovingToTile == false && desiredDirection != Direction.None)
            {
                float desiredX = this.X;
                float desiredY = this.Y;
                bool  isBlocked;
                MoveInDirection(desiredDirection, ref desiredX, ref desiredY);
                this.ForwardCollision.X = desiredX;
                this.ForwardCollision.Y = desiredY;

                isBlocked = GetIfIsBlocked(collision, characters);

                if (isBlocked)
                {
                    // move the collision back so it occupies the character's tile
                    this.ForwardCollision.Position = this.Position;
                }
                else
                {
                    float timeToTake = tileSize / MovementSpeed;

                    InstructionManager.MoveToAccurate(this, desiredX, desiredY, this.Z, timeToTake);
                    isMovingToTile = true;

                    this.Call(() =>
                    {
                        this.isMovingToTile        = false;
                        BackwardCollision.Position = this.Position;
                        UpdateActionCollision();
                    }).After(timeToTake);

                    movedNewDirection = true;
                }
            }

            return(movedNewDirection);
        }