Beispiel #1
0
    public override void Move()
    {
        time_start += Time.deltaTime;

        if (time_start >= 1.0f)
        {
            time_start = 0;
            switch (dir)
            {
            case CurrentDirection.Horizontal:
                vertical_dir = -vertical_dir;
                dir          = CurrentDirection.Vertical;
                break;

            case CurrentDirection.Vertical:
                dir = CurrentDirection.Horizontal;
                break;
            }
        }

        switch (dir)
        {
        case CurrentDirection.Horizontal:
            base.Move();
            break;

        case CurrentDirection.Vertical:
            mPosition.y       += mVelocity.y * mSpeed.y * Time.deltaTime * vertical_dir;
            mPosition.x        = transform.position.x;
            transform.position = mPosition;
            break;
        }
    }
Beispiel #2
0
        private void moveGhost()
        {
            // on deplace le fantome
            switch (CurrentDirection.ToEnum())
            {
            case DirectionEnum.Up:
                Y -= Constants.GRID_HEIGHT_4;
                break;

            case DirectionEnum.Right:
                X += Constants.GRID_WIDTH_4;
                if (X >= (Labyrinth.WIDTH * Constants.GRID_HEIGHT + Constants.GRID_WIDTH_X2))
                {
                    X = -Constants.GRID_WIDTH_X2;
                }
                break;

            case DirectionEnum.Down:
                Y += Constants.GRID_HEIGHT_4;
                break;

            case DirectionEnum.Left:
                X -= Constants.GRID_WIDTH_4;
                if (X <= -Constants.GRID_WIDTH_X2)
                {
                    X = (Labyrinth.WIDTH * Constants.GRID_WIDTH + Constants.GRID_WIDTH_X2);
                }
                break;
            }
        }
Beispiel #3
0
    void CreateFirstLayout()
    {
        int randomNum = Random.Range(0, LevelGenerator.upwardPossibilities.Length);
        CurrentDirection randomDirection = LevelGenerator.upwardPossibilities[randomNum];
        GameObject       firstLayout     = Instantiate(GameAssets.i.GetDesiredLevelLayout(CurrentDirection.UP, levelType).levelLayOutPrefab, new Vector3(firstLayoutPos.transform.position.x, firstLayoutPos.transform.position.y), Quaternion.identity);
        Transform        pivotAnchor     = firstLayout.transform.Find("PivotAnchor").transform;
        GameObject       generator       = pivotAnchor.Find("LevelGenerator").transform.gameObject;
        LevelGenerator   firstGenerator  = generator.GetComponent <LevelGenerator>();
        //firstGenerator.AdjustLayoutSizes();
        Transform positionBeforeSettingActive = pivotAnchor.GetComponentInChildren <LevelGenerator>().nextLayoutAnchor.transform;

        generator.SetActive(false);
        pivotAnchor.transform.position = firstLayout.transform.position;
        GameObject secondLayout = Instantiate(GameAssets.i.GetDesiredLevelLayout(randomDirection, levelType).levelLayOutPrefab, new Vector3(firstLayoutPos.transform.position.x, firstLayoutPos.transform.position.y), Quaternion.identity);
        Transform  pivotAnchor2 = secondLayout.transform.Find("PivotAnchor").transform;

        pivotAnchor2.transform.position = positionBeforeSettingActive.position;
        LevelGenerator levelGenerator = secondLayout.GetComponentInChildren <LevelGenerator>();

        levelGenerator.borderCollider.size = new Vector2(levelGenerator.borderCollider.size.x, levelGenerator.borderCollider.size.y + 30f);


        //////////////////
        GameObject backgroundFirstLayer = pivotAnchor.transform.Find("BrownBackground").gameObject;

        for (int i = 0; i < backgroundFirstLayer.transform.childCount; i++)
        {
            backgroundFirstLayer.transform.GetChild(i).GetComponent <SpriteRenderer>().sortingOrder += -10;
        }
    }
