Example #1
0
            //рисуем
            public void DrawCreep(SpriteBatch spriteBatch, bots B)
            {
                int       frameWidth = B.Hero_go_right_tex.Width / this.FrameCount;
                Rectangle creep_rec  = new Rectangle(frameWidth * this.frame, 0, frameWidth, B.Hero_go_right_tex.Height);

                spriteBatch.Begin();

                if (creep_napravlenie == "stop")
                {
                    spriteBatch.Draw(B.creepTex, this.creepPos, Color.White);
                }

                if (creep_napravlenie == "left")
                {
                    spriteBatch.Draw(B.creep_go_left_tex, this.creepPos, creep_rec, Color.White);
                }

                if (creep_napravlenie == "right")
                {
                    spriteBatch.Draw(B.creep_go_right_tex, this.creepPos, creep_rec, Color.White);
                }

                if (creep_napravlenie == "down")
                {
                    spriteBatch.Draw(B.creep_go_down_tex, this.creepPos, creep_rec, Color.White);
                }

                if (creep_napravlenie == "up")
                {
                    spriteBatch.Draw(B.creep_go_up_tex, this.creepPos, creep_rec, Color.White);
                }
                spriteBatch.End();
            }
Example #2
0
 //анимированое передвижение
 public void creep_moving(GameTime gameTime, bots B)
 {
     if (this.creep_napravlenie == "right")
     {
         this.creepPos.X += B.creep_speed;
     }
     if (this.creep_napravlenie == "left")
     {
         this.creepPos.X -= B.creep_speed;
     }
     if (this.creep_napravlenie == "down")
     {
         this.creepPos.Y += B.creep_speed;
     }
     if (this.creep_napravlenie == "up")
     {
         this.creepPos.Y -= B.creep_speed;
     }
     TotalTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
     if (TotalTime > TimeForFrame)
     {
         frame++;
         frame      = frame % (FrameCount - 1);
         TotalTime -= TimeForFrame;
     }
 }
Example #3
0
            //двигаемся по шагам
            public void bot_move(GameTime gameTime, bots B)
            {
                this.creep_moving(gameTime, B);
                this.creep_count_step++;

                if (this.creep_count_step * B.creep_speed >= B.X_cell)
                {
                    this.creep_count_step = 0;
                    if (this.creep_napravlenie == "right")
                    {
                        this.creep_move_in_mas(0, 1, B);
                    }
                    if (this.creep_napravlenie == "left")
                    {
                        this.creep_move_in_mas(0, -1, B);
                    }
                    if (this.creep_napravlenie == "down")
                    {
                        this.creep_move_in_mas(1, 0, B);
                    }
                    if (this.creep_napravlenie == "up")
                    {
                        this.creep_move_in_mas(-1, 0, B);
                    }
                    //this.creep_napravlenie = "stop";
                }
            }
Example #4
0
 //в массиве
 public void creep_move_in_mas(int I, int J, bots B)
 {
     this.creep_pos_i += I;
     this.creep_pos_j += J;
     if (B.M[this.creep_pos_i, this.creep_pos_j] == "P")
     {
         B.player_dead = true;
     }
     B.M[this.creep_pos_i, this.creep_pos_j]         = "C";
     B.M[this.creep_pos_i - I, this.creep_pos_j - J] = " ";
     this.creep_napravlenie = "stop";
     this.creepPos.X        = creep_pos_j * B.Y_cell;
     this.creepPos.Y        = creep_pos_i * B.Y_cell;
 }
Example #5
0
            // проверяем ботов
            public void check_dead_creep(GameTime gameTime, bots B)
            {
                for (int i = 0; i < B.size1; i++)
                {
                    for (int j = 0; j < B.size2; j++)
                    {
                        if (i == this.creep_pos_i && j == this.creep_pos_j)
                        {
                            if (B.M[i, j] != "C")
                            {
                                if (B.M[i, j] == "P")
                                {
                                    B.player_dead = true;
                                }
                                if (B.M[i, j] == "*")
                                {
                                    this.creep_dead = true;
                                    B.creep_kill++;
                                    B.bot_dead_sound.Play(0.1f, 0.0f, 0.0f);
                                }
                                else
                                {
                                    this.creep_dead = true;
                                    //B.creep_kill++;
                                }
                            }
                        }
                        if (i == this.creep_new_pos_i && j == this.creep_new_pos_j)
                        {
                            if (B.M[i, j] == "*")
                            {
                                this.creep_dead = true;
                                B.creep_kill++;
                                B.bot_dead_sound.Play(0.1f, 0.0f, 0.0f);
                            }

                            /*  if (B.M[i, j] == "P")
                             * {
                             *    B.player_dead = true;
                             * } */
                        }
                    }
                }
            }
