void advance(Enemy monster) // go toward player
        {
            PathFind pf          = new PathFind(game_state);
            int      mons_tile_x = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            int      mons_tile_y = (monster.getY() + (monster.getHeight())) / game_state.tile_engine.getTileSize();
            int      pl_tile_x   = (game_state.local_player.getX() + (game_state.local_player.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            int      pl_tile_y   = (game_state.local_player.getY() + (game_state.local_player.getHeight())) / game_state.tile_engine.getTileSize();

            monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, pl_tile_x, pl_tile_y));
        }
Exemplo n.º 2
0
        void advance(Enemy monster)
        {
            PathFind pf          = new PathFind(game_state);
            int      mons_tile_x = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            int      mons_tile_y = (monster.getY() + (monster.getHeight())) / game_state.tile_engine.getTileSize();
            int      pl_tile_x   = (game_state.local_player.getX() + (game_state.local_player.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            int      pl_tile_y   = (game_state.local_player.getY() + (game_state.local_player.getHeight())) / game_state.tile_engine.getTileSize();

            // pl_tile_y += 1;//get the enemies to head toward the bottom of the player so that they follow you on the bridge
            monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, pl_tile_x, pl_tile_y));
        }
        void align(Enemy monster)
        {
            PathFind pf          = new PathFind(game_state);
            int      dist_x      = game_state.local_player.getX() - monster.getX();
            int      dist_y      = game_state.local_player.getY() - monster.getY();
            int      mons_tile_x = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            int      mons_tile_y = (monster.getY() + (monster.getHeight() / 2)) / game_state.tile_engine.getTileSize();
            int      pl_tile_x   = game_state.local_player.getX() / game_state.tile_engine.getTileSize();
            int      pl_tile_y   = game_state.local_player.getY() / game_state.tile_engine.getTileSize();


            if (Math.Abs(dist_x) < Math.Abs(dist_y))
            {
                //Advance in the X direction toward the player
                monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, pl_tile_x, mons_tile_y));
            }
            else
            {
                //Advance in the Y direction toward the player
                monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_x, pl_tile_y - 1));
            }
        }
Exemplo n.º 4
0
        void idle(Enemy monster)
        {
            //THIS IS FOR DEBUG PURPOSES
            //PathFind pf = new PathFind(game_state);
            //int mons_tile_x = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            //int mons_tiel_y = (monster.getY() + (monster.getHeight())) / game_state.tile_engine.getTileSize();
            //monster.setPath(pf.FindPath(mons_tile_x, mons_tiel_y, 1, 1));

            PathFind pf           = new PathFind(game_state);
            int      mons_tile_x  = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            int      mons_tile_y  = (monster.getY() + (monster.getHeight() / 2)) / game_state.tile_engine.getTileSize();
            Random   r            = new Random();
            int      mons_tile_xr = mons_tile_x + r.Next(-10, 10);
            int      mons_tile_yr = mons_tile_y + r.Next(-10, 10);

            if (mons_tile_yr < 0)
            {
                mons_tile_yr = 0;
            }
            if (mons_tile_xr < 0)
            {
                mons_tile_xr = 0;
            }
            monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));

            /*
             * //Random number
             * System.Random generator = new System.Random();
             * int dir = generator.Next(4);
             * switch ((PlayerDir)dir)
             * {
             *  case PlayerDir.DOWN:
             *      monster.setY(monster.getY() + monster.getSpeed());
             *      monster.setDirection(PlayerDir.DOWN);
             *      break;
             *  case PlayerDir.LEFT:
             *      monster.setX(monster.getX() - monster.getSpeed());
             *      monster.setDirection(PlayerDir.LEFT);
             *      break;
             *  case PlayerDir.RIGHT:
             *      monster.setX(monster.getX() + monster.getSpeed());
             *      monster.setDirection(PlayerDir.RIGHT);
             *      break;
             *  case PlayerDir.UP:
             *      monster.setY(monster.getY() - monster.getSpeed());
             *      monster.setDirection(PlayerDir.UP);
             *      break;
             * }
             * */
        }
        void idle(Enemy monster) // dont do anything
        {
            PathFind pf           = new PathFind(game_state);
            int      mons_tile_x  = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            int      mons_tile_y  = (monster.getY() + (monster.getHeight() / 2)) / game_state.tile_engine.getTileSize();
            Random   r            = new Random();
            int      mons_tile_xr = mons_tile_x + r.Next(-10, 10);
            int      mons_tile_yr = mons_tile_y + r.Next(-10, 10);

            if (mons_tile_yr < 0)
            {
                mons_tile_yr = 0;
            }
            if (mons_tile_xr < 0)
            {
                mons_tile_xr = 0;
            }
            monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
        }