Beispiel #4
0
        /// <see cref="IForwardMoveCommand.TryMoveForward(int)"/>
        public bool TryMoveForward(int steps)
        {
            PerformValidationBeforeMove(steps);

            Position newPosition = CurrentDirection.MoveForward(CurrentPosition);

            return(TryMoveChessPiece(newPosition));
        }
Beispiel #5
0
 private void OnMazeChange(CurrentDirection current)
 {
     hasShownCurrentPrompt = true;
     HideInteractionPrompt();
     currentMaze = (currentMaze + (current == CurrentDirection.DOWN ? 1 : mazeLevels.Length - 1)) % mazeLevels.Length;
     SetCurrentMazeActive();
     SetLightRadius();
 }
Beispiel #6
0
        /// <summary>
        /// Applies sequential command.
        /// </summary>
        /// <param name="commands">Rover.Commands.L, Rover.Commands.M, ...</param>
        /// <returns>CurrentX, CurrentY, CurrentDirection</returns>
        public (int, int, Direction) Execute(params Commands[] commands)
        {
            foreach (Commands command in commands)
            {
                switch (command)
                {
                case Commands.R:
                    CurrentDirection++;
                    break;

                case Commands.L:
                    CurrentDirection--;
                    break;

                case Commands.M:
                    switch (CurrentDirection.ToValue())
                    {
                    case Direction.Values.N:
                        if (CurrentY < BoundaryY)
                        {
                            CurrentY++;
                        }
                        break;

                    case Direction.Values.E:
                        if (CurrentX < BoundaryX)
                        {
                            CurrentX++;
                        }
                        break;

                    case Direction.Values.S:
                        if (CurrentY > 0)
                        {
                            CurrentY--;
                        }
                        break;

                    case Direction.Values.W:
                        if (CurrentX > 0)
                        {
                            CurrentX--;
                        }
                        break;

                    default:
                        break;
                    }
                    break;

                default:
                    break;
                }
            }

            return(CurrentX, CurrentY, CurrentDirection);
        }
Beispiel #7
0
        public void MoveFoward()
        {
            Coordinates newCoordinates = CurrentDirection.MoveFrom(CurrentPosition);

            if (grid.IsWithinGrid(newCoordinates))
            {
                CurrentPosition = newCoordinates;
            }
        }