Example #6
0
            public float TotalTime;    //сколько времени прошло с показа предыдущего фрейма


            //конструктор
            public creep(int I, int J, bots B)
            {
                frame        = 0;
                TimeForFrame = (float)1 / 5;
                TotalTime    = 0;
                FrameCount   = 5;


                creep_pos_i       = I;
                creep_pos_j       = J;
                creep_new_pos_i   = I;
                creep_new_pos_j   = J;
                creep_dead        = false;
                creep_move_time   = 0;
                B.M[I, J]         = "C";
                creep_napravlenie = "stop";
                creepPos.X        = J * B.Y_cell;
                creepPos.Y        = I * B.Y_cell;
                creep_count_step  = 0;
            }
Example #7
0
 //выбираем сторону, куда пойдет крип
 public void lets_go_creep(GameTime gameTime, bots B)
 {
     if (this.creep_napravlenie == "stop")
     {
         Random rdn     = new Random();
         int    napravl = 0;      // направление (влево, вправо, вверх, вниз)
         napravl = rdn.Next(0, 9);
         if (napravl == 1 || napravl == 5)
         {
             if (B.is_empty_for_bots(this.creep_pos_i + 1, this.creep_pos_j))
             {
                 this.creep_napravlenie = "down";
                 if (B.is_empty_for_bots(this.creep_pos_i + 1, this.creep_pos_j))
                 {
                     if (B.M[this.creep_pos_i + 1, this.creep_pos_j] == "s")
                     {
                         B.creep_speed = 2;
                     }
                     B.M[this.creep_pos_i + 1, this.creep_pos_j] = "c";
                     this.creep_new_pos_i = this.creep_pos_i + 1;
                     this.creep_new_pos_j = this.creep_pos_j;
                     this.bot_move(gameTime, B);
                 }
             }
         }
         if (napravl == 2 || napravl == 6)
         {
             if (B.is_empty_for_bots(this.creep_pos_i - 1, this.creep_pos_j))
             {
                 this.creep_napravlenie = "up";
                 if (B.is_empty_for_bots(this.creep_pos_i - 1, this.creep_pos_j))
                 {
                     if (B.M[this.creep_pos_i - 1, this.creep_pos_j] == "s")
                     {
                         B.creep_speed = 2;
                     }
                     B.M[this.creep_pos_i - 1, this.creep_pos_j] = "c";
                     this.creep_new_pos_i = this.creep_pos_i - 1;
                     this.creep_new_pos_j = this.creep_pos_j;
                     this.bot_move(gameTime, B);
                 }
             }
         }
         if (napravl == 3 || napravl == 7)
         {
             if (B.is_empty_for_bots(this.creep_pos_i, this.creep_pos_j + 1))
             {
                 this.creep_napravlenie = "right";
                 if (B.is_empty_for_bots(this.creep_pos_i, this.creep_pos_j + 1))
                 {
                     if (B.M[this.creep_pos_i, this.creep_pos_j + 1] == "s")
                     {
                         B.creep_speed = 2;
                     }
                     B.M[this.creep_pos_i, this.creep_pos_j + 1] = "c";
                     this.creep_new_pos_i = this.creep_pos_i;
                     this.creep_new_pos_j = this.creep_pos_j + 1;
                     this.bot_move(gameTime, B);
                 }
             }
         }
         if (napravl == 4 || napravl == 8)
         {
             if (B.is_empty_for_bots(this.creep_pos_i, this.creep_pos_j - 1))
             {
                 this.creep_napravlenie = "left";
                 if (B.is_empty_for_bots(this.creep_pos_i, this.creep_pos_j - 1))
                 {
                     if (B.M[this.creep_pos_i, this.creep_pos_j - 1] == "s")
                     {
                         B.creep_speed = 2;
                     }
                     B.M[this.creep_pos_i, this.creep_pos_j - 1] = "c";
                     this.creep_new_pos_i = this.creep_pos_i;
                     this.creep_new_pos_j = this.creep_pos_j - 1;
                     this.bot_move(gameTime, B);
                 }
             }
         }
     }
 }