예제 #1
0
파일: Cell.cs 프로젝트: Gafchik/Cell_life
 public Cell(Cell n_cell)
 {
     HP              = n_cell.HP;
     Max_HP          = n_cell.Max_HP;
     this.damage     = n_cell.damage;
     this.random     = n_cell.random;
     this.id         = n_cell.id;
     this.location   = n_cell.location;
     this.size       = n_cell.size;
     this.count_food = n_cell.count_food;
     this.id_childs  = n_cell.id_childs;
     this.color      = n_cell.color;
     this.move_step  = n_cell.move_step;
     this.vision     = n_cell.vision;
     this.found_food = n_cell.found_food;
     this.cell_enemy = n_cell.cell_enemy;
     this.eirection  = n_cell.eirection;
 }
예제 #2
0
파일: Cell.cs 프로젝트: Gafchik/Cell_life
 public Cell(int id, Color color, Point point)
 {
     Max_HP          = HP = 100;
     random          = new Random();
     max_count_child = random.Next(0, 4);
     damage          = random.Next(2, 7);
     eirection       = (Eirection)random.Next(7);
     size            = new Size(10, 10);
     location        = new Point(point.X, point.Y);
     this.id         = id;
     count_food      = 0;
     count_child     = 0;
     id_childs       = new List <int>();
     this.color      = color;
     move_step       = 5;
     vision          = 500;
     found_food      = null;
     cell_enemy      = null;
 }
예제 #3
0
파일: Cell.cs 프로젝트: Gafchik/Cell_life
        private void No_Food_Move(Point point_zero_to_fild, Size size_field, Eirection eirection)
        {
            switch (eirection)
            {
            case Eirection.up:
                if (location.Y - move_step >= 0)
                {
                    location = new Point(location.X, location.Y - move_step);
                }
                else
                {
                    this.eirection = Eirection.down;
                    location       = new Point(location.X, location.Y + move_step);
                }
                break;

            case Eirection.up_right:
                if (location.Y - move_step >= 0)
                {
                    if (location.X + move_step <= point_zero_to_fild.X + size_field.Width - 100)
                    {
                        location = new Point(location.X + move_step, location.Y - move_step);
                    }
                    else
                    {
                        this.eirection = Eirection.down_left;
                        location       = new Point(location.X - move_step, location.Y + move_step);
                    }
                }
                else
                {
                    this.eirection = Eirection.down_left;
                    location       = new Point(location.X - move_step, location.Y + move_step);
                }
                break;

            case Eirection.right:
                if (location.X + move_step <= point_zero_to_fild.X + size_field.Width - 100)
                {
                    location = new Point(location.X + move_step, location.Y);
                }
                else
                {
                    this.eirection = Eirection.left;
                    location       = new Point(location.X - move_step, location.Y);
                }
                break;

            case Eirection.right_down:
                if (location.Y + move_step <= point_zero_to_fild.Y + size_field.Height - 120)
                {
                    if (location.X + move_step <= point_zero_to_fild.X + size_field.Width - 100)
                    {
                        location = new Point(location.X + move_step, location.Y + move_step);
                    }
                    else
                    {
                        this.eirection = Eirection.down_left;
                        location       = new Point(location.X - move_step, location.Y - move_step);
                    }
                }
                else
                {
                    this.eirection = Eirection.down_left;
                    location       = new Point(location.X - move_step, location.Y - move_step);
                }
                break;

            case Eirection.down:
                if (location.Y + move_step <= point_zero_to_fild.Y + size_field.Height - 120)
                {
                    location = new Point(location.X, location.Y + move_step);
                }
                else
                {
                    this.eirection = Eirection.up;
                    location       = new Point(location.X, location.Y - move_step);
                }
                break;

            case Eirection.down_left:
                if (location.Y + move_step <= point_zero_to_fild.Y + size_field.Height - 120)
                {
                    if (location.X - move_step >= point_zero_to_fild.X + 50)
                    {
                        location = new Point(location.X - move_step, location.Y + move_step);
                    }
                    else
                    {
                        this.eirection = Eirection.up_right;
                        location       = new Point(location.X + move_step, location.Y - move_step);
                    }
                }
                else
                {
                    this.eirection = Eirection.up_right;
                    location       = new Point(location.X + move_step, location.Y - move_step);
                }
                break;

            case Eirection.left:
                if (location.X - move_step >= point_zero_to_fild.X + 50)
                {
                    location = new Point(location.X - move_step, location.Y);
                }
                else
                {
                    this.eirection = Eirection.right;
                    location       = new Point(location.X + move_step, location.Y);
                }
                break;

            case Eirection.left_up:
                if (location.Y - move_step >= 0)
                {
                    if (location.X - move_step >= point_zero_to_fild.X + 50)
                    {
                        location = new Point(location.X - move_step, location.Y - move_step);
                    }
                    else
                    {
                        this.eirection = Eirection.right_down;
                        location       = new Point(location.X + move_step, location.Y + move_step);
                    }
                }
                else
                {
                    this.eirection = Eirection.right_down;
                    location       = new Point(location.X + move_step, location.Y + move_step);
                }
                break;

            default:
                break;
            }
        }
예제 #4
0
파일: Cell.cs 프로젝트: Gafchik/Cell_life
 public void Next_Move() => eirection = (Eirection)random.Next(7);