Beispiel #8
0
        /// <summary>
        ///     Moves the specified blocks.
        /// </summary>
        /// <param name="blocks">The blocks.</param>
        private void Move(int blocks)
        {
            // Store starting point.
            string startPoint = Coordinates();

            for (var i = 0; i < blocks; i++)
            {
                // Move 1 block at a time - required for Part 2
                int x = CurrentPoint.X;
                int y = CurrentPoint.Y;
                switch (CurrentDirection)
                {
                case Direction.East:
                    x++;
                    break;

                case Direction.West:
                    x--;
                    break;

                case Direction.North:
                    y++;
                    break;

                case Direction.South:
                    y--;
                    break;

                default:
                    Console.WriteLine(
                        $"Huh? It seems that you're trying to move in a non-standard direction. ({CurrentDirection})");
                    break;
                }

                // Set current position.
                CurrentPoint = new Point(x, y);

                // If there are any points in our log of previously visited points (X and Y coordinates match),
                // and we have not found a previously-visited block, set this block as our first revisited block.
                if (Points.Any(point => CurrentPoint.X == point.X && CurrentPoint.Y == point.Y) &&
                    FirstRevisitedPoint.X == 0 &&
                    FirstRevisitedPoint.Y == 0)
                {
                    FirstRevisitedPoint = CurrentPoint;
                }

                // Add the current point to our log of positions.
                Points.Add(CurrentPoint);
            }

            // Add the current movement to our log.
            Sb.AppendLine(string.Join(",", CurrentDirection.ToString(), blocks.ToString(), CurrentPoint.X.ToString(),
                                      CurrentPoint.Y.ToString()));
            Console.WriteLine(
                $"Travelled {blocks.ToString().PadLeft(6)} blocks {CurrentDirection.ToString().PadRight(10)} from {startPoint.PadRight(5)} to {Coordinates().PadRight(8)}");
        }
        public override void Update(GameTime gameTime, Level level)
        {
            base.Update(gameTime, level);
            if (Parent == null)
            {
                return;
            }

            var lookDirection = VectorHelper.AngleToV2(Angle + (float)(Math.PI / 2), 1);

            Position = Parent.CenterPosition + lookDirection * new Vector2(15);

            foreach (var ent in GetCollisionRects().SelectMany(e => level.CollidesWith(e, true)).Distinct())
            {
                if (ent is Arrow && ((Arrow)ent).HitEntity == null)
                {
                    ent.CurrentDirection = CurrentDirection.Rotate(-_swingedAngle / 4).Normalized();
                    ent.Parent           = Parent;
                }
                else if (ent != this && ent != Parent && (ent.Health != null || ent is Boomerang))
                {
                    var direction = VectorHelper.AngleToV2(Angle, 5);
                    direction = new Vector2(-direction.Y, direction.X);

                    ent.Hit(this, gameTime, level, direction);
                }
            }

            if (!_rotationCompleted || _keepRotating > 0)
            {
                var oldAngle = _swingedAngle;
                _swingedAngle += (float)(_swingDirection * _swingSpeed * gameTime.ElapsedGameTime.TotalMilliseconds / 1000);

                if (!_rotationCompleted && (_swingDirection > 0 == _swingedAngle > 0))
                {
                    _rotationCompleted = true;
                    if (!_removeOnComplete)
                    {
                        _swingedAngle = 0;
                    }
                }

                if (_rotationCompleted)
                {
                    _keepRotating--;
                    if (_removeOnComplete && _keepRotating <= 0)
                    {
                        level.RemoveEntity(this);
                        _removeOnComplete = false;
                    }
                }
            }

            Angle = _desiredAngle + _swingedAngle;
            Parent.Look(lookDirection, updateDirection: false);
        }
Beispiel #10
0
 /// <summary>
 /// Halts movement.
 /// </summary>
 /// <seealso cref="Resume"/>
 public void Wait()
 {
     _allowedDirections    = AllowReverse ? new Utility.EDirection4[2] : new Utility.EDirection4[1];
     _allowedDirections[0] = CurrentDirection;
     if (AllowReverse)
     {
         _allowedDirections[1] = CurrentDirection.Opposite();
     }
     CurrentDirection = Utility.EDirection4.None;
 }
Beispiel #11
0
        /// <see cref="IDiagonalForwardMoveCommand.TryMoveDiagonalRightForward(int)"/>
        public bool TryMoveDiagonalRightForward(int steps)
        {
            PerformValidationBeforeMove(steps);

            Position newPosition = CurrentDirection.MoveForward(CurrentPosition);

            newPosition = CurrentDirection.MoveRight(newPosition);

            return(Capture(newPosition));
        }
Beispiel #12
0
 public string Report()
 {
     try
     {
         return("Output: " + XPosition + "," + YPosition + "," + CurrentDirection.ToString());
     }
     catch (Exception ex)
     {
         //TODO : Exception to be logged
         return(UNKNOWN_ERROR);
     }
 }
Beispiel #13
0
        public void ChangeDirection_Direction11_ShouldReturnNextDirection()
        {
            // Arrange
            CurrentDirection direction = new CurrentDirection(1, 1);

            // Act
            Directions.ChangeDirection(direction);
            CurrentDirection expectedDirection = new CurrentDirection(1, 0);

            // Assert
            Assert.IsTrue(expectedDirection.X == direction.X && expectedDirection.Y == direction.Y);
        }
