ArcadeRPG.MonsterEngine.flee C# (CSharp) Метод

flee() приватный Метод

private flee ( ArcadeRPG.Enemy monster ) : void
monster ArcadeRPG.Enemy
Результат void
        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;

            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));
            }
        }