Пример #1
0
        private bool DoIt(string command, int materialInt, ref bool complette, ref bool clickStop)
        {
            if (string.Compare(command, "Go();", StringComparison.CurrentCultureIgnoreCase) == 0)
            {
                // param = 1; // один шаг
                // contr.Move(ref Cat1, ref Cat2, this.Size.Width, ref complette, ref CatStay, ref param, ref clickStop, ref materialInt);
                contr.MoveOneStep(ref Cat1, ref Cat2, this.Size.Width, ref complette, ref CatStay, ref clickStop, ref materialInt, ref labelINFO);
            }
            else
            if (string.Compare(command, "Jump();", StringComparison.CurrentCultureIgnoreCase) == 0)
            {
                int mat = level.GetMaterial();
                contr.Jump(ref Cat1, ref Cat2, this.Size.Width, ref complette, ref CatStay, ref clickStop, mat);
            }
            else if (string.Compare(command, "Attack();", StringComparison.CurrentCultureIgnoreCase) == 0)
            {
                Cat1.Visible     = false;
                Cat2.Visible     = false;
                CatStay.Location = Cat2.Location;
                CatStay.Visible  = true;

                bool existHolzBlock;

                contr.Attack(ref CatStay, ref clickStop, out existHolzBlock, ref labelINFO);

                if (level.GetMaterial() == 2 && existHolzBlock)
                {
                    holzBlock.Visible = false;
                    if (level.levelLabel().Equals("Level IV"))
                    {
                        magicHolz.Visible = false;
                    }
                }
            }
            else
            {
                ClassSound.playError();
                labelError.Visible = true;
                labelError.Text   += "\nНеизвестная команда " + command;
                labelError.Visible = true;
                timer1.Enabled     = false;
                clickStop          = true;
                return(false);
            }
            return(true); //выполнилась без ошибок
        }
Пример #2
0
 public Controller(LevelAbstract level, ref Label levelNum, ref PictureBox let, ref PictureBox holzBlock, ref PictureBox magicBlock)
 {
     //walkLet = false;//пройдено ли препятствие
     rnd = new Random();
     levelNum.Visible = true;
     levelNum.Text    = level.levelLabel();
     this.level       = level;
     flag             = true;
     if (levelNum.Text == "Level II")
     {
         let.Visible = true;
     }
     stayOnLet1 = false;
     if (levelNum.Text == "Level III")
     {
         holzBlock.Visible = true;
         ruinBlock3        = false;
     }
     if (levelNum.Text == "Level IV")
     {
         magicBlock.Visible = true;
         ruinBlock4         = false;
     }
 }