Beispiel #14
0
    /**
     *  Sets direction to a new direction. This changes the path of the ghosts.
     */
    void SetCurrentDirection()
    {
        canMove = false;
        CurrentDirection newDir = GetRandDirection();

        while (newDir == direction)
        {
            newDir = GetRandDirection();
        }
        direction = newDir;
        DetermineNextDirection();
        canMove = true;
    }
Beispiel #15
0
 void SetThisLevelTypeDirection()
 {
     if (transform.parent.parent.tag == "UpLayout")
     {
         thisLevelDirection = CurrentDirection.UP;
     }
     else if (transform.parent.parent.tag == "LeftLayout")
     {
         thisLevelDirection = CurrentDirection.LEFT;
     }
     else if (transform.parent.parent.tag == "RightLayout")
     {
         thisLevelDirection = CurrentDirection.RIGHT;
     }
 }
Beispiel #16
0
    public LevelLayouts GetCorrectOrRandomDirectionLayout(CurrentDirection direction, LevelType type)
    {
        List <LevelLayouts> possibleLayout = new List <LevelLayouts>();

        foreach (LevelLayouts obj in levelLayoutsAArray)
        {
            if (obj.direction == direction && obj.type == type)
            {
                possibleLayout.Add(obj);
            }
        }
        int randomNum = Random.Range(0, possibleLayout.Count);

        return(possibleLayout[randomNum]);
    }
Beispiel #17
0
    // Start is called before the first frame update

    /**
     *  Upon start, this sets the initial position and direction for the ghost
     */
    void Start()
    {
        destination = GetFirstDestination();
        if (Random.Range(0, 2) > 0)
        {
            direction = CurrentDirection.left;
            DetermineNextDirection();
        }
        else
        {
            direction = CurrentDirection.right;
            DetermineNextDirection();
        }
        canMove = true;
    }
Beispiel #18
0
        public override void Switch()
        {
            BaseTrack temp = NextTrack;

            NextTrack       = SecondNextTrack;
            SecondNextTrack = temp;

            if (CurrentDirection.Equals(Direction.UP))
            {
                CurrentDirection = Direction.DOWN;
            }
            else
            {
                CurrentDirection = Direction.UP;
            }
        }
Beispiel #19
0
        /// <summary>
        /// Causes this Entity to being walking in the given direction, either Left or Right.
        /// Walking may then be stopped through the StopWalking method.
        /// </summary>
        public void BeginWalking(Direction dir)
        {
            if (dir != Direction.Left && dir != Direction.Right)
            {
                throw new ArgumentException("Walk only applies to the Left and Right directions.");
            }

            _WalkDirection   = dir;
            CurrentDirection = _WalkDirection;
            IsWalking        = true;
            var Animation = SpriteComponent.Sprite.Animations["Walk" + CurrentDirection.ToString()];

            if (SpriteComponent.Sprite.ActiveAnimation != Animation)
            {
                SpriteComponent.Sprite.PlayAnimation(Animation.Name);
            }
        }
Beispiel #20
0
        public override void Switch()
        {
            BaseTrack previousTrack = null;

            PreviousTracks.TryGetValue(CurrentDirection, out previousTrack);

            if (CurrentDirection.Equals(Direction.UP))
            {
                CurrentDirection = Direction.DOWN;
            }
            else
            {
                CurrentDirection = Direction.UP;
            }

            PreviousTracks.TryGetValue(CurrentDirection, out previousTrack);
            previousTrack.NextTrack = this; //Tell track in current direction it has a next track        }
        }
Beispiel #21
0
        private int getYeuxNum()
        {
            int res = 9;

            switch (CurrentDirection.ToEnum())
            {
            case DirectionEnum.Up:
                res = 10;
                break;

            case DirectionEnum.Right:
                res = 9;
                break;

            case DirectionEnum.Down:
                res = 12;
                break;

            case DirectionEnum.Left:
                res = 11;
                break;
            }
            return(res);
        }
 //
 public CurrentDirection CheckDirection(Vector3 analogDirection)
 {
     if (analogDirection.z >= 0.9f)
     {
         currentDirection = CurrentDirection.Up;
     }
     else if (analogDirection.z <= -0.9f)
     {
         currentDirection = CurrentDirection.Down;
     }
     else if (analogDirection.x <= -0.9f)
     {
         currentDirection = CurrentDirection.Left;
     }
     else if (analogDirection.x >= 0.9f)
     {
         currentDirection = CurrentDirection.Right;
     }
     else
     {
         currentDirection = CurrentDirection.Neutral;
     }
     return(currentDirection);
 }