Exemplo n.º 6
0
        //Functions to calculate actions
        void flee(Enemy monster)
        {
            PathFind pf           = new PathFind(game_state);
            int      dist_x       = game_state.local_player.getX() - monster.getX();
            int      dist_y       = game_state.local_player.getY() - monster.getY();
            int      mons_tile_x  = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            int      mons_tile_y  = (monster.getY() + (monster.getHeight() / 2)) / game_state.tile_engine.getTileSize();
            int      pl_tile_x    = game_state.local_player.getX() / game_state.tile_engine.getTileSize();
            int      pl_tile_y    = game_state.local_player.getY() / game_state.tile_engine.getTileSize();
            Random   r            = new Random();
            int      mons_tile_xr = mons_tile_x;
            int      mons_tile_yr = mons_tile_y;

            //int pl_tile_yr = pl_tile_y + r.Next(-5, 5);
            //int pl_tile_xr = pl_tile_x + r.Next(-5, 5);
            if (Math.Abs(dist_x) < Math.Abs(dist_y))
            {
                //Flee in the Y direction from the player
                if (dist_y <= 0)
                {
                    mons_tile_yr += r.Next(-5, -10);
                    mons_tile_xr += r.Next(-10, 10);
                    if (mons_tile_yr < 0)
                    {
                        mons_tile_yr = 0;
                    }
                    if (mons_tile_xr < 0)
                    {
                        mons_tile_xr = 0;
                    }
                    monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
                }
                else
                {
                    mons_tile_yr += r.Next(5, 10);
                    mons_tile_xr += r.Next(-10, 10);
                    if (mons_tile_yr < 0)
                    {
                        mons_tile_yr = 0;
                    }
                    if (mons_tile_xr < 0)
                    {
                        mons_tile_xr = 0;
                    }
                    monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
                }
            }
            else
            {
                //Flee in the x direction from the player
                if (dist_x <= 0)
                {
                    mons_tile_yr += r.Next(-10, 10);
                    mons_tile_xr += r.Next(5, 10);
                    if (mons_tile_yr < 0)
                    {
                        mons_tile_yr = 0;
                    }
                    if (mons_tile_xr < 0)
                    {
                        mons_tile_xr = 0;
                    }
                    monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
                }
                else
                {
                    mons_tile_yr += r.Next(-10, 10);
                    mons_tile_xr += r.Next(5, 10);
                    if (mons_tile_yr < 0)
                    {
                        mons_tile_yr = 0;
                    }
                    if (mons_tile_xr < 0)
                    {
                        mons_tile_xr = 0;
                    }
                    monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
                }
                monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
            }

            //monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
        }
Exemplo n.º 7
0
        void idle(Enemy monster)
        {
            //THIS IS FOR DEBUG PURPOSES
            //PathFind pf = new PathFind(game_state);
            //int mons_tile_x = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            //int mons_tiel_y = (monster.getY() + (monster.getHeight())) / game_state.tile_engine.getTileSize();
            //monster.setPath(pf.FindPath(mons_tile_x, mons_tiel_y, 1, 1));

            PathFind pf = new PathFind(game_state);
            int mons_tile_x = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            int mons_tile_y = (monster.getY() + (monster.getHeight() / 2)) / game_state.tile_engine.getTileSize();
            Random r = new Random();
            int mons_tile_xr = mons_tile_x + r.Next(-10, 10);
            int mons_tile_yr = mons_tile_y + r.Next(-10, 10);
            if (mons_tile_yr < 0)
                mons_tile_yr = 0;
            if (mons_tile_xr < 0)
                mons_tile_xr = 0;
            monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));

            /*
            //Random number
            System.Random generator = new System.Random();
            int dir = generator.Next(4);
            switch ((PlayerDir)dir)
            {
                case PlayerDir.DOWN:
                    monster.setY(monster.getY() + monster.getSpeed());
                    monster.setDirection(PlayerDir.DOWN);
                    break;
                case PlayerDir.LEFT:
                    monster.setX(monster.getX() - monster.getSpeed());
                    monster.setDirection(PlayerDir.LEFT);
                    break;
                case PlayerDir.RIGHT:
                    monster.setX(monster.getX() + monster.getSpeed());
                    monster.setDirection(PlayerDir.RIGHT);
                    break;
                case PlayerDir.UP:
                    monster.setY(monster.getY() - monster.getSpeed());
                    monster.setDirection(PlayerDir.UP);
                    break;
            }
             * */
        }
Exemplo n.º 8
0
        //Functions to calculate actions
        void flee(Enemy monster)
        {
            PathFind pf = new PathFind(game_state);
            int dist_x = game_state.local_player.getX() - monster.getX();
            int dist_y = game_state.local_player.getY() - monster.getY();
            int mons_tile_x = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            int mons_tile_y = (monster.getY() + (monster.getHeight() / 2)) / game_state.tile_engine.getTileSize();
            int pl_tile_x = game_state.local_player.getX() / game_state.tile_engine.getTileSize();
            int pl_tile_y = game_state.local_player.getY() / game_state.tile_engine.getTileSize();
            Random r = new Random();
            int mons_tile_xr = mons_tile_x;
            int mons_tile_yr = mons_tile_y;
            //int pl_tile_yr = pl_tile_y + r.Next(-5, 5);
            //int pl_tile_xr = pl_tile_x + r.Next(-5, 5);
            if (Math.Abs(dist_x) < Math.Abs(dist_y))
            {
                //Flee in the Y direction from the player
                if (dist_y <= 0)
                {
                    mons_tile_yr += r.Next(-10, -5);
                    mons_tile_xr += r.Next(-10, 10);
                    if (mons_tile_yr < 0)
                        mons_tile_yr = 0;
                    if (mons_tile_xr < 0)
                        mons_tile_xr = 0;
                    monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
                }
                else
                {
                    mons_tile_yr += r.Next(5, 10);
                    mons_tile_xr += r.Next(-10, 10);
                    if (mons_tile_yr < 0)
                        mons_tile_yr = 0;
                    if (mons_tile_xr < 0)
                        mons_tile_xr = 0;
                    monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
                }
            }
            else
            {
                //Flee in the x direction from the player
                if (dist_x <= 0)
                {
                    mons_tile_yr += r.Next(-10, 10);
                    mons_tile_xr += r.Next(5, 10);
                    if (mons_tile_yr < 0)
                        mons_tile_yr = 0;
                    if (mons_tile_xr < 0)
                        mons_tile_xr = 0;
                    monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
                }
                else
                {
                    mons_tile_yr += r.Next(-10, 10);
                    mons_tile_xr += r.Next(5, 10);
                    if (mons_tile_yr < 0)
                        mons_tile_yr = 0;
                    if (mons_tile_xr < 0)
                        mons_tile_xr = 0;
                    monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
                }
                monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
            }

            //monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
        }
Exemplo n.º 9
0
        void align(Enemy monster)
        {
            PathFind pf = new PathFind(game_state);
            int dist_x = game_state.local_player.getX() - monster.getX();
            int dist_y = game_state.local_player.getY() - monster.getY();
            int mons_tile_x = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
            int mons_tile_y = (monster.getY() + (monster.getHeight() / 2)) / game_state.tile_engine.getTileSize();
            int pl_tile_x = game_state.local_player.getX() / game_state.tile_engine.getTileSize();
            int pl_tile_y = game_state.local_player.getY() / game_state.tile_engine.getTileSize();

            if (Math.Abs(dist_x) < Math.Abs(dist_y))
            {
                //Advance in the X direction toward the player

                monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, pl_tile_x, mons_tile_y));
            }
            else
            {
                //Advance in the Y direction toward the player

                monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_x, pl_tile_y-1));
            }
        }
Exemplo n.º 10
0
 void advance(Enemy monster)
 {
     PathFind pf = new PathFind(game_state);
     int mons_tile_x = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
     int mons_tile_y = (monster.getY() + (monster.getHeight())) / game_state.tile_engine.getTileSize();
     int pl_tile_x = (game_state.local_player.getX()+(game_state.local_player.getWidth()/2))/game_state.tile_engine.getTileSize();
     int pl_tile_y = (game_state.local_player.getY()+(game_state.local_player.getHeight()))/game_state.tile_engine.getTileSize();
        // pl_tile_y += 1;//get the enemies to head toward the bottom of the player so that they follow you on the bridge
     monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, pl_tile_x, pl_tile_y));
 }
Exemplo n.º 11
0
 // dont do anything
 void idle(Enemy monster)
 {
     PathFind pf = new PathFind(game_state);
     int mons_tile_x = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
     int mons_tile_y = (monster.getY() + (monster.getHeight() / 2)) / game_state.tile_engine.getTileSize();
     Random r = new Random();
     int mons_tile_xr = mons_tile_x + r.Next(-10, 10);
     int mons_tile_yr = mons_tile_y + r.Next(-10, 10);
     if (mons_tile_yr < 0)
         mons_tile_yr = 0;
     if (mons_tile_xr < 0)
         mons_tile_xr = 0;
     monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, mons_tile_xr, mons_tile_yr));
 }
Exemplo n.º 12
0
 // go toward player
 void advance(Enemy monster)
 {
     PathFind pf = new PathFind(game_state);
     int mons_tile_x = (monster.getX() + (monster.getWidth() / 2)) / game_state.tile_engine.getTileSize();
     int mons_tile_y = (monster.getY() + (monster.getHeight())) / game_state.tile_engine.getTileSize();
     int pl_tile_x = (game_state.local_player.getX()+(game_state.local_player.getWidth()/2))/game_state.tile_engine.getTileSize();
     int pl_tile_y = (game_state.local_player.getY()+(game_state.local_player.getHeight()))/game_state.tile_engine.getTileSize();
     monster.setPath(pf.FindPath(mons_tile_x, mons_tile_y, pl_tile_x, pl_tile_y));
 }