Beispiel #1
0
        bool CheckBox(my_positon target, int step_x, int step_y)
        {
            int i;

            for (i = 0; i < 3; i++)
            {
                my_positon d = rock[i];
                if (BoxCollision(target, step_x, step_y, d))
                {
                    if (CheckStone(d, step_x, step_y))
                    {
                        return(true);
                    }
                    if (!CheckBound(d, step_x, step_y))
                    {
                        return(true);
                    }
                    if (BoxCheckBox(d, step_x, step_y))
                    {
                        return(true);
                    }
                    if (!BoxCheckBox(d, step_x, step_y))
                    {
                        NPCMove(rock[i], step_x, step_y);
                    }
                }
            }
            return(false);
        }
Beispiel #2
0
 bool CheckStone(my_positon target, int step_x, int step_y)
 {
     if (StoneCollision(target, step_x, step_y))
     {
         return(true);
     }
     return(false);
 }
Beispiel #3
0
        void CheckKill()
        {
            my_positon d = kill;
            my_positon e = hero;

            if (AimCollision(d, e))
            {
                MessageBox.Show("You lose");
                NavigationService.Navigate(new Uri("HomePage.xaml", UriKind.Relative));
            }
        }
Beispiel #4
0
        void CheckAim()
        {
            my_positon c = aim;

            ISWIN = false;

            my_positon d = hero;

            if (AimCollision(c, d))
            {
                ISWIN = true;
            }
        }
Beispiel #5
0
        bool BoxCollision(my_positon target, int step_x, int step_y, my_positon target2)
        {
            var x1 = target.initial + target.x + step_x + step_y;
            var x2 = target2.initial + target2.x;

            if (x1 == x2)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #6
0
        bool AimCollision(my_positon target, my_positon target2)
        {
            var x1 = target2.initial + target2.x;
            var x2 = target.initial + target.x;

            if (x1 == x2)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #7
0
        void save()
        {
            positiondata data = new positiondata();

            data.person.initial = hero.initial;
            data.person.x       = hero.x;
            int i;

            for (i = 0; i < 3; i++)
            {
                my_positon boxposition = new my_positon();
                boxposition.x       = rock[i].x;
                boxposition.initial = rock[i].initial;
                data.save_box.Add(boxposition);
            }
            Saving.Add(data);
        }
Beispiel #8
0
        void save()
        {
            positiondata data = new positiondata();

            data.person.x = this.aa.X;
            data.person.y = this.aa.Y;
            int i;

            for (i = 0; i < 8; i++)
            {
                TranslateTransform d           = FindName(box_position[i]) as TranslateTransform;
                my_positon         boxposition = new my_positon();
                boxposition.x = d.X;
                boxposition.y = d.Y;
                data.save_box.Add(boxposition);
            }
            Saving.Add(data);
        }
Beispiel #9
0
        bool BoxCheckBox(my_positon target, int step_x, int step_y)
        {
            int i;

            for (i = 0; i < 3; i++)
            {
                my_positon b = rock[i];
                int        c = rock[i].initial + rock[i].x;
                int        d = target.initial + target.x;

                if (c != d)
                {
                    if (BoxCollision(target, step_x, step_y, b))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #10
0
        bool StoneCollision(my_positon target, int step_x, int step_y)
        {
            var x = target.initial + target.x + step_x + step_y;

            //132 --- 163 and 363 --- 394
            for (int i = 132; i < 164; i++)
            {
                if (x == i)
                {
                    return(true);
                }
            }
            for (int i = 363; i < 395; i++)
            {
                if (x == i)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #11
0
        void NPCMove(my_positon target, int step_x, int step_y)
        {
            if (step_x + step_y != 0)
            {
                var x = target.initial + target.x + step_x + step_y;

                if (MainMap.Text[x] == '#')
                {
                    MainMap.Text = MainMap.Text.Remove(x, 1);
                    if (target.initial == hero.initial)
                    {
                        MainMap.Text = MainMap.Text.Insert(x, "X");
                    }
                    else
                    {
                        MainMap.Text = MainMap.Text.Insert(x, "Y");
                    }
                }
                if (target.initial == hero.initial)
                {
                    hero.x += step_x + step_y;
                }
                else
                {
                    for (int i = 0; i < 3; i++)
                    {
                        if (target.initial == rock[i].initial)
                        {
                            rock[i].x += step_x + step_y;
                        }
                    }
                }

                if (MainMap.Text[target.x + target.initial] != 'H' && MainMap.Text[target.x + target.initial] != 'E')
                {
                    MainMap.Text = MainMap.Text.Remove(target.x + target.initial, 1);
                    MainMap.Text = MainMap.Text.Insert(target.x + target.initial, "#");
                }
            }
        }
Beispiel #12
0
        bool CheckBound(my_positon target, int step_x, int step_y)
        {
            var x = target.initial + target.x + step_x + step_y;
            var y = 1;

            if (x < 32)
            {
                y = 1;
            }
            else
            {
                y = (x + 1) % 33;
            }
            if (x <= 527 && x >= 0 && y != 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }