Beispiel #1
0
        static public void diagCheck(ref Point start_pos, Point dir, int vis_max, int cur_dur)
        {
            int   dir1, dir2;
            Point cur_dsqr, cur_vsqr, dir1p, dir2p;

            cur_dsqr = cur_vsqr = Point.Zero;

            dir1       = cur_dur - 1; dir2 = ((cur_dur + 1) >= Globals.NumDirects) ? 0 : (cur_dur + 1);
            dir1p      = Globals.Directions[dir1]; dir2p = Globals.Directions[dir2];
            cur_dsqr.X = start_pos.X + dir.X; cur_dsqr.Y = start_pos.Y + dir.Y;

            GamePlayScreen.clampSqr(ref cur_dsqr);
            rayCheck(ref start_pos, ref cur_dsqr, ref dir, ref dir1p, ref dir2p, vis_max);
        }
Beispiel #2
0
        static public void clearVisible(ref Point char_pos, int vis_max)
        {
            int   row_size  = 33;
            Point start_sqr = new Point(char_pos.X - 17, char_pos.Y - 17);
            Point cur_sqr   = start_sqr;

            for (int r = 0; r < row_size; r++)
            {
                cur_sqr.Y = start_sqr.Y + r;
                for (int c = 0; c < row_size; c++)
                {
                    GamePlayScreen.clampSqr(ref cur_sqr);
                    MapEngine.currMap.MSGrid[cur_sqr.Y][cur_sqr.X].MSStates[(int)MSFlagIndex.VIS_LVL] = MSFlag.NO_VIS;
                    cur_sqr.X = start_sqr.X + c;
                }
            }
        }
Beispiel #3
0
        static public bool linearDirCheck(ref Point start_pos, Point dir, int vis_max, bool break_early)
        {
            bool set_block, blockage;

            set_block = blockage = false;

            Point cur_sqr, block_sqr;

            cur_sqr   = Point.Zero;
            block_sqr = new Point(-1, -1);

            for (int s = 1; s <= vis_max; s++)
            {
                cur_sqr.X = start_pos.X + (s * dir.X); cur_sqr.Y = start_pos.Y + (s * dir.Y);

                GamePlayScreen.clampSqr(ref cur_sqr);
                if (cur_sqr == block_sqr)
                {
                    continue;
                }

                if (MapEngine.currMap.MSGrid[cur_sqr.Y][cur_sqr.X].MSStates[(int)MSFlagIndex.PASSABLE] == MSFlag.BLKD)
                {
                    set_block = true;
                    block_sqr = cur_sqr;
                }

                MapEngine.currMap.MSGrid[(int)cur_sqr.Y][(int)cur_sqr.X].MSStates[(int)MSFlagIndex.VIS_LVL] = (blockage) ? MSFlag.NO_VIS : MSFlag.HIGH_VIS;

                if (set_block)
                {
                    blockage = true;
                }

                if (blockage)
                {
                    if (break_early)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #4
0
        static public void drawLOS()
        {
            List <Point> cur_los_sqrs;

            Point tar_sqr = MapEngine.curMouseSqr;

            GamePlayScreen.clampSqr(ref tar_sqr);

            clearLOS();

            getTargetLOS(GameSession.curPlayer.tilePosition, ref tar_sqr, out cur_los_sqrs);
            if (cur_los_sqrs.Count > 0)
            {
                for (int i = 0; i < cur_los_sqrs.Count; i++)
                {
                    MapEngine.currMap.MSGrid[cur_los_sqrs[i].Y][cur_los_sqrs[i].X].AltColor = new Color(0, 200, 0, 10);
                    prevLOSSqrs.Add(cur_los_sqrs[i]);
                }
            }
        }
Beispiel #5
0
        static public void rayCheck(ref Point start_sqr, ref Point cur_sqr, ref Point diag_dir,
                                    ref Point dir1, ref Point dir2, int vis_max)
        {
            Point cur_dir, new_cur_sqr;
            int   block_c, low_vis_c, vis_max_diag, vis_max_diag_dir_line;

            block_c = low_vis_c = 0;
            bool is_blocked = false;

            cur_dir = new_cur_sqr = Point.Zero;

            vis_max_diag          = (vis_max > 3) ? vis_max - 2 : 1;
            vis_max_diag_dir_line = (vis_max > 3) ? vis_max_diag + 1 : 0;

            for (int v = 0; v < vis_max_diag /*vis_max*/; v++) // (vis_max - vis_count)
            {
                vis_max_diag_dir_line += (-1 * v);
                for (int d = 0; d < 2; d++)
                {
                    cur_dir = (d == 0) ? dir1 : dir2;
                    for (int dv = d; dv < (vis_max_diag_dir_line /*vis_max - v*/); dv++) // (vis_max - vis_count - v)
                    {
                        block_c       = 0;
                        is_blocked    = false;
                        new_cur_sqr.X = (cur_sqr.X + (v * diag_dir.X)) + (dv * cur_dir.X); // CUR TILE TO CHECK
                        new_cur_sqr.Y = (cur_sqr.Y + (v * diag_dir.Y)) + (dv * cur_dir.Y);
                        GamePlayScreen.clampSqr(ref new_cur_sqr);

                        //getCorners(ref new_cur_sqr, ref VecRays); // returns map vectors, in actual pixel (not tile) size
                        is_blocked = isSightBlocked(ref start_sqr, ref new_cur_sqr, ref block_c);

                        if (is_blocked)
                        {
                            MapEngine.currMap.MSGrid[(int)new_cur_sqr.Y][(int)new_cur_sqr.X].MSStates[(int)MSFlagIndex.VIS_LVL] = MSFlag.NO_VIS;
                        }
                        else
                        {
                            if (MapEngine.currMap.MSGrid[(int)new_cur_sqr.Y][(int)new_cur_sqr.X].MSStates[(int)MSFlagIndex.WALL_RM_ENT] == MSFlag.WALL)
                            {
                                low_vis_c = 2;
                            }
                            else
                            {
                                low_vis_c = 1;
                            }

                            if (block_c > low_vis_c)
                            {
                                MapEngine.currMap.MSGrid[(int)new_cur_sqr.Y][(int)new_cur_sqr.X].MSStates[(int)MSFlagIndex.VIS_LVL] = MSFlag.NO_VIS;
                            }
                            else if (block_c == low_vis_c)
                            {
                                MapEngine.currMap.MSGrid[(int)new_cur_sqr.Y][(int)new_cur_sqr.X].MSStates[(int)MSFlagIndex.VIS_LVL] = MSFlag.LOW_VIS;
                            }
                            else
                            {
                                MapEngine.currMap.MSGrid[(int)new_cur_sqr.Y][(int)new_cur_sqr.X].MSStates[(int)MSFlagIndex.VIS_LVL] = MSFlag.HIGH_VIS;
                            }
                        }
                    }
                }
            }
        }