Пример #3
0
        public void Jump(ref PictureBox Cat1, ref PictureBox Cat2, int width, ref bool complette, ref PictureBox CatStay, ref bool stop, int materialInt)
        {
            int x = 5; //число на которое увеличиваем X
            int y = -7;

            if (!level.completteLevel1(Cat1, Cat2))
            {
                if (level.levelLabel().Equals("Level II"))
                {
                    if (level.ExistLet(Cat1, Cat2))
                    {
                        CatStay.Visible = false;
                        stayOnLet1      = true;
                        for (int i = 0; i < 5; i++)
                        {
                            if (flag)
                            {
                                Cat1.Visible = true;
                                Cat2.Visible = false;
                                Cat1.Left   += x;
                                Cat2.Left   += x;
                                Cat1.Top    += y;
                                Cat2.Top    += y;
                                flag         = false;
                            }
                            else
                            {
                                Cat2.Visible = true;
                                Cat1.Visible = false;
                                Cat1.Left   += x;
                                Cat2.Left   += x;
                                Cat1.Top    += y;
                                Cat2.Top    += y;
                                flag         = true;
                            }
                            Wait(0.1);
                            x += 9;
                            if (i < 2)
                            {
                                y = -30;
                            }
                            if (i == 2)
                            {
                                y = 0;
                            }
                        }
                    }
                }
                else if (level.levelLabel().Equals("Level III"))
                {
                    if (level.ExistLet(Cat1, Cat2))
                    {
                        y = 0;
                        x = 0;
                        CatStay.Visible = false;
                        for (int i = 0; i < 4; i++)
                        {
                            if (flag)
                            {
                                Cat1.Visible = true;
                                Cat2.Visible = false;
                                Cat1.Top    += y;
                                Cat2.Top    += y;
                                flag         = false;
                            }
                            else
                            {
                                Cat2.Visible = true;
                                Cat1.Visible = false;
                                Cat1.Top    += y;
                                Cat2.Top    += y;
                                flag         = true;
                            }
                            Wait(0.1);
                            if (i < 2)
                            {
                                y -= 10;
                            }
                            if (i >= 2)
                            {
                                y += 45;
                            }
                        }

                        CatStay.Location = Cat1.Location;
                        CatStay.Location = Cat2.Location;
                        Cat1.Visible     = false;
                        Cat2.Visible     = false;
                        CatStay.Visible  = true;
                        return;
                    }
                }
                else if (level.levelLabel().Equals("Level IV"))
                {
                    if (materialInt == 1 && level.ExistLet(Cat1, Cat2)) //Если препятствие каменное, то перепрыгиваем его
                    {
                        CatStay.Visible = false;
                        stayOnLet2      = true;
                        for (int i = 0; i < 5; i++)
                        {
                            if (flag)
                            {
                                Cat1.Visible = true;
                                Cat2.Visible = false;
                                Cat1.Left   += x;
                                Cat2.Left   += x;
                                Cat1.Top    += y;
                                Cat2.Top    += y;
                                flag         = false;
                            }
                            else
                            {
                                Cat2.Visible = true;
                                Cat1.Visible = false;
                                Cat1.Left   += x;
                                Cat2.Left   += x;
                                Cat1.Top    += y;
                                Cat2.Top    += y;
                                flag         = true;
                            }
                            Wait(0.1);
                            x += 9;
                            if (i < 2)
                            {
                                y = -30;
                            }
                            if (i == 2)
                            {
                                y = 0;
                            }
                        }
                    }
                    else if (materialInt == 2 && level.ExistLet(Cat1, Cat2)) //Если препятствие - деревянное, прыгаем на месте
                    {
                        y = 0;
                        x = 0;
                        CatStay.Visible = false;
                        for (int i = 0; i < 4; i++)
                        {
                            if (flag)
                            {
                                Cat1.Visible = true;
                                Cat2.Visible = false;
                                Cat1.Top    += y;
                                Cat2.Top    += y;
                                flag         = false;
                            }
                            else
                            {
                                Cat2.Visible = true;
                                Cat1.Visible = false;
                                Cat1.Top    += y;
                                Cat2.Top    += y;
                                flag         = true;
                            }
                            Wait(0.1);
                            if (i < 2)
                            {
                                y -= 10;
                            }
                            if (i >= 2)
                            {
                                y += 45;
                            }
                        }

                        CatStay.Location = Cat1.Location;
                        CatStay.Location = Cat2.Location;
                        Cat1.Visible     = false;
                        Cat2.Visible     = false;
                        CatStay.Visible  = true;
                        return;
                    }
                }
                if (!level.ExistLet(Cat1, Cat2))
                {
                    CatStay.Visible = false;
                    for (int i = 0; i < 5; i++)
                    {
                        if (flag)
                        {
                            Cat1.Visible = true;
                            Cat2.Visible = false;
                            Cat1.Left   += x;
                            Cat2.Left   += x;
                            Cat1.Top    += y;
                            Cat2.Top    += y;
                            flag         = false;
                        }
                        else
                        {
                            Cat2.Visible = true;
                            Cat1.Visible = false;
                            Cat1.Left   += x;
                            Cat2.Left   += x;
                            Cat1.Top    += y;
                            Cat2.Top    += y;
                            flag         = true;
                        }
                        Wait(0.1);
                        x += 2;
                        if (i < 2)
                        {
                            y -= 5;
                        }
                        if (i == 2)
                        {
                            y += 30;
                        }
                        if (i > 2)
                        {
                            y += 10;
                        }
                    }
                }
            }
            CatStay.Location = Cat1.Location;
            CatStay.Visible  = true;
            Cat1.Visible     = false;
            Cat2.Visible     = false;
            complette        = level.completteLevel1(Cat1, Cat2);
        }