Beispiel #23
0
 public override string ToString()
 {
     return(string.Format("{0}\n{1}", CurrentPosition, CurrentDirection.ToStringDirection()));
 }
Beispiel #24
0
 public void RightTurn()
 {
     CurrentDirection = CurrentDirection.OneStepRight();
 }
Beispiel #25
0
 public void LeftTurn()
 {
     CurrentDirection = CurrentDirection.OneStepLeft();
 }
Beispiel #26
0
 public LevelLayouts GetDesiredLevelLayout(CurrentDirection direction, LevelType type)
 {
     return(GetCorrectOrRandomDirectionLayout(direction, type));
 }
Beispiel #27
0
 public override string ToString()
 {
     return($"{CurrentLocation.ToString()} {CurrentDirection.ToString()}");
 }
Beispiel #28
0
        private void RealFishMove(GameTime gt, List <Items.FoodPellet> pList)
        {
            hungerTimer -= gt.ElapsedGameTime.TotalSeconds;

            if (closestPellet != null && closestPellet._CurrentState == SpriteState.kStateInActive)
            {
                closestPellet = null;
                fishStatus    = FishStatus.kStatusRoam;
            }
            if (hungerTimer < 0)
            {
                Hunger++;
                hungerTimer = 0.5f;
                if (fishStatus == FishStatus.kStatusRoam)
                {
                    if (hunger > 40)
                    {
                        fishStatus = FishStatus.kStatusFood;
                    }
                }
            }
            if (fishStatus == FishStatus.kStatusRoam)
            {
                moveTimer -= gt.ElapsedGameTime.TotalSeconds;

                if (moveTimer <= 0)
                {
                    moving = true;
                    Random ran = new Random();

                    moveTimer = ran.Next(0, 8);


                    targetPos.X = ran.Next(10, 750);
                    targetPos.Y = ran.Next(85, 450);
                }
            }
            else if (fishStatus == FishStatus.kStatusFood)
            {
                if (pList.FindAll(x => x._CurrentState == SpriteState.kStateActive).Count > 0)
                {
                    float closestDistance = 100000;
                    foreach (Items.FoodPellet p in pList.FindAll(x => x._CurrentState == SpriteState.kStateActive))
                    {
                        //find closest pellet.
                        if (p._Position.Y < 70)
                        {
                            continue;
                        }
                        float currentDistance = Vector2.Distance(this.FishMouth.Location.ToVector2(), p._Position);
                        if (currentDistance < closestDistance)
                        {
                            closestPellet   = p;
                            closestDistance = currentDistance;
                        }
                    }
                }

                if (closestPellet != null)
                {
                    targetPos = closestPellet._Position;
                    moving    = true;



                    if (closestPellet._CurrentState == SpriteState.kStateInActive || closestPellet._Position.Y < 70)
                    {
                        moving = false;
                        if (_FlipX)
                        {
                            MyDir = CurrentDirection.kDirectionLeft;
                        }
                        else
                        {
                            MyDir = CurrentDirection.kDirectionRight;
                        }
                    }
                    if (closestPellet._BoundingBox.Intersects(this.FishMouth))
                    {
                        closestPellet.Deactivate();
                        closestPellet  = null;
                        Hunger        -= 50;
                        moving         = false;
                        fishStatus     = FishStatus.kStatusRoam;
                        this._Scale.X += 0.3f;
                        this._Scale.Y += 0.3f;

                        if (this._Scale.X > 2.0f)
                        {
                            this._Scale.X = 2.0f;
                            this._Scale.Y = 2.0f;
                        }
                    }
                }
                else
                {
                    fishStatus = FishStatus.kStatusRoam;
                }
            }
            //else if(fishStatus == FishStatus.kStatusDead)
            //{
            //    this._Rotation = MathHelper.ToRadians(180);
            //    if(this._Position.Y > 70)
            //    {
            //        float speed = 100f;
            //        this._Position.Y -= (float)(speed * gt.ElapsedGameTime.TotalSeconds);
            //    }
            //}

            //if (InputHelper.LeftButtonClicked)
            //{
            //    moving = true;
            //    targetPos = InputHelper.MouseScreenPos;
            //}

            //if(Hunger >= 100)
            //{
            //    this.fishStatus = FishStatus.kStatusDead;
            //}

            if (moving)
            {
                float speed = 100f;


                if (Math.Abs((this.FishMouth.Location.ToVector2().X - targetPos.X)) > 5)
                {
                    if (this.FishMouth.Location.ToVector2().X < targetPos.X)
                    {
                        this._Position.X += speed * (float)gt.ElapsedGameTime.TotalSeconds;


                        if (Math.Abs((this.FishMouth.Location.ToVector2().X - targetPos.X)) > 20)
                        {
                            this._FlipX = false;
                            MyDir       = CurrentDirection.kDirectionRight;
                        }
                    }
                    else if (this.FishMouth.Location.ToVector2().X > targetPos.X)
                    {
                        this._Position.X -= speed * (float)gt.ElapsedGameTime.TotalSeconds;
                        if (Math.Abs((this.FishMouth.Location.ToVector2().X - targetPos.X)) > 20)
                        {
                            this._FlipX = true;
                            MyDir       = CurrentDirection.kDirectionLeft;
                        }
                    }
                }


                if (Math.Abs((this.FishMouth.Location.ToVector2().Y - targetPos.Y)) > 5)
                {
                    if (this.FishMouth.Location.ToVector2().Y < targetPos.Y)
                    {
                        this._Position.Y += speed * (float)gt.ElapsedGameTime.TotalSeconds;

                        if (Math.Abs((this.FishMouth.Location.ToVector2().Y - targetPos.Y)) > 15)
                        {
                            if (_FlipX)
                            {
                                //this._Rotation = MathHelper.ToRadians(-45);
                                MyDir = CurrentDirection.kDirectionLeft;
                            }
                            else
                            {
                                //this._Rotation = MathHelper.ToRadians(45);
                                MyDir = CurrentDirection.kDirectionRight;
                            }
                        }
                    }
                    else if (this.FishMouth.Location.ToVector2().Y > targetPos.Y)
                    {
                        this._Position.Y -= speed * (float)gt.ElapsedGameTime.TotalSeconds;


                        if (Math.Abs((this.FishMouth.Location.ToVector2().Y - targetPos.Y)) > 15)
                        {
                            if (_FlipX)
                            {
                                //this._Rotation = MathHelper.ToRadians(45);
                                MyDir = CurrentDirection.kDirectionLeft;
                            }
                            else
                            {
                                //this._Rotation = MathHelper.ToRadians(-45);
                                MyDir = CurrentDirection.kDirectionRight;
                            }
                        }
                    }
                }
                else
                {
                    this._Rotation = 0;
                }


                if (Vector2.Distance(this.FishMouth.Location.ToVector2(), targetPos) < 10)
                {
                    moving         = false;
                    this._Rotation = 0;

                    if (_FlipX)
                    {
                        MyDir = CurrentDirection.kDirectionLeft;
                    }
                    else
                    {
                        MyDir = CurrentDirection.kDirectionRight;
                    }
                }
            }


            if (closestPellet != null)
            {
                pelletLastFrame = true;
            }
            else
            {
                pelletLastFrame = false;
            }
        }
