Beispiel #1
0
        /// <summary>
        /// Moves on the 2D Cartesian coordinates, conversion is on checking and drawing only
        /// </summary>
        /// <param name="direction"></param>
        /// <param name="deltaHorizontal"></param>
        /// <param name="deltaVertical"></param>
        private void Move(Directions direction)
        {
            IndexPair temp = playerCoordinates;

            switch (direction)
            {
            case Directions.Up:
                temp.I--;
                break;

            case Directions.Down:
                temp.I++;
                break;

            case Directions.Left:
                temp.J--;
                break;

            case Directions.Right:
                temp.J++;
                break;

            default:
                break;
            }

            // Wall detection
            if (MapLoader.IsWalkable(temp) || MapLoader.Level[temp.I, temp.J] == 6 || MapLoader.Level[temp.I, temp.J] == 7)
            {
                playerCoordinates = temp;
                playerAnimation.AnimationPosition = temp.IndexesToCorrdinates();
                Direction = direction;
                if (MapLoader.Level[temp.I, temp.J] == 7)
                {
                    ProjectilePool pool = ProjectilePool.Instance;
                    IWeapon        y    = pool.Acquire(Position, false);
                    System.Windows.Forms.MessageBox.Show("Gift");
                }
                if (MapLoader.Level[temp.I, temp.J] == 6)
                {
                    playerCoordinates = temp;
                    playerAnimation.AnimationPosition = temp.IndexesToCorrdinates();
                    Direction = direction;

                    System.Threading.Tasks.Task.Run(() =>
                    {
                        System.Threading.Thread.Sleep(100);
                        Program.MainWindow.RefreshTimer.Enabled = false;
                        System.Windows.Forms.MessageBox.Show("Game Over");
                    });
                }
            }
        }
Beispiel #2
0
        public void Initialize()
        {
            playerCoordinates = MapLoader.PlayerStartLocation;
            playerAnimation = (PlayerAnimation)AnimationFactory.CreateEmpyAnimation(AnimationType.PlayerAnimation);

            // Initialize the player location to the top of the screen
            playerAnimation.AnimationPosition = playerCoordinates.IndexesToCorrdinates();
            playerAnimation.Collider.Collided += Collider_Collided;
            Direction = Directions.Right;
        }
Beispiel #3
0
        public void Initialize()
        {
            playerCoordinates = MapLoader.PlayerStartLocation;
            playerAnimation   = (PlayerAnimation)AnimationFactory.CreateEmpyAnimation(AnimationType.PlayerAnimation);

            // Initialize the player location to the top of the screen
            playerAnimation.AnimationPosition  = playerCoordinates.IndexesToCorrdinates();
            playerAnimation.Collider.Collided += Collider_Collided;
            Direction = Directions.Right;
        }
Beispiel #4
0
        public Monster(IndexPair startPoint, IndexPair endPoint)
        {
            increasing = true;
            counter    = 0;
            AnimationFactory factory = new AnimationFactory();
            IndexPair        temp    = startPoint;

            myPath         = new PathFinder(new RouteInformation(startPoint, endPoint));
            tempPath       = myPath.FindPath();
            timer.Elapsed += Timer_Elapsed;
            timer.Enabled  = true;
            timer.Interval = 250;

            //MapLoader.MonsterStartLocation;
            //monsterAnimation.AnimationTileIndex = new IndexPair(1, 1);//temp.TileIndecies;

            monsterAnimation = (MonsterAnimation)factory.CreateAnimation(AnimationType.MonsterAnimation, tempPath[0]);
            monsterAnimation.AnimationPosition = temp.IndexesToCorrdinates();

            // TODO set Monster start position at game start. TODO set Monster Direction at game start.
            monsterAnimation.Collider.Collided += Monster_Collided;
        }