Beispiel #29
0
        private void DebugMove()
        {
            this._Rotation = 0;
            if (InputHelper.IsKeyDown(Keys.Left))
            {
                _FlipX = true;
                if (InputHelper.IsKeyDown(Keys.Down))
                {
                    //this._Rotation = MathHelper.ToRadians(-45);
                    MyDir = CurrentDirection.kDirectionLeft;
                }
                else if (InputHelper.IsKeyDown(Keys.Up))
                {
                    //this._Rotation = MathHelper.ToRadians(45);
                    MyDir = CurrentDirection.kDirectionLeft;
                }
                else
                {
                    MyDir = CurrentDirection.kDirectionLeft;
                }
            }
            else if (InputHelper.IsKeyDown(Keys.Right))
            {
                _FlipX = false;
                if (InputHelper.IsKeyDown(Keys.Up))
                {
                    //this._Rotation = MathHelper.ToRadians(-45);
                    MyDir = CurrentDirection.kDirectionRight;
                }
                else if (InputHelper.IsKeyDown(Keys.Down))
                {
                    //this._Rotation = MathHelper.ToRadians(45);
                    MyDir = CurrentDirection.kDirectionRight;
                }
                else
                {
                    MyDir = CurrentDirection.kDirectionRight;
                }
            }

            if (InputHelper.IsKeyDown(Keys.A))
            {
                this._Scale.X -= 0.03f;
                if (this._Scale.X < 0.1f)
                {
                    this._Scale.X = 0.1f;
                }
            }
            else if (InputHelper.IsKeyDown(Keys.D))
            {
                this._Scale.X += 0.03f;
                if (this._Scale.X > 2f)
                {
                    this._Scale.X = 2f;
                }
            }

            if (InputHelper.IsKeyDown(Keys.W))
            {
                this._Scale.Y -= 0.03f;
                if (this._Scale.Y < 0.1f)
                {
                    this._Scale.Y = 0.1f;
                }
            }
            else if (InputHelper.IsKeyDown(Keys.S))
            {
                this._Scale.Y += 0.03f;
                if (this._Scale.Y > 2f)
                {
                    this._Scale.Y = 2f;
                }
            }

            if (InputHelper.RightButtonClicked)
            {
                this._Position = InputHelper.MouseScreenPos;
            }

            if (InputHelper.IsKeyPressed(Keys.Space))
            {
                this._Scale    = Vector2.One;
                this._Rotation = 0;
            }

            if (InputHelper.IsKeyPressed(Keys.LeftControl))
            {
                this._Scale.X = 0.5f;
                this._Scale.Y = 0.5f;
            }

            //if(InputHelper.IsKeyDown(Keys.R))
            //{
            //    this._Rotation += 0.05f;
            //}
        }
Beispiel #30
0
        /// <summary>
        /// Has the car arrived at its destination?
        /// </summary>
        /// <returns>true if arrived, false if still transitioning.</returns>
        private bool ArrivedDestination()
        {
            bool arrived = false;

            // Are we heading in a direction, but servicing the opposite list (i.e. heading up to service the downList - or vice versa)
            Direction currentListDirection = (CurrentList == upList) ? Direction.up : Direction.down;

            if (currentListDirection != CurrentDirection)
            {
                // We are servicing opposing list / direction case.  We have only arrived if we are at the head of the list.
                if ((CurrentList.Count > 0) && (CurrentList[0] != CurrentFloor))
                {
                    return(arrived);
                }
            }

            if (CurrentList.Contains(CurrentFloor))
            {
                Console.WriteLine("Car is on floor {0}, loading/unloading passengers, and {1}.", CurrentFloor, (CurrentDirection == Direction.idle) ? "is idle" : "is heading " + CurrentDirection.ToString());
                Console.WriteLine("You have {0} seconds to choose your destination.  Otherwise, you may loose your turn.", ElevatorTimer.TheTimer.Interval / 1000);
                CurrentList.Remove(CurrentFloor);
                arrived = true;
            }

            return(arrived);
        }